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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Haiyang Zhang <haiyangz@xxxxxxxxxxxxx>
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.
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux