[PATCH net-next] hyperv: Add handling of IP header with option field in netvsc_set_hash()

From: Haiyang Zhang
Date: Tue Aug 19 2014 - 16:56:19 EST


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@xxxxxxxxxxxxx>
Reviewed-by: K. Y. Srinivasan <kys@xxxxxxxxxxxxx>

---
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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/