I was playing with IPv6 and routing and at a certain point I discovered this: poi / # netstat -unlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name udp 0 0 ::ffff:192.168.13.22:53 :::* 19393/dnscache udp 0 0 ::ffff:192.168.13.10:53 :::* 19212/dnscache poi / # ip -4 addr |grep 13 inet 192.168.13.222/32 scope global eth0 inet 192.168.13.100/24 scope global eth2 In other words, netstat truncates the IP when showing it. It phreaked me out and took me na hour to realize what was going on... Reproducible: Always Steps to Reproduce: 1.ip addr add 192.168.111.111 2.start something (dnscache) on that IP 3.check netstat -tunelp Actual Results: address truncated to 192.168.111.1 Expected Results: not truncated address IPv6 module Mark it critical, cause some scripts may be quite broken.
Does this has something to do with Gentoo or is this supposed to go upstream? Still present in sys-apps/net-tools-1.60-r8
from the net-stat source code inside the tcp_do_one() function: printf("tcp %6ld %6ld %-23s %-23s %-12s", rxq, txq, local_addr, rem_addr, _(tcp_state[state])); so it's a limitation in the source; the addresses are truncated to 23 characters ... the example you provided showed this; truncated to 23 characters
I see... I just spent an hour looking around for solution but I couldn't find any good one :-( At least I learned some things about the glibc internals... One possible solution will be to indicate that the address is truncated somehow (e.d. replace : with > on truncated addresses), but this is not very good for text based sys-app (good for GUI with tooltips), cause it may brake some scripts. Another workaround will be to print all IPv4 addresses mapped to IPv6 as normal IPv4 ( IN6_IS_ADDR_V4MAPPED macro). However that will need a few more lines of code and some time to test (=>I cannot do it now)... So, this is definately NOT a Gentoo bug, will have to go upstream. BTW, what happens to resolved bugs as UPSTREAM ?? Shall we (I) mark it as such?
Created attachment 41474 [details, diff] no_truncate.patch Well, I think I put enough comments in the patch itself, but it solves (although not so beautifully) the problem. It works as the original netstat unless there are long addresses. To beautify output, pipe output to "column -t".
Created attachment 41475 [details, diff] net-tools-1.60-r9.ebuild.diff This is the actual ebuild (trivial) patch. Also included are a few substuitutions for hard-coded version inside the ebuild.
resolving bugs as UPSTREAM is a do-it-as-we-feel solution :) if a bug is too big or the developer doesnt really want to handle it, we mark it as such ... kind of a cop out sometimes :) in this case, i wouldnt mind fixing it and sending it upstream ... as you say, UPSTREAM seems to be a bit dead anyways with net-tools
*** This bug has been marked as a duplicate of 53731 ***