Received: by 10.192.165.148 with SMTP id m20csp2189715imm; Thu, 26 Apr 2018 07:14:21 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+kzJbmosuGOriOASz0FNKhaDhA06u7XyiFU37lJE61B+dmQC7f4I0YNhdsf9G/oLyNGEkj X-Received: by 10.99.7.86 with SMTP id 83mr12567056pgh.211.1524752061332; Thu, 26 Apr 2018 07:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524752061; cv=none; d=google.com; s=arc-20160816; b=jrDY7rSvhYNqYw7sskbDg47vkPpi58eBq8mNEIorGrLxpMoo7RZ4xs9xSGuKzwc8Hi N8576wdDC+UB07l/5xZeKiq7T9cH6gyAN0s9DdsyWy8HyogRmPQw1CGlkgY7g4DSc9CK GoKehLxGyRqah7grvhcmr33pWxZvI5xHyGMtZ/exkz8ZPts4bJQG6i6mM9H8atS6lBZn FGhcXHgQirKOsL9mhyoNvvs0GzV6bOm/bh2DhViUVqTEViopQVjYuLdXjDFIyQ2BK9pz ihTqnrQgDvIVQi0YbBoQo5Q2x9md1HuDQ4Eb2Y9c2EvYruyRMTPNU8yWgBD1BDcNcvdQ MbBQ== 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=wG88yFod9pTvO9Bw663Q59odOaVFtBGrOcqnJLnOmmw=; b=LX855zLS2b602GW0hBPYw4Sghomnpjx2ouE9G6KWR7haYFTfxPjs674ZTKHmAOZ6hz IspuJeRX3WjMPoY8AQwkFVC+KO/GiUmT9qY6zw8HCTky8h6rc6AiqIRnkQWQyRhRV/JB a1z2tjKVdlMrcIWU6j4Y5HTtjQRRndlXGoEsLpqsYBSjmDKsqbw7QW/+Gw3nuZXNkLGk 14JnmC3fsmpfiVERueceYlLCgJET2+gR12vOPGP0y/+I0OWxYjZn4S0GFYnpLZkLQ5+4 2mz+c3rBBOsKhkIFDbNSUDA/Xpf5aDUpJ55OdShjNZI2NF371WskwYYBZ1ouUEDrURcI lu1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hSZPVAVz; 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 z124si19090811pfb.188.2018.04.26.07.14.06; Thu, 26 Apr 2018 07:14:21 -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=hSZPVAVz; 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 S1756535AbeDZOLV (ORCPT + 99 others); Thu, 26 Apr 2018 10:11:21 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:38466 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755384AbeDZOLR (ORCPT ); Thu, 26 Apr 2018 10:11:17 -0400 Received: by mail-wr0-f194.google.com with SMTP id h3-v6so56964690wrh.5; Thu, 26 Apr 2018 07:11:16 -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=wG88yFod9pTvO9Bw663Q59odOaVFtBGrOcqnJLnOmmw=; b=hSZPVAVzB9Xmttbvm26uZOogQpOabAHHnFtIovETnpmQ8mfyotjdSEDH2PgGTd6UnA 4Fn9SnnAOGBjT4KcfRbJQBWdO2RGkt0TcuM7a/PW6b+EKzEUqEW3kLxVdS7WtaBYdfXD c0T1DUleQEvDEnZmvTDK9ZMIg5VK3WKDR3N8azwVgKBZk3O10oNPuINa9i4msvgusNe0 r1p/cqwVpVdwZO6g/oGtXd8S5C0HhZhGlpcRurpx8hGpraQgetMXv+y7/980I8iR1uiS ZEOp2vuYxv6hvStPPeOYyt8GawdetLyprYO48h1xzQNsoTiWmK0kdZiBqRTVYo5vlwh6 21DQ== 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=wG88yFod9pTvO9Bw663Q59odOaVFtBGrOcqnJLnOmmw=; b=USVX5lXLUDpwbOriJEv+vKfqZy7t90nwUtYxGycDqpKAieat1jrqmtFC7ktyug/zJA 64Q4X0jjfGbGjr8nGxhM/daIygBoNOaDXYi44iqLT/0Op4h9tfSY75KQTd+B4y5ayXlt 0BsKLqjHXQ54wqR2Gr7sUGBvUxnPCbcr+9ERtzzE96bj0rHyYymk9Aj+Gvvu00G83nw3 z8vph+S4ikewF/0sUiP6zRzq0zipexaM42pUgx1MmalIsHcavWjQOc/oPZqJNjsPv/c8 OxLfZmbhE28+pc10nVg+EtVjMKBHmyqXcsZnYv7iCKtRayAX6Ixihzk71x4yLit+iUPp zGnw== X-Gm-Message-State: ALQs6tDY8u24M75leFi5pE3tCIe9Jtr3ZB142HYsvqbSL+3vavme0px4 puC6qZCKHjOjc5n86WJEIS8psrV0 X-Received: by 2002:adf:874c:: with SMTP id 12-v6mr27852507wrz.275.1524751876044; Thu, 26 Apr 2018 07:11:16 -0700 (PDT) Received: from localhost.localdomain ([192.135.27.140]) by smtp.gmail.com with ESMTPSA id b66sm14441811wmh.24.2018.04.26.07.11.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 26 Apr 2018 07:11:15 -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] ipv6: sr: Extract the right key values for "seg6_make_flowlabel" Date: Thu, 26 Apr 2018 16:11:11 +0200 Message-Id: <1524751871-1353-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) Signed-off-by: Ahmed Abdelsalam --- net/ipv6/seg6_iptunnel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c index 9898926..0df83c0 100644 --- a/net/ipv6/seg6_iptunnel.c +++ b/net/ipv6/seg6_iptunnel.c @@ -119,6 +119,9 @@ int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh, int proto) int hdrlen, tot_len, err; __be32 flowlabel; + inner_hdr = ipv6_hdr(skb); + flowlabel = seg6_make_flowlabel(net, skb, inner_hdr); + hdrlen = (osrh->hdrlen + 1) << 3; tot_len = hdrlen + sizeof(*hdr); @@ -126,8 +129,6 @@ int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh, int proto) if (unlikely(err)) return err; - inner_hdr = ipv6_hdr(skb); - skb_push(skb, tot_len); skb_reset_network_header(skb); skb_mac_header_rebuild(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