netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] bonding: enhance L2 hash helper with packet type
@ 2014-07-14  6:05 Xie Jianhua
  2014-07-14  9:15 ` Eric Dumazet
  2014-07-15  2:08 ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Xie Jianhua @ 2014-07-14  6:05 UTC (permalink / raw)
  To: netdev
  Cc: Jianhua Xie, Jay Vosburgh, Veaceslav Falico, Andy Gospodarek,
	David S. Miller, Pan Jiafei

From: Jianhua Xie <jianhua.xie@freescale.com>

Current L2 hash helper calculates destination eth addr and
source ether addr as L2 hash factors. This patch is adding
packet type ID field into hash factors, which can help to
distribute different types of packets like IPv4/IPv6 packets
to different slave devices while only BOND_XMIT_POLICY_LAYER2
is applied.

CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Veaceslav Falico <vfalico@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: David S. Miller <davem@davemloft.net>
CC: Pan Jiafei <Jiafei.Pan@freescale.com>

Signed-off-by: Jianhua Xie <jianhua.xie@freescale.com>
---
 drivers/net/bonding/bond_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 3a451b6..4a72c2f 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3002,7 +3002,7 @@ static inline u32 bond_eth_hash(struct sk_buff *skb)
 	struct ethhdr *data = (struct ethhdr *)skb->data;
 
 	if (skb_headlen(skb) >= offsetof(struct ethhdr, h_proto))
-		return data->h_dest[5] ^ data->h_source[5];
+		return data->h_dest[5] ^ data->h_source[5] ^ data->h_proto;
 
 	return 0;
 }
-- 
1.8.5

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

* Re: [PATCH net] bonding: enhance L2 hash helper with packet type
  2014-07-14  6:05 [PATCH net] bonding: enhance L2 hash helper with packet type Xie Jianhua
@ 2014-07-14  9:15 ` Eric Dumazet
  2014-07-14 11:17   ` Jianhua Xie
  2014-07-15  2:08 ` David Miller
  1 sibling, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2014-07-14  9:15 UTC (permalink / raw)
  To: Xie Jianhua
  Cc: netdev, Jay Vosburgh, Veaceslav Falico, Andy Gospodarek,
	David S. Miller, Pan Jiafei

On Mon, 2014-07-14 at 14:05 +0800, Xie Jianhua wrote:
> From: Jianhua Xie <jianhua.xie@freescale.com>
> 
> Current L2 hash helper calculates destination eth addr and
> source ether addr as L2 hash factors. This patch is adding
> packet type ID field into hash factors, which can help to
> distribute different types of packets like IPv4/IPv6 packets
> to different slave devices while only BOND_XMIT_POLICY_LAYER2
> is applied.
> 
> CC: Jay Vosburgh <j.vosburgh@gmail.com>
> CC: Veaceslav Falico <vfalico@gmail.com>
> CC: Andy Gospodarek <andy@greyhouse.net>
> CC: David S. Miller <davem@davemloft.net>
> CC: Pan Jiafei <Jiafei.Pan@freescale.com>
> 
> Signed-off-by: Jianhua Xie <jianhua.xie@freescale.com>
> ---
>  drivers/net/bonding/bond_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 3a451b6..4a72c2f 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -3002,7 +3002,7 @@ static inline u32 bond_eth_hash(struct sk_buff *skb)
>  	struct ethhdr *data = (struct ethhdr *)skb->data;
>  
>  	if (skb_headlen(skb) >= offsetof(struct ethhdr, h_proto))
> -		return data->h_dest[5] ^ data->h_source[5];
> +		return data->h_dest[5] ^ data->h_source[5] ^ data->h_proto;
>  
>  	return 0;
>  }

If you really want this, you also need to change the test, because
otherwise there is no guarantee data->h_proto is valid at his point.

if (skb_headlen(skb) >= sizeof(*data))
   ...

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

* Re: [PATCH net] bonding: enhance L2 hash helper with packet type
  2014-07-14  9:15 ` Eric Dumazet
@ 2014-07-14 11:17   ` Jianhua Xie
  0 siblings, 0 replies; 5+ messages in thread
From: Jianhua Xie @ 2014-07-14 11:17 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: netdev, Jay Vosburgh, Veaceslav Falico, Andy Gospodarek,
	David S. Miller, Pan Jiafei

