Skip to content

linux: apply -s UDP state lists to UDP sockets - #376

Merged
jiegec merged 2 commits into
lsof-org:masterfrom
Ar-maan05:udp-state-filter
Nov 3, 2026
Merged

jiegec merged 2 commits into
lsof-org:masterfrom
Ar-maan05:udp-state-filter

Conversation

@Ar-maan05

Copy link
Copy Markdown
Contributor

on linux -s UDP:... is accepted but doesn't filter anything:

lsof -iUDP -sUDP:ESTABLISHED   (one connected, one unconnected UDP socket)
before: both sockets
after:  only 127.0.0.1:38535->127.0.0.1:9 (ESTABLISHED)

-sUDP:^ESTABLISHED was ignored the same way, and combining -sTCP:LISTEN -sUDP:ESTABLISHED lost the UDP socket. both the IPv4 and IPv6 paths check every record against the TCP state tables, even UDP ones. the fix moves that into a small helper that picks the right tables by protocol.

extended case-20-udp-socket-state.bash to cover -s UDP:ESTABLISHED and ^ESTABLISHED, it fails before and passes after. make check is clean.

the IPv4 and IPv6 socket code checked every TCP and UDP record against the TCP state tables, so -s UDP:... did nothing and TCP state lists got applied to UDP sockets instead. check each record against its own protocol's tables. like on other dialects, a file is left out when only the other protocol has an inclusion list.
@hugojosealmeida

hugojosealmeida commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

I added complementary tests covering connected/unconnected UDP sockets, mixed TCP/UDP filters and protocol isolation for IPv4/IPv6: hugojosealmeida@38f759a

They pass with your fix and fail against its parent. Feel free to cherry-pick the tests-only commit.

Note that my IPv4/IPv6 tests pass with this PR and fail against its parent code, confirming coverage of UDP filtering and TCP/UDP isolation.

@Ar-maan05

Copy link
Copy Markdown
Contributor Author

thanks, that's way more thorough than mine. pulled your commit in as is

@jiegec
jiegec merged commit dae5d3f into lsof-org:master Nov 3, 2026
17 checks passed
@Ar-maan05
Ar-maan05 deleted the udp-state-filter branch November 3, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants