Skip to contentSkip to conversation

IPv6: sr: Fix End.X nexthop to use oif.

PATCH In review Reji Thomas 4 participants 9 messages Oct 15, 2020 – Oct 21, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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 ("ipv6: sr: implement several seg6local actions")

---
Changes in v2:
- Fixed seg6_strict_lookup_nexthop() to be a static function

- Fixed comments from Jakub Kicinski <[email protected]> -Sorted the variable declarations from longest to shortest. -fixes:tag and blank line fixed.

---
 net/ipv6/seg6_local.c | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)
net/ipv6/seg6_local.c +25 -7
index eba23279912d..4603daed9de6 100644
@@ -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,14 @@ 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);
+}
+
+static 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 +250,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_device *odev;
+	struct net *net = dev_net(skb->dev);
 
 	srh = get_and_validate_srh(skb);
 	if (!srh)
@@ -246,7 +259,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 +429,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 +583,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,
 	},
 	{
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 8 lines · On Thu, 15 Oct 2020 13:51:19 +0530 Reji Thomas wrote:

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 ("ipv6: sr: implement several seg6local actions")

David, Mathiey - any comments?

net/ipv6/seg6_local.c static int input_action_end(struct sk_buff *skb, struct seg6_local_lwt *slwt) · line 254

Quoted 6 lines
net/ipv6/seg6_local.c +2 -0
@@ -239,6 +250,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_device *odev;
+	struct net *net = dev_net(skb->dev);

Order longest to shortest.

net/ipv6/seg6_local.c static int input_action_end_x(struct sk_buff *skb, struct seg6_local_lwt *slwt) · line 264

Quoted 11 lines
net/ipv6/seg6_local.c +3 -1
 	srh = get_and_validate_srh(skb);
 	if (!srh)
@@ -246,7 +259,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;

Are you doing this lookup just to make sure that oif exists? Looks a little wasteful for fast path, but more importantly it won't be backward compatible, right? See below..

Quoted 7 lines
net/ipv6/seg6_local.c +2 -0
+
+	seg6_strict_lookup_nexthop(skb, &slwt->nh6, odev->ifindex, 0);
 
 	return dst_input(skb);
 

net/ipv6/seg6_local.c static struct seg6_action_desc seg6_action_table[] = { · line 590

Quoted 9 lines
net/ipv6/seg6_local.c +2 -1
@@ -566,7 +583,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,
 	},
 	{

If you set this parse_nla_action() will reject all SEG6_LOCAL_ACTION_END_X without OIF.

As you say the OIF is only required for using link local addresses, so this change breaks perfectly legitimate configurations.

Can we instead only warn about the missing OIF, and only do that when nh is link local?

Also doesn't SEG6_LOCAL_ACTION_END_DX6 need a similar treatment?

#2 lore raw

Hi,

Please find my replies inline below.

Regards
Reji

Quoted 13 lines · Jakub Kicinski
Quoted 8 lines · On Thu, 15 Oct 2020 13:51:19 +0530 Reji Thomas wrote:

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 ("ipv6: sr: implement several seg6local actions")

David, Mathiey - any comments?

Quoted 8 lines

net/ipv6/seg6_local.c static int input_action_end(struct sk_buff *skb, struct seg6_local_lwt *slwt) · line 254

Quoted 6 lines
net/ipv6/seg6_local.c +2 -0
@@ -239,6 +250,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_device *odev;
+     struct net *net = dev_net(skb->dev);

Order longest to shortest.

Sorry. Will fix it.

Quoted 9 lines
Quoted 9 lines
net/ipv6/seg6_local.c +0 -0
      srh = get_and_validate_srh(skb);
      if (!srh)
@@ -246,7 +259,11 @@ static int input_action_end_x(struct sk_buff *skb, struct seg6_local_lwt *slwt)
 
      advance_nextseg(srh, &ipv6_hdr(skb)->daddr);
 
Quoted 9 lines

net/ipv6/seg6_local.c static int input_action_end_x(struct sk_buff *skb, struct seg6_local_lwt *slwt) · line 264

Quoted 4 lines
net/ipv6/seg6_local.c +3 -1
-     seg6_lookup_nexthop(skb, &slwt->nh6, 0);
+     odev = dev_get_by_index_rcu(net, slwt->oif);
+     if (!odev)
+             goto drop;

Are you doing this lookup just to make sure that oif exists? Looks a little wasteful for fast path, but more importantly it won't be backward compatible, right? See below..

Please see reply below.

Quoted 20 lines
Quoted 7 lines
net/ipv6/seg6_local.c +2 -0
+
+     seg6_strict_lookup_nexthop(skb, &slwt->nh6, odev->ifindex, 0);
 
      return dst_input(skb);
 

net/ipv6/seg6_local.c static struct seg6_action_desc seg6_action_table[] = { · line 590

Quoted 9 lines
net/ipv6/seg6_local.c +2 -1
@@ -566,7 +583,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,
      },
      {

If you set this parse_nla_action() will reject all SEG6_LOCAL_ACTION_END_X without OIF.

Quoted 6 lines

As you say the OIF is only required for using link local addresses, so this change breaks perfectly legitimate configurations.

Can we instead only warn about the missing OIF, and only do that when nh is link local?

End.X is defined as an adjacency-sid and is used to select a specific link to a neighbor for both global and link-local addresses. The intention was to drop the
packet even for global addresses if the route via the specific interface is not found.
Alternatively(believe semantically correct for End.X definition) I could do a neighbor lookup
for nexthop address over specific interface and send the packet out.

Quoted 1 line

Also doesn't SEG6_LOCAL_ACTION_END_DX6 need a similar treatment?

Yes. I will update the patch for End.DX6 based on the patch finalized for End.X.

maintainer
#3 lore raw
Quoted 20 lines · On Mon, 19 Oct 2020 09:25:12 +0530 Reji Thomas wrote:
Quoted 14 lines

net/ipv6/seg6_local.c static struct seg6_action_desc seg6_action_table[] = { · line 590

Quoted 10 lines
net/ipv6/seg6_local.c +2 -1
@@ -566,7 +583,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,
      },
      {  

If you set this parse_nla_action() will reject all SEG6_LOCAL_ACTION_END_X without OIF.

Quoted 6 lines

As you say the OIF is only required for using link local addresses, so this change breaks perfectly legitimate configurations.

Can we instead only warn about the missing OIF, and only do that when nh is link local?

Quoted 8 lines

End.X is defined as an adjacency-sid and is used to select a specific link to a neighbor for both global and link-local addresses. The intention was to drop the
packet even for global addresses if the route via the specific interface is not found.
Alternatively(believe semantically correct for End.X definition) I could do a neighbor lookup
for nexthop address over specific interface and send the packet out.

If we can save the device lookup and still be semantically correct, that's probably better.

#4 lore raw
Quoted 3 lines · Jakub Kicinski

If we can save the device lookup and still be semantically correct, that's probably better.

I am afraid we need to do a device lookup if I am looking up the neighbor. neigh_lookup
apis expect dev to be passed. If I go through the current lookup ie ip6_pol_route() I can
drop the dev lookup at risk of returning a non neighbor route as it exists today.

#5 lore raw
In reply to Reji Thomas

Jakub, Reji,

Andrea (CC'ed) and I have been working on a patch that could solve this issue. The patch allows to provide optional parameters to when SRv6 behavior. The OIF can be provided as an optional parameter when configuring SRv6 End.X, End.DX6 or End.DX4 (we are submiting in the next couple of days to support End.DX4).

We can submit the optional parameter again. Then Reji can leverage this to provide OIF as an optional parameters.

Would you agree ?

Thanks
Ahmed

Quoted 89 lines · On Mon, 19 Oct 2020 09:25:12 +0530 Reji Thomas <[email protected]> wrote:

Hi,

Please find my replies inline below.

Regards
Reji

Quoted 13 lines · Jakub Kicinski
Quoted 8 lines · On Thu, 15 Oct 2020 13:51:19 +0530 Reji Thomas wrote:

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 ("ipv6: sr: implement several seg6local actions")

David, Mathiey - any comments?

Quoted 8 lines

net/ipv6/seg6_local.c static int input_action_end(struct sk_buff *skb, struct seg6_local_lwt *slwt) · line 254

Quoted 6 lines
net/ipv6/seg6_local.c +2 -0
@@ -239,6 +250,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_device *odev;
+     struct net *net = dev_net(skb->dev);

Order longest to shortest.

Sorry. Will fix it.

Quoted 9 lines
Quoted 9 lines
net/ipv6/seg6_local.c +0 -0
      srh = get_and_validate_srh(skb);
      if (!srh)
@@ -246,7 +259,11 @@ static int input_action_end_x(struct sk_buff *skb, struct seg6_local_lwt *slwt)
 
      advance_nextseg(srh, &ipv6_hdr(skb)->daddr);
 
Quoted 9 lines

net/ipv6/seg6_local.c static int input_action_end_x(struct sk_buff *skb, struct seg6_local_lwt *slwt) · line 264

Quoted 4 lines
net/ipv6/seg6_local.c +3 -1
-     seg6_lookup_nexthop(skb, &slwt->nh6, 0);
+     odev = dev_get_by_index_rcu(net, slwt->oif);
+     if (!odev)
+             goto drop;

Are you doing this lookup just to make sure that oif exists? Looks a little wasteful for fast path, but more importantly it won't be backward compatible, right? See below..

Please see reply below.

Quoted 20 lines
Quoted 7 lines
net/ipv6/seg6_local.c +2 -0
+
+     seg6_strict_lookup_nexthop(skb, &slwt->nh6, odev->ifindex, 0);
 
      return dst_input(skb);
 

net/ipv6/seg6_local.c static struct seg6_action_desc seg6_action_table[] = { · line 590

Quoted 9 lines
net/ipv6/seg6_local.c +2 -1
@@ -566,7 +583,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,
      },
      {

If you set this parse_nla_action() will reject all SEG6_LOCAL_ACTION_END_X without OIF.

Quoted 6 lines

As you say the OIF is only required for using link local addresses, so this change breaks perfectly legitimate configurations.

Can we instead only warn about the missing OIF, and only do that when nh is link local?

End.X is defined as an adjacency-sid and is used to select a specific link to a neighbor for both global and link-local addresses. The intention was to drop the
packet even for global addresses if the route via the specific interface is not found.
Alternatively(believe semantically correct for End.X definition) I could do a neighbor lookup
for nexthop address over specific interface and send the packet out.

Quoted 1 line

Also doesn't SEG6_LOCAL_ACTION_END_DX6 need a similar treatment?

Yes. I will update the patch for End.DX6 based on the patch finalized for End.X.

Signature · 1 line
Ahmed Abdelsalam <[email protected]>
#6 lore raw

We are submitting the patch for End.DT4. End.DX4 is already there.

So the optional parameter and OIF applies directly to End.X/End.DX6/End.DX4.

Quoted 113 lines · On Tue, 20 Oct 2020 11:28:29 +0200 Ahmed Abdelsalam <[email protected]>…

Jakub, Reji,

Andrea (CC'ed) and I have been working on a patch that could solve this issue. The patch allows to provide optional parameters to when SRv6 behavior. The OIF can be provided as an optional parameter when configuring SRv6 End.X, End.DX6 or End.DX4 (we are submiting in the next couple of days to support End.DX4).

We can submit the optional parameter again. Then Reji can leverage this to provide OIF as an optional parameters.

Would you agree ?

Thanks
Ahmed

Quoted 89 lines · On Mon, 19 Oct 2020 09:25:12 +0530 Reji Thomas <[email protected]> wrote:

Hi,

Please find my replies inline below.

Regards
Reji

Quoted 13 lines · Jakub Kicinski
Quoted 8 lines · On Thu, 15 Oct 2020 13:51:19 +0530 Reji Thomas wrote:

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 ("ipv6: sr: implement several seg6local actions")

David, Mathiey - any comments?

Quoted 8 lines

net/ipv6/seg6_local.c static int input_action_end(struct sk_buff *skb, struct seg6_local_lwt *slwt) · line 254

Quoted 6 lines
net/ipv6/seg6_local.c +2 -0
@@ -239,6 +250,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_device *odev;
+     struct net *net = dev_net(skb->dev);

Order longest to shortest.

Sorry. Will fix it.

Quoted 9 lines
Quoted 9 lines
net/ipv6/seg6_local.c +0 -0
      srh = get_and_validate_srh(skb);
      if (!srh)
@@ -246,7 +259,11 @@ static int input_action_end_x(struct sk_buff *skb, struct seg6_local_lwt *slwt)
 
      advance_nextseg(srh, &ipv6_hdr(skb)->daddr);
 
Quoted 9 lines

net/ipv6/seg6_local.c static int input_action_end_x(struct sk_buff *skb, struct seg6_local_lwt *slwt) · line 264

Quoted 4 lines
net/ipv6/seg6_local.c +3 -1
-     seg6_lookup_nexthop(skb, &slwt->nh6, 0);
+     odev = dev_get_by_index_rcu(net, slwt->oif);
+     if (!odev)
+             goto drop;

Are you doing this lookup just to make sure that oif exists? Looks a little wasteful for fast path, but more importantly it won't be backward compatible, right? See below..

Please see reply below.

Quoted 20 lines
Quoted 7 lines
net/ipv6/seg6_local.c +2 -0
+
+     seg6_strict_lookup_nexthop(skb, &slwt->nh6, odev->ifindex, 0);
 
      return dst_input(skb);
 

net/ipv6/seg6_local.c static struct seg6_action_desc seg6_action_table[] = { · line 590

Quoted 9 lines
net/ipv6/seg6_local.c +2 -1
@@ -566,7 +583,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,
      },
      {

If you set this parse_nla_action() will reject all SEG6_LOCAL_ACTION_END_X without OIF.

Quoted 6 lines

As you say the OIF is only required for using link local addresses, so this change breaks perfectly legitimate configurations.

Can we instead only warn about the missing OIF, and only do that when nh is link local?

End.X is defined as an adjacency-sid and is used to select a specific link to a neighbor for both global and link-local addresses. The intention was to drop the
packet even for global addresses if the route via the specific interface is not found.
Alternatively(believe semantically correct for End.X definition) I could do a neighbor lookup
for nexthop address over specific interface and send the packet out.

Quoted 1 line

Also doesn't SEG6_LOCAL_ACTION_END_DX6 need a similar treatment?

Yes. I will update the patch for End.DX6 based on the patch finalized for End.X.

Signature · 1 line
Ahmed Abdelsalam <[email protected]>
Signature · 1 line
Ahmed Abdelsalam <[email protected]>
#7 lore raw

Hi Ahmed,

Quoted 5 lines · Ahmed Abdelsalam

We are submitting the patch for End.DT4. End.DX4 is already there.

So the optional parameter and OIF applies directly to End.X/End.DX6/End.DX4.

The only catch is OIF cannot be an optional parameter for linklocal address. For global address, it can be made to depend on user specifying the oif in which case
code can enforce the lookup with oif and in other cases do an "any" interface lookup.
That would also solve Jakub's concern in breaking any existing implementations(using global address)
thereby passing the onus to the control plane to enforce the interface behavior as
needed for global address.

I will wait for the patch. Hope there will be a way to enforce the oif for linklocal address..

Quoted 121 lines
Quoted 106 lines · On Tue, 20 Oct 2020 11:28:29 +0200 Ahmed Abdelsalam <[email protected]>…

Jakub, Reji,

Andrea (CC'ed) and I have been working on a patch that could solve this issue. The patch allows to provide optional parameters to when SRv6 behavior. The OIF can be provided as an optional parameter when configuring SRv6 End.X, End.DX6 or End.DX4 (we are submiting in the next couple of days to support End.DX4).

We can submit the optional parameter again. Then Reji can leverage this to provide OIF as an optional parameters.

Would you agree ?

Thanks
Ahmed

Quoted 86 lines · On Mon, 19 Oct 2020 09:25:12 +0530 Reji Thomas <[email protected]> wrote:

Hi,

Please find my replies inline below.

Regards
Reji

Quoted 13 lines · Jakub Kicinski
Quoted 8 lines · On Thu, 15 Oct 2020 13:51:19 +0530 Reji Thomas wrote:

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 ("ipv6: sr: implement several seg6local actions")

David, Mathiey - any comments?

Quoted 8 lines

net/ipv6/seg6_local.c static int input_action_end(struct sk_buff *skb, struct seg6_local_lwt *slwt) · line 254

Quoted 6 lines
net/ipv6/seg6_local.c +2 -0
@@ -239,6 +250,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_device *odev;
+     struct net *net = dev_net(skb->dev);

Order longest to shortest.

Sorry. Will fix it.

Quoted 9 lines
Quoted 9 lines
net/ipv6/seg6_local.c +0 -0
      srh = get_and_validate_srh(skb);
      if (!srh)
@@ -246,7 +259,11 @@ static int input_action_end_x(struct sk_buff *skb, struct seg6_local_lwt *slwt)
 
      advance_nextseg(srh, &ipv6_hdr(skb)->daddr);
 
Quoted 9 lines

net/ipv6/seg6_local.c static int input_action_end_x(struct sk_buff *skb, struct seg6_local_lwt *slwt) · line 264

Quoted 4 lines
net/ipv6/seg6_local.c +3 -1
-     seg6_lookup_nexthop(skb, &slwt->nh6, 0);
+     odev = dev_get_by_index_rcu(net, slwt->oif);
+     if (!odev)
+             goto drop;

Are you doing this lookup just to make sure that oif exists? Looks a little wasteful for fast path, but more importantly it won't be backward compatible, right? See below..

Please see reply below.

Quoted 20 lines
Quoted 7 lines
net/ipv6/seg6_local.c +2 -0
+
+     seg6_strict_lookup_nexthop(skb, &slwt->nh6, odev->ifindex, 0);
 
      return dst_input(skb);
 

net/ipv6/seg6_local.c static struct seg6_action_desc seg6_action_table[] = { · line 590

Quoted 9 lines
net/ipv6/seg6_local.c +2 -1
@@ -566,7 +583,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,
      },
      {

If you set this parse_nla_action() will reject all SEG6_LOCAL_ACTION_END_X without OIF.

Quoted 6 lines

As you say the OIF is only required for using link local addresses, so this change breaks perfectly legitimate configurations.

Can we instead only warn about the missing OIF, and only do that when nh is link local?

End.X is defined as an adjacency-sid and is used to select a specific link to a neighbor for both global and link-local addresses. The intention was to drop the
packet even for global addresses if the route via the specific interface is not found.
Alternatively(believe semantically correct for End.X definition) I could do a neighbor lookup
for nexthop address over specific interface and send the packet out.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Also doesn't SEG6_LOCAL_ACTION_END_DX6 need a similar treatment?

Yes. I will update the patch for End.DX6 based on the patch finalized for End.X.

--
Ahmed Abdelsalam <[email protected]>

--
Ahmed Abdelsalam <[email protected]>

#8 lore raw

Hi Reji,

We are going to send the patch to the mailer in the next days.

As for the link local addresses, we can add a check for that and kernel returns error in case of link local and OIF not provided.

We will add you and Jakub to the recipients when we send the patch.

Best,
Ahmed

Quoted 146 lines · On Tue, 20 Oct 2020 18:05:47 +0530 Reji Thomas <[email protected]> wrote:

Hi Ahmed,

Quoted 5 lines · Ahmed Abdelsalam

We are submitting the patch for End.DT4. End.DX4 is already there.

So the optional parameter and OIF applies directly to End.X/End.DX6/End.DX4.

The only catch is OIF cannot be an optional parameter for linklocal address. For global address, it can be made to depend on user specifying the oif in which case
code can enforce the lookup with oif and in other cases do an "any" interface lookup.
That would also solve Jakub's concern in breaking any existing implementations(using global address)
thereby passing the onus to the control plane to enforce the interface behavior as
needed for global address.

I will wait for the patch. Hope there will be a way to enforce the oif for linklocal address..

Quoted 121 lines
Quoted 106 lines · On Tue, 20 Oct 2020 11:28:29 +0200 Ahmed Abdelsalam <[email protected]>…

Jakub, Reji,

Andrea (CC'ed) and I have been working on a patch that could solve this issue. The patch allows to provide optional parameters to when SRv6 behavior. The OIF can be provided as an optional parameter when configuring SRv6 End.X, End.DX6 or End.DX4 (we are submiting in the next couple of days to support End.DX4).

We can submit the optional parameter again. Then Reji can leverage this to provide OIF as an optional parameters.

Would you agree ?

Thanks
Ahmed

Quoted 86 lines · On Mon, 19 Oct 2020 09:25:12 +0530 Reji Thomas <[email protected]> wrote:

Hi,

Please find my replies inline below.

Regards
Reji

Quoted 13 lines · Jakub Kicinski
Quoted 8 lines · On Thu, 15 Oct 2020 13:51:19 +0530 Reji Thomas wrote:

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 ("ipv6: sr: implement several seg6local actions")

David, Mathiey - any comments?

Quoted 8 lines

net/ipv6/seg6_local.c static int input_action_end(struct sk_buff *skb, struct seg6_local_lwt *slwt) · line 254

Quoted 6 lines
net/ipv6/seg6_local.c +2 -0
@@ -239,6 +250,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_device *odev;
+     struct net *net = dev_net(skb->dev);

Order longest to shortest.

Sorry. Will fix it.

Quoted 9 lines
Quoted 9 lines
net/ipv6/seg6_local.c +0 -0
      srh = get_and_validate_srh(skb);
      if (!srh)
@@ -246,7 +259,11 @@ static int input_action_end_x(struct sk_buff *skb, struct seg6_local_lwt *slwt)
 
      advance_nextseg(srh, &ipv6_hdr(skb)->daddr);
 
Quoted 9 lines

net/ipv6/seg6_local.c static int input_action_end_x(struct sk_buff *skb, struct seg6_local_lwt *slwt) · line 264

Quoted 4 lines
net/ipv6/seg6_local.c +3 -1
-     seg6_lookup_nexthop(skb, &slwt->nh6, 0);
+     odev = dev_get_by_index_rcu(net, slwt->oif);
+     if (!odev)
+             goto drop;

Are you doing this lookup just to make sure that oif exists? Looks a little wasteful for fast path, but more importantly it won't be backward compatible, right? See below..

Please see reply below.

Quoted 20 lines
Quoted 7 lines
net/ipv6/seg6_local.c +2 -0
+
+     seg6_strict_lookup_nexthop(skb, &slwt->nh6, odev->ifindex, 0);
 
      return dst_input(skb);
 

net/ipv6/seg6_local.c static struct seg6_action_desc seg6_action_table[] = { · line 590

Quoted 9 lines
net/ipv6/seg6_local.c +2 -1
@@ -566,7 +583,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,
      },
      {

If you set this parse_nla_action() will reject all SEG6_LOCAL_ACTION_END_X without OIF.

Quoted 6 lines

As you say the OIF is only required for using link local addresses, so this change breaks perfectly legitimate configurations.

Can we instead only warn about the missing OIF, and only do that when nh is link local?

End.X is defined as an adjacency-sid and is used to select a specific link to a neighbor for both global and link-local addresses. The intention was to drop the
packet even for global addresses if the route via the specific interface is not found.
Alternatively(believe semantically correct for End.X definition) I could do a neighbor lookup
for nexthop address over specific interface and send the packet out.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Also doesn't SEG6_LOCAL_ACTION_END_DX6 need a similar treatment?

Yes. I will update the patch for End.DX6 based on the patch finalized for End.X.

--
Ahmed Abdelsalam <[email protected]>

--
Ahmed Abdelsalam <[email protected]>

Signature · 1 line
Ahmed Abdelsalam <[email protected]>