From: Paolo Abeni <pabeni@redhat.com>
To: Justin Iurman <justin.iurman@uliege.be>, netdev@vger.kernel.org
Cc: davem@davemloft.net, dsahern@kernel.org, edumazet@google.com,
kuba@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 2/2] net: ipv6: ioam6: new feature tunsrc
Date: Tue, 13 Aug 2024 13:06:15 +0200 [thread overview]
Message-ID: <8fe01ef6-2c85-4843-b686-8cb43cc1f454@redhat.com> (raw)
In-Reply-To: <20240809123915.27812-3-justin.iurman@uliege.be>
On 8/9/24 14:39, Justin Iurman wrote:
> This patch provides a new feature (i.e., "tunsrc") for the tunnel (i.e.,
> "encap") mode of ioam6. Just like seg6 already does, except it is
> attached to a route. The "tunsrc" is optional: when not provided (by
> default), the automatic resolution is applied. Using "tunsrc" when
> possible has a benefit: performance.
It's customary to include performances figures in performance related
changeset ;)
>
> Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
> ---
> include/uapi/linux/ioam6_iptunnel.h | 7 +++++
> net/ipv6/ioam6_iptunnel.c | 48 ++++++++++++++++++++++++++---
> 2 files changed, 51 insertions(+), 4 deletions(-)
>
> diff --git a/include/uapi/linux/ioam6_iptunnel.h b/include/uapi/linux/ioam6_iptunnel.h
> index 38f6a8fdfd34..6cdbd0da7ad8 100644
> --- a/include/uapi/linux/ioam6_iptunnel.h
> +++ b/include/uapi/linux/ioam6_iptunnel.h
> @@ -50,6 +50,13 @@ enum {
> IOAM6_IPTUNNEL_FREQ_K, /* u32 */
> IOAM6_IPTUNNEL_FREQ_N, /* u32 */
>
> + /* Tunnel src address.
> + * For encap,auto modes.
> + * Optional (automatic if
> + * not provided).
> + */
> + IOAM6_IPTUNNEL_SRC, /* struct in6_addr */
> +
> __IOAM6_IPTUNNEL_MAX,
> };
>
> diff --git a/net/ipv6/ioam6_iptunnel.c b/net/ipv6/ioam6_iptunnel.c
> index cd2522f04edf..e0e73faf9969 100644
> --- a/net/ipv6/ioam6_iptunnel.c
> +++ b/net/ipv6/ioam6_iptunnel.c
> @@ -42,6 +42,8 @@ struct ioam6_lwt {
> struct ioam6_lwt_freq freq;
> atomic_t pkt_cnt;
> u8 mode;
> + bool has_tunsrc;
> + struct in6_addr tunsrc;
> struct in6_addr tundst;
> struct ioam6_lwt_encap tuninfo;
> };
> @@ -72,6 +74,7 @@ static const struct nla_policy ioam6_iptunnel_policy[IOAM6_IPTUNNEL_MAX + 1] = {
> [IOAM6_IPTUNNEL_MODE] = NLA_POLICY_RANGE(NLA_U8,
> IOAM6_IPTUNNEL_MODE_MIN,
> IOAM6_IPTUNNEL_MODE_MAX),
> + [IOAM6_IPTUNNEL_SRC] = NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)),
> [IOAM6_IPTUNNEL_DST] = NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)),
> [IOAM6_IPTUNNEL_TRACE] = NLA_POLICY_EXACT_LEN(
> sizeof(struct ioam6_trace_hdr)),
> @@ -144,6 +147,11 @@ static int ioam6_build_state(struct net *net, struct nlattr *nla,
> else
> mode = nla_get_u8(tb[IOAM6_IPTUNNEL_MODE]);
>
> + if (tb[IOAM6_IPTUNNEL_SRC] && mode == IOAM6_IPTUNNEL_MODE_INLINE) {
> + NL_SET_ERR_MSG(extack, "no tunnel source expected in this mode");
> + return -EINVAL;
> + }
when mode is IOAM6_IPTUNNEL_MODE_AUTO, the data path could still add the
encapsulation for forwarded packets, why explicitly preventing this
optimization in such scenario?
> +
> if (!tb[IOAM6_IPTUNNEL_DST] && mode != IOAM6_IPTUNNEL_MODE_INLINE) {
> NL_SET_ERR_MSG(extack, "this mode needs a tunnel destination");
> return -EINVAL;
> @@ -178,6 +186,14 @@ static int ioam6_build_state(struct net *net, struct nlattr *nla,
> ilwt->freq.n = freq_n;
>
> ilwt->mode = mode;
> +
> + if (!tb[IOAM6_IPTUNNEL_SRC]) {
> + ilwt->has_tunsrc = false;
> + } else {
> + ilwt->has_tunsrc = true;
> + ilwt->tunsrc = nla_get_in6_addr(tb[IOAM6_IPTUNNEL_SRC]);
Since you are going to use the source address only if != ANY, I think it
would be cleaner to refuse such addresses here. That will avoid an
additional check in the datapath.
Cheers,
Paolo
next prev parent reply other threads:[~2024-08-13 11:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-09 12:39 [PATCH net-next 0/2] net: ipv6: ioam6: introduce tunsrc Justin Iurman
2024-08-09 12:39 ` [PATCH net-next 1/2] net: ipv6: ioam6: code alignment Justin Iurman
2024-08-09 12:39 ` [PATCH net-next 2/2] net: ipv6: ioam6: new feature tunsrc Justin Iurman
2024-08-13 11:06 ` Paolo Abeni [this message]
2024-08-13 11:20 ` Justin Iurman
2024-08-13 11:43 ` Justin Iurman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8fe01ef6-2c85-4843-b686-8cb43cc1f454@redhat.com \
--to=pabeni@redhat.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=justin.iurman@uliege.be \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®