* [PATCH iproute2-next v2 0/2] add support for tunsrc @ 2024-08-26 13:52 Justin Iurman 2024-08-26 13:52 ` [PATCH iproute2-next v2 1/2] ip: lwtunnel: tunsrc support Justin Iurman 2024-08-26 13:52 ` [PATCH iproute2-next v2 2/2] man8: ip-route: update documentation Justin Iurman 0 siblings, 2 replies; 6+ messages in thread From: Justin Iurman @ 2024-08-26 13:52 UTC (permalink / raw) To: netdev; +Cc: dsahern, justin.iurman v2: - removed uapi patch (@David please pull from net-next, thanks) This patchset provides support for the new ioam6 feature called "tunsrc". Justin Iurman (2): ip: lwtunnel: tunsrc support man8: ip-route: update documentation ip/iproute_lwtunnel.c | 40 ++++++++++++++++++++++++++++++++++------ man/man8/ip-route.8.in | 8 ++++++++ 2 files changed, 42 insertions(+), 6 deletions(-) -- 2.34.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH iproute2-next v2 1/2] ip: lwtunnel: tunsrc support 2024-08-26 13:52 [PATCH iproute2-next v2 0/2] add support for tunsrc Justin Iurman @ 2024-08-26 13:52 ` Justin Iurman 2024-08-26 15:59 ` Stephen Hemminger 2024-08-26 13:52 ` [PATCH iproute2-next v2 2/2] man8: ip-route: update documentation Justin Iurman 1 sibling, 1 reply; 6+ messages in thread From: Justin Iurman @ 2024-08-26 13:52 UTC (permalink / raw) To: netdev; +Cc: dsahern, justin.iurman Add support for setting/getting the new "tunsrc" feature. Signed-off-by: Justin Iurman <justin.iurman@uliege.be> --- ip/iproute_lwtunnel.c | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c index b4df4348..009045cb 100644 --- a/ip/iproute_lwtunnel.c +++ b/ip/iproute_lwtunnel.c @@ -352,14 +352,22 @@ static void print_encap_ioam6(FILE *fp, struct rtattr *encap) 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) + if ((tb[IOAM6_IPTUNNEL_SRC] && mode == IOAM6_IPTUNNEL_MODE_INLINE) || + (!tb[IOAM6_IPTUNNEL_DST] && mode != IOAM6_IPTUNNEL_MODE_INLINE)) return; print_string(PRINT_ANY, "mode", "mode %s ", format_ioam6mode_type(mode)); - if (mode != IOAM6_IPTUNNEL_MODE_INLINE) + if (mode != IOAM6_IPTUNNEL_MODE_INLINE) { + if (tb[IOAM6_IPTUNNEL_SRC]) { + print_string(PRINT_ANY, "tunsrc", "tunsrc %s ", + rt_addr_n2a_rta(AF_INET6, + tb[IOAM6_IPTUNNEL_SRC])); + } + print_string(PRINT_ANY, "tundst", "tundst %s ", rt_addr_n2a_rta(AF_INET6, tb[IOAM6_IPTUNNEL_DST])); + } trace = RTA_DATA(tb[IOAM6_IPTUNNEL_TRACE]); @@ -1111,11 +1119,12 @@ static int parse_encap_ioam6(struct rtattr *rta, size_t len, int *argcp, int ns_found = 0, argc = *argcp; __u16 trace_ns, trace_size = 0; struct ioam6_trace_hdr *trace; + inet_prefix saddr, daddr; char **argv = *argvp; __u32 trace_type = 0; __u32 freq_k, freq_n; char buf[16] = {0}; - inet_prefix addr; + bool has_src; __u8 mode; if (strcmp(*argv, "freq") != 0) { @@ -1158,6 +1167,23 @@ static int parse_encap_ioam6(struct rtattr *rta, size_t len, int *argcp, NEXT_ARG(); } + if (strcmp(*argv, "tunsrc") != 0) { + has_src = false; + } else { + has_src = true; + + if (mode == IOAM6_IPTUNNEL_MODE_INLINE) + invarg("Inline mode does not need tunsrc", *argv); + + NEXT_ARG(); + + get_addr(&saddr, *argv, AF_INET6); + if (saddr.family != AF_INET6 || saddr.bytelen != 16) + invarg("Invalid IPv6 address for tunsrc", *argv); + + NEXT_ARG(); + } + if (strcmp(*argv, "tundst") != 0) { if (mode != IOAM6_IPTUNNEL_MODE_INLINE) missarg("tundst"); @@ -1167,8 +1193,8 @@ static int parse_encap_ioam6(struct rtattr *rta, size_t len, int *argcp, NEXT_ARG(); - get_addr(&addr, *argv, AF_INET6); - if (addr.family != AF_INET6 || addr.bytelen != 16) + get_addr(&daddr, *argv, AF_INET6); + if (daddr.family != AF_INET6 || daddr.bytelen != 16) invarg("Invalid IPv6 address for tundst", *argv); NEXT_ARG(); @@ -1239,8 +1265,10 @@ static int parse_encap_ioam6(struct rtattr *rta, size_t len, int *argcp, 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 && has_src && + rta_addattr_l(rta, len, IOAM6_IPTUNNEL_SRC, &saddr.data, saddr.bytelen)) || (mode != IOAM6_IPTUNNEL_MODE_INLINE && - rta_addattr_l(rta, len, IOAM6_IPTUNNEL_DST, &addr.data, addr.bytelen)) || + rta_addattr_l(rta, len, IOAM6_IPTUNNEL_DST, &daddr.data, daddr.bytelen)) || rta_addattr_l(rta, len, IOAM6_IPTUNNEL_TRACE, trace, sizeof(*trace))) { free(trace); return -1; -- 2.34.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH iproute2-next v2 1/2] ip: lwtunnel: tunsrc support 2024-08-26 13:52 ` [PATCH iproute2-next v2 1/2] ip: lwtunnel: tunsrc support Justin Iurman @ 2024-08-26 15:59 ` Stephen Hemminger 2024-08-27 7:41 ` Justin Iurman 0 siblings, 1 reply; 6+ messages in thread From: Stephen Hemminger @ 2024-08-26 15:59 UTC (permalink / raw) To: Justin Iurman; +Cc: netdev, dsahern On Mon, 26 Aug 2024 15:52:28 +0200 Justin Iurman <justin.iurman@uliege.be> wrote: > - if (mode != IOAM6_IPTUNNEL_MODE_INLINE) > + if (mode != IOAM6_IPTUNNEL_MODE_INLINE) { > + if (tb[IOAM6_IPTUNNEL_SRC]) { > + print_string(PRINT_ANY, "tunsrc", "tunsrc %s ", > + rt_addr_n2a_rta(AF_INET6, > + tb[IOAM6_IPTUNNEL_SRC])); > + } > + > print_string(PRINT_ANY, "tundst", "tundst %s ", > rt_addr_n2a_rta(AF_INET6, tb[IOAM6_IPTUNNEL_DST])); > + } Looks good. These strings should be printed with print_color_string(PRINT_ANY, COLOR_INET6, ... but that is not urgent. Just to follow convention. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH iproute2-next v2 1/2] ip: lwtunnel: tunsrc support 2024-08-26 15:59 ` Stephen Hemminger @ 2024-08-27 7:41 ` Justin Iurman 2024-08-28 22:22 ` David Ahern 0 siblings, 1 reply; 6+ messages in thread From: Justin Iurman @ 2024-08-27 7:41 UTC (permalink / raw) To: Stephen Hemminger; +Cc: netdev, dsahern On 8/26/24 17:59, Stephen Hemminger wrote: > On Mon, 26 Aug 2024 15:52:28 +0200 > Justin Iurman <justin.iurman@uliege.be> wrote: > >> - if (mode != IOAM6_IPTUNNEL_MODE_INLINE) >> + if (mode != IOAM6_IPTUNNEL_MODE_INLINE) { >> + if (tb[IOAM6_IPTUNNEL_SRC]) { >> + print_string(PRINT_ANY, "tunsrc", "tunsrc %s ", >> + rt_addr_n2a_rta(AF_INET6, >> + tb[IOAM6_IPTUNNEL_SRC])); >> + } >> + >> print_string(PRINT_ANY, "tundst", "tundst %s ", >> rt_addr_n2a_rta(AF_INET6, tb[IOAM6_IPTUNNEL_DST])); >> + } > > Looks good. > These strings should be printed with > print_color_string(PRINT_ANY, COLOR_INET6, ... > > but that is not urgent. Just to follow convention. Ack, thanks! I can submit -v3 now to include the change though. WDYT? ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH iproute2-next v2 1/2] ip: lwtunnel: tunsrc support 2024-08-27 7:41 ` Justin Iurman @ 2024-08-28 22:22 ` David Ahern 0 siblings, 0 replies; 6+ messages in thread From: David Ahern @ 2024-08-28 22:22 UTC (permalink / raw) To: Justin Iurman, Stephen Hemminger; +Cc: netdev On 8/27/24 1:41 AM, Justin Iurman wrote: > On 8/26/24 17:59, Stephen Hemminger wrote: >> On Mon, 26 Aug 2024 15:52:28 +0200 >> Justin Iurman <justin.iurman@uliege.be> wrote: >> >>> - if (mode != IOAM6_IPTUNNEL_MODE_INLINE) >>> + if (mode != IOAM6_IPTUNNEL_MODE_INLINE) { >>> + if (tb[IOAM6_IPTUNNEL_SRC]) { >>> + print_string(PRINT_ANY, "tunsrc", "tunsrc %s ", >>> + rt_addr_n2a_rta(AF_INET6, >>> + tb[IOAM6_IPTUNNEL_SRC])); >>> + } >>> + >>> print_string(PRINT_ANY, "tundst", "tundst %s ", >>> rt_addr_n2a_rta(AF_INET6, tb[IOAM6_IPTUNNEL_DST])); >>> + } >> >> Looks good. >> These strings should be printed with >> print_color_string(PRINT_ANY, COLOR_INET6, ... >> >> but that is not urgent. Just to follow convention. > > Ack, thanks! I can submit -v3 now to include the change though. WDYT? sure. send an update now. I most likely will not have time to update the headers and commit until this weekend. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH iproute2-next v2 2/2] man8: ip-route: update documentation 2024-08-26 13:52 [PATCH iproute2-next v2 0/2] add support for tunsrc Justin Iurman 2024-08-26 13:52 ` [PATCH iproute2-next v2 1/2] ip: lwtunnel: tunsrc support Justin Iurman @ 2024-08-26 13:52 ` Justin Iurman 1 sibling, 0 replies; 6+ messages in thread From: Justin Iurman @ 2024-08-26 13:52 UTC (permalink / raw) To: netdev; +Cc: dsahern, justin.iurman Include "tunsrc" in the man page. Signed-off-by: Justin Iurman <justin.iurman@uliege.be> --- man/man8/ip-route.8.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/man/man8/ip-route.8.in b/man/man8/ip-route.8.in index df49f8b0..676f289a 100644 --- a/man/man8/ip-route.8.in +++ b/man/man8/ip-route.8.in @@ -253,6 +253,8 @@ throw " | " unreachable " | " prohibit " | " blackhole " | " nat " ]" .IR K "/" N " ] " .BR mode " [ " .BR inline " | " encap " | " auto " ] [" +.B tunsrc +.IR ADDRESS " ] [" .B tundst .IR ADDRESS " ] " .B trace @@ -1037,6 +1039,12 @@ divisible by 8. This attribute can be used only with NEXT-C-SID flavor. packets. .sp +.B tunsrc +.I ADDRESS +- IPv6 address of the tunnel source (outer header), not used with inline mode. +It is optional: if not provided, the tunnel source address is chosen +automatically. + .B tundst .I ADDRESS - IPv6 address of the tunnel destination (outer header), not used with inline -- 2.34.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-08-28 22:22 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-08-26 13:52 [PATCH iproute2-next v2 0/2] add support for tunsrc Justin Iurman 2024-08-26 13:52 ` [PATCH iproute2-next v2 1/2] ip: lwtunnel: tunsrc support Justin Iurman 2024-08-26 15:59 ` Stephen Hemminger 2024-08-27 7:41 ` Justin Iurman 2024-08-28 22:22 ` David Ahern 2024-08-26 13:52 ` [PATCH iproute2-next v2 2/2] man8: ip-route: update documentation Justin Iurman
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox