[PATCH SRv6 End.X] Signed-off-by: Reji Thomas <rejithomas@xxxxxxxxxxx>

From: Reji Thomas
Date: Mon Oct 12 2020 - 05:51:39 EST


seg6: 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
while using link local address as the End.X nexthop.The patch
fixes this for link local addresses.

Signed-off-by: Reji Thomas <rejithomas@xxxxxxxxxxx>
---
net/ipv6/seg6_local.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c
index eba23279912d..26a1c1e3e560 100644
--- a/net/ipv6/seg6_local.c
+++ b/net/ipv6/seg6_local.c
@@ -246,6 +246,16 @@ static int input_action_end_x(struct sk_buff *skb, struct seg6_local_lwt *slwt)

advance_nextseg(srh, &ipv6_hdr(skb)->daddr);

+ if (ipv6_addr_type(&slwt->nh6) & IPV6_ADDR_LINKLOCAL) {
+ struct net *net = dev_net(skb->dev);
+ struct net_device *odev;
+
+ odev = dev_get_by_index_rcu(net, slwt->oif);
+ if (!odev)
+ goto drop;
+ skb->dev = odev;
+ }
+
seg6_lookup_nexthop(skb, &slwt->nh6, 0);

return dst_input(skb);
@@ -566,7 +576,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