Received: by 10.192.165.148 with SMTP id m20csp1686317imm; Sat, 28 Apr 2018 03:19:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZotO6pJlPxeFFeLuEVGHsj3CJ4rW/ylDAUdhLW+TRBb3iL97aSlW63HuULIIIxRKtCtf7Bp X-Received: by 2002:a63:5fd1:: with SMTP id t200-v6mr4919947pgb.246.1524910797795; Sat, 28 Apr 2018 03:19:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524910797; cv=none; d=google.com; s=arc-20160816; b=R0ZVdzYNvQOrjc33Xlcj481qzpmeOF6IXp2FNop0gieBAnazVa+Q75KjiNO5NnHOyh VbXHYEURDqzgcyrV3wi4cvj6+IfwrR0YG3KmNQZwEeBNGqrhZ8GqxdzohpHMExJqlUhy rCOsst16XKQm5ONlo+zX16eKcRwOD3N5AfZOPBG6+CqLjZAs/pgX+keZkjOAbHvCrpVC L/Ho5yikMvZjFPk+Qf9xBc5d4XxZrLJ6Y+26jG8wbaveEt3Y8OGz1et/xxN3EUm6tiXu dziaHOdB/ufEhEaPK/ZtSKkdHH/nuik5fyCUX4gpLhs36nrvuZhhr2imrssCqH4XP8yr nAlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Jfc/eSfn+pgAxVJjNyKca3Q3Knsuh5VRPGVU0h7rktQ=; b=aDPhoDj7oD4jn48trG9rSmKp7pfbXWRhFWwyTh82hcJkE5bMeA+i9f7T1jnStvel76 nMnMwSvOb8bl4LGuaidPatNfjhe495raO1yPrp1U0jYHZWIoFhukd/NjnoUpVYkM07yz ghBZYZlse5a0J44cqTCx0T++hEgmi6tZQnObH3+ZqDQVO53/qdHkBnv3vt9TefddEzDs +8jdkqezwkMkssKsFtMWWF6eHFkL2J6+ivaD3x/7FeTLsyE5DTxA4o9/PYnufg8zg6+e qeAY8L3F/dozcVK4Dteh1T4cqpx9ylCRousPNzJaAeB2oWhiXP4Wy7FqxuHCZUnY64kh HLdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TlK+S2bD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t7-v6si2943756pgo.686.2018.04.28.03.19.41; Sat, 28 Apr 2018 03:19:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TlK+S2bD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759829AbeD1KSg (ORCPT + 99 others); Sat, 28 Apr 2018 06:18:36 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:41343 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759745AbeD1KSf (ORCPT ); Sat, 28 Apr 2018 06:18:35 -0400 Received: by mail-wr0-f193.google.com with SMTP id g21-v6so3885041wrb.8; Sat, 28 Apr 2018 03:18:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Jfc/eSfn+pgAxVJjNyKca3Q3Knsuh5VRPGVU0h7rktQ=; b=TlK+S2bDL3MEeN19LQIaUPlj+y0U/m50LDDLV1qeLdfCztQfiIGsCjQ4oGrOBel/GM 7tna4FeG5+YjqTGaWXsGQrhz7b1HS1tp6ypL0r6AdmzD5u3fawxKQ6iUXHdRS8Sr6OXu +6aHeQQCdMNVM9NI7BgHbSR4hlTi14Eu97jdHBJSsiv9myNfvn4SKUSmedVfPk1+/Pzz vBsoCiIuc6SBlQbXHNFGNHH4OjrvAP2CHdh+MxSZjRpwWB9Owfuo5pE+kIBT1r8SRvXa bTT7RXbYknF7W1Q0vtj3DmyNrQsDznlxp/56/6TcJyaSZqMqGxqzMmoBNUQlzPkiwMa6 iGzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Jfc/eSfn+pgAxVJjNyKca3Q3Knsuh5VRPGVU0h7rktQ=; b=dD0/uwsbwAS7bzyKi7R4xIPBvGeJKWqut+qw4dMR3kMYndsmiiqufoPc7Q/FC//S2o ESUvowqvqC2lIoVs3L890rSJIVDE32IK03bWfQHKKqdT4RjEud1wzx/o3ryAYV8kyg7Z /0yz2X2GNnxie7gilyH6aidkXu0Fexppfxi/zqaMPpmCd+DgXzZXJK36q+ERR33ng2Fo oejVm4kZQZDdiIgkyJi5FialNMmP+eqbrd+Ksn4zrWtUpJYTidxB5X/dmYtaxQaTUsqK 66tXgR8lue6EA0KCtJsKhUCj95ESXepHv7adgsc2I1H2yKmtcA2Xh6uxhMyKCbQPIMa4 LDTg== X-Gm-Message-State: ALQs6tDQaTBNb0nXDXsDmEAMb7WnYafWBk/uyq8MG28WhQKI/gFzVnw+ /Bud1VRgLDe2N0A8BfMKhyAbQqGK X-Received: by 2002:adf:b067:: with SMTP id g36-v6mr4043835wra.128.1524910713544; Sat, 28 Apr 2018 03:18:33 -0700 (PDT) Received: from localhost.localdomain ([192.135.27.140]) by smtp.gmail.com with ESMTPSA id 80sm4472579wmk.46.2018.04.28.03.18.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 28 Apr 2018 03:18:32 -0700 (PDT) From: Ahmed Abdelsalam To: davem@davemloft.net, dav.lebrun@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ahmed Abdelsalam Subject: [net-next v2] ipv6: sr: extract the right key values for "seg6_make_flowlabel" Date: Sat, 28 Apr 2018 12:18:35 +0200 Message-Id: <1524910715-12097-1-git-send-email-amsalam20@gmail.com> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The seg6_make_flowlabel() is used by seg6_do_srh_encap() to compute the flowlabel from a given skb. It relies on skb_get_hash() which eventually calls __skb_flow_dissect() to extract the flow_keys struct values from the skb. In case of IPv4 traffic, calling seg6_make_flowlabel() after skb_push(), skb_reset_network_header(), and skb_mac_header_rebuild() will results in flow_keys struct of all key values set to zero. This patch calls seg6_make_flowlabel() before resetting the headers of skb to get the right key values. Extracted Key values are based on the type inner packet as follows: 1) IPv6 traffic: src_IP, dst_IP, L4 proto, and flowlabel of inner packet. 2) IPv4 traffic: src_IP, dst_IP, L4 proto, src_port, and dst_port 3) L2 traffic: depends on what kind of traffic carried into the L2 frame. IPv6 and IPv4 traffic works as discussed 1) and 2) Here a hex_dump of struct flow_keys for IPv4 and IPv6 traffic 10.100.1.100: 47302 > 30.0.0.2: 5001 00000000: 14 00 02 00 00 00 00 00 08 00 11 00 00 00 00 00 00000010: 00 00 00 00 00 00 00 00 13 89 b8 c6 1e 00 00 02 00000020: 0a 64 01 64 fc00:a1:a > b2::2 00000000: 28 00 03 00 00 00 00 00 86 dd 11 00 99 f9 02 00 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 b2 00 00 00000020: 00 00 00 00 00 00 00 00 00 00 00 02 fc 00 00 a1 00000030: 00 00 00 00 00 00 00 00 00 00 00 0a Signed-off-by: Ahmed Abdelsalam --- net/ipv6/seg6_iptunnel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c index 9898926..eab39bd 100644 --- a/net/ipv6/seg6_iptunnel.c +++ b/net/ipv6/seg6_iptunnel.c @@ -127,6 +127,7 @@ int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh, int proto) return err; inner_hdr = ipv6_hdr(skb); + flowlabel = seg6_make_flowlabel(net, skb, inner_hdr); skb_push(skb, tot_len); skb_reset_network_header(skb); @@ -138,7 +139,6 @@ int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh, int proto) * decapsulation will overwrite inner hlim with outer hlim */ - flowlabel = seg6_make_flowlabel(net, skb, inner_hdr); if (skb->protocol == htons(ETH_P_IPV6)) { ip6_flow_hdr(hdr, ip6_tclass(ip6_flowinfo(inner_hdr)), flowlabel); -- 2.1.4