netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: [PATCH net-next, v2] hyperv: Add handling of IP header with option field in netvsc_set_hash()
       [not found] <1413317117-28678-1-git-send-email-haiyangz@microsoft.com>
@ 2014-10-15  0:41 ` Haiyang Zhang
  2014-10-15  2:05 ` [PATCH net-next,v2] " David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: Haiyang Zhang @ 2014-10-15  0:41 UTC (permalink / raw)
  To: Haiyang Zhang, davem, netdev
  Cc: driverdev-devel, olaf, jasowang, linux-kernel



> -----Original Message-----
> From: Haiyang Zhang [mailto:haiyangz@microsoft.com]
> Sent: Tuesday, October 14, 2014 4:05 PM
> To: davem@davemloft.net; netdev@vger.kernel.org
> Cc: Haiyang Zhang; KY Srinivasan; olaf@aepfle.de; jasowang@redhat.com;
> linux-kernel@vger.kernel.org; driverdev-devel@linuxdriverproject.org
> Subject: [PATCH net-next,v2] hyperv: Add handling of IP header with
> option field in netvsc_set_hash()
> 

This is a duplicate of a patch submitted earlier today. Please ignore.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next,v2] hyperv: Add handling of IP header with option field in netvsc_set_hash()
       [not found] <1413317117-28678-1-git-send-email-haiyangz@microsoft.com>
  2014-10-15  0:41 ` [PATCH net-next, v2] hyperv: Add handling of IP header with option field in netvsc_set_hash() Haiyang Zhang
@ 2014-10-15  2:05 ` David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2014-10-15  2:05 UTC (permalink / raw)
  To: haiyangz; +Cc: olaf, netdev, jasowang, driverdev-devel, linux-kernel

From: Haiyang Zhang <haiyangz@microsoft.com>
Date: Tue, 14 Oct 2014 20:05:17 +0000

> In case that the IP header has optional field at the end, this patch will
> get the port numbers after that field, and compute the hash.
> 
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>

This isn't even close to what I asked for.

I said to remove all of this by-hand header parsing code in the
hyperv driver, and use the generic code networking facilities
that exist already to do this.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next, v2] hyperv: Add handling of IP header with option field in netvsc_set_hash()
@ 2014-10-14 22:16 Haiyang Zhang
  2014-10-14 21:37 ` [PATCH net-next,v2] " David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Haiyang Zhang @ 2014-10-14 22:16 UTC (permalink / raw)
  To: davem, netdev; +Cc: olaf, jasowang, driverdev-devel, linux-kernel, haiyangz

In case that the IP header has optional field at the end, this patch will
get the port numbers after that field, and compute the hash.

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
---
 drivers/net/hyperv/netvsc_drv.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 0fcb5e7..0d60c91 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -162,7 +162,7 @@ union sub_key {
  * data: network byte order
  * return: host byte order
  */
-static u32 comp_hash(u8 *key, int klen, u8 *data, int dlen)
+static u32 comp_hash(u8 *key, int klen, void *data, int dlen)
 {
 	union sub_key subk;
 	int k_next = 4;
@@ -176,7 +176,7 @@ static u32 comp_hash(u8 *key, int klen, u8 *data, int dlen)
 	for (i = 0; i < dlen; i++) {
 		subk.kb = key[k_next];
 		k_next = (k_next + 1) % klen;
-		dt = data[i];
+		dt = ((u8 *)data)[i];
 		for (j = 0; j < 8; j++) {
 			if (dt & 0x80)
 				ret ^= subk.ka;
@@ -191,6 +191,7 @@ static u32 comp_hash(u8 *key, int klen, u8 *data, int dlen)
 static bool netvsc_set_hash(u32 *hash, struct sk_buff *skb)
 {
 	struct iphdr *iphdr;
+	__be32 dbuf[3];
 	int data_len;
 	bool ret = false;
 
@@ -200,12 +201,15 @@ static bool netvsc_set_hash(u32 *hash, struct sk_buff *skb)
 	iphdr = ip_hdr(skb);
 
 	if (iphdr->version == 4) {
-		if (iphdr->protocol == IPPROTO_TCP)
+		dbuf[0] = iphdr->saddr;
+		dbuf[1] = iphdr->daddr;
+		if (iphdr->protocol == IPPROTO_TCP) {
+			dbuf[2] = *(__be32 *)&tcp_hdr(skb)->source;
 			data_len = 12;
-		else
+		} else {
 			data_len = 8;
-		*hash = comp_hash(netvsc_hash_key, HASH_KEYLEN,
-				  (u8 *)&iphdr->saddr, data_len);
+		}
+		*hash = comp_hash(netvsc_hash_key, HASH_KEYLEN, dbuf, data_len);
 		ret = true;
 	}
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH net-next,v2] hyperv: Add handling of IP header with option field in netvsc_set_hash()
  2014-10-14 21:37 ` [PATCH net-next,v2] " David Miller
