Netdev List
 help / color / mirror / Atom feed
* [PATCH iproute2-next] ip: xfrm: add IP-TFS mode and iptfs-opts
@ 2026-11-30  1:36 Andrii Tereshchenko
  2026-11-30 17:07 ` Stephen Hemminger
  0 siblings, 1 reply; 2+ messages in thread
From: Andrii Tereshchenko @ 2026-11-30  1:36 UTC (permalink / raw)
  To: David Ahern
  Cc: Stephen Hemminger, Steffen Klassert, Herbert Xu, Christian Hopps,
	Sabrina Dubroca, netdev, ipsec

The kernel has IP Traffic Flow Security (RFC 9347) since v6.14, as
XFRM_MODE_IPTFS with six XFRMA_IPTFS_* attributes, but ip xfrm cannot
create such an SA or a policy template that uses the mode.

Add "iptfs" to MODE for states and policy templates, and an
"iptfs-opts" list for states: drop-time and reorder-window for inbound
SAs; dont-frag, init-delay, max-queue-size and pkt-size for outbound
SAs. The keywords follow the out-of-tree LabN iproute2 tree, so scripts
written for it keep working. The list ends at the first word that is
not an IP-TFS option, as FLAG-LIST does. Times take the get_time()
units (us, ms, s and their long forms, in any case); a bare number is
decimal microseconds, as in the kernel attributes. packet-size is an
alias of pkt-size, the name other IPsec implementations use.
Only the options given are sent, 0 included, so the kernel defaults
apply to the others. Direction rules are left to the kernel, which
names the offending option in its extack. The new mode word is matched
exactly, so "mode i" still means in_trigger.

ip xfrm state prints the attributes the kernel returns as one
iptfs-opts line that "ip xfrm state add" accepts back.

A kernel without IP-TFS support (CONFIG_XFRM_IPTFS off, or xfrm_iptfs
not loadable) can accept an IP-TFS SA, drop its options and then fail
its traffic. A kernel with it reports the SA's IP-TFS attributes back,
defaults included, so after an IP-TFS add or update ip reads the SA
back; without IP-TFS attributes it reports the missing support, does
not keep an SA it just added, and exits with an error.

Made with an AI coding assistant, reviewed by the submitter.

Signed-off-by: Andrii Tereshchenko <opensource@andrii.net>
---
Tested in QEMU guests on ipsec master kernels with CONFIG_XFRM_IPTFS=y,
two of them debug builds with KASAN and lockdep: every option in both
directions, add, update, get, delete and flush, policy templates with
mode iptfs, the printed iptfs-opts line fed back to "ip xfrm state add",
the time units and limits, the kernel's refusals, and traffic between two
namespaces through IP-TFS SAs set up with ip alone. On a kernel built
without IP-TFS support, ip reports it, removes the SA and exits 2.
Builds with gcc, clang and gcc -m32 add no warnings.

Not done: no JSON output, as for the rest of ip xfrm.

 ip/ipxfrm.c        | 162 +++++++++++++++++++++++++++++++++++++++++++++
 ip/xfrm.h          |  22 ++++++
 ip/xfrm_policy.c   |   2 +-
 ip/xfrm_state.c    |  96 ++++++++++++++++++++++++++-
 man/man8/ip-xfrm.8 | 110 +++++++++++++++++++++++++++++-
 5 files changed, 387 insertions(+), 5 deletions(-)

diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c
index 78d9e192..24d6dd9d 100644
--- a/ip/ipxfrm.c
+++ b/ip/ipxfrm.c
@@ -303,6 +303,9 @@ static void xfrm_id_info_print(xfrm_address_t *saddr, struct xfrm_id *id,
 	case XFRM_MODE_BEET:
 		fprintf(fp, "beet");
 		break;
+	case XFRM_MODE_IPTFS:
+		fprintf(fp, "iptfs");
+		break;
 	default:
 		fprintf(fp, "%u", mode);
 		break;
@@ -907,6 +910,7 @@ void xfrm_xfrma_print(struct rtattr *tb[], __u16 family, FILE *fp,
 		fprintf(fp, "tfcpad %u", tfcpad);
 		fprintf(fp, "%s", _SL_);
 	}
+	xfrm_iptfs_opts_print(tb, fp, prefix);
 	if (tb[XFRMA_SA_DIR]) {
 		__u8 dir = rta_getattr_u8(tb[XFRMA_SA_DIR]);
 
@@ -1214,6 +1218,8 @@ int xfrm_mode_parse(__u8 *mode, int *argcp, char ***argvp)
 		*mode = XFRM_MODE_IN_TRIGGER;
 	else if (matches(*argv, "beet") == 0)
 		*mode = XFRM_MODE_BEET;
+	else if (strcmp(*argv, "iptfs") == 0)
+		*mode = XFRM_MODE_IPTFS;
 	else
 		invarg("MODE value is invalid", *argv);
 
@@ -1243,6 +1249,162 @@ int xfrm_encap_type_parse(__u16 *type, int *argcp, char ***argvp)
 	return 0;
 }
 
+/*
+ * IP-TFS times are microseconds, as in the kernel attributes. A bare
+ * number is decimal microseconds; a unit is one of the get_time() units,
+ * in any case. Unlike get_time(), refuse values that overflow or are not
+ * whole microseconds instead of truncating them.
+ */
+static int xfrm_iptfs_get_usec(__u32 *val, const char *arg)
+{
+	static const struct {
+		const char *name;
+		double mult;
+	} units[] = {
+		{ "s", 1e6 }, { "sec", 1e6 }, { "secs", 1e6 },
+		{ "ms", 1e3 }, { "msec", 1e3 }, { "msecs", 1e3 },
+		{ "us", 1 }, { "usec", 1 }, { "usecs", 1 },
+	};
+	unsigned int i;
+	double t;
+	char *p;
+
+	if (get_u32(val, arg, 10) == 0)
+		return 0;
+
+	t = strtod(arg, &p);
+	if (p == arg || t < 0 || !*p)
+		return -1;
+	for (i = 0; i < ARRAY_SIZE(units); i++)
+		if (strcasecmp(p, units[i].name) == 0)
+			break;
+	if (i == ARRAY_SIZE(units))
+		return -1;
+	t *= units[i].mult;
+	if (t > UINT32_MAX || (double)(__u32)t != t)
+		return -1;	/* out of range or not whole microseconds */
+
+	*val = t;
+	return 0;
+}
+
+static int xfrm_iptfs_opt_parse(struct xfrm_iptfs_opts *o, int *argcp,
+				char ***argvp)
+{
+	int argc = *argcp;
+	char **argv = *argvp;
+
+	if (strcmp(*argv, "drop-time") == 0) {
+		NEXT_ARG();
+		if (xfrm_iptfs_get_usec(&o->drop_time, *argv))
+			invarg("value after \"drop-time\" is invalid", *argv);
+		o->set |= XFRM_IPTFS_OPT_DROP_TIME;
+	} else if (strcmp(*argv, "reorder-window") == 0) {
+		NEXT_ARG();
+		if (get_u16(&o->reorder_window, *argv, 0))
+			invarg("value after \"reorder-window\" is invalid", *argv);
+		o->set |= XFRM_IPTFS_OPT_REORDER_WINDOW;
+	} else if (strcmp(*argv, "dont-frag") == 0) {
+		o->set |= XFRM_IPTFS_OPT_DONT_FRAG;
+	} else if (strcmp(*argv, "init-delay") == 0) {
+		NEXT_ARG();
+		if (xfrm_iptfs_get_usec(&o->init_delay, *argv))
+			invarg("value after \"init-delay\" is invalid", *argv);
+		o->set |= XFRM_IPTFS_OPT_INIT_DELAY;
+	} else if (strcmp(*argv, "max-queue-size") == 0) {
+		NEXT_ARG();
+		if (get_u32(&o->max_qsize, *argv, 0))
+			invarg("value after \"max-queue-size\" is invalid", *argv);
+		o->set |= XFRM_IPTFS_OPT_MAX_QSIZE;
+	} else if (strcmp(*argv, "pkt-size") == 0 ||
+		   strcmp(*argv, "packet-size") == 0) {
+		NEXT_ARG();
+		if (get_u32(&o->pkt_size, *argv, 0))
+			invarg("value after \"pkt-size\" is invalid", *argv);
+		o->set |= XFRM_IPTFS_OPT_PKT_SIZE;
+	} else {
+		return -1;
+	}
+
+	*argcp = argc;
+	*argvp = argv;
+
+	return 0;
+}
+
+/* IPTFS-OPT-LIST: one or more options, ended by the first other word */
+int xfrm_iptfs_opts_parse(struct xfrm_iptfs_opts *o, int *argcp,
+			  char ***argvp)
+{
+	int argc = *argcp;
+	char **argv = *argvp;
+
+	if (xfrm_iptfs_opt_parse(o, &argc, &argv))
+		invarg("IPTFS-OPT value is invalid", *argv);
+
+	while (NEXT_ARG_OK()) {
+		NEXT_ARG();
+		if (xfrm_iptfs_opt_parse(o, &argc, &argv)) {
+			PREV_ARG(); /* back track */
+			break;
+		}
+	}
+
+	*argcp = argc;
+	*argvp = argv;
+
+	return 0;
+}
+
+void xfrm_iptfs_opts_addattr(struct nlmsghdr *n, int maxlen,
+			     const struct xfrm_iptfs_opts *o)
+{
+	if (o->set & XFRM_IPTFS_OPT_DROP_TIME)
+		addattr32(n, maxlen, XFRMA_IPTFS_DROP_TIME, o->drop_time);
+	if (o->set & XFRM_IPTFS_OPT_REORDER_WINDOW)
+		addattr16(n, maxlen, XFRMA_IPTFS_REORDER_WINDOW,
+			  o->reorder_window);
+	if (o->set & XFRM_IPTFS_OPT_DONT_FRAG)
+		addattr(n, maxlen, XFRMA_IPTFS_DONT_FRAG);
+	if (o->set & XFRM_IPTFS_OPT_INIT_DELAY)
+		addattr32(n, maxlen, XFRMA_IPTFS_INIT_DELAY, o->init_delay);
+	if (o->set & XFRM_IPTFS_OPT_MAX_QSIZE)
+		addattr32(n, maxlen, XFRMA_IPTFS_MAX_QSIZE, o->max_qsize);
+	if (o->set & XFRM_IPTFS_OPT_PKT_SIZE)
+		addattr32(n, maxlen, XFRMA_IPTFS_PKT_SIZE, o->pkt_size);
+}
+
+/* One line that "ip xfrm state add ... iptfs-opts" accepts back. */
+void xfrm_iptfs_opts_print(struct rtattr *tb[], FILE *fp, const char *prefix)
+{
+	if (!tb[XFRMA_IPTFS_DROP_TIME] && !tb[XFRMA_IPTFS_REORDER_WINDOW] &&
+	    !tb[XFRMA_IPTFS_DONT_FRAG] && !tb[XFRMA_IPTFS_INIT_DELAY] &&
+	    !tb[XFRMA_IPTFS_MAX_QSIZE] && !tb[XFRMA_IPTFS_PKT_SIZE])
+		return;
+
+	if (prefix)
+		fputs(prefix, fp);
+	fprintf(fp, "iptfs-opts");
+	if (tb[XFRMA_IPTFS_DROP_TIME])
+		fprintf(fp, " drop-time %u",
+			rta_getattr_u32(tb[XFRMA_IPTFS_DROP_TIME]));
+	if (tb[XFRMA_IPTFS_REORDER_WINDOW])
+		fprintf(fp, " reorder-window %u",
+			rta_getattr_u16(tb[XFRMA_IPTFS_REORDER_WINDOW]));
+	if (tb[XFRMA_IPTFS_DONT_FRAG])
+		fprintf(fp, " dont-frag");
+	if (tb[XFRMA_IPTFS_INIT_DELAY])
+		fprintf(fp, " init-delay %u",
+			rta_getattr_u32(tb[XFRMA_IPTFS_INIT_DELAY]));
+	if (tb[XFRMA_IPTFS_MAX_QSIZE])
+		fprintf(fp, " max-queue-size %u",
+			rta_getattr_u32(tb[XFRMA_IPTFS_MAX_QSIZE]));
+	if (tb[XFRMA_IPTFS_PKT_SIZE])
+		fprintf(fp, " pkt-size %u",
+			rta_getattr_u32(tb[XFRMA_IPTFS_PKT_SIZE]));
+	fprintf(fp, "%s", _SL_);
+}
+
 /* NOTE: reqid is used by host-byte order */
 int xfrm_reqid_parse(__u32 *reqid, int *argcp, char ***argvp)
 {
diff --git a/ip/xfrm.h b/ip/xfrm.h
index 5238fc8b..ca1b6497 100644
--- a/ip/xfrm.h
+++ b/ip/xfrm.h
@@ -120,6 +120,28 @@ int xfrm_policy_default_print(struct nlmsghdr *n, FILE *fp);
 int xfrm_id_parse(xfrm_address_t *saddr, struct xfrm_id *id, __u16 *family,
 		  int loose, int *argcp, char ***argvp);
 int xfrm_mode_parse(__u8 *mode, int *argcp, char ***argvp);
+
+#define XFRM_IPTFS_OPT_DROP_TIME	BIT(0)
+#define XFRM_IPTFS_OPT_REORDER_WINDOW	BIT(1)
+#define XFRM_IPTFS_OPT_DONT_FRAG	BIT(2)
+#define XFRM_IPTFS_OPT_INIT_DELAY	BIT(3)
+#define XFRM_IPTFS_OPT_MAX_QSIZE	BIT(4)
+#define XFRM_IPTFS_OPT_PKT_SIZE		BIT(5)
+
+struct xfrm_iptfs_opts {
+	__u32 set;		/* XFRM_IPTFS_OPT_* given on the command line */
+	__u32 drop_time;	/* usec */
+	__u32 init_delay;	/* usec */
+	__u32 max_qsize;	/* octets */
+	__u32 pkt_size;		/* octets, 0: path MTU */
+	__u16 reorder_window;	/* packets */
+};
+
+int xfrm_iptfs_opts_parse(struct xfrm_iptfs_opts *o, int *argcp,
+			  char ***argvp);
+void xfrm_iptfs_opts_addattr(struct nlmsghdr *n, int maxlen,
+			     const struct xfrm_iptfs_opts *o);
+void xfrm_iptfs_opts_print(struct rtattr *tb[], FILE *fp, const char *prefix);
 int xfrm_encap_type_parse(__u16 *type, int *argcp, char ***argvp);
 int xfrm_reqid_parse(__u32 *reqid, int *argcp, char ***argvp);
 int xfrm_selector_parse(struct xfrm_selector *sel, int *argcp, char ***argvp);
diff --git a/ip/xfrm_policy.c b/ip/xfrm_policy.c
index 5261a292..6b119b21 100644
--- a/ip/xfrm_policy.c
+++ b/ip/xfrm_policy.c
@@ -77,7 +77,7 @@ static void usage(void)
 		strxf_xfrmproto(IPPROTO_ROUTING),
 		strxf_xfrmproto(IPPROTO_DSTOPTS));
 	fprintf(stderr,
-		"MODE := transport | tunnel | beet | ro | in_trigger\n"
+		"MODE := transport | tunnel | beet | ro | in_trigger | iptfs\n"
 		"LEVEL := required | use\n");
 
 	exit(-1);
diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
index dcd08d59..8f22cea5 100644
--- a/ip/xfrm_state.c
+++ b/ip/xfrm_state.c
@@ -48,6 +48,7 @@ static void usage(void)
 		"        [ offload [ crypto | packet ] dev DEV dir DIR ]\n"
 		"        [ output-mark OUTPUT-MARK [ mask MASK ] ]\n"
 		"        [ if_id IF_ID ] [ tfcpad LENGTH ] [ pcpu-num CPUNUM ]\n"
+		"        [ iptfs-opts IPTFS-OPT-LIST ]\n"
 		"Usage: ip xfrm state allocspi ID [ mode MODE ] [ mark MARK [ mask MASK ] ]\n"
 		"        [ reqid REQID ] [ dir DIR ] [ seq SEQ ] [ min SPI max SPI ] [ pcpu-num CPUNUM ]\n"
 		"Usage: ip xfrm state { delete | get } ID [ mark MARK [ mask MASK ] ]\n"
@@ -84,7 +85,7 @@ static void usage(void)
 		"        %s", strxf_algotype(XFRMA_ALG_COMP));
 	fprintf(stderr,
 		" ALGO-NAME\n"
-		"MODE := transport | tunnel | beet | ro | in_trigger\n"
+		"MODE := transport | tunnel | beet | ro | in_trigger | iptfs\n"
 		"FLAG-LIST := [ FLAG-LIST ] FLAG\n"
 		"FLAG := noecn | decap-dscp | nopmtudisc | wildrecv | icmp | af-unspec | align4 | esn\n"
 		"EXTRA-FLAG-LIST := [ EXTRA-FLAG-LIST ] EXTRA-FLAG\n"
@@ -97,7 +98,12 @@ static void usage(void)
 		"LIMIT := { time-soft | time-hard | time-use-soft | time-use-hard } SECONDS |\n"
 		"         { byte-soft | byte-hard } SIZE | { packet-soft | packet-hard } COUNT\n"
 		"ENCAP := { espinudp | espinudp-nonike | espintcp } SPORT DPORT OADDR\n"
-		"DIR := in | out\n");
+		"DIR := in | out\n"
+		"IPTFS-OPT-LIST := IPTFS-OPT [ IPTFS-OPT-LIST ]\n"
+		"IPTFS-OPT := drop-time TIME | reorder-window COUNT |\n"
+		"             dont-frag | init-delay TIME |\n"
+		"             max-queue-size SIZE | { pkt-size | packet-size } SIZE\n"
+		"TIME := NUMBER[us|usec|ms|msec|s|sec] (default unit: us)\n");
 
 	exit(-1);
 }
@@ -267,6 +273,66 @@ static void xfrm_dir_parse(__u8 *dir, int *argcp, char ***argvp)
 	*argvp = argv;
 }
 
+/* Send GETSA or DELSA for the SA that xsinfo and mark identify. */
+static int xfrm_state_id_talk(struct rtnl_handle *rth, __u16 type,
+			      const struct xfrm_usersa_info *xsinfo,
+			      const struct xfrm_mark *mark,
+			      struct nlmsghdr **answer)
+{
+	struct {
+		struct nlmsghdr	n;
+		struct xfrm_usersa_id	xsid;
+		char			buf[RTA_BUF_SIZE];
+	} req = {
+		.n.nlmsg_len = NLMSG_LENGTH(sizeof(req.xsid)),
+		.n.nlmsg_flags = NLM_F_REQUEST,
+		.n.nlmsg_type = type,
+		.xsid.daddr = xsinfo->id.daddr,
+		.xsid.spi = xsinfo->id.spi,
+		.xsid.family = xsinfo->family,
+		.xsid.proto = xsinfo->id.proto,
+	};
+
+	if (mark->m)
+		addattr_l(&req.n, sizeof(req.buf), XFRMA_MARK, mark,
+			  sizeof(*mark));
+
+	return rtnl_talk(rth, &req.n, answer);
+}
+
+/*
+ * A kernel without IP-TFS support (CONFIG_XFRM_IPTFS off, or the
+ * xfrm_iptfs module not loadable) may accept an IP-TFS SA, drop its
+ * IP-TFS options and then fail its traffic. A kernel with it reports
+ * the SA's IP-TFS attributes back, defaults included, so ask.
+ */
+static bool xfrm_state_has_iptfs(struct rtnl_handle *rth,
+				 const struct xfrm_usersa_info *xsinfo,
+				 const struct xfrm_mark *mark)
+{
+	struct rtattr *tb[XFRMA_MAX + 1];
+	struct xfrm_usersa_info *info;
+	struct nlmsghdr *answer;
+	bool has = true;	/* if the kernel cannot tell us, trust it */
+	int len, i;
+
+	if (xfrm_state_id_talk(rth, XFRM_MSG_GETSA, xsinfo, mark, &answer) < 0)
+		return true;
+
+	info = NLMSG_DATA(answer);
+	len = answer->nlmsg_len - NLMSG_SPACE(sizeof(*info));
+	if (answer->nlmsg_type == XFRM_MSG_NEWSA && len >= 0) {
+		parse_rtattr(tb, XFRMA_MAX, XFRMS_RTA(info), len);
+		has = false;
+		for (i = XFRMA_IPTFS_DROP_TIME; i <= XFRMA_IPTFS_PKT_SIZE; i++)
+			if (tb[i])
+				has = true;
+	}
+	free(answer);
+
+	return has;
+}
+
 static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv)
 {
 	struct rtnl_handle rth;
@@ -310,6 +376,7 @@ static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv)
 	__u32 pcpu_num = -1;
 	__u32 if_id = 0;
 	__u32 tfcpad = 0;
+	struct xfrm_iptfs_opts iptfs = {};
 
 	while (argc > 0) {
 		if (strcmp(*argv, "mode") == 0) {
@@ -463,6 +530,9 @@ static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv)
 			NEXT_ARG();
 			if (get_u32(&pcpu_num, *argv, 0))
 				invarg("value after \"pcpu-num\" is invalid", *argv);
+		} else if (strcmp(*argv, "iptfs-opts") == 0) {
+			NEXT_ARG();
+			xfrm_iptfs_opts_parse(&iptfs, &argc, &argv);
 		} else {
 			/* try to assume ALGO */
 			int type = xfrm_algotype_getbyname(*argv);
@@ -653,12 +723,21 @@ static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv)
 	if (tfcpad)
 		addattr32(&req.n, sizeof(req.buf), XFRMA_TFCPAD, tfcpad);
 
+	if (iptfs.set) {
+		if (req.xsinfo.mode != XFRM_MODE_IPTFS) {
+			fprintf(stderr, "\"iptfs-opts\" requires \"mode iptfs\"\n");
+			exit(1);
+		}
+		xfrm_iptfs_opts_addattr(&req.n, sizeof(req.buf), &iptfs);
+	}
+
 	if (xfrm_xfrmproto_is_ipsec(req.xsinfo.id.proto)) {
 		switch (req.xsinfo.mode) {
 		case XFRM_MODE_TRANSPORT:
 		case XFRM_MODE_TUNNEL:
 			break;
 		case XFRM_MODE_BEET:
+		case XFRM_MODE_IPTFS:
 			if (req.xsinfo.id.proto == IPPROTO_ESP)
 				break;
 			/* fallthrough */
@@ -781,6 +860,19 @@ static int xfrm_state_modify(int cmd, unsigned int flags, int argc, char **argv)
 	if (rtnl_talk(&rth, &req.n, NULL) < 0)
 		exit(2);
 
+	if (req.xsinfo.mode == XFRM_MODE_IPTFS &&
+	    !xfrm_state_has_iptfs(&rth, &req.xsinfo, &mark)) {
+		fprintf(stderr,
+			"Error: the kernel has no IP-TFS support (CONFIG_XFRM_IPTFS, module xfrm_iptfs)");
+		if (cmd == XFRM_MSG_NEWSA &&
+		    xfrm_state_id_talk(&rth, XFRM_MSG_DELSA, &req.xsinfo,
+				       &mark, NULL) == 0)
+			fprintf(stderr, "; the SA was not kept.\n");
+		else
+			fprintf(stderr, "; the SA cannot pass traffic.\n");
+		exit(2);
+	}
+
 	rtnl_close(&rth);
 
 	return 0;
diff --git a/man/man8/ip-xfrm.8 b/man/man8/ip-xfrm.8
index 50fbb1a7..895a232a 100644
--- a/man/man8/ip-xfrm.8
+++ b/man/man8/ip-xfrm.8
@@ -78,6 +78,8 @@ ip-xfrm \- transform configuration
 .IR LENGTH " ]"
 .RB "[ " pcpu-num
 .IR CPUNUM " ]"
+.RB "[ " iptfs-opts
+.IR IPTFS-OPT-LIST " ]"
 
 .ti -8
 .B "ip xfrm state allocspi"
@@ -169,12 +171,30 @@ ip-xfrm \- transform configuration
 
 .ti -8
 .IR MODE " := "
-.BR transport " | " tunnel " | " beet " | " ro " | " in_trigger
+.BR transport " | " tunnel " | " beet " | " ro " | " in_trigger " | " iptfs
 
 .ti -8
 .IR SA-DIR " := "
 .BR in " | " out
 
+.ti -8
+.IR IPTFS-OPT-LIST " := " IPTFS-OPT " [ " IPTFS-OPT-LIST " ]"
+
+.ti -8
+.IR IPTFS-OPT " := "
+.B drop-time
+.IR TIME " | "
+.B reorder-window
+.IR COUNT " | "
+.BR dont-frag " | "
+.B init-delay
+.IR TIME " |"
+.br
+.B max-queue-size
+.IR SIZE " | { "
+.BR pkt-size " | " packet-size " } "
+.I SIZE
+
 .ti -8
 .IR FLAG-LIST " := [ " FLAG-LIST " ] " FLAG
 
@@ -425,7 +445,7 @@ ip-xfrm \- transform configuration
 
 .ti -8
 .IR MODE " := "
-.BR transport " | " tunnel " | " beet " | " ro " | " in_trigger
+.BR transport " | " tunnel " | " beet " | " ro " | " in_trigger " | " iptfs
 
 .ti -8
 .IR LEVEL " :="
@@ -558,6 +578,92 @@ Mobile IPv6 modes are route optimization
 and inbound trigger
 .RB "(" in_trigger ")."
 
+IPsec ESP also has IP Traffic Flow Security
+.RB "(" iptfs ","
+RFC 9347), which needs
+.BR dir " in or " out
+and takes
+.IR IPTFS-OPT-LIST "."
+
+.TP
+.I IPTFS-OPT-LIST
+sets IP-TFS parameters of an
+.B iptfs
+mode SA. Options not given keep the kernel defaults. Each option applies to
+one SA direction; the kernel refuses an option given for the other one.
+The list ends at the first word that is not an IP-TFS option.
+.I TIME
+is a decimal number with an optional unit
+.BR us ", " usec ", " ms ", " msec ", " s ", or " sec
+(also with a trailing
+.BR s ","
+in any case). Without a unit it is microseconds, unlike
+.B limit time-*
+(seconds). It must come to whole microseconds.
+.I SIZE
+and
+.I COUNT
+are plain numbers (octets, packets).
+The settings are fixed when the SA is created:
+.B ip xfrm state update
+does not change them on an existing SA (delete and add it again).
+The kernel needs
+.B CONFIG_XFRM_IPTFS
+(module
+.BR xfrm_iptfs ")."
+Some kernels without it accept an IP-TFS SA and then cannot pass its
+traffic;
+.B ip
+reads the SA back after
+.B add
+or
+.BR update ","
+reports an error, and does not keep an SA it just added.
+.RS
+.TP
+.BI drop-time " TIME"
+(in) how long to wait for a missing outer packet before treating it as lost
+(kernel default 1s).
+.TP
+.BI reorder-window " COUNT"
+(in) how many outer packets may be held to put them back in order; 0 turns
+reordering off (kernel default 3).
+.TP
+.B dont-frag
+(out) do not fragment inner packets across outer packets; an inner packet
+too large for one outer packet is dropped. This is not the DF bit of the
+outer IP header, nor
+.BR nopmtudisc .
+.TP
+.BI init-delay " TIME"
+(out) how long to wait for more inner packets before sending the first
+outer packet (kernel default 0).
+.TP
+.BI max-queue-size " SIZE"
+(out) the most octets of inner packets queued for sending (kernel default
+10485760, 10 MiB).
+.TP
+.BI pkt-size " SIZE"
+(out) the size of the outer packets in octets; 0 uses the path MTU (kernel
+default 0).
+.B packet-size
+is the same option.
+.RE
+.IP
+The RFC 9348 (YANG) names of these parameters are
+.B lost-packet-timer-interval
+.RB "(" drop-time "),"
+.B window-size
+.RB "(" reorder-window "),"
+.B dont-fragment
+.RB "(" dont-frag "),"
+.B max-aggregation-time
+.RB "(" init-delay "),"
+and
+.B outer-packet-size
+.RB "(" pkt-size ");"
+RFC 9348 counts times in milliseconds.
+
 .TP
 .I FLAG-LIST
 contains one or more of the following optional flags:

base-commit: 8055701cb470fdc9e5e9909369bff3f7e24c872e
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-30 17:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30  1:36 [PATCH iproute2-next] ip: xfrm: add IP-TFS mode and iptfs-opts Andrii Tereshchenko
2026-11-30 17:07 ` Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox