Skip to content

Commit b34441e

Browse files
committed
Merge branch 'seg6-allow-end-x-behavior-to-accept-an-oif'
Ido Schimmel says: ==================== seg6: Allow End.X behavior to accept an oif Patches kernel-patches#1-kernel-patches#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 kernel-patches#4 adds test cases to the existing End.X selftest to cover the new functionality. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 0550890 + 04d752d commit b34441e

File tree

2 files changed

+61
-9
lines changed

2 files changed

+61
-9
lines changed

net/ipv6/seg6_local.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ static void advance_nextseg(struct ipv6_sr_hdr *srh, struct in6_addr *daddr)
270270

271271
static int
272272
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)
274274
{
275275
struct net *net = dev_net(skb->dev);
276276
struct ipv6hdr *hdr = ipv6_hdr(skb);
@@ -282,6 +282,7 @@ seg6_lookup_any_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr,
282282

283283
memset(&fl6, 0, sizeof(fl6));
284284
fl6.flowi6_iif = skb->dev->ifindex;
285+
fl6.flowi6_oif = oif;
285286
fl6.daddr = nhaddr ? *nhaddr : hdr->daddr;
286287
fl6.saddr = hdr->saddr;
287288
fl6.flowlabel = ip6_flowinfo(hdr);
@@ -291,17 +292,19 @@ seg6_lookup_any_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr,
291292
if (nhaddr)
292293
fl6.flowi6_flags = FLOWI_FLAG_KNOWN_NH;
293294

294-
if (!tbl_id) {
295+
if (!tbl_id && !oif) {
295296
dst = ip6_route_input_lookup(net, skb->dev, &fl6, skb, flags);
296-
} else {
297+
} else if (tbl_id) {
297298
struct fib6_table *table;
298299

299300
table = fib6_get_table(net, tbl_id);
300301
if (!table)
301302
goto out;
302303

303-
rt = ip6_pol_route(net, table, 0, &fl6, skb, flags);
304+
rt = ip6_pol_route(net, table, oif, &fl6, skb, flags);
304305
dst = &rt->dst;
306+
} else {
307+
dst = ip6_route_output(net, NULL, &fl6);
305308
}
306309

307310
/* we want to discard traffic destined for local packet processing,
@@ -330,7 +333,7 @@ seg6_lookup_any_nexthop(struct sk_buff *skb, struct in6_addr *nhaddr,
330333
int seg6_lookup_nexthop(struct sk_buff *skb,
331334
struct in6_addr *nhaddr, u32 tbl_id)
332335
{
333-
return seg6_lookup_any_nexthop(skb, nhaddr, tbl_id, false);
336+
return seg6_lookup_any_nexthop(skb, nhaddr, tbl_id, false, 0);
334337
}
335338

336339
static __u8 seg6_flv_lcblock_octects(const struct seg6_flavors_info *finfo)
@@ -418,7 +421,7 @@ static int end_next_csid_core(struct sk_buff *skb, struct seg6_local_lwt *slwt)
418421
static int input_action_end_x_finish(struct sk_buff *skb,
419422
struct seg6_local_lwt *slwt)
420423
{
421-
seg6_lookup_nexthop(skb, &slwt->nh6, 0);
424+
seg6_lookup_any_nexthop(skb, &slwt->nh6, 0, false, slwt->oif);
422425

423426
return dst_input(skb);
424427
}
@@ -1277,15 +1280,15 @@ static int input_action_end_dt6(struct sk_buff *skb,
12771280
/* note: this time we do not need to specify the table because the VRF
12781281
* takes care of selecting the correct table.
12791282
*/
1280-
seg6_lookup_any_nexthop(skb, NULL, 0, true);
1283+
seg6_lookup_any_nexthop(skb, NULL, 0, true, 0);
12811284

12821285
return dst_input(skb);
12831286

12841287
legacy_mode:
12851288
#endif
12861289
skb_set_transport_header(skb, sizeof(struct ipv6hdr));
12871290

1288-
seg6_lookup_any_nexthop(skb, NULL, slwt->table, true);
1291+
seg6_lookup_any_nexthop(skb, NULL, slwt->table, true, 0);
12891292

12901293
return dst_input(skb);
12911294

@@ -1477,7 +1480,8 @@ static struct seg6_action_desc seg6_action_table[] = {
14771480
.action = SEG6_LOCAL_ACTION_END_X,
14781481
.attrs = SEG6_F_ATTR(SEG6_LOCAL_NH6),
14791482
.optattrs = SEG6_F_LOCAL_COUNTERS |
1480-
SEG6_F_LOCAL_FLAVORS,
1483+
SEG6_F_LOCAL_FLAVORS |
1484+
SEG6_F_ATTR(SEG6_LOCAL_OIF),
14811485
.input = input_action_end_x,
14821486
},
14831487
{

tools/testing/selftests/net/srv6_end_x_next_csid_l3vpn_test.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
# Every fcf0:0:x:y::/64 network interconnects the SRv6 routers rt-x with rt-y in
7373
# the selftest network.
7474
#
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+
#
7578
# Local SID/C-SID table
7679
# =====================
7780
#
@@ -521,6 +524,9 @@ setup_rt_networking()
521524
ip -netns "${nsname}" addr \
522525
add "${net_prefix}::${rt}/64" dev "${devname}" nodad
523526

527+
ip -netns "${nsname}" addr \
528+
add "fe80::${rt}:${neigh}/64" dev "${devname}" nodad
529+
524530
ip -netns "${nsname}" link set "${devname}" up
525531
done
526532

@@ -609,6 +615,27 @@ set_end_x_nextcsid()
609615
nflen "${LCNODEFUNC_BLEN}" dev "${DUMMY_DEVNAME}"
610616
}
611617

618+
set_end_x_ll_nextcsid()
619+
{
620+
local rt="$1"
621+
local adj="$2"
622+
623+
eval nsname=\${$(get_rtname "${rt}")}
624+
lcnode_func_prefix="$(build_lcnode_func_prefix "${rt}")"
625+
nh6_ll_addr="fe80::${adj}:${rt}"
626+
oifname="veth-rt-${rt}-${adj}"
627+
628+
# enabled NEXT-C-SID SRv6 End.X behavior via an IPv6 link-local nexthop
629+
# address (note that "dev" is the dummy dum0 device chosen for the sake
630+
# of simplicity).
631+
ip -netns "${nsname}" -6 route \
632+
replace "${lcnode_func_prefix}" \
633+
table "${LOCALSID_TABLE_ID}" \
634+
encap seg6local action End.X nh6 "${nh6_ll_addr}" \
635+
oif "${oifname}" flavors next-csid lblen "${LCBLOCK_BLEN}" \
636+
nflen "${LCNODEFUNC_BLEN}" dev "${DUMMY_DEVNAME}"
637+
}
638+
612639
set_underlay_sids_reachability()
613640
{
614641
local rt="$1"
@@ -1016,6 +1043,27 @@ host_vpn_tests()
10161043

10171044
check_and_log_hs_ipv4_connectivity 1 2
10181045
check_and_log_hs_ipv4_connectivity 2 1
1046+
1047+
# Setup the adjacencies in the SRv6 aware routers using IPv6 link-local
1048+
# addresses.
1049+
# - rt-3 SRv6 End.X adjacency with rt-4
1050+
# - rt-4 SRv6 End.X adjacency with rt-1
1051+
set_end_x_ll_nextcsid 3 4
1052+
set_end_x_ll_nextcsid 4 1
1053+
1054+
log_section "SRv6 VPN connectivity test hosts (h1 <-> h2, IPv6), link-local"
1055+
1056+
check_and_log_hs_ipv6_connectivity 1 2
1057+
check_and_log_hs_ipv6_connectivity 2 1
1058+
1059+
log_section "SRv6 VPN connectivity test hosts (h1 <-> h2, IPv4), link-local"
1060+
1061+
check_and_log_hs_ipv4_connectivity 1 2
1062+
check_and_log_hs_ipv4_connectivity 2 1
1063+
1064+
# Restore the previous adjacencies.
1065+
set_end_x_nextcsid 3 4
1066+
set_end_x_nextcsid 4 1
10191067
}
10201068

10211069
__nextcsid_end_x_behavior_test()

0 commit comments

Comments
 (0)