From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202504 header.b=A4fxk5Vx; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 858D85A0272 for ; Mon, 14 Apr 2025 06:23:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202504; t=1744604603; bh=Lwc0Om3D6Pcu44iXIKG6yFwUHZNO34MZBwb8otaU8Es=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=A4fxk5VxnWj7XfMYLnxkq+htegoun3gBFudqrUefSTvHxH4hmMe5xsxSz2bYd91Yn 3TXrYdzo2n3p/8/1tllKQTtaQPXJoKQWe13vw3S9z1KN5v9sqrU6OkKaqUvdL3W2xV T+kgSUkuXCvpOnJwkjlhjz6MmkA+zSB2Yoso/I23+Y5FDK8X2bYdo8iGZNxOIv/Pcf y/1wB4IDu4XtqbN9LqKn9wWoUA+ydLIGaPmI1GRJM58XjQiWjLqJsk0iJFDYf/SE+P Mh9R4l8hNbpU/JdGxT4Sl6vq2FqM+RNRmFkjGOP2cUBYVFcdBggD6ZyO/kO1hsVfz9 zszS7UmPEjT8g== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4ZbZ0W39tmz4x1V; Mon, 14 Apr 2025 14:23:23 +1000 (AEST) Date: Mon, 14 Apr 2025 14:10:57 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH v2 14/20] dhcpv6: Extract sending of NotOnLink status Message-ID: References: <20250411131031.1398006-1-lvivier@redhat.com> <20250411131031.1398006-15-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lbpFaiNqAn/ykbmb" Content-Disposition: inline In-Reply-To: <20250411131031.1398006-15-lvivier@redhat.com> Message-ID-Hash: BDCNDMTBJUWG35FMYBYSIKSIPKFWMLHK X-Message-ID-Hash: BDCNDMTBJUWG35FMYBYSIKSIPKFWMLHK X-MailFrom: dgibson@gandalf.ozlabs.org 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 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: --lbpFaiNqAn/ykbmb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 11, 2025 at 03:10:24PM +0200, Laurent Vivier wrote: > Extract code from dhcpv6() into a new function, dhcpv6_send_ia_notonlink() >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > dhcpv6.c | 60 ++++++++++++++++++++++++++++++++++++-------------------- > 1 file changed, 39 insertions(+), 21 deletions(-) >=20 > diff --git a/dhcpv6.c b/dhcpv6.c > index be51c278af7a..549ddbbea735 100644 > --- a/dhcpv6.c > +++ b/dhcpv6.c > @@ -355,6 +355,44 @@ err: > return ia; > } > =20 > +/** > + * dhcpv6_send_ia_notonlink() - Send NotOnLink status > + * @c: Execution context > + * @ia: Pointer to non-appropriate IA_NA or IA_TA > + * @client_id: Client ID message option > + * xid: Transaction ID for message exchange > + */ > +static void dhcpv6_send_ia_notonlink(struct ctx *c, struct opt_hdr *ia, > + const struct opt_hdr *client_id, > + uint32_t xid) > +{ > + const struct in6_addr *src =3D &c->ip6.our_tap_ll; > + size_t n; > + > + info("DHCPv6: received CONFIRM with inappropriate IA," > + " sending NotOnLink status in REPLY"); > + > + ia->l =3D htons(OPT_VSIZE(ia_na) + sizeof(sc_not_on_link)); > + > + n =3D sizeof(struct opt_ia_na); > + memcpy(resp_not_on_link.var, ia, n); > + memcpy(resp_not_on_link.var + n, &sc_not_on_link, > + sizeof(sc_not_on_link)); > + > + n +=3D sizeof(sc_not_on_link); > + memcpy(resp_not_on_link.var + n, client_id, > + sizeof(struct opt_hdr) + ntohs(client_id->l)); > + > + n +=3D sizeof(struct opt_hdr) + ntohs(client_id->l); > + > + n =3D offsetof(struct resp_not_on_link_t, var) + n; > + > + resp_not_on_link.hdr.xid =3D xid; > + > + tap_udp6_send(c, src, 547, tap_ip6_daddr(c, src), 546, > + xid, &resp_not_on_link, n); > +} > + > /** > * dhcpv6_dns_fill() - Fill in DNS Servers and Domain Search list options > * @c: Execution context > @@ -547,28 +585,8 @@ int dhcpv6(struct ctx *c, const struct pool *p, > return -1; > =20 > if ((bad_ia =3D dhcpv6_ia_notonlink(p, &c->ip6.addr))) { > - info("DHCPv6: received CONFIRM with inappropriate IA," > - " sending NotOnLink status in REPLY"); > - > - bad_ia->l =3D htons(OPT_VSIZE(ia_na) + > - sizeof(sc_not_on_link)); > - n =3D sizeof(struct opt_ia_na); > - memcpy(resp_not_on_link.var, bad_ia, n); > - > - memcpy(resp_not_on_link.var + n, > - &sc_not_on_link, sizeof(sc_not_on_link)); > - n +=3D sizeof(sc_not_on_link); > - > - memcpy(resp_not_on_link.var + n, client_id, > - sizeof(struct opt_hdr) + ntohs(client_id->l)); > - n +=3D sizeof(struct opt_hdr) + ntohs(client_id->l); > - > - n =3D offsetof(struct resp_not_on_link_t, var) + n; > - > - resp_not_on_link.hdr.xid =3D mh->xid; > =20 > - tap_udp6_send(c, src, 547, tap_ip6_daddr(c, src), 546, > - mh->xid, &resp_not_on_link, n); > + dhcpv6_send_ia_notonlink(c, bad_ia, client_id, mh->xid); > =20 > return 1; > } --=20 David Gibson (he or they) | 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 --lbpFaiNqAn/ykbmb Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmf8itAACgkQzQJF27ox 2GfQzA/+I1pu4/vxY6/vPVeNuwx8wvfxoH+1qVRpzJphqIWr7DZnbgoPL8s6Sx01 EDuqWMMjvmqhE1lBQcxknU/nlfAJlWQUIE2Kbuj98OP2SXjkYRyA+sg17nkzquhq jDkOT7rtCIGaw/ldwzyb9XPPDHjyAcr+MJocEhDvlmUNTqgf4fcehJSSUiVenwmR qOGPjyMXY6/MKQr43qudiOdXYpaMnT2J9H27MZSWouAI7IrejnEOjW4HCkWLPWhT 7b43EoH4IdONOwJHB9vCr0i+fNC1eErV8y443AqtXhMOxtL3eCZ0RzVt0A2ZOXIa HaYAIVMt3E+JwfEEPHYlDOp16IOgg2htrYMLMznjgWbmvkKNbYRE3GQxpqcpm6Co s0LgvDG+TcfFQhIWlTe/pYFXBmlxxAeTUQyK/BbL2JjV65CennR4k4rCammEiCPu NYnJdfMNdWCTcn90QOa74D7sRhGAY/fWXj0kDkLxbv5mwWc6qOa/rMWoJdiUR/gd ewrLjzSRwSsCUgrOw4p5OZO6SFgzsXPhe2pOiCVptxTAOJMOs22yRQKunp4b1cPo 9ReQY5oeIoIpDOjd1510MJNeOtD+z1WKIqKKA4WiChJY21Q4sALOkvZLAeFS4Efp s8rEDoeHjjBORVmGQ+np+LKb+AaB20AYM0tfvnjst5PgoAPLfEg= =YFZY -----END PGP SIGNATURE----- --lbpFaiNqAn/ykbmb--