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=adMv/xYC; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id B65415A0271 for ; Thu, 08 Jan 2026 11:55:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767869712; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to: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=sNKgUvlRvWwNF1O4zmRRtEVqaoB6f+p415w168BZx5w=; b=adMv/xYCEW8396wuaU+TXK9IXDwWIswdFHJQeCw/FbDpB4RN9qj2H6WZZ9U/GyxPPJTzhV kDzjsj7bh9pxd2JR5f+4BGNJuJ+tnW5DieTVxCPRpjWbnqLFtXYQ4phFas9thw1x2AJeYO vxESbGNXAWPrQHRt2jt3vjEEwnfevyY= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-224-L8lunIP2PxK5OU8v_5QPRQ-1; Thu, 08 Jan 2026 05:55:11 -0500 X-MC-Unique: L8lunIP2PxK5OU8v_5QPRQ-1 X-Mimecast-MFC-AGG-ID: L8lunIP2PxK5OU8v_5QPRQ_1767869710 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-477964c22e0so15214005e9.0 for ; Thu, 08 Jan 2026 02:55:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767869710; x=1768474510; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references: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=sNKgUvlRvWwNF1O4zmRRtEVqaoB6f+p415w168BZx5w=; b=d9NyToxg3/EOuHymvPju4i0Bdk4ibz/+UkjNgSAHuLIhoMKZqGLyRVqhop2OJm3u6/ yMt+bOo7UvwXji5bqpJNrk9zJ4jLblOPvGUo+ZLr1/mIiiWp4LHUPW5LECBzraVacxKa n0EMxBcjPFBuMysu/KAp8QqSkmDS1NF0GInKCbyd8kkqIWGwvNkRMVwKfgOd52S87e8r 3OyJhl8vPUVCpiNNtQdsDguGYUuHyRHG42gXN98LmGl8JFxS2JsVB0PH2f4050IDrn2x cBrQBfKgQES9RIRobZBf17dsietDIPdz8Y8d+GrHndPnRIaNZlVfmz4GrYx4vU1rVCGQ aemQ== X-Forwarded-Encrypted: i=1; AJvYcCWSyshRw4MHTfUtzDRXVi+dWrwS+boLpnMzUX6QGuT6i67mRxjJU/zdWxpTLAcIMW2RC6q34UnXMtM=@passt.top X-Gm-Message-State: AOJu0YzY13FpmF7YtdEhpPtV0bemlVwXx3y+HfvZfACE33/p7K+HmGb7 AahyBwDGrj5H65i2Ykw5WuxO/bPui9g6Mw6iSiiXssD0cVPheraG+TEMDrFRiRpIp+d+e1YKcIn 36JOrQbf0cFs4eLD/3iFrn5XIOlpBYTlL1ib2SKP91OUFaxHtzV6MrM7Z5cNSeA== X-Gm-Gg: AY/fxX7CTHmss3Gid7KIB6LezFkhTA3v4skCwWXBFwOTVuppyxm8NHSbrQlvwX41d9I mn2nxwgVbX5FbKn+Tm3VeNbaveRoNVjf4i/DvUJ73QaL/TZnCfdPzfEbV4kIa3O7TMmYY59ycxt A5ttsRd6v9SXGGYtVUNY5LEVqIOjfDet0rRYLnSD6v+OQEnAqzB3Vn0QK5mKPdvc+G3/9SvI6c7 ff4t0BAi2X/qPp0/HmigaJ5UUF144f4Wq/Dx4xQtjd3C3YeohoNmdxWvlsVFRjQZ1pX93Mwy4uK hFuYMAxTwUrdMWWUruTbetkRY2MpRnpjjz+mtj7CxpIMghubLVyoAvCGxGFYYLH7NdedR/y/K3J 6nhtP4vGvKjwysS/KX0mFA1+jSi46invG5sknxMqn0Fy82lA8 X-Received: by 2002:a05:600c:8b6c:b0:46e:59bd:f7e2 with SMTP id 5b1f17b1804b1-47d8486ccebmr64931905e9.11.1767869709944; Thu, 08 Jan 2026 02:55:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IExRd6ZLP4ugzlRfiZRdTss6zPbiJSiZhP0OwDvBk7XJK4l8n6fgvyOgw0bN8S8e15g4kbo1w== X-Received: by 2002:a05:600c:8b6c:b0:46e:59bd:f7e2 with SMTP id 5b1f17b1804b1-47d8486ccebmr64931785e9.11.1767869709456; Thu, 08 Jan 2026 02:55:09 -0800 (PST) Received: from ?IPV6:2a01:e0a:e10:ef90:343a:68f:2e91:95c? ([2a01:e0a:e10:ef90:343a:68f:2e91:95c]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d7f7035f2sm139942985e9.12.2026.01.08.02.55.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 08 Jan 2026 02:55:09 -0800 (PST) Message-ID: <51accb0d-bac9-441b-a98d-25c9b4a3f43e@redhat.com> Date: Thu, 8 Jan 2026 11:55:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 3/3] fwd, tcp, udp: Consolidate epoll refs for listening sockets To: David Gibson , passt-dev@passt.top, Stefano Brivio References: <20260108021450.2650004-1-david@gibson.dropbear.id.au> <20260108021450.2650004-4-david@gibson.dropbear.id.au> From: Laurent Vivier Autocrypt: addr=lvivier@redhat.com; keydata= xsFNBFYFJhkBEAC2me7w2+RizYOKZM+vZCx69GTewOwqzHrrHSG07MUAxJ6AY29/+HYf6EY2 WoeuLWDmXE7A3oJoIsRecD6BXHTb0OYS20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g3TsjEybxDEUBm8dBmnKqcnTBFmxN5FFtI WlEuY8+YMiWRykd8Ln9RJ/98/ghABHz9TN8TRo2b6WimV64FmlVn17Ri6FgFU3xNt9TTEChq AcNg88eYryKsYpFwegGpwUlaUaaGh1m9OrTzcQy+klVfZWaVJ9Nw0keoGRGb8j4XjVpL8+2x OhXKrM1fzzb8JtAuSbuzZSQPDwQEI5CKKxp7zf76J21YeRrEW4WDznPyVcDTa+tz++q2S/Bp P4W98bXCBIuQgs2m+OflERv5c3Ojldp04/S4NEjXEYRWdiCxN7ca5iPml5gLtuvhJMSy36gl U6IW9kn30IWuSoBpTkgV7rLUEhh9Ms82VWW/h2TxL8enfx40PrfbDtWwqRID3WY8jLrjKfTd R3LW8BnUDNkG+c4FzvvGUs8AvuqxxyHbXAfDx9o/jXfPHVRmJVhSmd+hC3mcQ+4iX5bBPBPM oDqSoLt5w9GoQQ6gDVP2ZjTWqwSRMLzNr37rJjZ1pt0DCMMTbiYIUcrhX8eveCJtY7NGWNyx FCRkhxRuGcpwPmRVDwOl39MB3iTsRighiMnijkbLXiKoJ5CDVvX5yicNqYJPKh5MFXN1bvsB kmYiStMRbrD0HoY1kx5/VozBtc70OU0EB8Wrv9hZD+Ofp0T3KOr1RUHvCZoLURfFhSQ= In-Reply-To: <20260108021450.2650004-4-david@gibson.dropbear.id.au> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: o_8RjQ3wjyvBDoPaaiw7uaqoZh057uxtW8LMUMXpB8Y_1767869710 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: WZUKKGLJIYHTQMHIKSMW6KAAWMNQ5LDS X-Message-ID-Hash: WZUKKGLJIYHTQMHIKSMW6KAAWMNQ5LDS 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 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 1/8/26 03:14, David Gibson wrote: > The epoll references we use for TCP listening sockets and UDP "listening" > sockets have identical information. Combine them into a single structure. > Note that, despite the name, epoll_ref.udp was only ever used for > "listening" sockets, not flow sockets. > > Signed-off-by: David Gibson > --- > epoll_ctl.h | 6 ++---- > fwd.h | 13 +++++++++++++ > tcp.c | 8 ++++---- > tcp.h | 14 -------------- > udp.c | 6 +++--- > udp.h | 15 --------------- > 6 files changed, 22 insertions(+), 40 deletions(-) > > diff --git a/epoll_ctl.h b/epoll_ctl.h > index 02b081e2..3f802e76 100644 > --- a/epoll_ctl.h > +++ b/epoll_ctl.h > @@ -21,8 +21,7 @@ > * @fd: File descriptor number (implies < 2^24 total descriptors) > * @flow: Index of the flow this fd is linked to > * @flowside: Index and side of a flow this fd is linked to > - * @tcp_listen: TCP-specific reference part for listening sockets > - * @udp: UDP-specific reference part > + * @listen: Information for listening sockets > * @data: Data handled by protocol handlers > * @nsdir_fd: netns dirfd for fallback timer checking if namespace is gone > * @queue: vhost-user queue index for this fd > @@ -35,8 +34,7 @@ union epoll_ref { > union { > uint32_t flow; > flow_sidx_t flowside; > - union tcp_listen_epoll_ref tcp_listen; > - union udp_listen_epoll_ref udp; > + union fwd_listen_ref listen; > uint32_t data; > int nsdir_fd; > int queue; > diff --git a/fwd.h b/fwd.h > index 77925822..934bab33 100644 > --- a/fwd.h > +++ b/fwd.h > @@ -16,6 +16,19 @@ struct flowside; > void fwd_probe_ephemeral(void); > bool fwd_port_is_ephemeral(in_port_t port); > > +/** > + * union fwd_listen_ref - information about a single listening socket > + * @port: Bound port number of the socket > + * @pif: pif in which the socket is listening > + */ > +union fwd_listen_ref { > + struct { > + in_port_t port; > + uint8_t pif; > + }; > + uint32_t u32; > +}; > + > enum fwd_ports_mode { > FWD_UNSET = 0, > FWD_SPEC = 1, > diff --git a/tcp.c b/tcp.c > index e7fa85f3..9fc385d2 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -2485,8 +2485,8 @@ void tcp_listen_handler(const struct ctx *c, union epoll_ref ref, > * address, record that as our address, as implemented for vhost-user > * mode only, below. > */ > - ini = flow_initiate_sa(flow, ref.tcp_listen.pif, &sa, > - NULL, ref.tcp_listen.port); > + ini = flow_initiate_sa(flow, ref.listen.pif, &sa, > + NULL, ref.listen.port); > > if (getsockname(s, &sa.sa, &sl) || > inany_from_sockaddr(&ini->oaddr, &ini->oport, &sa) < 0) > @@ -2685,7 +2685,7 @@ void tcp_sock_handler(const struct ctx *c, union epoll_ref ref, > int tcp_listen(const struct ctx *c, uint8_t pif, > const union inany_addr *addr, const char *ifname, in_port_t port) > { > - union tcp_listen_epoll_ref tref = { > + union fwd_listen_ref ref = { > .port = port, > .pif = pif, > }; > @@ -2722,7 +2722,7 @@ int tcp_listen(const struct ctx *c, uint8_t pif, > } > > s = pif_sock_l4(c, EPOLL_TYPE_TCP_LISTEN, pif, addr, ifname, > - port, tref.u32); > + port, ref.u32); > > if (fwd->mode == FWD_AUTO) { > if (!addr || inany_v4(addr)) > diff --git a/tcp.h b/tcp.h > index 516dfef5..ef1e3544 100644 > --- a/tcp.h > +++ b/tcp.h > @@ -30,20 +30,6 @@ void tcp_update_l2_buf(const unsigned char *eth_d); > > extern bool peek_offset_cap; > > -/** > - * union tcp_listen_epoll_ref - epoll reference portion for TCP listening > - * @port: Bound port number of the socket > - * @pif: pif in which the socket is listening > - * @u32: Opaque u32 value of reference > - */ > -union tcp_listen_epoll_ref { > - struct { > - in_port_t port; > - uint8_t pif; > - }; > - uint32_t u32; > -}; > - > /** > * struct tcp_ctx - Execution context for TCP routines > * @port_to_tap: Ports bound host-side, packets to tap or spliced > diff --git a/udp.c b/udp.c > index eda55c39..747d4dd4 100644 > --- a/udp.c > +++ b/udp.c > @@ -928,7 +928,7 @@ void udp_listen_sock_handler(const struct ctx *c, > const struct timespec *now) > { > if (events & (EPOLLERR | EPOLLIN)) > - udp_sock_fwd(c, ref.fd, ref.udp.pif, ref.udp.port, now); > + udp_sock_fwd(c, ref.fd, ref.listen.pif, ref.listen.port, now); > } > > /** > @@ -1141,7 +1141,7 @@ int udp_tap_handler(const struct ctx *c, uint8_t pif, > int udp_listen(const struct ctx *c, uint8_t pif, > const union inany_addr *addr, const char *ifname, in_port_t port) > { > - union udp_listen_epoll_ref uref = { > + union fwd_listen_ref ref = { > .pif = pif, > .port = port, > }; > @@ -1175,7 +1175,7 @@ int udp_listen(const struct ctx *c, uint8_t pif, > } > > s = pif_sock_l4(c, EPOLL_TYPE_UDP_LISTEN, pif, > - addr, ifname, port, uref.u32); > + addr, ifname, port, ref.u32); > > if (!addr || inany_v4(addr)) > socks[V4][port] = s < 0 ? -1 : s; > diff --git a/udp.h b/udp.h > index 5407db3b..94c698e2 100644 > --- a/udp.h > +++ b/udp.h > @@ -22,21 +22,6 @@ int udp_init(struct ctx *c); > void udp_port_rebind_all(struct ctx *c); > void udp_update_l2_buf(const unsigned char *eth_d); > > -/** > - * union udp_listen_epoll_ref - epoll reference for "listening" UDP sockets > - * @port: Source port for connected sockets, bound port otherwise > - * @pif: pif for this socket > - * @u32: Opaque u32 value of reference > - */ > -union udp_listen_epoll_ref { > - struct { > - in_port_t port; > - uint8_t pif; > - }; > - uint32_t u32; > -}; > - > - > /** > * struct udp_ctx - Execution context for UDP > * @fwd_in: Port forwarding configuration for inbound packets Reviewed-by: Laurent Vivier