@ 2014-10-14 21:47   ` Haiyang Zhang
  0 siblings, 0 replies; 5+ messages in thread
From: Haiyang Zhang @ 2014-10-14 21:47 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, KY Srinivasan, olaf, jasowang, linux-kernel, driverdev-devel



> -----Original Message-----
> From: David Miller [mailto:davem@davemloft.net]
> Sent: Tuesday, October 14, 2014 5:37 PM
> To: Haiyang Zhang
> Cc: netdev@vger.kernel.org; KY Srinivasan; olaf@aepfle.de;
> jasowang@redhat.com; linux-kernel@vger.kernel.org; driverdev-
> devel@linuxdriverproject.org
> Subject: Re: [PATCH net-next,v2] hyperv: Add handling of IP header with option
> field in netvsc_set_hash()
> 
> From: Haiyang Zhang <haiyangz@microsoft.com>
> Date: Tue, 14 Oct 2014 15:16:28 -0700
> 
> > In case that the IP header has optional field at the end, this patch
> > will get the port numbers after that field, and compute the hash.
> >
> > Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> > Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>
> 
> Instead of adding hack after hack after hack to your internal header parser, just
> use the generic flow dissector we already have in the kernel to fetch out the
> values you need.
> 
> __skb_flow_get_ports() etc.

Thanks. I will update the patch.

- Haiyang

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next,v2] hyperv: Add handling of IP header with option field in netvsc_set_hash()
  2014-10-14 22:16 [PATCH net-next, v2] " Haiyang Zhang
@ 2014-10-14 21:37 ` David Miller
  2014-10-14 21:47   ` Haiyang Zhang
  0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2014-10-14 21:37 UTC (permalink / raw)
  To: haiyangz; +Cc: olaf, netdev, jasowang, driverdev-devel, linux-kernel

From: Haiyang Zhang <haiyangz@microsoft.com>
Date: Tue, 14 Oct 2014 15:16:28 -0700

> In case that the IP header has optional field at the end, this patch will
> get the port numbers after that field, and compute the hash.
> 
> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
> Reviewed-by: K. Y. Srinivasan <kys@microsoft.com>

Instead of adding hack after hack after hack to your internal header
parser, just use the generic flow dissector we already have in the
kernel to fetch out the values you need.

__skb_flow_get_ports() etc.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-15  2:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1413317117-28678-1-git-send-email-haiyangz@microsoft.com>
2014-10-15  0:41 ` [PATCH net-next, v2] hyperv: Add handling of IP header with option field in netvsc_set_hash() Haiyang Zhang
2014-10-15  2:05 ` [PATCH net-next,v2] " David Miller
2014-10-14 22:16 [PATCH net-next, v2] " Haiyang Zhang
2014-10-14 21:37 ` [PATCH net-next,v2] " David Miller
2014-10-14 21:47   ` Haiyang Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).