Commit Graph

513 Commits

Author SHA1 Message Date
bad 83f02db3da mention ifmcstat(8) in SEE ALSO. 2022-01-07 10:17:39 +00:00
nia 74f6d0d926 netstat(1): convert malloc(x * y) and realloc(x * y) to reallocarr 2021-10-30 11:23:07 +00:00
rillig 133e932a29 usr.bin: remove unnecessary lint comment CONSTCOND
Since 2021-01-31, lint no longer warns about 'do ... while (0)'.

No functional change.
2021-09-10 21:52:17 +00:00
simonb 4e642ca22c Remove Network ATM soft intr queue reporting, we don't have that in the
kernel anymore.
2021-03-10 00:32:15 +00:00
simonb ec07c80492 Don't show any of the completely and utterly undocumented VTW info if
the feature isn't enabled (by checking net.inet.tcp.vtw.enable).
2021-03-02 01:02:12 +00:00
ozaki-r 1d675d5a3a netstat: strengthen against kernel changes
netstat uses sysctlbyname to get counter data from the kernel.
sysctlbyname fails with ENOMEM if actual counter data in the kernel is
larger than a passed buffer.  netstat just skips showing counters of a
category if sysctlbyname fails, so if we added new counters of the
category to the kernel, nestat shows nothing for the category.

Fortunately sysctlbyname fills data as much as possible even if a passed
buffer is short.  So we can allow netstat to show the filled data anyway
if sysctlbyname fails with ENOMEM.

Note that this backcompat mechanism works only if new counters are
appended, and doesn't work if new counters are inserted into the middle
or counters are moved.
2020-08-28 07:23:48 +00:00
ozaki-r fb54873b52 netstat: support new packet counters 2020-08-28 06:34:17 +00:00
knakahara e3a3fcce9b add missing {IP,IP6}_STAT_NOIPSEC to netstat. 2020-08-06 07:38:54 +00:00
gutteridge 5c46104e5e netstat.1: add various xrefs present in the body to "See Also" 2020-07-21 04:58:43 +00:00
yamaguchi b5ec3f8464 Update sysctl key in netstat(1) 2020-05-27 05:59:16 +00:00
joerg 364664a7a3 Avoid common symbol definitions. 2020-04-23 00:24:50 +00:00
joerg f908f46288 sockb is only used locally, so move it into the function 2020-04-23 00:24:16 +00:00
joerg 4f6512cdad Avoid global scope for variables only used locally 2020-04-23 00:23:31 +00:00
christos 92aab12c02 remove unused 2020-04-03 16:41:59 +00:00
martin af2ed9cf6e Make route and netstat share the same struct progops (and initialization
code)
2020-04-03 16:20:51 +00:00
thorpej af11cf9023 Update for per-cpu interface statistics. 2020-02-02 03:41:12 +00:00
mrg de11d87641 introduce some common variables for use in GCC warning disables:
GCC_NO_FORMAT_TRUNCATION    -Wno-format-truncation (GCC 7/8)
GCC_NO_STRINGOP_TRUNCATION  -Wno-stringop-truncation (GCC 8)
GCC_NO_STRINGOP_OVERFLOW    -Wno-stringop-overflow (GCC 8)
GCC_NO_CAST_FUNCTION_TYPE   -Wno-cast-function-type (GCC 8)

use these to turn off warnings for most GCC-8 complaints.  many
of these are false positives, most of the real bugs are already
commited, or are yet to come.


we plan to introduce versions of (some?) of these that use the
"-Wno-error=" form, which still displays the warnings but does
not make it an error, and all of the above will be re-considered
as either being "fix me" (warning still displayed) or "warning
is wrong."
2019-10-13 07:28:04 +00:00
mrg 4df8bc966e sprintf() -> snprintf(), and adjust a buffer size to avoid any
potential for overflow.
2019-10-06 00:27:50 +00:00
kamil fc2fae23cf netstat: Add indirection of symbols to remove clash with sanitizers
Add indirection and symbol renaming under MKSANITIZER for the linked in
version of sysctlbyname, sysctlgetmibinfo and sysctlnametomib.
2019-08-18 04:14:40 +00:00
martin 787f237e5b Limit maximum owner name to appease gcc 2019-06-25 14:52:55 +00:00
ozaki-r e28ae3abe7 Show the number of packets dropped by pfil 2019-05-13 07:48:42 +00:00
msaitoh 24a510d5b0 Print iqdrops, too. This change also fixes a bug that Odrops prints
iqdrops when kvm read failed.
2018-07-11 07:46:20 +00:00
msaitoh 90fcd8faa4 Fix a bug that BPF_D_OUT isn't printed correctly. 2018-06-26 09:50:42 +00:00
msaitoh 3cd62456f9 Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

 This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
