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=fail reason="key not found in DNS" header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202312 header.b=mzFQVvuD; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 820BE5A0275 for ; Thu, 15 Aug 2024 05:43:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1723693394; bh=zjUDypcgaCo99KHy2R5IVymLxdGlWJP0rU7PgeJ8YH4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mzFQVvuDh31kPdVaYEuF2M06WKURW35pnOaTGAR1jZ70GPbQMA4f2b2oby6nYMAr3 hE6Y+gQ8MSXoi8Xim5e+XYQ4kWCA8WKowuDudGTJrLHCaumRUD5LU1wyxMaQR6V5K9 OgFwQFSDftEmuMW+/HqOQuPF9DGl5LmsFF7ELoWoAMHnV1F1wmDjrNieRg1j1OHcrL IGBzNN60rkG9Fify6srqdH7m1jn+HApzUFBzmNbiQ5IwZSEde55YoB/kqNHlSvIgDx lCMROuhHSlu76QGObn85qjt2woTK3VcciAGM5jCLzfUAzI8cEHYhnICeta8/yqJ5ny ZCwTCSBxEGnaw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4WkrYt0HP1z4x3r; Thu, 15 Aug 2024 13:43:14 +1000 (AEST) Date: Thu, 15 Aug 2024 12:42:20 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 3/7] netlink, pasta: Turn nl_link_up() into a generic function to set link flags Message-ID: References: <20240814225429.3707908-1-sbrivio@redhat.com> <20240814225429.3707908-4-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="yI7fw2NwbOZUbl77" Content-Disposition: inline In-Reply-To: <20240814225429.3707908-4-sbrivio@redhat.com> Message-ID-Hash: MG2AHACONGSVJVNOOY6ZZHWFJQLHDXKD X-Message-ID-Hash: MG2AHACONGSVJVNOOY6ZZHWFJQLHDXKD 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, 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: --yI7fw2NwbOZUbl77 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Aug 15, 2024 at 12:54:25AM +0200, Stefano Brivio wrote: > In the next patches, we'll reuse it to set flags other than IFF_UP. >=20 > Signed-off-by: Stefano Brivio If we had more instances it might be nice to have a wrapper to just ifup, but there's only 2 callers, so, Reviewed-by: David Gibson > --- > netlink.c | 11 +++++++---- > netlink.h | 3 ++- > pasta.c | 4 ++-- > 3 files changed, 11 insertions(+), 7 deletions(-) >=20 > diff --git a/netlink.c b/netlink.c > index e33765e..873e6c7 100644 > --- a/netlink.c > +++ b/netlink.c > @@ -968,13 +968,16 @@ int nl_link_set_mtu(int s, unsigned int ifi, int mt= u) > } > =20 > /** > - * nl_link_up() - Bring link up > + * nl_link_set_flags() - Set link flags > * @s: Netlink socket > * @ifi: Interface index > + * @set: Device flags to set > + * @change: Mask of device flag changes > * > * Return: 0 on success, negative error code on failure > */ > -int nl_link_up(int s, unsigned int ifi) > +int nl_link_set_flags(int s, unsigned int ifi, > + unsigned int set, unsigned int change) > { > struct req_t { > struct nlmsghdr nlh; > @@ -982,8 +985,8 @@ int nl_link_up(int s, unsigned int ifi) > } req =3D { > .ifm.ifi_family =3D AF_UNSPEC, > .ifm.ifi_index =3D ifi, > - .ifm.ifi_flags =3D IFF_UP, > - .ifm.ifi_change =3D IFF_UP, > + .ifm.ifi_flags =3D set, > + .ifm.ifi_change =3D change, > }; > =20 > return nl_do(s, &req, RTM_NEWLINK, 0, sizeof(req)); > diff --git a/netlink.h b/netlink.h > index 87d27ae..178f8ae 100644 > --- a/netlink.h > +++ b/netlink.h > @@ -24,6 +24,7 @@ int nl_addr_dup(int s_src, unsigned int ifi_src, > int nl_link_get_mac(int s, unsigned int ifi, void *mac); > int nl_link_set_mac(int s, unsigned int ifi, const void *mac); > int nl_link_set_mtu(int s, unsigned int ifi, int mtu); > -int nl_link_up(int s, unsigned int ifi); > +int nl_link_set_flags(int s, unsigned int ifi, > + unsigned int set, unsigned int change); > =20 > #endif /* NETLINK_H */ > diff --git a/pasta.c b/pasta.c > index 3a0652e..96545b1 100644 > --- a/pasta.c > +++ b/pasta.c > @@ -288,7 +288,7 @@ void pasta_ns_conf(struct ctx *c) > { > int rc =3D 0; > =20 > - rc =3D nl_link_up(nl_sock_ns, 1 /* lo */); > + rc =3D nl_link_set_flags(nl_sock_ns, 1 /* lo */, IFF_UP, IFF_UP); > if (rc < 0) > die("Couldn't bring up loopback interface in namespace: %s", > strerror(-rc)); > @@ -306,7 +306,7 @@ void pasta_ns_conf(struct ctx *c) > if (c->mtu !=3D -1) > nl_link_set_mtu(nl_sock_ns, c->pasta_ifi, c->mtu); > =20 > - nl_link_up(nl_sock_ns, c->pasta_ifi); > + nl_link_set_flags(nl_sock_ns, c->pasta_ifi, IFF_UP, IFF_UP); > =20 > if (c->ifi4) { > if (c->ip4.no_copy_addrs) { --=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 --yI7fw2NwbOZUbl77 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAma9awwACgkQzQJF27ox 2Gd5chAAmMaQhLu3wLXnES7MU08usaIrmkeUlotxhAAfIXTeb/gl/4hk4N9EYzia hwEo8516KxmI1N2j8dpJ9v85rc2i7+BoN3GldKoYMtpjbsKP7nY0rnCJQfdw/uy4 uZBpceiO4goJS7IGpMs7GTFI7x9GTPJk6p8FjRufV5sUyTlcozO+WHsHl7S0PWPv kFXS6E+UsjI+6agiMjpPvzV4YxvY4FECpr3qHGopaKyV1qf4lHAck4cYJhz2ZtJW J/Qd+ZK4s6/wkA1czB1PboWhIzKyQmghLiytVtLAjD0/vkIz7aw70x4L0xZLLR9E WwHf8byzJ5o3bwBz3KKJyXVeQLmTOScMT3A9X33OWc1MOcMzITd8O2EBh8w6fxTR ANIW/WkQHCCZaxrQqXC/buH2avvCKVk+gRkfq28YIJKJ4OyGwc+JP7brgn3q+aFT gkMCaTbh9Qvvs12aNQMuVKATEgEy+5ald3ABPYh+CvgYbpjOOLmtAASsepiyx0/a Jwt5L8hxuAhH83xwaJT1XiHSKyKJeW0wqRG5cwutjay1d7dceIYQD8+V79DznTK6 YbNNn4u2//qHdmGASnOPS6nMu6wUEb+2PWr222OOExRYEI33Ogc/InF6svG042R6 bL0UeL4a3qf7SzVqSqAEEzVfjftu2/07+GlZ654DG0VCDF3YKSA= =1maD -----END PGP SIGNATURE----- --yI7fw2NwbOZUbl77--