seg6: add support of 'nh-vrf' flag
Subsystems (3)
RFC PATCH 1/1 seg6: add support of 'nh-vrf' flag
This new flag enables to have x-vrf routes.
Signed-off-by Nicolas Dichtel <[email protected]>
---
A formal submission will be done once the kernel patch is merged.
include/uapi/linux/seg6_iptunnel.h | 2 ++ ip/iproute_lwtunnel.c | 10 ++++++++++ man/man8/ip-route.8.in | 9 ++++++++- 3 files changed, 20 insertions(+), 1 deletion(-)
include/uapi/linux/seg6_iptunnel.h +2 -0
@@ -20,6 +20,8 @@enum {SEG6_IPTUNNEL_UNSPEC ,SEG6_IPTUNNEL_SRH , +SEG6_IPTUNNEL_SRC ,/* struct in6_addr */ +SEG6_IPTUNNEL_NH_VRF , __SEG6_IPTUNNEL_MAX, };#define SEG6_IPTUNNEL_MAX (__SEG6_IPTUNNEL_MAX - 1)
ip/iproute_lwtunnel.c +10 -0
@@ -267,6 +267,9 @@ static void print_encap_seg6(FILE *fp, struct rtattr *encap) "mode %s ", format_seg6mode_type(tuninfo->mode));print_srh (fp, tuninfo->srh); + +if (tb[SEG6_IPTUNNEL_NH_VRF ]) +print_string (PRINT_ANY ,NULL ,"%s " ,"nh-vrf" ); }static void print_rpl_srh (FILE *fp,struct ipv6_rpl_sr_hdr *srh)
@@ -953,6 +956,7 @@ static int parse_encap_seg6(struct rtattr *rta, size_t len, int *argcp,struct ipv6_sr_hdr *srh;char **argv = *argvp;char segbuf[1024 ] ="" ; +bool nh_vrf = false;int argc = *argcp;int encap =-1 ;__u32 hmac =0 ;
@@ -981,6 +985,8 @@ static int parse_encap_seg6(struct rtattr *rta, size_t len, int *argcp,if (hmac_ok++)duparg2 ("hmac" , *argv);get_u32 (&hmac, *argv,0 ); + }else if (strcmp (*argv,"nh-vrf" ) ==0 ) { + nh_vrf = true; }else {break ; }
@@ -1005,6 +1011,10 @@ static int parse_encap_seg6(struct rtattr *rta, size_t len, int *argcp, sizeof(*tuninfo) + srhlen)) goto out; +if (nh_vrf && +rta_addattr_l (rta, len,SEG6_IPTUNNEL_NH_VRF ,NULL ,0 )) + goto out; + *argcp = argc +1 ; *argvp = argv -1 ; ret =0 ;
man/man8/ip-route.8.in +8 -1
@@ -240,7 +240,9 @@ throw " | " unreachable " | " prohibit " | " blackhole " | " nat " ]" .IR ENCAP_SEG6 " := " .B seg6 .BR mode " [ " -.BR encap " | " encap.red " | " inline " | " l2encap " | " l2encap.red " ] " +.BR encap " | " encap.red " | " inline " | " l2encap " | " l2encap.red " ] [" +.B nh-vrf +.IR "]" .B segs .IR SEGMENTS " [ " .B hmac
@@ -893,6 +895,11 @@ applying the reduced segment list. When there is only one segment and the HMAC is not present, the SRH is omitted. .sp +.B nh-vrf +- use the vrf attached to the next hop device to route the encapsulated +packet. +.sp + .I SEGMENTS - List of comma-separated IPv6 addresses .sp
Signature · 1 line
2.52.0