From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=X+pwOMNk; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 7BE685A026E for ; Sat, 17 Aug 2024 10:37:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723883845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HU1sqkvfUUUkCJKKWxdja5azQrTn0tw8pAY3r0zJIIg=; b=X+pwOMNkYT6PDQLLCB5VuBeTX8SzBaFOODH/HqA8z737W4tL/HggrikLyQ4l8YOSs37vDu BL4OMSTrqrOXq+6dJOSceyh5fk3MBI9qX6QuoVILW5Ld4XHwqhCeRMJlpR4MuvYvZZNy0T VT/pKNmgxoJY+IBYa0OybVl85nd0IRc= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-255-1UjWzZMgPySu3472QbYzyg-1; Sat, 17 Aug 2024 04:37:22 -0400 X-MC-Unique: 1UjWzZMgPySu3472QbYzyg-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42aa70df35eso9077455e9.2 for ; Sat, 17 Aug 2024 01:37:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723883841; x=1724488641; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=HU1sqkvfUUUkCJKKWxdja5azQrTn0tw8pAY3r0zJIIg=; b=E9AkMlRNDvtf1Z3suzXGsYpFbkr9NXPLV4jZsyuuqz3gUEkSi6Udtd69TwXB25H7av +3QsK2o1R9ou0CeUPTdLrs3+XT4LKKzXBMWHlB3/w00ORNZoApZ9kXzjAAnTTzS0dwOV wH2c4UCz3kI53oTv6I6CUioNuOVMT316gLDrns9nGqGD+N0xnGdIcO7sEUQSw37uiN5U aMN7XJYFJWW2VVMRlgGLaWLvJEBzZdwLP/Ux9JFOPJL1E9/6eCPPGUPNLnQs2LGbHmqm SHCBQ1nMC8dSa3/JtQUUS+KWI7tKcoA3tbWiYhZvFB5Y8mje6yRFVlqecu2H+PO1wE5f 1jvg== X-Gm-Message-State: AOJu0YzW/Tnk4gJYDkZdL6AlkG+Ks04SOu29DPAaYsvf0YTM48WvXCAb VND762FfLxs7jm0SC/0ZvgsifWGvkEx6HxseepzywvRLtVsAB2/0jsDi/Z2Au1ieyEo7Bv5rckB OhJ0sQTt7zLg/inNghIHzilSdkKtIbYrlKZBkzZt9ujdGu4SZPg== X-Received: by 2002:a05:600c:1ca4:b0:426:6857:3156 with SMTP id 5b1f17b1804b1-429ed7d5ff5mr40755745e9.27.1723883841339; Sat, 17 Aug 2024 01:37:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGog5pezVbYCCCOnBI/CCUTxQOBVzlAykt6N2Ikxh46mrvxd8qZRHNX+t1gMiIcgeP3QgauPA== X-Received: by 2002:a05:600c:1ca4:b0:426:6857:3156 with SMTP id 5b1f17b1804b1-429ed7d5ff5mr40755595e9.27.1723883840786; Sat, 17 Aug 2024 01:37:20 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded292f8sm96548545e9.14.2024.08.17.01.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Aug 2024 01:37:20 -0700 (PDT) Date: Sat, 17 Aug 2024 10:37:16 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH v3 4/7] netlink, pasta: Disable DAD for link-local addresses on namespace interface Message-ID: <20240817103716.10135435@elisabeth> In-Reply-To: References: <20240816073918.1483136-1-sbrivio@redhat.com> <20240816073918.1483136-5-sbrivio@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: KCZM2JYCCL7CBYE5DLQWZQWTGNMQ7JYL X-Message-ID-Hash: KCZM2JYCCL7CBYE5DLQWZQWTGNMQ7JYL X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, Paul Holzinger X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Sat, 17 Aug 2024 17:59:45 +1000 David Gibson wrote: > On Fri, Aug 16, 2024 at 09:39:15AM +0200, Stefano Brivio wrote: > > It makes no sense for a container or a guest to try and perform > > duplicate address detection for their link-local address, as we'll > > anyway not relay neighbour solicitations with an unspecified source > > address. > > > > While they perform duplicate address detection, the link-local address > > is not usable, which prevents us from bringing up especially > > containers and communicate with them right away via IPv6. > > > > This is not enough to prevent DAD and reach the container right away: > > we'll need a couple more patches. > > > > As we send NLM_F_REPLACE requests right away, while we still have to > > read out other addresses on the same socket, we can't use nl_do(): > > keep track of the last sequence we sent (last address we changed), and > > deal with the answers to those NLM_F_REPLACE requests in a separate > > loop, later. > > > > Link: https://github.com/containers/podman/pull/23561#discussion_r1711639663 > > Signed-off-by: Stefano Brivio > > --- > > netlink.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > netlink.h | 1 + > > pasta.c | 6 ++++++ > > 3 files changed, 62 insertions(+) > > > > diff --git a/netlink.c b/netlink.c > > index 873e6c7..59f2fd9 100644 > > --- a/netlink.c > > +++ b/netlink.c > > @@ -673,6 +673,61 @@ int nl_route_dup(int s_src, unsigned int ifi_src, > > return 0; > > } > > > > +/** > > + * nl_addr_set_ll_nodad() - Set IFA_F_NODAD on IPv6 link-local addresses > > + * @s: Netlink socket > > + * @ifi: Interface index in target namespace > > + * > > + * Return: 0 on success, negative error code on failure > > + */ > > +int nl_addr_set_ll_nodad(int s, unsigned int ifi) > > +{ > > + struct req_t { > > + struct nlmsghdr nlh; > > + struct ifaddrmsg ifa; > > + } req = { > > + .ifa.ifa_family = AF_INET6, > > + .ifa.ifa_index = ifi, > > + }; > > + unsigned ll_addrs = 0; > > + struct nlmsghdr *nh; > > + char buf[NLBUFSIZ]; > > + ssize_t status; > > + uint32_t seq; > > + > > + seq = nl_send(s, &req, RTM_GETADDR, NLM_F_DUMP, sizeof(req)); > > + nl_foreach_oftype(nh, status, s, buf, seq, RTM_NEWADDR) { > > + struct ifaddrmsg *ifa = (struct ifaddrmsg *)NLMSG_DATA(nh); > > + struct rtattr *rta; > > + size_t na; > > + > > + if (ifa->ifa_index != ifi || ifa->ifa_scope != RT_SCOPE_LINK) > > + continue; > > + > > + ifa->ifa_flags |= IFA_F_NODAD; > > + > > + for (rta = IFA_RTA(ifa), na = IFA_PAYLOAD(nh); RTA_OK(rta, na); > > + rta = RTA_NEXT(rta, na)) { > > + /* 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; > > + } > > + > > + nl_send(s, nh, RTM_NEWADDR, NLM_F_REPLACE, nh->nlmsg_len); > > + ll_addrs++; > > + } > > Uh.. did you forget to push an update. This looks like the last > version. Worse :( I accidentally squashed the new changes into 5/7. Respinning... thanks for noticing. -- Stefano