* [PATCH net-next] hyperv: Add handling of IP header with option field in netvsc_set_hash()
@ 2014-08-19 20:53 Haiyang Zhang
2014-08-22 4:30 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Haiyang Zhang @ 2014-08-19 20:53 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, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index a9c5eaa..b12dcd9 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -191,6 +191,8 @@ 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;
+ u8 dbuf[12];
+ u8 *data;
int data_len;
bool ret = false;
@@ -200,12 +202,18 @@ static bool netvsc_set_hash(u32 *hash, struct sk_buff *skb)
iphdr = ip_hdr(skb);
if (iphdr->version == 4) {
- if (iphdr->protocol == IPPROTO_TCP)
+ data = (u8 *)&iphdr->saddr;
+ if (iphdr->protocol == IPPROTO_TCP) {
data_len = 12;
- else
+ if (iphdr->ihl > 5) {
+ memcpy(dbuf, &iphdr->saddr, 8);
+ memcpy(&dbuf[8], &tcp_hdr(skb)->source, 4);
+ data = dbuf;
+ }
+ } 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, data, data_len);
ret = true;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] hyperv: Add handling of IP header with option field in netvsc_set_hash()
2014-08-19 20:53 [PATCH net-next] hyperv: Add handling of IP header with option field in netvsc_set_hash() Haiyang Zhang
@ 2014-08-22 4:30 ` David Miller
2014-08-22 21:06 ` Haiyang Zhang
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2014-08-22 4:30 UTC (permalink / raw)
To: haiyangz; +Cc: olaf, netdev, jasowang, driverdev-devel, linux-kernel
From: Haiyang Zhang <haiyangz@microsoft.com>
Date: Tue, 19 Aug 2014 20:53:55 +0000
> @@ -200,12 +202,18 @@ static bool netvsc_set_hash(u32 *hash, struct sk_buff *skb)
> iphdr = ip_hdr(skb);
>
> if (iphdr->version == 4) {
> - if (iphdr->protocol == IPPROTO_TCP)
> + data = (u8 *)&iphdr->saddr;
> + if (iphdr->protocol == IPPROTO_TCP) {
> data_len = 12;
> - else
> + if (iphdr->ihl > 5) {
> + memcpy(dbuf, &iphdr->saddr, 8);
> + memcpy(&dbuf[8], &tcp_hdr(skb)->source, 4);
This is rediculous.
Make hash_comp() take a void pointer for the buffer.
Then your code is simply:
be32 dbuf[2];
dbuf[1] = iph->saddr;
dbuf[2] = iph->daddr;
dbuf[3] = *(be32 *)tcph->source;
*hash = comp_hash(netvsc_hash_key, HASH_KEYLEN, dbuf, 12);
No special cases for IP options or any garbage like that.
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH net-next] hyperv: Add handling of IP header with option field in netvsc_set_hash()
2014-08-22 4:30 ` David Miller
@ 2014-08-22 21:06 ` Haiyang Zhang
0 siblings, 0 replies; 3+ messages in thread
From: Haiyang Zhang @ 2014-08-22 21:06 UTC (permalink / raw)
To: David Miller
Cc: olaf@aepfle.de, netdev@vger.kernel.org, jasowang@redhat.com,
driverdev-devel@linuxdriverproject.org,
linux-kernel@vger.kernel.org
> -----Original Message-----
> From: David Miller [mailto:davem@davemloft.net]
> Sent: Friday, August 22, 2014 12:31 AM
> 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] hyperv: Add handling of IP header with
> option field in netvsc_set_hash()
>
> From: Haiyang Zhang <haiyangz@microsoft.com>
> Date: Tue, 19 Aug 2014 20:53:55 +0000
>
> > @@ -200,12 +202,18 @@ static bool netvsc_set_hash(u32 *hash, struct
> sk_buff *skb)
> > iphdr = ip_hdr(skb);
> >
> > if (iphdr->version == 4) {
> > - if (iphdr->protocol == IPPROTO_TCP)
> > + data = (u8 *)&iphdr->saddr;
> > + if (iphdr->protocol == IPPROTO_TCP) {
> > data_len = 12;
> > - else
> > + if (iphdr->ihl > 5) {
> > + memcpy(dbuf, &iphdr->saddr, 8);
> > + memcpy(&dbuf[8], &tcp_hdr(skb)->source, 4);
>
> This is rediculous.
>
> Make hash_comp() take a void pointer for the buffer.
>
> Then your code is simply:
>
> be32 dbuf[2];
>
> dbuf[1] = iph->saddr;
> dbuf[2] = iph->daddr;
> dbuf[3] = *(be32 *)tcph->source;
>
> *hash = comp_hash(netvsc_hash_key, HASH_KEYLEN, dbuf, 12);
>
> No special cases for IP options or any garbage like that.
I have submitted a revised patch with the suggested changes.
Thanks,
- Haiyang
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-08-22 21:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-19 20:53 [PATCH net-next] hyperv: Add handling of IP header with option field in netvsc_set_hash() Haiyang Zhang
2014-08-22 4:30 ` David Miller
2014-08-22 21:06 ` 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).