[PATCH 0/4] Assorted minor socket creation cleanups
As discussed on our recent call, I was looking again at bug 167. I discovered it's still fairly fiddly to address this, but while investigating spotted a number of cleanups to make in the vicinity. I think they make sense even without fixing bug 167 (yet), so here they are. David Gibson (4): flow: Correct misleading signature of flowside_sock_l4() Makefile: Remove unused DUAL_STACK_SOCKETS define fwd, pif: Remove duplicated logic between tcp_listen() and udp_listen() pif, util: Move listen(2) call from sock_l4_() to pif_listen() Makefile | 5 ----- flow.c | 11 +++++------ fwd.c | 8 +------- pif.c | 45 ++++++++++++++++++++++++++++++++++++--------- pif.h | 2 +- tcp.c | 38 -------------------------------------- tcp.h | 2 -- udp.c | 38 -------------------------------------- udp.h | 2 -- util.c | 7 ------- 10 files changed, 43 insertions(+), 115 deletions(-) -- 2.54.0
flowside_sock_l4() takes a @tgt parameter with the side to create a socket
for. The name is misleading, however, although ICMP only uses it for the
target side of the flow, UDP can use it for either or both sides. TCP
doesn't use it at all. Rename it to @side.
While we're there remove the stale comment for the @data paremeter which
was removed in 05972c7c4daf.
Fixes: 05972c7c4daf ("util: Move epoll registration out of sock_l4_sa()")
Signed-off-by: David Gibson
We have a make variable DUAL_STACK_SOCKETS which used to determine whether
we'd use dual stack sockets. When we introduced it we were concerned that
we might have future ports to systems which did not support them.
We've since discovered that the dual stack interface is described in
RFC 3493, and supported by both Windows and BSD. Platforms sometimes
differ in the default setting for the IPV6_V6ONLY socket option, but the
feature itself is widely supported. So, since b8d4fac6a2e7 ("util, pif:
Replace sock_l4() with pif_sock_l4()") we've simply assumed its presence.
The makefile still defines the now unused variable, though. Remove it.
Signed-off-by: David Gibson
tcp_listen() and udp_listen() have only some simple logic around a call to
pif_listen(), and it's basically identical in each case. If we move the
common logic into pif_listen() we can then remove {tcp,udp}_listen()
entirely, with their caller in fwd_sync_one() calling pif_listen()
directly.
We also move the logic converting from a protocol id to an epoll type from
fwd_sync_one() into pif_listen(). It's a bit arbitrary, but seems slightly
nicer that way.
Signed-off-by: David Gibson
On Tue, 9 Jun 2026 16:30:01 +1000
David Gibson
As discussed on our recent call, I was looking again at bug 167. I discovered it's still fairly fiddly to address this, but while investigating spotted a number of cleanups to make in the vicinity. I think they make sense even without fixing bug 167 (yet), so here they are.
David Gibson (4): flow: Correct misleading signature of flowside_sock_l4() Makefile: Remove unused DUAL_STACK_SOCKETS define fwd, pif: Remove duplicated logic between tcp_listen() and udp_listen() pif, util: Move listen(2) call from sock_l4_() to pif_listen()
I was about to apply this (there are no apparent conflicts with "[PATCH 0/4] RFC: Improvements to flow specific logging", which I still need to review), but cppcheck now says: --- flow.c:216:31: style: inconclusive: Function 'flowside_sock_l4' argument 4 names different: declaration 'tgt' definition 'side'. [funcArgNamesDifferent] const struct flowside *side) ^ flow.h:176:31: note: Function 'flowside_sock_l4' argument 4 names different: declaration 'tgt' definition 'side'. const struct flowside *tgt); ^ flow.c:216:31: note: Function 'flowside_sock_l4' argument 4 names different: declaration 'tgt' definition 'side'. const struct flowside *side) ^ pif.c:111:10: error: Overlapping read/write of union is undefined behavior [overlappingWriteUnion] ref.fd = sock_l4_dualstack_any(c, ref.type, port, ifname); ^ pif.c:116:10: error: Overlapping read/write of union is undefined behavior [overlappingWriteUnion] ref.fd = sock_l4(c, ref.type, &sa, ifname); ^ --- ...is it just my version (2.19.0)? -- Stefano
On Fri, Jun 12, 2026 at 01:05:17AM +0200, Stefano Brivio wrote:
On Tue, 9 Jun 2026 16:30:01 +1000 David Gibson
wrote: As discussed on our recent call, I was looking again at bug 167. I discovered it's still fairly fiddly to address this, but while investigating spotted a number of cleanups to make in the vicinity. I think they make sense even without fixing bug 167 (yet), so here they are.
David Gibson (4): flow: Correct misleading signature of flowside_sock_l4() Makefile: Remove unused DUAL_STACK_SOCKETS define fwd, pif: Remove duplicated logic between tcp_listen() and udp_listen() pif, util: Move listen(2) call from sock_l4_() to pif_listen()
I was about to apply this (there are no apparent conflicts with "[PATCH 0/4] RFC: Improvements to flow specific logging", which I still need to review), but cppcheck now says:
--- flow.c:216:31: style: inconclusive: Function 'flowside_sock_l4' argument 4 names different: declaration 'tgt' definition 'side'. [funcArgNamesDifferent] const struct flowside *side) ^ flow.h:176:31: note: Function 'flowside_sock_l4' argument 4 names different: declaration 'tgt' definition 'side'. const struct flowside *tgt); ^ flow.c:216:31: note: Function 'flowside_sock_l4' argument 4 names different: declaration 'tgt' definition 'side'. const struct flowside *side) ^ pif.c:111:10: error: Overlapping read/write of union is undefined behavior [overlappingWriteUnion] ref.fd = sock_l4_dualstack_any(c, ref.type, port, ifname); ^ pif.c:116:10: error: Overlapping read/write of union is undefined behavior [overlappingWriteUnion] ref.fd = sock_l4(c, ref.type, &sa, ifname); ^ ---
Bother. I thought I'd done a cppcheck / clang-tidy pass, but apparently I missed it :(.
...is it just my version (2.19.0)?
No. Although my version (2.21.0) also gives some new errors on the main branch. Hang on.. -- 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
participants (2)
-
David Gibson
-
Stefano Brivio