public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Stefano Brivio <sbrivio@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH] netlink: Use IFA_F_NODAD also while duplicating addresses from the host
Date: Fri, 26 Apr 2024 11:13:44 +1000	[thread overview]
Message-ID: <Zir_yJ_aWBw3oAbM@zatzit> (raw)
In-Reply-To: <20240425221015.452760-1-sbrivio@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1942 bytes --]

On Fri, Apr 26, 2024 at 12:10:15AM +0200, Stefano Brivio wrote:
> ...not just for a single set address (legacy operation with
> --no-copy-addrs). I forgot to add this to nl_addr_dup().
> 
> Note that we can have two version of flags: the 8-bit ifa_flags in
> ifaddrmsg, and the newer 32-bit version as IFA_FLAGS attribute, which
> is given priority if present. Make sure IFA_F_NODAD is set in both.
> 
> Without this, a Podman user reports, something on the lines of:
>   pasta --config-net -- ping -c1 -6 passt.top
> 
> would fail as the kernel would start Duplicate Address Detection
> once we configure the address, which can't really work (and doesn't
> make sense) in this case.
> 
> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  netlink.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/netlink.c b/netlink.c
> index 447fea2..b3897e6 100644
> --- a/netlink.c
> +++ b/netlink.c
> @@ -804,6 +804,8 @@ int nl_addr_dup(int s_src, unsigned int ifi_src,
>  			continue;
>  
>  		ifa->ifa_index = ifi_dst;
> +		/* Same as nl_addr_set(), but here it's more than a default */
> +		ifa->ifa_flags |= IFA_F_NODAD;
>  
>  		for (rta = IFA_RTA(ifa), na = IFA_PAYLOAD(nh); RTA_OK(rta, na);
>  		     rta = RTA_NEXT(rta, na)) {
> @@ -811,6 +813,10 @@ int nl_addr_dup(int s_src, unsigned int ifi_src,
>  			if (rta->rta_type == IFA_LABEL ||
>  			    rta->rta_type == IFA_CACHEINFO)
>  				rta->rta_type = IFA_UNSPEC;
> +
> +			/* If 32-bit flags are used, add IFA_F_NODAD there */
> +			if (rta->rta_type == IFA_FLAGS)
> +				*(uint32_t *)RTA_DATA(rta) |= IFA_F_NODAD;
>  		}
>  
>  		rc = nl_do(s_dst, nh, RTM_NEWADDR,

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2024-04-26  2:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-25 22:10 [PATCH] netlink: Use IFA_F_NODAD also while duplicating addresses from the host Stefano Brivio
2024-04-26  1:13 ` David Gibson [this message]

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=Zir_yJ_aWBw3oAbM@zatzit \
    --to=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).