Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2281730ybc; Wed, 13 Nov 2019 11:49:51 -0800 (PST) X-Google-Smtp-Source: APXvYqyqbJVDyJKLm5w1BdvFEdLmkYvUV49DEu+PTlgUjSZqQ/fhUbSsjWbF7NmeOaKLNFkkfr4/ X-Received: by 2002:a17:906:7e41:: with SMTP id z1mr3725757ejr.63.1573674591624; Wed, 13 Nov 2019 11:49:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573674591; cv=none; d=google.com; s=arc-20160816; b=nFZoojOjbfpTNxwtlUJj7XZMKGZcV/XXhBlFKCry8wU3LSMIvcPeNkFid1W9psgHRd EY2+ICtvt7SySC0trCKFj5CwbecG8fbnl3kvMn/a2ocgJorECrQ42SYYWQBDbRJn5XGX xQX46yT59hUUSbkiGyskMwHiQuC3cMyYKSHVJDts2ICHcwpqa3Lsdb9Xoi5XBeft2I2k z45zQoJ4F5WgAc7Wlon35l9W3vTx4zxtyFGTuAaf18f5nN+wiEg9gqD5HL3kJ8tQZ6jc rUKsLZczwvtAdvFchKNzykyW8W6ue+B8P9T30+1r8QSOX1fsgxjxCu69++lbl4RBpTzN V5HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=mjX5RQsn6mF0nrj2YDCshnpJMd0P5Fyak6S0/+o/Fcs=; b=D8RQFmdfxQYj7icM28HJbz+Vws05HcGVx2V2yOcQYtboPumBPESAADZ8NfA52Z4YJE XFbu853lVBaYgECf+vBBU/CPNA3SXovXk4UQfRtg206k0/82X3ambNaEczwQfuaE0q9K HuN8U1093GiWxvAe3ZZSAlBmmjCt/vQ6PfDWLeoGbMqw8RbtOQONgLRuezsFFfNP7d7t VYJ3smCaDArvbg8iOkRIskbMJv4V7/If1KFhEHXonEe+lWJLsPV2AL9J/cE2i1F+vZi1 YOzKMNeyWRcbH32C9/Kl5PtyS0CNMDDxIU97U1CjBXPNHCPq7L136i4mi4K7Fv2PFu6W f5uw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=uniroma2.it Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p25si1743489eji.415.2019.11.13.11.49.27; Wed, 13 Nov 2019 11:49:51 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=uniroma2.it Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727078AbfKMTsP (ORCPT + 99 others); Wed, 13 Nov 2019 14:48:15 -0500 Received: from smtp.uniroma2.it ([160.80.6.16]:57695 "EHLO smtp.uniroma2.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbfKMTsN (ORCPT ); Wed, 13 Nov 2019 14:48:13 -0500 X-Greylist: delayed 1019 seconds by postgrey-1.27 at vger.kernel.org; Wed, 13 Nov 2019 14:47:58 EST Received: from localhost.localdomain ([160.80.103.126]) by smtp-2015.uniroma2.it (8.14.4/8.14.4/Debian-8) with ESMTP id xADJTimn023525 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Wed, 13 Nov 2019 20:31:38 +0100 From: Andrea Mayer To: "David S. Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , David Lebrun , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Andrea Mayer Subject: [net-next, 3/3] seg6: allow local packet processing for SRv6 End.DT6 behavior Date: Wed, 13 Nov 2019 20:29:12 +0100 Message-Id: <20191113192912.17546-4-andrea.mayer@uniroma2.it> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191113192912.17546-1-andrea.mayer@uniroma2.it> References: <20191113192912.17546-1-andrea.mayer@uniroma2.it> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.100.0 at smtp-2015 X-Virus-Status: Clean Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org End.DT6 behavior makes use of seg6_lookup_nexthop function which drops all packets that are destined to be locally processed. However, DT* should be able to delivery decapsulated packets that are destined to local addresses. Function seg6_lookup_nexthop is also used by DX6, so in order to maintain compatibility I created another routing helper function which is called seg6_lookup_any_nexthop. This function is able to take in to account both packets that have to be processed locally and the ones that are destined to be forwarded directly to another machine. Hence, seg6_lookup_any_nexthop is used in DT6 rather than seg6_lookup_nexthop to allow local delivery. Signed-off-by: Andrea Mayer --- net/ipv6/seg6_local.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c index 948a4c2a59f2..8a723ab3d29c 100644 --- a/net/ipv6/seg6_local.c +++ b/net/ipv6/seg6_local.c @@ -148,8 +148,9 @@ static void advance_nextseg(struct ipv6_sr_hdr *srh, struct in6_addr *daddr) *daddr = *addr; } -int seg6_lookup_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr, - u32 tbl_id) +static int +seg6_lookup_any_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr, + u32 tbl_id, int local_delivery) { struct net *net = dev_net(skb->dev); struct ipv6hdr *hdr = ipv6_hdr(skb); @@ -157,6 +158,7 @@ int seg6_lookup_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr, struct dst_entry *dst = NULL; struct rt6_info *rt; struct flowi6 fl6; + int dev_flags = 0; fl6.flowi6_iif = skb->dev->ifindex; fl6.daddr = nhaddr ? *nhaddr : hdr->daddr; @@ -181,7 +183,13 @@ int seg6_lookup_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr, dst = &rt->dst; } - if (dst && dst->dev->flags & IFF_LOOPBACK && !dst->error) { + /* we want to discard traffic destined for local packet processing, + * if @local_delivery is set to false. + */ + if (!local_delivery) + dev_flags |= IFF_LOOPBACK; + + if (dst && (dst->dev->flags & dev_flags) && !dst->error) { dst_release(dst); dst = NULL; } @@ -198,6 +206,12 @@ int seg6_lookup_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr, return dst->error; } +inline int seg6_lookup_nexthop(struct sk_buff *skb, + struct in6_addr *nhaddr, u32 tbl_id) +{ + return seg6_lookup_any_nexthop(skb, nhaddr, tbl_id, false); +} + /* regular endpoint function */ static int input_action_end(struct sk_buff *skb, struct seg6_local_lwt *slwt) { @@ -395,7 +409,7 @@ static int input_action_end_dt6(struct sk_buff *skb, skb_set_transport_header(skb, sizeof(struct ipv6hdr)); - seg6_lookup_nexthop(skb, NULL, slwt->table); + seg6_lookup_any_nexthop(skb, NULL, slwt->table, true); return dst_input(skb); -- 2.20.1