From patchwork Sat Mar 31 09:14:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Jian X-Patchwork-Id: 893748 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40Ct9w18vdz9s1S for ; Sat, 31 Mar 2018 20:15:15 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752422AbeCaJPL (ORCPT ); Sat, 31 Mar 2018 05:15:11 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7142 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751560AbeCaJPK (ORCPT ); Sat, 31 Mar 2018 05:15:10 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id E5A146B807F6D; Sat, 31 Mar 2018 17:14:54 +0800 (CST) Received: from localhost (10.177.97.126) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.361.1; Sat, 31 Mar 2018 17:14:45 +0800 From: To: , , , CC: , , Subject: [PATCH] net: bond: skip vlan header when do layer 3+4 hash policy Date: Sat, 31 Mar 2018 17:14:30 +0800 Message-ID: <1522487670-15796-1-git-send-email-liujian56@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.177.97.126] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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);