Bug 233196 - Netstat shows zero counters for aliases IP addresses
Summary: Netstat shows zero counters for aliases IP addresses
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 11.2-RELEASE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-net (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-13 11:41 UTC by Kirill
Modified: 2018-11-13 13:55 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kirill 2018-11-13 11:41:37 UTC
Hi.

root@vm1:/usr/home/user # netstat -i
Name    Mtu Network   Address              Ipkts Ierrs Idrop    Opkts Oerrs  Coll
em0 1500 <Link#1>     08:00:27:76:25:92      588     0     0      416     0     0
lo0 16384 <Link#2>    lo0                     12     0     0       12     0     0
lo0  - localhost     localhost                0     -     -        0     -     -
lo0  - fe80::%lo0/64 fe80::1%lo0              0     -     -        0     -     -
lo0  - your-net      localhost                6     -     -       12     -     -
lagg0 1500 <Link#3>   08:00:27:76:25:92      588     0     0      416     1     0
lagg0 - 10.0.2.0/24   10.0.2.15              586     -     -      413     -     -
lagg0 - 192.168.0.0/2 192.168.0.1              6     -     -        0     -     -

See row for IP 192.168.0.1, column Oerrs = 0. Is it bug or feature?
Comment 1 Bjoern A. Zeeb freebsd_committer 2018-11-13 13:05:56 UTC
It was never implemented for IPv4.
In IPv6 it's been done right from the start.

I think this patch (probably for FreeBSD 9) was supposed to improve the situation for IPv4, but nobody ever did the performance evaluation as it's an extra loop over all interface addresses:
https://people.freebsd.org/~bz/20100816-01-in_ifawithifp-legacy-o-counters.diff
Comment 2 Yuri Pankov freebsd_committer 2018-11-13 13:45:04 UTC
Which column exactly is this about?  Oerrs is "-" for all *IP* interfaces, not only the alias one; same for Ierrs, Idrop, Coll as these stats likely make sense only for link level.  And it seems to work for me just fine, "alias" address is 10.10.10.1/24 (running HEAD):

$ netstat -i
Name    Mtu Network       Address              Ipkts Ierrs Idrop    Opkts Oerrs  Coll
em0    9000 <Link#1>      94:c6:91:1c:80:16    40212     0     0    23337     0     0
em0       - fe80::%em0/64 fe80::96c6:91ff:f        5     -     -        7     -     -
em0       - fd4b:fd13:e02 fd4b:fd13:e02a:0:        3     -     -        2     -     -
em0       - 192.168.1.0/2 thor                 38106     -     -    23108     -     -
em0       - 10.10.10.0/24 10.10.10.1             171     -     -      171     -     -
lo0   16384 <Link#2>      lo0                     18     0     0       18     0     0
lo0       - localhost     localhost                0     -     -        0     -     -
lo0       - fe80::%lo0/64 fe80::1%lo0              0     -     -        0     -     -
lo0       - your-net      localhost               18     -     -       18     -     -
Comment 3 Bjoern A. Zeeb freebsd_committer 2018-11-13 13:49:24 UTC
(In reply to Yuri Pankov from comment #2)

It's for output octets (probably also packets).

You need a secondary address of the same network, e.g., 192.168.1.123/32 and then use that as outbound address.  People used to see this with IP based jails for example.
Comment 4 Kirill 2018-11-13 13:55:08 UTC
I mean Opkts column.
Comment 5 Yuri Pankov freebsd_committer 2018-11-13 13:55:37 UTC
(In reply to Bjoern A. Zeeb from comment #3)
Got it, thanks.  I was confused a bit by description saying Oerrs, having addresses from different subnets, combined with your reply.  And yes, now I see it (used `ping -S <alias-address>`).