From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine 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=V2CGly4J; 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 ESMTPS id D38725A0619 for ; Mon, 04 May 2026 16:52:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777906372; 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:autocrypt:autocrypt; bh=84fHEcyq0UmzM7bh+pdKpE19AFxpL1XPH0PSBY1h9Ys=; b=V2CGly4Jn6etufOYqQJWipNbifVlhb0UqOPRswliPvnDdrVBfS6QsSYKkk9K2yEbG0OdrK giuZ8Kk8Q1QVT7DwvO0rNPRpKKbheA/5Obu+WUMvQ20fb13Mc7Q6AroOU1JAf2q7hb//Us /64pvShWFuozrB8E+BQRhQ9TVemUulA= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-451-tXM20AmHOruLpuc1bmU4MA-1; Mon, 04 May 2026 10:52:51 -0400 X-MC-Unique: tXM20AmHOruLpuc1bmU4MA-1 X-Mimecast-MFC-AGG-ID: tXM20AmHOruLpuc1bmU4MA_1777906370 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-bbfaa3ad205so241502266b.0 for ; Mon, 04 May 2026 07:52:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777906370; x=1778511170; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=84fHEcyq0UmzM7bh+pdKpE19AFxpL1XPH0PSBY1h9Ys=; b=Q8KHV1y6Z+8DEnIJzjJKXKphyHkE/IABNQ5TtMUlCTd7DAHpdvkfR+1eTVFmrUCKLR WauUekRh4/QEQd8/p3WIcjIvUgOAZPDjyi5zEo/0EaIRYkHaeljNP5lIOff0WGFXAMdN RlJZxoTmJPInDyVzb0niTXlP8rFGtApvXx9ZwMN8r2Vg/wLldDcnesz5w4LLVhltuQhd +GttWP5RY0wxrMzrbD6OizpuTWE6pvOHfmT/Vox4CtBmyFEwhH89FefJGfbK/PPjVa2M U565NbUqzTxvaCF5UYxC86+Q9mp0/cUanA0xdfBaDp/Uux2FBUekn/xPMfLU/oN6Wv5H hCVg== X-Forwarded-Encrypted: i=1; AFNElJ+Gr96+M2UGETtWKX2xLWpYwSfDd1xT0pJVWhV/bYQbeGMZxyHkLc9I9fHpBnhqUP5sG5A5PWSB3qo=@passt.top X-Gm-Message-State: AOJu0YzkOlijAHb6tp5QvY40GNmIBl6ClcDP1qUOhTtZaByYl9KUY1jQ Bs0yZvHes4ppjUqgqAb0R75QdY+hOdnxfFpDco1LENfRKWd9P1I2ho8AnymWLO7eDp+ha+I8fq6 FWAwHSlkDuPxof2T6KHmrjl/9QYtCZIteiUQ7anSrHqujrijYgsMkDg== X-Gm-Gg: AeBDiev1FfBTt8u3gw2BXS7Qa9vzuVP7dHenWYw9HZvlXnOQ+fQhT5tklVy55+B9clf dhXOgfO+xzFNSt6NCySNYmf5dhU0Nx/jygHjI+sagsPnEPpJsvKg0ibeRCk32DTojb3ntKFsYub KNeZebM4fpci7TyobVc3Qc4xWivxREtQ9QNUrSLm70KuqXbx4Fk3ueCcRkSM9D2ipPAwYgEb5bS FRdbrIqBzPspEhkULGh8zrQDB6i7XbsFr8ULFZ6Q79dqe6ZbuEOloHjblWNELhCWQdS0e6nsBgw iJGiD52ArfPLOdXiWU+HkuNWkVQtmxuZ2EVpkPALGfUQB2JKNcipt8KVcxADzBxScQ4EP2vpy/8 k4XIkfX4PaP0Byg+AjHuLDy3dBieq2CYr/0kzaAEtVF9QJ9KXHf+9BTs2rnwoxBf4BA== X-Received: by 2002:a17:907:2d1e:b0:bc3:99d5:a29f with SMTP id a640c23a62f3a-bc399d5af91mr43871966b.5.1777906370009; Mon, 04 May 2026 07:52:50 -0700 (PDT) X-Received: by 2002:a17:907:2d1e:b0:bc3:99d5:a29f with SMTP id a640c23a62f3a-bc399d5af91mr43867266b.5.1777906368481; Mon, 04 May 2026 07:52:48 -0700 (PDT) Received: from [192.168.100.100] (82-64-211-94.subs.proxad.net. [82.64.211.94]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-bc24cbd70d8sm116481466b.39.2026.05.04.07.52.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 04 May 2026 07:52:47 -0700 (PDT) Message-ID: Date: Mon, 4 May 2026 16:52:47 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 12/18] ip: Prepare ip.[ch] for sharing with pesto tool To: Stefano Brivio , passt-dev@passt.top References: <20260503215601.823029-1-sbrivio@redhat.com> <20260503215601.823029-13-sbrivio@redhat.com> From: Laurent Vivier Autocrypt: addr=lvivier@redhat.com; keydata= xsFNBFYFJhkBEAC2me7w2+RizYOKZM+vZCx69GTewOwqzHrrHSG07MUAxJ6AY29/+HYf6EY2 WoeuLWDmXE7A3oJoIsRecD6BXHTb0OYS20lS608anr3B0xn5g0BX7es9Mw+hV/pL+63EOCVm SUVTEQwbGQN62guOKnJJJfphbbv82glIC/Ei4Ky8BwZkUuXd7d5NFJKC9/GDrbWdj75cDNQx UZ9XXbXEKY9MHX83Uy7JFoiFDMOVHn55HnncflUncO0zDzY7CxFeQFwYRbsCXOUL9yBtqLer Ky8/yj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fzzb8JtAuSbuzZSQPDwQEI5CKKxp7zf76J21YeRrEW4WDznPyVcDTa+tz++q2S/Bp P4W98bXCBIuQgs2m+OflERv5c3Ojldp04/S4NEjXEYRWdiCxN7ca5iPml5gLtuvhJMSy36gl U6IW9kn30IWuSoBpTkgV7rLUEhh9Ms82VWW/h2TxL8enfx40PrfbDtWwqRID3WY8jLrjKfTd R3LW8BnUDNkG+c4FzvvGUs8AvuqxxyHbXAfDx9o/jXfPHVRmJVhSmd+hC3mcQ+4iX5bBPBPM oDqSoLt5w9GoQQ6gDVP2ZjTWqwSRMLzNr37rJjZ1pt0DCMMTbiYIUcrhX8eveCJtY7NGWNyx FCRkhxRuGcpwPmRVDwOl39MB3iTsRighiMnijkbLXiKoJ5CDVvX5yicNqYJPKh5MFXN1bvsB kmYiStMRbrD0HoY1kx5/VozBtc70OU0EB8Wrv9hZD+Ofp0T3KOr1RUHvCZoLURfFhSQ= In-Reply-To: <20260503215601.823029-13-sbrivio@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: uHfP1S-vbaoPBKWrQsAkqQBzioxNMOobGAeGBa1yF6U_1777906370 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID-Hash: X5XYIH33EOSFJCHWRHM7O636E4ZUFXN4 X-Message-ID-Hash: X5XYIH33EOSFJCHWRHM7O636E4ZUFXN4 X-MailFrom: lvivier@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: Jon Maloy , David Gibson 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 5/3/26 23:55, Stefano Brivio wrote: > From: David Gibson > > Most things in ip.[ch] related purely to IP addresses and headers with > no dependency on other passt/pasta internals. A number of these will be > useful to re-use in pesto. The exception is ipv6_l4hdr() which uses > iov_tail. > > The only caller of this is in tap.c, so move the function there. Along > with moving the constant byteswapping functions to common.h, that lets > ip.[ch] to be linked into pesto as well as passt/pasta. > > Signed-off-by: David Gibson > Signed-off-by: Stefano Brivio Reviewed-by: Laurent Vivier But we can fix a pre-existing error while doing the move, see below: > --- > common.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ > inany.h | 2 ++ > ip.c | 56 +++----------------------------------------------------- > ip.h | 4 +--- > tap.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > util.h | 48 ------------------------------------------------ > 6 files changed, 106 insertions(+), 104 deletions(-) > > diff --git a/common.h b/common.h > index 45f66ea..4a167ae 100644 > --- a/common.h > +++ b/common.h > @@ -55,4 +55,52 @@ static inline const char *strerror_(int errnum) > > #define ARRAY_SIZE(a) ((int)(sizeof(a) / sizeof((a)[0]))) > > +#ifndef __bswap_constant_16 > +#define __bswap_constant_16(x) \ > + ((uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))) > +#endif > + > +#ifndef __bswap_constant_32 > +#define __bswap_constant_32(x) \ > + ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ > + (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) > +#endif > + > +#ifndef __bswap_constant_32 > +#define __bswap_constant_32(x) \ > + ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ > + (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) > +#endif __bswap_constant_32 block is written twice. > + > +#ifndef __bswap_constant_64 > +#define __bswap_constant_64(x) \ > + ((((x) & 0xff00000000000000ULL) >> 56) | \ > + (((x) & 0x00ff000000000000ULL) >> 40) | \ > + (((x) & 0x0000ff0000000000ULL) >> 24) | \ > + (((x) & 0x000000ff00000000ULL) >> 8) | \ > + (((x) & 0x00000000ff000000ULL) << 8) | \ > + (((x) & 0x0000000000ff0000ULL) << 24) | \ > + (((x) & 0x000000000000ff00ULL) << 40) | \ > + (((x) & 0x00000000000000ffULL) << 56)) > +#endif > + > +#if __BYTE_ORDER == __BIG_ENDIAN > +#define htons_constant(x) (x) > +#define htonl_constant(x) (x) > +#define htonll_constant(x) (x) > +#define ntohs_constant(x) (x) > +#define ntohl_constant(x) (x) > +#define ntohll_constant(x) (x) > +#else > +#define htons_constant(x) (__bswap_constant_16(x)) > +#define htonl_constant(x) (__bswap_constant_32(x)) > +#define htonll_constant(x) (__bswap_constant_64(x)) > +#define ntohs_constant(x) (__bswap_constant_16(x)) > +#define ntohl_constant(x) (__bswap_constant_32(x)) > +#define ntohll_constant(x) (__bswap_constant_64(x)) > +#endif > + > +#define ntohll(x) (be64toh((x))) > +#define htonll(x) (htobe64((x))) > + > #endif /* _COMMON_H */ > diff --git a/inany.h b/inany.h > index 30e2416..1f7741d 100644 > --- a/inany.h > +++ b/inany.h > @@ -10,8 +10,10 @@ > #define INANY_H > > #include > +#include > #include > > +#include "util.h" > #include "ip.h" > #include "siphash.h" > > diff --git a/ip.c b/ip.c > index 25fa407..f2506bb 100644 > --- a/ip.c > +++ b/ip.c > @@ -6,6 +6,9 @@ > * PASTA - Pack A Subtle Tap Abstraction > * for network namespace/tap device mode > * > + * PESTO - Programmable Extensible Socket Translation Orchestrator > + * front-end for passt(1) and pasta(1) forwarding configuration > + * > * ip.c - IP related functions > * > * Copyright (c) 2020-2021 Red Hat GmbH > @@ -16,61 +19,8 @@ > #include > #include > > -#include "util.h" > #include "ip.h" > > -#define IPV6_NH_OPT(nh) \ > - ((nh) == 0 || (nh) == 43 || (nh) == 44 || (nh) == 50 || \ > - (nh) == 51 || (nh) == 60 || (nh) == 135 || (nh) == 139 || \ > - (nh) == 140 || (nh) == 253 || (nh) == 254) > - > -/** > - * ipv6_l4hdr() - Find pointer to L4 header in IPv6 packet and extract protocol > - * @data: IPv6 packet > - * @proto: Filled with L4 protocol number > - * @dlen: Data length (payload excluding header extensions), set on return > - * > - * Return: true if the L4 header is found and @data, @proto, @dlen are set, > - * false on error. Outputs are indeterminate on failure. > - */ > -bool ipv6_l4hdr(struct iov_tail *data, uint8_t *proto, size_t *dlen) > -{ > - struct ipv6_opt_hdr o_storage; > - const struct ipv6_opt_hdr *o; > - struct ipv6hdr ip6h_storage; > - const struct ipv6hdr *ip6h; > - int hdrlen; > - uint8_t nh; > - > - ip6h = IOV_REMOVE_HEADER(data, ip6h_storage); > - if (!ip6h) > - return false; > - > - nh = ip6h->nexthdr; > - if (!IPV6_NH_OPT(nh)) > - goto found; > - > - while ((o = IOV_PEEK_HEADER(data, o_storage))) { > - nh = o->nexthdr; > - hdrlen = (o->hdrlen + 1) * 8; > - > - if (IPV6_NH_OPT(nh)) > - iov_drop_header(data, hdrlen); > - else > - goto found; > - } > - > - return false; > - > -found: > - if (nh == IPPROTO_NONE) > - return false; > - > - *dlen = iov_tail_size(data); > - *proto = nh; > - return true; > -} > - > /** > * ipproto_name() - Get IP protocol name from number > * @proto: IP protocol number > diff --git a/ip.h b/ip.h > index fb4119a..aab9b86 100644 > --- a/ip.h > +++ b/ip.h > @@ -9,7 +9,7 @@ > #include > #include > > -#include "util.h" > +#include "common.h" > > #define IN4_IS_ADDR_UNSPECIFIED(a) \ > (((struct in_addr *)(a))->s_addr == htonl_constant(INADDR_ANY)) > @@ -117,8 +117,6 @@ static inline uint32_t ip6_get_flow_lbl(const struct ipv6hdr *ip6h) > ip6h->flow_lbl[2]; > } > > -bool ipv6_l4hdr(struct iov_tail *data, uint8_t *proto, size_t *dlen); > - > #define IPPROTO_STRLEN (sizeof("")) > const char *ipproto_name(uint8_t proto); > > diff --git a/tap.c b/tap.c > index 7d06189..cfd7b64 100644 > --- a/tap.c > +++ b/tap.c > @@ -874,6 +874,58 @@ append: > return in->count; > } > > +#define IPV6_NH_OPT(nh) \ > + ((nh) == 0 || (nh) == 43 || (nh) == 44 || (nh) == 50 || \ > + (nh) == 51 || (nh) == 60 || (nh) == 135 || (nh) == 139 || \ > + (nh) == 140 || (nh) == 253 || (nh) == 254) > + > +/** > + * ipv6_l4hdr() - Find pointer to L4 header in IPv6 packet and extract protocol > + * @data: IPv6 packet > + * @proto: Filled with L4 protocol number > + * @dlen: Data length (payload excluding header extensions), set on return > + * > + * Return: true if the L4 header is found and @data, @proto, @dlen are set, > + * false on error. Outputs are indeterminate on failure. > + */ > +static bool ipv6_l4hdr(struct iov_tail *data, uint8_t *proto, size_t *dlen) > +{ > + struct ipv6_opt_hdr o_storage; > + const struct ipv6_opt_hdr *o; > + struct ipv6hdr ip6h_storage; > + const struct ipv6hdr *ip6h; > + int hdrlen; > + uint8_t nh; > + > + ip6h = IOV_REMOVE_HEADER(data, ip6h_storage); > + if (!ip6h) > + return false; > + > + nh = ip6h->nexthdr; > + if (!IPV6_NH_OPT(nh)) > + goto found; > + > + while ((o = IOV_PEEK_HEADER(data, o_storage))) { > + nh = o->nexthdr; > + hdrlen = (o->hdrlen + 1) * 8; > + > + if (IPV6_NH_OPT(nh)) > + iov_drop_header(data, hdrlen); > + else > + goto found; > + } > + > + return false; > + > +found: > + if (nh == IPPROTO_NONE) > + return false; > + > + *dlen = iov_tail_size(data); > + *proto = nh; > + return true; > +} > + > /** > * tap6_handler() - IPv6 packet handler for tap file descriptor > * @c: Execution context > diff --git a/util.h b/util.h > index c788382..dc14c78 100644 > --- a/util.h > +++ b/util.h > @@ -101,54 +101,6 @@ void abort_with_msg(const char *fmt, ...) > #define MAC_UNDEF MAC_BROADCAST > #define MAC_IS_UNDEF(addr) (!memcmp((addr), MAC_UNDEF, ETH_ALEN)) > > -#ifndef __bswap_constant_16 > -#define __bswap_constant_16(x) \ > - ((uint16_t) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8))) > -#endif > - > -#ifndef __bswap_constant_32 > -#define __bswap_constant_32(x) \ > - ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ > - (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) > -#endif > - > -#ifndef __bswap_constant_32 > -#define __bswap_constant_32(x) \ > - ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ > - (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) > -#endif > - > -#ifndef __bswap_constant_64 > -#define __bswap_constant_64(x) \ > - ((((x) & 0xff00000000000000ULL) >> 56) | \ > - (((x) & 0x00ff000000000000ULL) >> 40) | \ > - (((x) & 0x0000ff0000000000ULL) >> 24) | \ > - (((x) & 0x000000ff00000000ULL) >> 8) | \ > - (((x) & 0x00000000ff000000ULL) << 8) | \ > - (((x) & 0x0000000000ff0000ULL) << 24) | \ > - (((x) & 0x000000000000ff00ULL) << 40) | \ > - (((x) & 0x00000000000000ffULL) << 56)) > -#endif > - > -#if __BYTE_ORDER == __BIG_ENDIAN > -#define htons_constant(x) (x) > -#define htonl_constant(x) (x) > -#define htonll_constant(x) (x) > -#define ntohs_constant(x) (x) > -#define ntohl_constant(x) (x) > -#define ntohll_constant(x) (x) > -#else > -#define htons_constant(x) (__bswap_constant_16(x)) > -#define htonl_constant(x) (__bswap_constant_32(x)) > -#define htonll_constant(x) (__bswap_constant_64(x)) > -#define ntohs_constant(x) (__bswap_constant_16(x)) > -#define ntohl_constant(x) (__bswap_constant_32(x)) > -#define ntohll_constant(x) (__bswap_constant_64(x)) > -#endif > - > -#define ntohll(x) (be64toh((x))) > -#define htonll(x) (htobe64((x))) > - > extern uint8_t eth_pad[ETH_ZLEN]; > > /**