2018-06-26 06:47:57 +00:00
maxv 5d73803e75 Remove now unused tcpip.h includes. Some were already unused before. 2018-05-03 07:13:48 +00:00
kre c56c6100f2 Add names of a few more ICMPv6 messages, from RFC6275 (Mobile IPv6)
and RFC4286 (Multicast Router Discovery.) and as shown in the IANA
parameters page available at:
  https://www.ietf.org/assignments/icmpv6-parameters/icmpv6-parameters.txt

Also make the array be explicitly 256 entries long, one for each possible
code, which will detect attempts to insert names without deleting the
place holder (and mean a good solid NULL de-ref if too many place holders
are deleted, rather than just random results.)
2017-12-19 17:05:15 +00:00
christos e68fbebd32 use librumpres 2017-10-10 19:30:41 +00:00
ozaki-r 5bd67db98a Tweak outputs of netstat -s for IPsec
- Get rid of "Fast"
- Use ipsec and ipsec6 for titles to clarify protocol
- Indent outputs of sub protocols

Original outputs were organized like this:

(Fast) IPsec:
IPsec ah:
IPsec esp:
IPsec ipip:
IPsec ipcomp:
(Fast) IPsec:
IPsec ah:
IPsec esp:
IPsec ipip:
IPsec ipcomp:

New outputs are organized like this:

ipsec:
	ah:
	esp:
	ipip:
	ipcomp:
ipsec6:
	ah:
	esp:
	ipip:
	ipcomp:
2017-06-29 07:15:27 +00:00
christos 62446aa148 Redo the statistics through an indirection array and put the definitions
of the arrays in pfkeyv2.h so that they are next to the index definitions.
Remove "bogus" comment about compressing the statistics which is now fixed.
2017-04-13 16:38:31 +00:00
ozaki-r 00a9cf741d Remove mkludge stuffs
For unknown reasons, IPv6 multicast addresses are linked to a first
IPv6 address assigned to an interface. Due to the design, when removing
a first address having multicast addresses, we need to save them to
somewhere and later restore them once a new IPv6 address is activated.
mkludge stuffs support the operations.

This change links multicast addresses to an interface directly and
throws the kludge away.

Note that as usual some obsolete member variables remain for kvm(3)
users. And also sysctl net.inet6.multicast_kludge remains to avoid
breaking old ifmcstat.

TODO: currently ifnet has a list of in6_multi but obviously the list
should be protocol independent. Provide a common structure (if_multi
or something) to handle in6_multi and in_multi together as well as
ifaddr does for in_ifaddr and in6_ifaddr.
2017-02-23 07:57:09 +00:00
mrg 1e71d48020 re-do the previous to avoid malloc/free on the same size every iteration.
with this, or the previous, 'netstat -b 1' no longer leaks memory in
-current (or any older release using sysctl for this.)
2017-01-22 04:52:04 +00:00
christos e5282544de sprinkle free 2017-01-22 04:26:31 +00:00
christos a91ed3e0f7 use _KMEMUSER for <sys/file.h> 2017-01-13 04:22:51 +00:00
ozaki-r 5787b995ac Fix showing multicast addresses of !IFF_UP interfaces
netstat appends '*' to the name of an interface without IFF_UP, so
if_nametoindex which is used in mc_print fails. mc_print needs just
an interface index so pass it instead of a tweaked interface name.
2017-01-11 01:25:05 +00:00
mrg 0537635d0c for 64 bit mips platforms where we built userland largely as n32 by
default, build a handful of tools as n64 so they work properly.

unfortunately, they're also static as dynamic n64 has a problem.

of these tools pstat is probably the lowest hanging fruit to convert
to sysctl.  systat would be close were it not for the netstat screen,
which includes netstat itself.

the rest are difficult to perhaps foolish.


