* [PATCH 2/5] net/hyperv: Correct the assignment in netvsc_recv_callback()
2012-01-30 16:33 [PATCH 1/5] net/hyperv: Convert camel cased variables in rndis_filter.c to lower cases Haiyang Zhang
@ 2012-01-30 16:33 ` Haiyang Zhang
2012-01-30 16:33 ` [PATCH 3/5] net/hyperv: Remove the unnecessary memset in rndis_filter_send() Haiyang Zhang
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Haiyang Zhang @ 2012-01-30 16:33 UTC (permalink / raw)
To: haiyangz, kys, davem, netdev, linux-kernel
The first assignment to variable "net" is wrong, but overridden by the
latter assignments. So the bug isn't manifested.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
drivers/net/hyperv/netvsc_drv.c | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 1a1ca6c..af25771 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -267,13 +267,10 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj,
int netvsc_recv_callback(struct hv_device *device_obj,
struct hv_netvsc_packet *packet)
{
- struct net_device *net = dev_get_drvdata(&device_obj->device);
+ struct net_device *net;
struct sk_buff *skb;
- struct netvsc_device *net_device;
-
- net_device = hv_get_drvdata(device_obj);
- net = net_device->ndev;
+ net = ((struct netvsc_device *)hv_get_drvdata(device_obj))->ndev;
if (!net) {
netdev_err(net, "got receive callback but net device"
" not initialized yet\n");
--
1.7.7
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/5] net/hyperv: Remove the unnecessary memset in rndis_filter_send()
2012-01-30 16:33 [PATCH 1/5] net/hyperv: Convert camel cased variables in rndis_filter.c to lower cases Haiyang Zhang
2012-01-30 16:33 ` [PATCH 2/5] net/hyperv: Correct the assignment in netvsc_recv_callback() Haiyang Zhang
@ 2012-01-30 16:33 ` Haiyang Zhang
2012-01-30 16:33 ` [PATCH 4/5] net/hyperv: Fix the page buffer when an RNDIS message goes beyond page boundary Haiyang Zhang
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Haiyang Zhang @ 2012-01-30 16:33 UTC (permalink / raw)
To: haiyangz, kys, davem, netdev, linux-kernel
The memory has been allocated by kzalloc, so it's unnecessary to memset
again.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
drivers/net/hyperv/rndis_filter.c | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index 129e696..c0aa8b0 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -759,8 +759,6 @@ int rndis_filter_send(struct hv_device *dev,
/* Add the rndis header */
filter_pkt = (struct rndis_filter_packet *)pkt->extension;
- memset(filter_pkt, 0, sizeof(struct rndis_filter_packet));
-
rndis_msg = &filter_pkt->msg;
rndis_msg_size = RNDIS_MESSAGE_SIZE(struct rndis_packet);
--
1.7.7
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/5] net/hyperv: Fix the page buffer when an RNDIS message goes beyond page boundary
2012-01-30 16:33 [PATCH 1/5] net/hyperv: Convert camel cased variables in rndis_filter.c to lower cases Haiyang Zhang
2012-01-30 16:33 ` [PATCH 2/5] net/hyperv: Correct the assignment in netvsc_recv_callback() Haiyang Zhang
2012-01-30 16:33 ` [PATCH 3/5] net/hyperv: Remove the unnecessary memset in rndis_filter_send() Haiyang Zhang
@ 2012-01-30 16:33 ` Haiyang Zhang
2012-01-30 16:33 ` [PATCH 5/5] net/hyperv: Use netif_tx_disable() instead of netif_stop_queue() when necessary Haiyang Zhang
2012-02-01 19:36 ` [PATCH 1/5] net/hyperv: Convert camel cased variables in rndis_filter.c to lower cases David Miller
4 siblings, 0 replies; 7+ messages in thread
From: Haiyang Zhang @ 2012-01-30 16:33 UTC (permalink / raw)
To: haiyangz, kys, davem, netdev, linux-kernel
There is a possible data corruption if an RNDIS message goes beyond page
boundary in the sending code path. This patch fixes the problem.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
drivers/net/hyperv/netvsc_drv.c | 8 ++++----
drivers/net/hyperv/rndis_filter.c | 13 +++++++++++++
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index af25771..cf5716b 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -151,10 +151,10 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
int ret;
unsigned int i, num_pages, npg_data;
- /* Add multipage for skb->data and additional one for RNDIS */
+ /* Add multipages for skb->data and additional 2 for RNDIS */
npg_data = (((unsigned long)skb->data + skb_headlen(skb) - 1)
>> PAGE_SHIFT) - ((unsigned long)skb->data >> PAGE_SHIFT) + 1;
- num_pages = skb_shinfo(skb)->nr_frags + npg_data + 1;
+ num_pages = skb_shinfo(skb)->nr_frags + npg_data + 2;
/* Allocate a netvsc packet based on # of frags. */
packet = kzalloc(sizeof(struct hv_netvsc_packet) +
@@ -173,8 +173,8 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net)
sizeof(struct hv_netvsc_packet) +
(num_pages * sizeof(struct hv_page_buffer));
- /* Setup the rndis header */
- packet->page_buf_cnt = num_pages;
+ /* If the rndis msg goes beyond 1 page, we will add 1 later */
+ packet->page_buf_cnt = num_pages - 1;
/* Initialize it from the skb */
packet->total_data_buflen = skb->len;
diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
index c0aa8b0..6add018 100644
--- a/drivers/net/hyperv/rndis_filter.c
+++ b/drivers/net/hyperv/rndis_filter.c
@@ -776,6 +776,19 @@ int rndis_filter_send(struct hv_device *dev,
(unsigned long)rndis_msg & (PAGE_SIZE-1);
pkt->page_buf[0].len = rndis_msg_size;
+ /* Add one page_buf if the rndis msg goes beyond page boundary */
+ if (pkt->page_buf[0].offset + rndis_msg_size > PAGE_SIZE) {
+ int i;
+ for (i = pkt->page_buf_cnt; i > 1; i--)
+ pkt->page_buf[i] = pkt->page_buf[i-1];
+ pkt->page_buf_cnt++;
+ pkt->page_buf[0].len = PAGE_SIZE - pkt->page_buf[0].offset;
+ pkt->page_buf[1].pfn = virt_to_phys((void *)((ulong)rndis_msg +
+ pkt->page_buf[0].len)) >> PAGE_SHIFT;
+ pkt->page_buf[1].offset = 0;
+ pkt->page_buf[1].len = rndis_msg_size - pkt->page_buf[0].len;
+ }
+
/* Save the packet send completion and context */
filter_pkt->completion = pkt->completion.send.send_completion;
filter_pkt->completion_ctx =
--
1.7.7
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/5] net/hyperv: Use netif_tx_disable() instead of netif_stop_queue() when necessary
2012-01-30 16:33 [PATCH 1/5] net/hyperv: Convert camel cased variables in rndis_filter.c to lower cases Haiyang Zhang
` (2 preceding siblings ...)
2012-01-30 16:33 ` [PATCH 4/5] net/hyperv: Fix the page buffer when an RNDIS message goes beyond page boundary Haiyang Zhang
@ 2012-01-30 16:33 ` Haiyang Zhang
2012-02-01 19:36 ` [PATCH 1/5] net/hyperv: Convert camel cased variables in rndis_filter.c to lower cases David Miller
4 siblings, 0 replies; 7+ messages in thread
From: Haiyang Zhang @ 2012-01-30 16:33 UTC (permalink / raw)
To: haiyangz, kys, davem, netdev, linux-kernel
For code path not on the xmit, use netif_tx_disable() instead of
netif_stop_queue() to ensure other CPUs are not doing xmit.
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
drivers/net/hyperv/netvsc_drv.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index cf5716b..3385566 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -123,7 +123,7 @@ static int netvsc_close(struct net_device *net)
struct hv_device *device_obj = net_device_ctx->device_ctx;
int ret;
- netif_stop_queue(net);
+ netif_tx_disable(net);
ret = rndis_filter_close(device_obj);
if (ret != 0)
@@ -256,7 +256,7 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj,
schedule_delayed_work(&ndev_ctx->dwork, msecs_to_jiffies(20));
} else {
netif_carrier_off(net);
- netif_stop_queue(net);
+ netif_tx_disable(net);
}
}
@@ -334,7 +334,7 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu)
nvdev->start_remove = true;
cancel_delayed_work_sync(&ndevctx->dwork);
- netif_stop_queue(ndev);
+ netif_tx_disable(ndev);
rndis_filter_device_remove(hdev);
ndev->mtu = mtu;
@@ -457,7 +457,7 @@ static int netvsc_remove(struct hv_device *dev)
cancel_delayed_work_sync(&ndev_ctx->dwork);
/* Stop outbound asap */
- netif_stop_queue(net);
+ netif_tx_disable(net);
unregister_netdev(net);
--
1.7.7
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/5] net/hyperv: Convert camel cased variables in rndis_filter.c to lower cases
2012-01-30 16:33 [PATCH 1/5] net/hyperv: Convert camel cased variables in rndis_filter.c to lower cases Haiyang Zhang
` (3 preceding siblings ...)
2012-01-30 16:33 ` [PATCH 5/5] net/hyperv: Use netif_tx_disable() instead of netif_stop_queue() when necessary Haiyang Zhang
@ 2012-02-01 19:36 ` David Miller
2012-02-01 19:39 ` Haiyang Zhang
4 siblings, 1 reply; 7+ messages in thread
From: David Miller @ 2012-02-01 19:36 UTC (permalink / raw)
To: haiyangz; +Cc: kys, netdev, linux-kernel
Please do not mix cleanups with real bug fixes.
Patches #4 and #5 in this series fix real bugs, so you should submit them
seperately for inclusion to my 'net' tree.
Once those fixes have propagated to my 'net-next' tree, you can then submit
the cleanups.
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH 1/5] net/hyperv: Convert camel cased variables in rndis_filter.c to lower cases
2012-02-01 19:36 ` [PATCH 1/5] net/hyperv: Convert camel cased variables in rndis_filter.c to lower cases David Miller
@ 2012-02-01 19:39 ` Haiyang Zhang
0 siblings, 0 replies; 7+ messages in thread
From: Haiyang Zhang @ 2012-02-01 19:39 UTC (permalink / raw)
To: David Miller; +Cc: KY Srinivasan, netdev, linux-kernel
> -----Original Message-----
> From: David Miller [mailto:davem@davemloft.net]
> Sent: Wednesday, February 01, 2012 2:37 PM
> To: Haiyang Zhang
> Cc: KY Srinivasan; netdev@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH 1/5] net/hyperv: Convert camel cased variables in
> rndis_filter.c to lower cases
>
>
> Please do not mix cleanups with real bug fixes.
>
> Patches #4 and #5 in this series fix real bugs, so you should submit them
> seperately for inclusion to my 'net' tree.
>
> Once those fixes have propagated to my 'net-next' tree, you can then
> submit
> the cleanups.
Will do.
Thanks,
- Haiyang
^ permalink raw reply [flat|nested] 7+ messages in thread