[PATCH v1 2/2] ipv6: always accept routing headers with 0 segments left

From: Mathis Marion
Date: Mon Jun 24 2024 - 10:32:55 EST


From: Mathis Marion <mathis.marion@xxxxxxxxxx>

Routing headers of type 3 and 4 would be rejected even if segments left
was 0, in the case that they were disabled through system configuration.

RFC 8200 section 4.4 specifies:

If Segments Left is zero, the node must ignore the Routing header
and proceed to process the next header in the packet, whose type
is identified by the Next Header field in the Routing header.

Signed-off-by: Mathis Marion <mathis.marion@xxxxxxxxxx>
---
net/ipv6/exthdrs.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 083dbbafb166..913160b0fe13 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -662,17 +662,6 @@ static int ipv6_rthdr_rcv(struct sk_buff *skb)
return -1;
}

- switch (hdr->type) {
- case IPV6_SRCRT_TYPE_4:
- /* segment routing */
- return ipv6_srh_rcv(skb);
- case IPV6_SRCRT_TYPE_3:
- /* rpl segment routing */
- return ipv6_rpl_srh_rcv(skb);
- default:
- break;
- }
-
looped_back:
if (hdr->segments_left == 0) {
switch (hdr->type) {
@@ -708,6 +697,12 @@ static int ipv6_rthdr_rcv(struct sk_buff *skb)
}
break;
#endif
+ case IPV6_SRCRT_TYPE_3:
+ /* rpl segment routing */
+ return ipv6_rpl_srh_rcv(skb);
+ case IPV6_SRCRT_TYPE_4:
+ /* segment routing */
+ return ipv6_srh_rcv(skb);
default:
goto unknown_rh;
}
--
2.43.0