the upside is that netstat, pmap and fstat all work properly now.
2016-12-23 10:19:57 +00:00
mrg 20c21f9f52 in getpcblist_sysctl() if sysctlnametomib() fails, return NULL and
set *len = 0, rather than bailing.  now "netstat" doesn't give up
early on kernels without INET6.
2016-12-23 06:22:00 +00:00
mlelstv d19ac03c1e Print previously missing fields from a TCP6 PCB. 2016-12-17 09:12:22 +00:00
dholland 950f040fa2 Fix "sidewaysintpr", the thing that prints interface statistics in a
loop, to use signals properly. There are two copies of this code; one
uses kvm and the other uses sysctls. One copy had been updated to use
sigset_t and sigsuspend; the other was using vintage sigpause(). Sync
up the code so both use sigpause. Also, use sig_atomic_t, and block
SIGALRM when not waiting for it to avoid a small and unlikely but real
race.

Since the non-modernized copy of the code *had* for some been
modernized to use setitimer instead of just alarm(), propagate that
change to the other copy.

These copies could share more logic than they do.
2016-11-24 00:05:13 +00:00
christos b305547c0c more XXX removal. 2016-07-14 20:38:20 +00:00
christos 1584c6d3ed XXX: removal 2016-07-14 20:34:36 +00:00
christos fb3d963d14 remove soft interrupt queues that don't exist anymore. 2016-07-14 20:13:10 +00:00
christos bb9aed0669 remove __P 2016-07-14 19:39:41 +00:00
christos cfa835e475 dedup 2016-07-14 18:58:26 +00:00
christos 21c3ca2d5c use sysctl to print multicast addresses 2016-07-14 18:19:11 +00:00
christos 143eb5c5cf fix sysctl based interface printing, and annotate where we should add the
missing multicast printing code.
2016-07-13 22:01:12 +00:00
christos 543b506e7c Use sysctl for interface printing (-i), leave on for multicast address printing
(-ia) and comment in the code where this is missing?
XXX: should that be an ioctl or sysctl? provide getifmultiaddrs() via the
routing socket? I guess since this is just for netstat a simple sysctl or
ioctl would suffice. I lean towards sysctl.
2016-07-13 21:57:01 +00:00
ozaki-r 278a4a7caa Remove duplicate routing flag list
We alreay have it in route(8) and shouldn't have another one.
(Actually the removed list is forgot to be updated.)
2016-05-12 03:44:11 +00:00
ozaki-r 09973b35ac Separate nexthop caches from the routing table
By this change, nexthop caches (IP-MAC address pair) are not stored
in the routing table anymore. Instead nexthop caches are stored in
each network interface; we already have lltable/llentry data structure
for this purpose. This change also obsoletes the concept of cloning/cloned
routes. Cloned routes no longer exist while cloning routes still exist
with renamed to connected routes.

Noticeable changes are:
- Nexthop caches aren't listed in route show/netstat -r
  - sysctl(NET_RT_DUMP) doesn't return them
  - If RTF_LLDATA is specified, it returns nexthop caches
- Several definitions of routing flags and messages are removed
  - RTF_CLONING, RTF_XRESOLVE, RTF_LLINFO, RTF_CLONED and RTM_RESOLVE
- RTF_CONNECTED is added
  - It has the same value of RTF_CLONING for backward compatibility
- route's -xresolve, -[no]cloned and -llinfo options are removed
  - -[no]cloning remains because it seems there are users
  - -[no]connected is introduced and recommended
    to be used instead of -[no]cloning
- route show/netstat -r drops some flags
  - 'L' and 'c' are not seen anymore
  - 'C' now indicates a connected route
- Gateway value of a route of an interface address is now not
  a L2 address but "link#N" like a connected (cloning) route
- Proxy ARP: "arp -s ... pub" doesn't create a route

You can know details of behavior changes by seeing diffs under tests/.

Proposed on tech-net and tech-kern:
  http://mail-index.netbsd.org/tech-net/2016/03/11/msg005701.html
2016-04-04 07:37:07 +00:00
christos bad095e351 PR/50872: David Binderman: Use logical and instead of arithmetic 2016-02-29 18:21:15 +00:00
christos bfc1db599b PR/50873: David Binderman: use logical or instead of arithmetic 2016-02-29 18:19:46 +00:00