ip: xfrm: support "external" mode for xfrm interfaces
Subsystems (2)
cover ip: xfrm: support "external" mode for xfrm interfaces
This series adds support for configuring XFRM interfaces in "external" mode as recently merged.
Eyal Birger (2):
ip: xfrm: support "external" (collect_md) mode in xfrm interfaces
ip: xfrm: support adding xfrm metadata as lwtunnel info in routes
include/uapi/linux/if_link.h | 1 + include/uapi/linux/lwtunnel.h | 10 +++++ ip/iproute.c | 5 ++- ip/iproute_lwtunnel.c | 83 +++++++++++++++++++++++++++++++++++ ip/link_xfrm.c | 18 ++++++++ man/man8/ip-link.8.in | 7 +++ man/man8/ip-route.8.in | 11 +++++ 7 files changed, 133 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/2 ip: xfrm: support "external" (`collect_md`) mode in xfrm interfaces
Support for collect metadata mode was introduced in kernel commit abc340b38ba2 ("xfrm: interface: support collect metadata mode")
This commit adds support for creating xfrm interfaces in this mode.
Example use:
ip link add ipsec1 type xfrm external
--- include/uapi/linux/if_link.h | 1 + ip/link_xfrm.c | 18 ++++++++++++++++++ man/man8/ip-link.8.in | 7 +++++++ 3 files changed, 26 insertions(+)
include/uapi/linux/if_link.h +1 -0
@@ -693,6 +693,7 @@ enum {IFLA_XFRM_UNSPEC ,IFLA_XFRM_LINK ,IFLA_XFRM_IF_ID , +IFLA_XFRM_COLLECT_METADATA , __IFLA_XFRM_MAX };
ip/link_xfrm.c +18 -0
@@ -18,6 +18,7 @@ static void xfrm_print_help(struct link_util *lu, int argc, char **argv, {fprintf (f,"Usage: ... %-4s dev [ PHYS_DEV ] [ if_id IF-ID ]\n" +" [ external ]\n" "\n" "Where: IF-ID := { 0x1..0xffffffff }\n" , lu->id);
@@ -27,6 +28,7 @@ static int xfrm_parse_opt(struct link_util *lu, int argc, char **argv, struct nlmsghdr *n) {unsigned int link =0 ; +bool metadata = false;__u32 if_id =0 ;while (argc >0 ) {
@@ -43,6 +45,8 @@ static int xfrm_parse_opt(struct link_util *lu, int argc, char **argv,invarg ("if_id value is invalid" , *argv); else addattr32(n, 1024, IFLA_XFRM_IF_ID, if_id); + }else if (!matches (*argv,"external" )) { + metadata = true; }else {xfrm_print_help (lu, argc, argv, stderr);return -1 ;
@@ -50,6 +54,15 @@ static int xfrm_parse_opt(struct link_util *lu, int argc, char **argv, argc--; argv++; } +if (metadata) { +if (if_id || link) { +fprintf (stderr,"xfrmi: both 'external' and if_id/link cannot be specified\n" ); +return -1 ; + } +addattr (n,1024 ,IFLA_XFRM_COLLECT_METADATA ); +return 0 ; + } +if (!if_id)missarg ("IF_ID" );
@@ -65,6 +78,11 @@ static void xfrm_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])if (!tb)return ; +if (tb[IFLA_XFRM_COLLECT_METADATA ]) { +print_bool (PRINT_ANY ,"external" ,"external " , true); +return ; + } +if (tb[IFLA_XFRM_IF_ID ]) {__u32 id =rta_getattr_u32 (tb[IFLA_XFRM_IF_ID ]);
man/man8/ip-link.8.in +7 -0
@@ -1957,6 +1957,7 @@ For a link of type the following additional arguments are supported: .BI "ip link add " DEVICE " type xfrm dev " PHYS_DEV " [ if_id " IF_ID " ]" +.BR "[ external ]" .in +8 .sp
@@ -1969,6 +1970,12 @@ the following additional arguments are supported: policies. Policies must be configured with the same key. If not set, the key defaults to 0 and will match any policies which similarly do not have a lookup key configuration. +.sp +.BI external +- make this device externally controlled. This flag is mutually exclusive with the +.BR dev " and " if_id +options. + .in -8 .TP
Signature · 1 line
2.34.1
Re: [PATCH iproute2-next 1/2] ip: xfrm: support "external" (`collect_md`) mode in xfrm interfaces
Le 03/10/2022 à 11:12, Eyal Birger a écrit :
Quoted 11 lines
Support for collect metadata mode was introduced in kernel commit
abc340b38ba2("xfrm: interface: support collect metadata mode")This commit adds support for creating xfrm interfaces in this mode.
Example use:
ip link add ipsec1 type xfrm external
Signed-off-by Eyal Birger <[email protected]>
PATCH 2/2 ip: xfrm: support adding xfrm metadata as lwtunnel info in routes
In reply to Eyal BirgerSupport for xfrm metadata as lwtunnel metadata was added in kernel commit 2c2493b9da91 ("xfrm: lwtunnel: add lwtunnel support for xfrm interfaces in collect_md mode")
This commit adds the respective support in lwt routes.
Example use (consider ipsec1 as an xfrm interface in "external" mode):
ip route add 10.1.0.0/24 dev ipsec1 encap xfrm if_id 1
Or in the context of vrf, one can also specify the "link" property:
ip route add 10.1.0.0/24 dev ipsec1 encap xfrm if_id 1 link_dev eth15
--- include/uapi/linux/lwtunnel.h | 10 +++++ ip/iproute.c | 5 ++- ip/iproute_lwtunnel.c | 83 +++++++++++++++++++++++++++++++++++ man/man8/ip-route.8.in | 11 +++++ 4 files changed, 107 insertions(+), 2 deletions(-)
include/uapi/linux/lwtunnel.h +10 -0
@@ -15,6 +15,7 @@ enum lwtunnel_encap_types {LWTUNNEL_ENCAP_SEG6_LOCAL ,LWTUNNEL_ENCAP_RPL ,LWTUNNEL_ENCAP_IOAM6 , +LWTUNNEL_ENCAP_XFRM , __LWTUNNEL_ENCAP_MAX, };
@@ -111,4 +112,13 @@ enum {#define LWT_BPF_MAX_HEADROOM 256 +enum { +LWT_XFRM_UNSPEC , +LWT_XFRM_IF_ID , +LWT_XFRM_LINK , + __LWT_XFRM_MAX, +}; + +#define LWT_XFRM_MAX (__LWT_XFRM_MAX - 1) +#endif /* _LWTUNNEL_H_ */
ip/iproute.c +3 -2
@@ -102,8 +102,8 @@ static void usage(void)"TIME := NUMBER[s|ms]\n" "BOOL := [1|0]\n" "FEATURES := ecn\n" -"ENCAPTYPE := [ mpls | ip | ip6 | seg6 | seg6local | rpl | ioam6 ]\n" -"ENCAPHDR := [ MPLSLABEL | SEG6HDR | SEG6LOCAL | IOAM6HDR ]\n" +"ENCAPTYPE := [ mpls | ip | ip6 | seg6 | seg6local | rpl | ioam6 | xfrm ]\n" +"ENCAPHDR := [ MPLSLABEL | SEG6HDR | SEG6LOCAL | IOAM6HDR | XFRMINFO ]\n" "SEG6HDR := [ mode SEGMODE ] segs ADDR1,ADDRi,ADDRn [hmac HMACKEYID] [cleanup]\n" "SEGMODE := [ encap | encap.red | inline | l2encap | l2encap.red ]\n" "SEG6LOCAL := action ACTION [ OPTIONS ] [ count ]\n"
@@ -116,6 +116,7 @@ static void usage(void)"FLAVORS := { FLAVOR[,FLAVOR] }\n" "FLAVOR := { psp | usp | usd | next-csid }\n" "IOAM6HDR := trace prealloc type IOAM6_TRACE_TYPE ns IOAM6_NAMESPACE size IOAM6_TRACE_SIZE\n" +"XFRMINFO := if_id IF_ID [ link_dev LINK ]\n" "ROUTE_GET_FLAGS := [ fibmatch ]\n");exit (-1 ); }
ip/iproute_lwtunnel.c +83 -0
119 lines not on this page · raw message
man/man8/ip-route.8.in +11 -0
@@ -738,6 +738,9 @@ is a string specifying the supported encapsulation type. Namely: .sp .BI ioam6 - encapsulation type IPv6 IOAM +.sp +.BI xfrm +- encapsulation type XFRM .in -8 .I ENCAPHDR
@@ -1024,6 +1027,14 @@ mode. .B size .I IOAM6_TRACE_SIZE - Size, in octets, of the pre-allocated trace data block. +.in -2 + +.B xfrm +.in +2 +.B if_id +.I IF_ID +.B " [ link_dev +.IR LINK_DEV " ] " .in -4 .in -8
Signature · 1 line
2.34.1
Re: [PATCH iproute2-next 2/2] ip: xfrm: support adding xfrm metadata as lwtunnel info in routes
Le 03/10/2022 à 11:12, Eyal Birger a écrit :
Quoted 7 lines
Support for xfrm metadata as lwtunnel metadata was added in kernel commit
2c2493b9da91("xfrm: lwtunnel: add lwtunnel support for xfrm interfaces incollect_mdmode")This commit adds the respective support in lwt routes.
Example use (consider ipsec1 as an xfrm interface in "external" mode):
Quoted 7 lines
ip route add 10.1.0.0/24 dev ipsec1 encap xfrm
if_id1Or in the context of vrf, one can also specify the "link" property:
ip route add 10.1.0.0/24 dev ipsec1 encap xfrm
if_id1link_deveth15Signed-off-by Eyal Birger <[email protected]>
Quoted 7 lines · Eyal Birger
This series adds support for configuring XFRM interfaces in "external" mode as recently merged.
Eyal Birger (2):
ip: xfrm: support "external" (collect_md) mode in xfrm interfaces
ip: xfrm: support adding xfrm metadata as lwtunnel info in routes
Quoted 9 lines
include/uapi/linux/if_link.h | 1 + include/uapi/linux/lwtunnel.h | 10 +++++ ip/iproute.c | 5 ++- ip/iproute_lwtunnel.c | 83 +++++++++++++++++++++++++++++++++++ ip/link_xfrm.c | 18 ++++++++ man/man8/ip-link.8.in | 7 +++ man/man8/ip-route.8.in | 11 +++++ 7 files changed, 133 insertions(+), 2 deletions(-)
always put all uapi changes in a separate patch. headers are synched via a script and a separate patch is easier to drop then editing patches.
Removed the use of matches() in patch 1 and applied to iproute2-next.