[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201013120151.9777-1-rejithomas@juniper.net>
Date: Tue, 13 Oct 2020 17:31:51 +0530
From: Reji Thomas <rejithomas@...iper.net>
To: kuba@...nel.org
Cc: david.lebrun@...ouvain.be, davem@...emloft.net,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
rejithomas@...iper.net, rejithomas.d@...il.com
Subject: [PATCH] IPv6: sr: Fix End.X nexthop to use oif.
Currently End.X action doesn't consider the outgoing interface
while looking up the nexthop.This breaks packet path functionality
specifically while using link local address as the End.X nexthop.
The patch fixes this by enforcing End.X action to have both nh6 and
oif and using oif in lookup.It seems this is a day one issue.
Fixes: 140f04c33bbc ("implement several seg6local actions")
Signed-off-by: Reji Thomas <rejithomas@...iper.net>
---
net/ipv6/seg6_local.c | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
index eba23279912d..1a669f12d56c 100644
--- a/net/ipv6/seg6_local.c
+++ b/net/ipv6/seg6_local.c
@@ -153,7 +153,7 @@ static void advance_nextseg(struct ipv6_sr_hdr *srh, struct in6_addr *daddr)
static int
seg6_lookup_any_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr,
- u32 tbl_id, bool local_delivery)
+ int oif, u32 tbl_id, bool local_delivery)
{
struct net *net = dev_net(skb->dev);
struct ipv6hdr *hdr = ipv6_hdr(skb);
@@ -164,6 +164,7 @@ seg6_lookup_any_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr,
int dev_flags = 0;
fl6.flowi6_iif = skb->dev->ifindex;
+ fl6.flowi6_oif = oif;
fl6.daddr = nhaddr ? *nhaddr : hdr->daddr;
fl6.saddr = hdr->saddr;
fl6.flowlabel = ip6_flowinfo(hdr);
@@ -173,7 +174,10 @@ seg6_lookup_any_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr,
if (nhaddr)
fl6.flowi6_flags = FLOWI_FLAG_KNOWN_NH;
- if (!tbl_id) {
+ if (oif)
+ flags |= RT6_LOOKUP_F_IFACE;
+
+ if (!tbl_id && !oif) {
dst = ip6_route_input_lookup(net, skb->dev, &fl6, skb, flags);
} else {
struct fib6_table *table;
@@ -182,7 +186,7 @@ seg6_lookup_any_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr,
if (!table)
goto out;
- rt = ip6_pol_route(net, table, 0, &fl6, skb, flags);
+ rt = ip6_pol_route(net, table, oif, &fl6, skb, flags);
dst = &rt->dst;
}
@@ -212,7 +216,13 @@ seg6_lookup_any_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr,
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);
+ return seg6_lookup_any_nexthop(skb, nhaddr, 0, tbl_id, false);
+}
+
+int seg6_strict_lookup_nexthop(struct sk_buff *skb,
+ struct in6_addr *nhaddr, int oif, u32 tbl_id)
+{
+ return seg6_lookup_any_nexthop(skb, nhaddr, oif, tbl_id, false);
}
/* regular endpoint function */
@@ -239,6 +249,8 @@ static int input_action_end(struct sk_buff *skb, struct seg6_local_lwt *slwt)
static int input_action_end_x(struct sk_buff *skb, struct seg6_local_lwt *slwt)
{
struct ipv6_sr_hdr *srh;
+ struct net *net = dev_net(skb->dev);
+ struct net_device *odev;
srh = get_and_validate_srh(skb);
if (!srh)
@@ -246,7 +258,11 @@ static int input_action_end_x(struct sk_buff *skb, struct seg6_local_lwt *slwt)
advance_nextseg(srh, &ipv6_hdr(skb)->daddr);
- seg6_lookup_nexthop(skb, &slwt->nh6, 0);
+ odev = dev_get_by_index_rcu(net, slwt->oif);
+ if (!odev)
+ goto drop;
+
+ seg6_strict_lookup_nexthop(skb, &slwt->nh6, odev->ifindex, 0);
return dst_input(skb);
@@ -412,7 +428,7 @@ static int input_action_end_dt6(struct sk_buff *skb,
skb_set_transport_header(skb, sizeof(struct ipv6hdr));
- seg6_lookup_any_nexthop(skb, NULL, slwt->table, true);
+ seg6_lookup_any_nexthop(skb, NULL, 0, slwt->table, true);
return dst_input(skb);
@@ -566,7 +582,8 @@ static struct seg6_action_desc seg6_action_table[] = {
},
{
.action = SEG6_LOCAL_ACTION_END_X,
- .attrs = (1 << SEG6_LOCAL_NH6),
+ .attrs = ((1 << SEG6_LOCAL_NH6) |
+ (1 << SEG6_LOCAL_OIF)),
.input = input_action_end_x,
},
{
--
2.17.1
Powered by blists - more mailing lists