On 7/14/2014 5:15 PM, Eric Dumazet wrote:
> On Mon, 2014-07-14 at 14:05 +0800, Xie Jianhua wrote:
>> From: Jianhua Xie <jianhua.xie@freescale.com>
>>
>> Current L2 hash helper calculates destination eth addr and
>> source ether addr as L2 hash factors. This patch is adding
>> packet type ID field into hash factors, which can help to
>> distribute different types of packets like IPv4/IPv6 packets
>> to different slave devices while only BOND_XMIT_POLICY_LAYER2
>> is applied.
>>
>> CC: Jay Vosburgh <j.vosburgh@gmail.com>
>> CC: Veaceslav Falico <vfalico@gmail.com>
>> CC: Andy Gospodarek <andy@greyhouse.net>
>> CC: David S. Miller <davem@davemloft.net>
>> CC: Pan Jiafei <Jiafei.Pan@freescale.com>
>>
>> Signed-off-by: Jianhua Xie <jianhua.xie@freescale.com>
>> ---
>>   drivers/net/bonding/bond_main.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>> index 3a451b6..4a72c2f 100644
>> --- a/drivers/net/bonding/bond_main.c
>> +++ b/drivers/net/bonding/bond_main.c
>> @@ -3002,7 +3002,7 @@ static inline u32 bond_eth_hash(struct sk_buff *skb)
>>   	struct ethhdr *data = (struct ethhdr *)skb->data;
>>   
>>   	if (skb_headlen(skb) >= offsetof(struct ethhdr, h_proto))
>> -		return data->h_dest[5] ^ data->h_source[5];
>> +		return data->h_dest[5] ^ data->h_source[5] ^ data->h_proto;
>>   
>>   	return 0;
>>   }
> If you really want this, you also need to change the test, because
> otherwise there is no guarantee data->h_proto is valid at his point.
>
> if (skb_headlen(skb) >= sizeof(*data))
>     ..
Thanks for so helpful comments, I see now.  May I use ETH_HLEN to 
instead of sizeof(*data)?

Regards,
Jianhua

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

* Re: [PATCH net] bonding: enhance L2 hash helper with packet type
  2014-07-14  6:05 [PATCH net] bonding: enhance L2 hash helper with packet type Xie Jianhua
  2014-07-14  9:15 ` Eric Dumazet
@ 2014-07-15  2:08 ` David Miller
  2014-07-15  7:48   ` Jianhua Xie
  1 sibling, 1 reply; 5+ messages in thread
From: David Miller @ 2014-07-15  2:08 UTC (permalink / raw)
  To: Jianhua.Xie; +Cc: netdev, j.vosburgh, vfalico, andy, Jiafei.Pan

From: Xie Jianhua <Jianhua.Xie@freescale.com>
Date: Mon, 14 Jul 2014 14:05:26 +0800

> @@ -3002,7 +3002,7 @@ static inline u32 bond_eth_hash(struct sk_buff *skb)
>  	struct ethhdr *data = (struct ethhdr *)skb->data;
>  
>  	if (skb_headlen(skb) >= offsetof(struct ethhdr, h_proto))
> -		return data->h_dest[5] ^ data->h_source[5];
> +		return data->h_dest[5] ^ data->h_source[5] ^ data->h_proto;
>  
>  	return 0;
>  }

About the headlen check, I don't like the idea that the hash depends upon
whether we have a fully fragmented packet or not.

Just use the appropriate interface, skb_header_pointer(), and recode this
as:

	struct ethhdr *ep, _hdr;

	ep = skb_header_pointer(skb, 0, sizeof(_hdr), &_hdr);
	if (ep)
		return ep->h_dest[5] ^ ep->h_source[5] ^ ep->h_proto;
	return 0;

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

* Re: [PATCH net] bonding: enhance L2 hash helper with packet type
  2014-07-15  2:08 ` David Miller
@ 2014-07-15  7:48   ` Jianhua Xie
  0 siblings, 0 replies; 5+ messages in thread
From: Jianhua Xie @ 2014-07-15  7:48 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, j.vosburgh, vfalico, andy, Jiafei.Pan

On 7/15/2014 10:08 AM, David Miller wrote:
> From: Xie Jianhua <Jianhua.Xie@freescale.com>
> Date: Mon, 14 Jul 2014 14:05:26 +0800
>
>> @@ -3002,7 +3002,7 @@ static inline u32 bond_eth_hash(struct sk_buff *skb)
>>   	struct ethhdr *data = (struct ethhdr *)skb->data;
>>   
>>   	if (skb_headlen(skb) >= offsetof(struct ethhdr, h_proto))
>> -		return data->h_dest[5] ^ data->h_source[5];
>> +		return data->h_dest[5] ^ data->h_source[5] ^ data->h_proto;
>>   
>>   	return 0;
>>   }
> About the headlen check, I don't like the idea that the hash depends upon
> whether we have a fully fragmented packet or not.
>
> Just use the appropriate interface, skb_header_pointer(), and recode this
> as:
>
> 	struct ethhdr *ep, _hdr;
>
> 	ep = skb_header_pointer(skb, 0, sizeof(_hdr), &_hdr);
> 	if (ep)
> 		return ep->h_dest[5] ^ ep->h_source[5] ^ ep->h_proto;
> 	return 0;
Many thanks, patch v2 is coming.

Best Regards,
Jianhua

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

end of thread, other threads:[~2014-07-15  7:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-14  6:05 [PATCH net] bonding: enhance L2 hash helper with packet type Xie Jianhua
2014-07-14  9:15 ` Eric Dumazet
2014-07-14 11:17   ` Jianhua Xie
2014-07-15  2:08 ` David Miller
2014-07-15  7:48   ` Jianhua Xie

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