All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2-next 0/2] Support for the IOAM insertion frequency
@ 2022-02-05 15:52 Justin Iurman
  2022-02-05 15:52 ` [PATCH iproute2-next 1/2] Add support " Justin Iurman
  2022-02-05 15:52 ` [PATCH iproute2-next 2/2] Update documentation Justin Iurman
  0 siblings, 2 replies; 5+ messages in thread
From: Justin Iurman @ 2022-02-05 15:52 UTC (permalink / raw)
  To: netdev; +Cc: dsahern, stephen, justin.iurman

This patchset requires an update of kernel headers:

diff --git a/include/uapi/linux/ioam6_iptunnel.h b/include/uapi/linux/ioam6_iptunnel.h
index 829ffdfcacca8..38f6a8fdfd343 100644
--- a/include/uapi/linux/ioam6_iptunnel.h
+++ b/include/uapi/linux/ioam6_iptunnel.h
@@ -41,6 +41,15 @@ enum {
 	/* IOAM Trace Header */
 	IOAM6_IPTUNNEL_TRACE,		/* struct ioam6_trace_hdr */
 
+	/* Insertion frequency:
+	 * "k over n" packets (0 < k <= n)
+	 * [0.0001% ... 100%]
+	 */
+#define IOAM6_IPTUNNEL_FREQ_MIN 1
+#define IOAM6_IPTUNNEL_FREQ_MAX 1000000
+	IOAM6_IPTUNNEL_FREQ_K,		/* u32 */
+	IOAM6_IPTUNNEL_FREQ_N,		/* u32 */
+
 	__IOAM6_IPTUNNEL_MAX,
 };

The insertion frequency is represented as "k/n", meaning IOAM will be
added to "k" packets over "n" packets, with 0 < k <= n <= 1000000.
Therefore, it provides the following range of insertion frequencies:
[0.0001% ... 100%].

Default frequency is "1/1" (i.e., applied to all packets) for backward
compatibility.

Previous command:
ip -6 ro ad fc00::1/128 encap ioam6 mode ...
    
New command:
ip -6 ro ad fc00::1/128 encap ioam6 [ freq k/n ] mode ...

Justin Iurman (2):
  Add support for the IOAM insertion frequency
  Update documentation

 ip/iproute_lwtunnel.c  | 69 ++++++++++++++++++++++++++++++++++++++++--
 man/man8/ip-route.8.in | 11 +++++--
 2 files changed, 75 insertions(+), 5 deletions(-)

-- 
2.25.1


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

* [PATCH iproute2-next 1/2] Add support for the IOAM insertion frequency
  2022-02-05 15:52 [PATCH iproute2-next 0/2] Support for the IOAM insertion frequency Justin Iurman
