From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id EEE525A0272 for ; Wed, 8 Nov 2023 02:15:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1699406129; bh=riIBWp9JQxKNMxkJa0MkRyYs1JuN+BjqaUc35iXG/9k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AWY6xJlrMTDSLtLSvjAPEot4S3hIcP7KaKUMnl6ZIMxg4OM/JaIBZBX48Z1Ddsb8j lPQFt3cIDKhuELBN5Pw+oMrx+GWyNvJPBbd4rNeNxJbVVcokkR+omxDQUNQrsMjzxi P0MwGfipns3xSGZjDlNJXc8lTGNwbV0Kkc5k01Dc= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4SQ6b50Rl9z4xDB; Wed, 8 Nov 2023 12:15:29 +1100 (AEDT) Date: Wed, 8 Nov 2023 10:32:13 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 1/3] netlink: Sequence numbers are actually 32 bits wide Message-ID: References: <20231107122833.1673498-1-sbrivio@redhat.com> <20231107122833.1673498-2-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="QRdNlHti/NMOMXLp" Content-Disposition: inline In-Reply-To: <20231107122833.1673498-2-sbrivio@redhat.com> Message-ID-Hash: W3MBNBKMQNZXP66WMHKXPQ5HSPMAAZMV X-Message-ID-Hash: W3MBNBKMQNZXP66WMHKXPQ5HSPMAAZMV 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: --QRdNlHti/NMOMXLp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 07, 2023 at 01:28:31PM +0100, Stefano Brivio wrote: > Harmless, as we use sequence numbers monotonically anyway, but now > clang-tidy reports: >=20 > /home/sbrivio/passt/netlink.c:155:7: error: format specifies type 'unsign= ed short' but the argument has type '__u32' (aka 'unsigned int') [clang-dia= gnostic-format,-warnings-as-errors] > nh->nlmsg_seq, seq); > ^ > /home/sbrivio/passt/log.h:26:7: note: expanded from macro 'die' > err(__VA_ARGS__); \ > ^~~~~~~~~~~ > /home/sbrivio/passt/log.h:19:34: note: expanded from macro 'err' > ^~~~~~~~~~~ > Suppressed 222820 warnings (222816 in non-user code, 4 NOLINT). > Use -header-filter=3D.* to display errors from all non-system headers. Us= e -system-headers to display errors from system headers as well. > 1 warning treated as error > make: *** [Makefile:255: clang-tidy] Error 1 Hrm. I wonder why clang-tidy didn't find this one for me :/ > Fixes: 9d4ab98d538f ("netlink: Add nl_do() helper for simple operations w= ith error checking") > Signed-off-by: Stefano Brivio > --- > netlink.c | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) >=20 > diff --git a/netlink.c b/netlink.c > index 768c6fd..6cc04a0 100644 > --- a/netlink.c > +++ b/netlink.c > @@ -113,7 +113,7 @@ fail: > * > * Return: sequence number of request on success, terminates on error > */ > -static uint16_t nl_send(int s, void *req, uint16_t type, > +static uint32_t nl_send(int s, void *req, uint16_t type, > uint16_t flags, ssize_t len) > { > struct nlmsghdr *nh; > @@ -146,12 +146,12 @@ static uint16_t nl_send(int s, void *req, uint16_t = type, > * > 0 @n if there are more responses to request @seq > * terminates if sequence numbers are out of sync > */ > -static int nl_status(const struct nlmsghdr *nh, ssize_t n, uint16_t seq) > +static int nl_status(const struct nlmsghdr *nh, ssize_t n, uint32_t seq) > { > ASSERT(NLMSG_OK(nh, n)); > =20 > if (nh->nlmsg_seq !=3D seq) > - die("netlink: Unexpected sequence number (%hu !=3D %hu)", > + die("netlink: Unexpected sequence number (%u !=3D %u)", > nh->nlmsg_seq, seq); > =20 > if (nh->nlmsg_type =3D=3D NLMSG_DONE) { > @@ -229,7 +229,7 @@ static int nl_do(int s, void *req, uint16_t type, uin= t16_t flags, ssize_t len) > struct nlmsghdr *nh; > char buf[NLBUFSIZ]; > ssize_t status; > - uint16_t seq; > + uint32_t seq; > =20 > seq =3D nl_send(s, req, type, flags, len); > nl_foreach(nh, status, s, buf, seq) > @@ -259,7 +259,7 @@ unsigned int nl_get_ext_if(int s, sa_family_t af) > struct rtattr *rta; > char buf[NLBUFSIZ]; > ssize_t status; > - uint16_t seq; > + uint32_t seq; > size_t na; > =20 > seq =3D nl_send(s, &req, RTM_GETROUTE, NLM_F_DUMP, sizeof(req)); > @@ -313,7 +313,7 @@ int nl_route_get_def(int s, unsigned int ifi, sa_fami= ly_t af, void *gw) > bool found =3D false; > char buf[NLBUFSIZ]; > ssize_t status; > - uint16_t seq; > + uint32_t seq; > =20 > seq =3D nl_send(s, &req, RTM_GETROUTE, NLM_F_DUMP, sizeof(req)); > nl_foreach_oftype(nh, status, s, buf, seq, RTM_NEWROUTE) { > @@ -438,7 +438,7 @@ int nl_route_dup(int s_src, unsigned int ifi_src, > unsigned dup_routes =3D 0; > struct nlmsghdr *nh; > char buf[NLBUFSIZ]; > - uint16_t seq; > + uint32_t seq; > unsigned i; > =20 > seq =3D nl_send(s_src, &req, RTM_GETROUTE, NLM_F_DUMP, sizeof(req)); > @@ -550,7 +550,7 @@ int nl_addr_get(int s, unsigned int ifi, sa_family_t = af, > struct nlmsghdr *nh; > char buf[NLBUFSIZ]; > ssize_t status; > - uint16_t seq; > + uint32_t seq; > =20 > seq =3D nl_send(s, &req, RTM_GETADDR, NLM_F_DUMP, sizeof(req)); > nl_foreach_oftype(nh, status, s, buf, seq, RTM_NEWADDR) { > @@ -674,7 +674,7 @@ int nl_addr_dup(int s_src, unsigned int ifi_src, > char buf[NLBUFSIZ]; > struct nlmsghdr *nh; > ssize_t status; > - uint16_t seq; > + uint32_t seq; > int rc =3D 0; > =20 > seq =3D nl_send(s_src, &req, RTM_GETADDR, NLM_F_DUMP, sizeof(req)); > @@ -729,7 +729,7 @@ int nl_link_get_mac(int s, unsigned int ifi, void *ma= c) > struct nlmsghdr *nh; > char buf[NLBUFSIZ]; > ssize_t status; > - uint16_t seq; > + uint32_t seq; > =20 > seq =3D nl_send(s, &req, RTM_GETLINK, 0, sizeof(req)); > nl_foreach_oftype(nh, status, s, buf, seq, RTM_NEWLINK) { --=20 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 --QRdNlHti/NMOMXLp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmVKyPUACgkQzQJF27ox 2Gc9tA/9H7XVpcrhS9DRLAUTsVj4mccRhmWRcCbyow39Z4l3vSHy/KvPU9oM2av8 jR4dZ4Y0159xsRe+thG1bjr6gdJqxwwAxBlPu11BcwDUQvIX4niJ5W0LDhr0gJd4 gYuYiQIy7fusE5cAP3Ug3YnQIFvo/k6ArPSziwg3yfbp7VgHUqravBp4fmCMHJV6 fm2T9AMW4uHGTm8/MoDfMe/bwErf4/+GtKsv+qb+RnqhaG2HhKaHGvxc1ELY8+4Q +z/AH8nm1VJ5JLah5d9tSzSvKZJtR5KTWcuNgzwAPgWEFaSXyinzdvFh8gUC8LU7 EAe774KByCOGHA/UsyVSa1uExQWG5EPdISiJNUKPva3Z9sduUcA3U507X5UGiYtx K7iEmS7TSvPP++Cw3iUqh7ZzYaAfdQEeU8WBUUmXN0w/vMOS5B8hDBn85h3GQk4M mBKI822lvpcYwXFksXJruNZ2HAFiT7jc4V2a+7cOKJVSfrHBVMxVr9NR/2QLBEf3 t0YnJ40ljdI2Dw2X6BRKgrrDq5cX+8lNIApZvFqjz1cGqsiSRxa28T7LPBZS2QFK NrDvOxvJHia5G3PuPlfHg9+d2OKsjhf8JrSfntzs0BeMQhPxAt++JrbRfbrDV9IQ dp2mcUfcl8tLEquHi7tPt31s09uUXHWTTrWerRbar/CLD/nC2KQ= =fXCm -----END PGP SIGNATURE----- --QRdNlHti/NMOMXLp--