Open ChriMarMe opened 5 months ago
Hm not sure if that was intentional, it does look a bit supprising. Since the man page lists it as a extra option and does not mention connections, we can probably change it (especially since there is no negative option to turn it off).
hmm... or maybe it should filter only sockets listening on those groups... havent used much mcast tooling lately.
I cant tell. My goal is to reimplement netstat in golang and found this weird behavior. The code was not helpful in showing the intention or if there was any. That's why I ended up asking.
I will change it.
BTW if you reimplement something, I would not go with the /proc interface"ces but use (lib)netlink like ss
from the iproute2 is doing, it's not only faster but also more complete information (for example multiple interface ips)
Thanks for the advice.
Yeah, the data from /proc is a nightmare to parse and process. So many different formats to read from.....
Sadly I already have most functionality done and encountered this issue here, but I certainly will have a look. Maybe it allows more clean and structured code. Thank you.
I checked again and I think the issue is coming from specifying -4 and -6 - those are not documented in the man-page as AF settings für -g:
netstat {--groups|-g} [--numeric|-n] [--numeric-hosts] [--nu‐ meric-ports] [--numeric-users] [--continuous|-c] [delay]
So it basically uses -46 as an indicator to show IP sockets besides the group. If you only use "netstat -g" it works (limited support for address families).
However it could be useful to limit to IPv4 or IPv6 address family?
The patch here needs some more rework for man and translations, but it works now that you can filter like "netstat -g4" or "netstat -g -6" or "netstat -g46" which is the same as "netstat -g". There is also a buffer corruption with netstat "-g46c".
usage: netstat [-vWeenNcCF] [<Af>] -r netstat {-V|--version|-h|--help}
netstat [-vWnNcaeol] [<Socket> ...]
netstat { [-vWeenNac] -i | [-cnNe] -M | [-6tuw] -s | [-cn46] -g }
$ ./netstat -gn4
IPv4 Group Memberships
Interface RefCnt Group
--------------- ------ ---------------------
lo 1 224.0.0.1
ens5 1 224.0.0.1
Is that behaviour deliberate or a bug?