@ 2022-02-05 15:52 ` Justin Iurman
  2022-02-10 18:10   ` patchwork-bot+netdevbpf
  2022-02-05 15:52 ` [PATCH iproute2-next 2/2] Update documentation Justin Iurman
  1 sibling, 1 reply; 5+ messages in thread
From: Justin Iurman @ 2022-02-05 15:52 UTC (permalink / raw)
  To: netdev; +Cc: dsahern, stephen, justin.iurman

This patch adds support for the IOAM insertion frequency by introducing
a new parameter "freq". The expected value is "k/n", see the patchset
description for more details.

Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
---
 ip/iproute_lwtunnel.c | 69 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 67 insertions(+), 2 deletions(-)

diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
index b05dffc6..f4192229 100644
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -242,12 +242,20 @@ static void print_encap_ioam6(FILE *fp, struct rtattr *encap)
 {
 	struct rtattr *tb[IOAM6_IPTUNNEL_MAX + 1];
 	struct ioam6_trace_hdr *trace;
+	__u32 freq_k, freq_n;
 	__u8 mode;
 
 	parse_rtattr_nested(tb, IOAM6_IPTUNNEL_MAX, encap);
-	if (!tb[IOAM6_IPTUNNEL_MODE] || !tb[IOAM6_IPTUNNEL_TRACE])
+	if (!tb[IOAM6_IPTUNNEL_MODE] || !tb[IOAM6_IPTUNNEL_TRACE] ||
+	    !tb[IOAM6_IPTUNNEL_FREQ_K] || !tb[IOAM6_IPTUNNEL_FREQ_N])
 		return;
 
+	freq_k = rta_getattr_u32(tb[IOAM6_IPTUNNEL_FREQ_K]);
+	freq_n = rta_getattr_u32(tb[IOAM6_IPTUNNEL_FREQ_N]);
+
+	print_uint(PRINT_ANY, "freqk", "freq %u", freq_k);
+	print_uint(PRINT_ANY, "freqn", "/%u ", freq_n);
+
 	mode = rta_getattr_u8(tb[IOAM6_IPTUNNEL_MODE]);
 	if (!tb[IOAM6_IPTUNNEL_DST] && mode != IOAM6_IPTUNNEL_MODE_INLINE)
 		return;
@@ -919,6 +927,31 @@ out:
 	return ret;
 }
 
+static int parse_ioam6_freq(char *buf, __u32 *freq_k, __u32 *freq_n)
+{
+	char *s;
+	int i;
+
+	s = buf;
+	for (i = 0; *s; *s++ == '/' ? i++ : *s);
+	if (i != 1)
+		return 1;
+
+	s = strtok(buf, "/");
+	if (!s || get_u32(freq_k, s, 10))
+		return 1;
+
+	s = strtok(NULL, "/");
+	if (!s || get_u32(freq_n, s, 10))
+		return 1;
+
+	s = strtok(NULL, "/");
+	if (s)
+		return 1;
+
+	return 0;
+}
+
 static int parse_encap_ioam6(struct rtattr *rta, size_t len, int *argcp,
 			     char ***argvp)
 {
@@ -927,9 +960,39 @@ static int parse_encap_ioam6(struct rtattr *rta, size_t len, int *argcp,
 	struct ioam6_trace_hdr *trace;
 	char **argv = *argvp;
 	__u32 trace_type = 0;
+	__u32 freq_k, freq_n;
+	char buf[16] = {0};
 	inet_prefix addr;
 	__u8 mode;
 
+	if (strcmp(*argv, "freq") != 0) {
+		freq_k = IOAM6_IPTUNNEL_FREQ_MIN;
+		freq_n = IOAM6_IPTUNNEL_FREQ_MIN;
+	} else {
+		NEXT_ARG();
+
+		if (strlen(*argv) > sizeof(buf) - 1)
+			invarg("Invalid frequency (too long)", *argv);
+
+		strncpy(buf, *argv, sizeof(buf));
+
+		if (parse_ioam6_freq(buf, &freq_k, &freq_n))
+			invarg("Invalid frequency (malformed)", *argv);
+
+		if (freq_k < IOAM6_IPTUNNEL_FREQ_MIN ||
+		    freq_k > IOAM6_IPTUNNEL_FREQ_MAX)
+			invarg("Out of bound \"k\" frequency", *argv);
+
+		if (freq_n < IOAM6_IPTUNNEL_FREQ_MIN ||
+		    freq_n > IOAM6_IPTUNNEL_FREQ_MAX)
+			invarg("Out of bound \"n\" frequency", *argv);
+
+		if (freq_k > freq_n)
+			invarg("Frequency with k > n is forbidden", *argv);
+
+		NEXT_ARG();
+	}
+
 	if (strcmp(*argv, "mode") != 0) {
 		mode = IOAM6_IPTUNNEL_MODE_INLINE;
 	} else {
@@ -1020,7 +1083,9 @@ static int parse_encap_ioam6(struct rtattr *rta, size_t len, int *argcp,
 	trace->namespace_id = htons(trace_ns);
 	trace->remlen = (__u8)(trace_size / 4);
 
-	if (rta_addattr8(rta, len, IOAM6_IPTUNNEL_MODE, mode) ||
+	if (rta_addattr32(rta, len, IOAM6_IPTUNNEL_FREQ_K, freq_k) ||
+	    rta_addattr32(rta, len, IOAM6_IPTUNNEL_FREQ_N, freq_n) ||
+	    rta_addattr8(rta, len, IOAM6_IPTUNNEL_MODE, mode) ||
 	    (mode != IOAM6_IPTUNNEL_MODE_INLINE &&
 	     rta_addattr_l(rta, len, IOAM6_IPTUNNEL_DST, &addr.data, addr.bytelen)) ||
 	    rta_addattr_l(rta, len, IOAM6_IPTUNNEL_TRACE, trace, sizeof(*trace))) {
-- 
2.25.1


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

* [PATCH iproute2-next 2/2] Update documentation
  2022-02-05 15:52 [PATCH iproute2-next 0/2] Support for the IOAM insertion frequency Justin Iurman
  2022-02-05 15:52 ` [PATCH iproute2-next 1/2] Add support " Justin Iurman
