RE: [PATCH] net: bond: skip vlan header when do layer 3+4 hash policy

2018-04-02 Thread liujian (CE)
> -Original Message-
> From: Nikolay Aleksandrov [mailto:niko...@cumulusnetworks.com]
> Sent: Saturday, March 31, 2018 5:23 PM
> To: liujian (CE) ; da...@davemloft.net;
> j.vosbu...@gmail.com; vfal...@gmail.com; a...@greyhouse.net
> Cc: netdev@vger.kernel.org; weiyongjun (A) 
> Subject: Re: [PATCH] net: bond: skip vlan header when do layer 3+4 hash policy
> 
> On 31/03/18 12:14, liujia...@huawei.com wrote:
> > From: liujian 
> >
> > When the hash policy is BOND_XMIT_POLICY_LAYER34 mode and skb
> protocol
> > is 802.1q VLAN, the policy will be degenerated to LAYER2 mode; Now,
> > change it to get the next layer protocol to ensure that it worked in
> > BOND_XMIT_POLICY_LAYER34 mode.
> >
> > Signed-off-by: liujian 
> > ---
> >   drivers/net/bonding/bond_main.c | 11 ---
> >   1 file changed, 8 insertions(+), 3 deletions(-)
> 
> 
> Nak
> Use BOND_XMIT_POLICY_ENCAP34 (encap3+4), that was one of the main
> reasons it was added.

Got it, thank you~


Re: [PATCH] net: bond: skip vlan header when do layer 3+4 hash policy

2018-03-31 Thread kbuild test robot
Hi liujian,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[also build test WARNING on v4.16-rc7 next-20180329]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/liujian56-huawei-com/net-bond-skip-vlan-header-when-do-layer-3-4-hash-policy/20180401-045327
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

   drivers/net/bonding/bond_main.c:2343:26: sparse: restricted __be16 degrades 
to integer
   drivers/net/bonding/bond_main.c:2349:20: sparse: restricted __be16 degrades 
to integer
   drivers/net/bonding/bond_main.c:2396:40: sparse: incorrect type in 
assignment (different base types) @@expected restricted __be16 [usertype] 
vlan_proto @@got e] vlan_proto @@
   drivers/net/bonding/bond_main.c:2396:40:expected restricted __be16 
[usertype] vlan_proto
   drivers/net/bonding/bond_main.c:2396:40:got int
>> drivers/net/bonding/bond_main.c:3217:18: sparse: incorrect type in 
>> assignment (different base types) @@expected int [signed] skbproto @@
>> got restricted __be1int [signed] skbproto @@
   drivers/net/bonding/bond_main.c:3217:18:expected int [signed] skbproto
   drivers/net/bonding/bond_main.c:3217:18:got restricted __be16 [usertype] 
protocol
>> drivers/net/bonding/bond_main.c:3219:26: sparse: incorrect type in 
>> assignment (different base types) @@expected int [signed] skbproto @@
>> got restint [signed] skbproto @@
   drivers/net/bonding/bond_main.c:3219:26:expected int [signed] skbproto
   drivers/net/bonding/bond_main.c:3219:26:got restricted __be16
   drivers/net/bonding/bond_main.c:3221:25: sparse: restricted __be16 degrades 
to integer
   drivers/net/bonding/bond_main.c:3229:32: sparse: restricted __be16 degrades 
to integer
   drivers/net/bonding/bond_main.c:3199:60: sparse: restricted __be16 degrades 
to integer
   drivers/net/bonding/bond_main.c:3199:60: sparse: restricted __be16 degrades 
to integer

vim +3217 drivers/net/bonding/bond_main.c

  3202  
  3203  /* Extract the appropriate headers based on bond's xmit policy */
  3204  static bool bond_flow_dissect(struct bonding *bond, struct sk_buff *skb,
  3205struct flow_keys *fk)
  3206  {
  3207  const struct ipv6hdr *iph6;
  3208  const struct iphdr *iph;
  3209  int noff, proto = -1, skbproto;
  3210  
  3211  if (bond->params.xmit_policy > BOND_XMIT_POLICY_LAYER23)
  3212  return skb_flow_dissect_flow_keys(skb, fk, 0);
  3213  
  3214  fk->ports.ports = 0;
  3215  noff = skb_network_offset(skb);
  3216  
> 3217  skbproto = skb->protocol;
  3218  if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER34)
> 3219  skbproto = vlan_get_protocol(skb);
  3220  
  3221  if (skbproto == htons(ETH_P_IP)) {
  3222  if (unlikely(!pskb_may_pull(skb, noff + sizeof(*iph
  3223  return false;
  3224  iph = ip_hdr(skb);
  3225  iph_to_flow_copy_v4addrs(fk, iph);
  3226  noff += iph->ihl << 2;
  3227  if (!ip_is_fragment(iph))
  3228  proto = iph->protocol;
  3229  } else if (skbproto == htons(ETH_P_IPV6)) {
  3230  if (unlikely(!pskb_may_pull(skb, noff + sizeof(*iph6
  3231  return false;
  3232  iph6 = ipv6_hdr(skb);
  3233  iph_to_flow_copy_v6addrs(fk, iph6);
  3234  noff += sizeof(*iph6);
  3235  proto = iph6->nexthdr;
  3236  } else {
  3237  return false;
  3238  }
  3239  if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER34 && 
proto >= 0)
  3240  fk->ports.ports = skb_flow_get_ports(skb, noff, proto);
  3241  
  3242  return true;
  3243  }
  3244  

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


Re: [PATCH] net: bond: skip vlan header when do layer 3+4 hash policy

2018-03-31 Thread Nikolay Aleksandrov

On 31/03/18 12:14, liujia...@huawei.com wrote:

From: liujian 

When the hash policy is BOND_XMIT_POLICY_LAYER34 mode and skb protocol
is 802.1q VLAN, the policy will be degenerated to LAYER2 mode; Now,
change it to get the next layer protocol to ensure that it worked in
BOND_XMIT_POLICY_LAYER34 mode.

Signed-off-by: liujian 
---
  drivers/net/bonding/bond_main.c | 11 ---
  1 file changed, 8 insertions(+), 3 deletions(-)



Nak
Use BOND_XMIT_POLICY_ENCAP34 (encap3+4), that was one of the main reasons it 
was added.



[PATCH] net: bond: skip vlan header when do layer 3+4 hash policy

2018-03-31 Thread liujian56
From: liujian 

When the hash policy is BOND_XMIT_POLICY_LAYER34 mode and skb protocol 
is 802.1q VLAN, the policy will be degenerated to LAYER2 mode; Now, 
change it to get the next layer protocol to ensure that it worked in 
BOND_XMIT_POLICY_LAYER34 mode.

Signed-off-by: liujian 
---
 drivers/net/bonding/bond_main.c | 11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index c669554..d9f58819 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3206,14 +3206,19 @@ static bool bond_flow_dissect(struct bonding *bond, 
struct sk_buff *skb,
 {
const struct ipv6hdr *iph6;
const struct iphdr *iph;
-   int noff, proto = -1;
+   int noff, proto = -1, skbproto;
 
if (bond->params.xmit_policy > BOND_XMIT_POLICY_LAYER23)
return skb_flow_dissect_flow_keys(skb, fk, 0);
 
fk->ports.ports = 0;
noff = skb_network_offset(skb);
-   if (skb->protocol == htons(ETH_P_IP)) {
+
+   skbproto = skb->protocol;
+   if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER34)
+   skbproto = vlan_get_protocol(skb);
+
+   if (skbproto == htons(ETH_P_IP)) {
if (unlikely(!pskb_may_pull(skb, noff + sizeof(*iph
return false;
iph = ip_hdr(skb);
@@ -3221,7 +3226,7 @@ static bool bond_flow_dissect(struct bonding *bond, 
struct sk_buff *skb,
noff += iph->ihl << 2;
if (!ip_is_fragment(iph))
proto = iph->protocol;
-   } else if (skb->protocol == htons(ETH_P_IPV6)) {
+   } else if (skbproto == htons(ETH_P_IPV6)) {
if (unlikely(!pskb_may_pull(skb, noff + sizeof(*iph6
return false;
iph6 = ipv6_hdr(skb);
-- 
2.7.4