Skip to content

Commit 925615c

Browse files
David Lebrundavem330
authored andcommitted
ipv6: sr: allow SRH insertion with arbitrary segments_left value
The seg6_validate_srh() function only allows SRHs whose active segment is the first segment of the path. However, an application may insert an SRH whose active segment is not the first one. Such an application might be for example an SR-aware Virtual Network Function. This patch enables to insert SRHs with an arbitrary active segment. Signed-off-by: David Lebrun <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4cc7b95 commit 925615c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

net/ipv6/exthdrs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ static void ipv6_push_rthdr4(struct sk_buff *skb, u8 *proto,
882882
(hops - 1) * sizeof(struct in6_addr));
883883

884884
sr_phdr->segments[0] = **addr_p;
885-
*addr_p = &sr_ihdr->segments[hops - 1];
885+
*addr_p = &sr_ihdr->segments[sr_ihdr->segments_left];
886886

887887
#ifdef CONFIG_IPV6_SEG6_HMAC
888888
if (sr_has_hmac(sr_phdr)) {
@@ -1174,7 +1174,7 @@ struct in6_addr *fl6_update_dst(struct flowi6 *fl6,
11741174
{
11751175
struct ipv6_sr_hdr *srh = (struct ipv6_sr_hdr *)opt->srcrt;
11761176

1177-
fl6->daddr = srh->segments[srh->first_segment];
1177+
fl6->daddr = srh->segments[srh->segments_left];
11781178
break;
11791179
}
11801180
default:

net/ipv6/seg6.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ bool seg6_validate_srh(struct ipv6_sr_hdr *srh, int len)
4040
if (((srh->hdrlen + 1) << 3) != len)
4141
return false;
4242

43-
if (srh->segments_left != srh->first_segment)
43+
if (srh->segments_left > srh->first_segment)
4444
return false;
4545

4646
tlv_offset = sizeof(*srh) + ((srh->first_segment + 1) << 4);

0 commit comments

Comments
 (0)