@ 2022-02-05 15:52 ` Justin Iurman
  1 sibling, 0 replies; 5+ messages in thread
From: Justin Iurman @ 2022-02-05 15:52 UTC (permalink / raw)
  To: netdev; +Cc: dsahern, stephen, justin.iurman

Update the ip-route documentation to include the IOAM insertion
frequency.

Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
---
 man/man8/ip-route.8.in | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/man/man8/ip-route.8.in b/man/man8/ip-route.8.in
index ed628455..462ff269 100644
--- a/man/man8/ip-route.8.in
+++ b/man/man8/ip-route.8.in
@@ -245,7 +245,9 @@ throw " | " unreachable " | " prohibit " | " blackhole " | " nat " ]"
 
 .ti -8
 .IR ENCAP_IOAM6 " := "
-.B ioam6
+.BR ioam6 " ["
+.B freq
+.IR K "/" N " ] "
 .BR mode " [ "
 .BR inline " | " encap " | " auto " ] ["
 .B tundst
@@ -919,6 +921,9 @@ address is set as described in \fBip-sr\fR(8).
 
 .B ioam6
 .in +2
+.B freq K/N
+- Inject IOAM in K packets every N packets (default is 1/1).
+
 .B mode inline
 - Directly insert IOAM after IPv6 header (default mode).
 .sp
@@ -1274,9 +1279,9 @@ ip -6 route add 2001:db8:1::/64 encap seg6local action End.DT46 vrftable 100 dev
 Adds an IPv6 route with SRv6 decapsulation and forward with lookup in VRF table.
 .RE
 .PP
-ip -6 route add 2001:db8:1::/64 encap ioam6 mode encap tundst 2001:db8:42::1 trace prealloc type 0x800000 ns 1 size 12 dev eth0
+ip -6 route add 2001:db8:1::/64 encap ioam6 freq 2/5 mode encap tundst 2001:db8:42::1 trace prealloc type 0x800000 ns 1 size 12 dev eth0
 .RS 4
-Adds an IPv6 route with an IOAM Pre-allocated Trace encapsulation (ip6ip6) that only includes the hop limit and the node id, configured for the IOAM namespace 1 and a pre-allocated data block of 12 octets.
+Adds an IPv6 route with an IOAM Pre-allocated Trace encapsulation (ip6ip6) that only includes the hop limit and the node id, configured for the IOAM namespace 1 and a pre-allocated data block of 12 octets (will be injected in 2 packets every 5 packets).
 .RE
 .PP
 ip route add 10.1.1.0/30 nhid 10
-- 
2.25.1


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

* Re: [PATCH iproute2-next 1/2] Add support for the IOAM insertion frequency
  2022-02-05 15:52 ` [PATCH iproute2-next 1/2] Add support " Justin Iurman
@ 2022-02-10 18:10   ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-10 18:10 UTC (permalink / raw)
  To: Justin Iurman; +Cc: netdev, dsahern, stephen

Hello:

This series was applied to iproute2/iproute2-next.git (main)
by David Ahern <dsahern@kernel.org>:

On Sat,  5 Feb 2022 16:52:07 +0100 you wrote:
> This patch adds support for the IOAM insertion frequency by introducing
> a new parameter "freq". The expected value is "k/n", see the patchset
> description for more details.
> 
> Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
> ---
>  ip/iproute_lwtunnel.c | 69 +++++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 67 insertions(+), 2 deletions(-)

Here is the summary with links:
  - [iproute2-next,1/2] Add support for the IOAM insertion frequency
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=8908cb25711e
  - [iproute2-next,2/2] Update documentation
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=ff14875e9d77

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* [PATCH iproute2-next 2/2] Update documentation
  2021-10-04 13:06 [PATCH iproute2-next 0/2] Support for IOAM encap modes Justin Iurman
