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=202512 header.b=Iexqqik7; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 807A45A004E for ; Fri, 09 Jan 2026 00:13:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1767913977; bh=7ww5NVXmfma22faQ7CCZBqas2kjWkGGqA8WYpGg2cnY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Iexqqik7caduSlbSl8tTJ/fe6U5/rdZfPSyX2u7e4Vv9s260cP/19IRPjc7DCWt+o +oEVvo32yVXAMV8ytrv7jIcjZunRnaKdIS0iLo8nPeif0tTlnQ7CzGqmLk9kntkz3f wPxNxuZzRuPqg3qsiHugNJCunX67cKGy+smT50gZoVEvTR1CfsOO7fSVHSwey8VG5P bKY4OCH2/qh9D7cuNj6JRuPrMqa9D5xTb45PCIl1tl6SmBoeUIEjTTggl51lBwtPXT FfISe2Trw+blvGKPqXeUVX/yMoyhUBFQdG9EV7JaZ9yG7S9hxSh3zWJiyDOSPAJ9S1 mrwSQInTHrr6A== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dnLKj3096z4wQG; Fri, 09 Jan 2026 10:12:57 +1100 (AEDT) Date: Fri, 9 Jan 2026 10:12:50 +1100 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH v3 06/14] ip: Add ipproto_name() function Message-ID: References: <20260108022948.2657573-1-david@gibson.dropbear.id.au> <20260108022948.2657573-7-david@gibson.dropbear.id.au> <91ab17a2-744d-4e4d-b533-f2c5849883de@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Qg56ScLgpXZ1Xohl" Content-Disposition: inline In-Reply-To: <91ab17a2-744d-4e4d-b533-f2c5849883de@redhat.com> Message-ID-Hash: FZJG5444LTBCMZ43MOE7DOSFNLZFD6ZP X-Message-ID-Hash: FZJG5444LTBCMZ43MOE7DOSFNLZFD6ZP 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: Stefano Brivio , 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: --Qg56ScLgpXZ1Xohl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jan 08, 2026 at 02:22:21PM +0100, Laurent Vivier wrote: > On 1/8/26 03:29, David Gibson wrote: > > Add a function to get the name of an IP protocol from its number. Usua= lly > > this would be done by getprotobynumber(), but that requires access to > > /etc/protocols and might allocate. We can't do either of those once we= 've > > self-isolated. > >=20 > > Signed-off-by: David Gibson > > --- > > ip.c | 27 +++++++++++++++++++++++++++ > > ip.h | 2 ++ > > 2 files changed, 29 insertions(+) > >=20 > > diff --git a/ip.c b/ip.c > > index 9a7f4c54..f1d224bd 100644 > > --- a/ip.c > > +++ b/ip.c > > @@ -67,3 +67,30 @@ found: > > *proto =3D nh; > > return true; > > } > > + > > +/** > > + * ipproto_name() - Get IP protocol name from number > > + * @proto: IP protocol number > > + * > > + * Return: pointer to name of protocol @proto > > + * > > + * Usually this would be done with getprotobynumber(3) but that reads > > + * /etc/protocols and might allocate, which isn't possible for us once > > + * self-isolated. > > + */ > > +/* cppcheck-suppress unusedFunction */ > > +const char *ipproto_name(uint8_t proto) > > +{ > > + switch (proto) { > > + case IPPROTO_ICMP: > > + return "ICMP"; > > + case IPPROTO_TCP: > > + return "TCP"; > > + case IPPROTO_UDP: > > + return "UDP"; > > + case IPPROTO_ICMPV6: > > + return "ICMPv6"; > > + default: > > + return ""; > > + } > > +} > > diff --git a/ip.h b/ip.h > > index 5830b923..42b417c5 100644 > > --- a/ip.h > > +++ b/ip.h > > @@ -116,6 +116,7 @@ static inline uint32_t ip6_get_flow_lbl(const struc= t ipv6hdr *ip6h) > > } > > bool ipv6_l4hdr(struct iov_tail *data, uint8_t *proto, size_t *dlen); > > +const char *ipproto_name(uint8_t proto); > > /* IPv6 link-local all-nodes multicast address, ff02::1 */ > > static const struct in6_addr in6addr_ll_all_nodes =3D { > > @@ -135,4 +136,5 @@ static const struct in_addr in4addr_broadcast =3D {= 0xffffffff }; > > #define IPV6_MIN_MTU 1280 > > #endif > > + >=20 > Extra blank line Oops, fixed. > > #endif /* IP_H */ >=20 > Reviewed-by: Laurent Vivier >=20 --=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 --Qg56ScLgpXZ1Xohl Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmlgOfEACgkQzQJF27ox 2GdHyg//RNuIAp8PcLkTYs6zK3jyzKZODkE7PhSRMZ7L4Swgz2I8ZSvXlJ/c5HGl RAkVq2KlJy49sQH7sDG3LwhhJvJuafxWxblC3PMjZ0nvj9cSwvswuBEuG1IEkAv4 hmOk2tz71SQEG9UTHnmdLUhBWSdNTnJfvRlcVP87lFEU1w7MK8kgPxYaUcx+b3PY o/qGqXBiV+RaWh173EcgErfnxt/Sxz7SM3f8OZYtKKKgYqktAN7+fwkQhQLbkUEv fozWw2bcDpXQejdvHq/Q4Fgytv90jTsmROhWg2cAMWoCxHFtUlp7a3NKUoLxKVNu EvRHuPirdbeBj46IvQsX1rEAahpAK6lla4Z8rAd+YMkHvnjFWqOkU3KN54KNxWHP P0FOeChBVQx80a8Jc6n8w1O0C6HkLMSqHNp4lfvbeBBV5AkIp2r+yrOYXCJDEUiX zUi5vn5468GxUJmh2+NjCgxIT3n9Bdqmi1j0T6bH/uh9LXPYjr0ZnsHbKcBEU2jH W/pC41Ov/C3mMrfOEvEUSA3Ok8ANgJhoYttFv53UGU1y8J0yP6BpJtmno3BVrILf lJN+m+er/Hl3JsIaTx7URX/Yo5mIMzLK6NEHrvl7GLWdLjWT/qjReNtnNQN2A0+B pU1S2TYcIshOmuIh/OmDpTRAQMVgrFCWqQayZYu47hx0cZv0Kb8= =5RrB -----END PGP SIGNATURE----- --Qg56ScLgpXZ1Xohl--