Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'seg6-allow-end-x-behavior-to-accept-an-oif'

Ido Schimmel says:

====================
seg6: Allow End.X behavior to accept an oif

Patches #1-#3 gradually extend the End.X behavior to accept an output
interface as an optional argument. This is needed for cases where user
space wishes to specify an IPv6 link-local address as the nexthop
address.

Patch #4 adds test cases to the existing End.X selftest to cover the new
functionality.
====================

Link: https://patch.msgid.link/20250612122323.584113-1-idosch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+61 -9
+13 -9
net/ipv6/seg6_local.c
··· 270 270 271 271 static int 272 272 seg6_lookup_any_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr, 273 - u32 tbl_id, bool local_delivery) 273 + u32 tbl_id, bool local_delivery, int oif) 274 274 { 275 275 struct net *net = dev_net(skb->dev); 276 276 struct ipv6hdr *hdr = ipv6_hdr(skb); ··· 282 282 283 283 memset(&fl6, 0, sizeof(fl6)); 284 284 fl6.flowi6_iif = skb->dev->ifindex; 285 + fl6.flowi6_oif = oif; 285 286 fl6.daddr = nhaddr ? *nhaddr : hdr->daddr; 286 287 fl6.saddr = hdr->saddr; 287 288 fl6.flowlabel = ip6_flowinfo(hdr); ··· 292 291 if (nhaddr) 293 292 fl6.flowi6_flags = FLOWI_FLAG_KNOWN_NH; 294 293 295 - if (!tbl_id) { 294 + if (!tbl_id && !oif) { 296 295 dst = ip6_route_input_lookup(net, skb->dev, &fl6, skb, flags); 297 - } else { 296 + } else if (tbl_id) { 298 297 struct fib6_table *table; 299 298 300 299 table = fib6_get_table(net, tbl_id); 301 300 if (!table) 302 301 goto out; 303 302 304 - rt = ip6_pol_route(net, table, 0, &fl6, skb, flags); 303 + rt = ip6_pol_route(net, table, oif, &fl6, skb, flags); 305 304 dst = &rt->dst; 305 + } else { 306 + dst = ip6_route_output(net, NULL, &fl6); 306 307 } 307 308 308 309 /* we want to discard traffic destined for local packet processing, ··· 333 330 int seg6_lookup_nexthop(struct sk_buff *skb, 334 331 struct in6_addr *nhaddr, u32 tbl_id) 335 332 { 336 - return seg6_lookup_any_nexthop(skb, nhaddr, tbl_id, false); 333 + return seg6_lookup_any_nexthop(skb, nhaddr, tbl_id, false, 0); 337 334 } 338 335 339 336 static __u8 seg6_flv_lcblock_octects(const struct seg6_flavors_info *finfo) ··· 421 418 static int input_action_end_x_finish(struct sk_buff *skb, 422 419 struct seg6_local_lwt *slwt) 423 420 { 424 - seg6_lookup_nexthop(skb, &slwt->nh6, 0); 421 + seg6_lookup_any_nexthop(skb, &slwt->nh6, 0, false, slwt->oif); 425 422 426 423 return dst_input(skb); 427 424 } ··· 1280 1277 /* note: this time we do not need to specify the table because the VRF 1281 1278 * takes care of selecting the correct table. 1282 1279 */ 1283 - seg6_lookup_any_nexthop(skb, NULL, 0, true); 1280 + seg6_lookup_any_nexthop(skb, NULL, 0, true, 0); 1284 1281 1285 1282 return dst_input(skb); 1286 1283 ··· 1288 1285 #endif 1289 1286 skb_set_transport_header(skb, sizeof(struct ipv6hdr)); 1290 1287 1291 - seg6_lookup_any_nexthop(skb, NULL, slwt->table, true); 1288 + seg6_lookup_any_nexthop(skb, NULL, slwt->table, true, 0); 1292 1289 1293 1290 return dst_input(skb); 1294 1291 ··· 1480 1477 .action = SEG6_LOCAL_ACTION_END_X, 1481 1478 .attrs = SEG6_F_ATTR(SEG6_LOCAL_NH6), 1482 1479 .optattrs = SEG6_F_LOCAL_COUNTERS | 1483 - SEG6_F_LOCAL_FLAVORS, 1480 + SEG6_F_LOCAL_FLAVORS | 1481 + SEG6_F_ATTR(SEG6_LOCAL_OIF), 1484 1482 .input = input_action_end_x, 1485 1483 }, 1486 1484 {
+48
tools/testing/selftests/net/srv6_end_x_next_csid_l3vpn_test.sh
··· 72 72 # Every fcf0:0:x:y::/64 network interconnects the SRv6 routers rt-x with rt-y in 73 73 # the selftest network. 74 74 # 75 + # In addition, every router interface connecting rt-x to rt-y is assigned an 76 + # IPv6 link-local address fe80::x:y/64. 77 + # 75 78 # Local SID/C-SID table 76 79 # ===================== 77 80 # ··· 524 521 ip -netns "${nsname}" addr \ 525 522 add "${net_prefix}::${rt}/64" dev "${devname}" nodad 526 523 524 + ip -netns "${nsname}" addr \ 525 + add "fe80::${rt}:${neigh}/64" dev "${devname}" nodad 526 + 527 527 ip -netns "${nsname}" link set "${devname}" up 528 528 done 529 529 ··· 612 606 table "${LOCALSID_TABLE_ID}" \ 613 607 encap seg6local action End.X nh6 "${net_prefix}::${adj}" \ 614 608 flavors next-csid lblen "${LCBLOCK_BLEN}" \ 609 + nflen "${LCNODEFUNC_BLEN}" dev "${DUMMY_DEVNAME}" 610 + } 611 + 612 + set_end_x_ll_nextcsid() 613 + { 614 + local rt="$1" 615 + local adj="$2" 616 + 617 + eval nsname=\${$(get_rtname "${rt}")} 618 + lcnode_func_prefix="$(build_lcnode_func_prefix "${rt}")" 619 + nh6_ll_addr="fe80::${adj}:${rt}" 620 + oifname="veth-rt-${rt}-${adj}" 621 + 622 + # enabled NEXT-C-SID SRv6 End.X behavior via an IPv6 link-local nexthop 623 + # address (note that "dev" is the dummy dum0 device chosen for the sake 624 + # of simplicity). 625 + ip -netns "${nsname}" -6 route \ 626 + replace "${lcnode_func_prefix}" \ 627 + table "${LOCALSID_TABLE_ID}" \ 628 + encap seg6local action End.X nh6 "${nh6_ll_addr}" \ 629 + oif "${oifname}" flavors next-csid lblen "${LCBLOCK_BLEN}" \ 615 630 nflen "${LCNODEFUNC_BLEN}" dev "${DUMMY_DEVNAME}" 616 631 } 617 632 ··· 1043 1016 1044 1017 check_and_log_hs_ipv4_connectivity 1 2 1045 1018 check_and_log_hs_ipv4_connectivity 2 1 1019 + 1020 + # Setup the adjacencies in the SRv6 aware routers using IPv6 link-local 1021 + # addresses. 1022 + # - rt-3 SRv6 End.X adjacency with rt-4 1023 + # - rt-4 SRv6 End.X adjacency with rt-1 1024 + set_end_x_ll_nextcsid 3 4 1025 + set_end_x_ll_nextcsid 4 1 1026 + 1027 + log_section "SRv6 VPN connectivity test hosts (h1 <-> h2, IPv6), link-local" 1028 + 1029 + check_and_log_hs_ipv6_connectivity 1 2 1030 + check_and_log_hs_ipv6_connectivity 2 1 1031 + 1032 + log_section "SRv6 VPN connectivity test hosts (h1 <-> h2, IPv4), link-local" 1033 + 1034 + check_and_log_hs_ipv4_connectivity 1 2 1035 + check_and_log_hs_ipv4_connectivity 2 1 1036 + 1037 + # Restore the previous adjacencies. 1038 + set_end_x_nextcsid 3 4 1039 + set_end_x_nextcsid 4 1 1046 1040 } 1047 1041 1048 1042 __nextcsid_end_x_behavior_test()