@ 2021-10-04 13:06 ` Justin Iurman
  0 siblings, 0 replies; 5+ messages in thread
From: Justin Iurman @ 2021-10-04 13:06 UTC (permalink / raw)
  To: netdev; +Cc: davem, dsahern, stephen, justin.iurman

This patch updates the IOAM documentation (ip-route man page) to reflect the
three encap modes that were introduced.

Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
---
 man/man8/ip-route.8.in | 39 ++++++++++++++++++++++++++++++++-------
 1 file changed, 32 insertions(+), 7 deletions(-)

diff --git a/man/man8/ip-route.8.in b/man/man8/ip-route.8.in
index c9a9cbf1..ed628455 100644
--- a/man/man8/ip-route.8.in
+++ b/man/man8/ip-route.8.in
@@ -246,13 +246,17 @@ throw " | " unreachable " | " prohibit " | " blackhole " | " nat " ]"
 .ti -8
 .IR ENCAP_IOAM6 " := "
 .B ioam6
-.BR trace
-.BR prealloc
-.BR type
+.BR mode " [ "
+.BR inline " | " encap " | " auto " ] ["
+.B tundst
+.IR ADDRESS " ] "
+.B trace
+.B prealloc
+.B type
 .IR IOAM6_TRACE_TYPE
-.BR ns
+.B ns
 .IR IOAM6_NAMESPACE
-.BR size
+.B size
 .IR IOAM6_TRACE_SIZE
 
 .ti -8
@@ -915,14 +919,35 @@ address is set as described in \fBip-sr\fR(8).
 
 .B ioam6
 .in +2
+.B mode inline
+- Directly insert IOAM after IPv6 header (default mode).
+.sp
+
+.B mode encap
+- Encapsulate packet in an outer IPv6 header with IOAM.
+.sp
+
+.B mode auto
+- Automatically use inline mode for local packets and encap mode for in-transit
+packets.
+.sp
+
+.B tundst
+.I ADDRESS
+- IPv6 address of the tunnel destination (outer header), not used with inline
+mode.
+
+.B type
 .I IOAM6_TRACE_TYPE
 - List of IOAM data required in the trace, represented by a bitfield (24 bits).
 .sp
 
+.B ns
 .I IOAM6_NAMESPACE
 - Numerical value to represent an IOAM namespace. See \fBip-ioam\fR(8).
 .sp
 
+.B size
 .I IOAM6_TRACE_SIZE
 - Size, in octets, of the pre-allocated trace data block.
 .in -4
@@ -1249,9 +1274,9 @@ ip -6 route add 2001:db8:1::/64 encap seg6local action End.DT46 vrftable 100 dev
 Adds an IPv6 route with SRv6 decapsulation and forward with lookup in VRF table.
 .RE
 .PP
-ip -6 route add 2001:db8:1::/64 encap ioam6 trace prealloc type 0x800000 ns 1 size 12 dev eth0
+ip -6 route add 2001:db8:1::/64 encap ioam6 mode encap tundst 2001:db8:42::1 trace prealloc type 0x800000 ns 1 size 12 dev eth0
 .RS 4
-Adds an IPv6 route with an IOAM Pre-allocated Trace encapsulation that only includes the hop limit and the node id, configured for the IOAM namespace 1 and a pre-allocated data block of 12 octets.
+Adds an IPv6 route with an IOAM Pre-allocated Trace encapsulation (ip6ip6) that only includes the hop limit and the node id, configured for the IOAM namespace 1 and a pre-allocated data block of 12 octets.
 .RE
 .PP
 ip route add 10.1.1.0/30 nhid 10
-- 
2.25.1


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

end of thread, other threads:[~2022-02-10 18:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-05 15:52 [PATCH iproute2-next 0/2] Support for the IOAM insertion frequency Justin Iurman
2022-02-05 15:52 ` [PATCH iproute2-next 1/2] Add support " Justin Iurman
2022-02-10 18:10   ` patchwork-bot+netdevbpf
2022-02-05 15:52 ` [PATCH iproute2-next 2/2] Update documentation Justin Iurman
  -- strict thread matches above, loose matches on Subject: below --
2021-10-04 13:06 [PATCH iproute2-next 0/2] Support for IOAM encap modes Justin Iurman
2021-10-04 13:06 ` [PATCH iproute2-next 2/2] Update documentation Justin Iurman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.