Commit Graph

485 Commits

Author SHA1 Message Date
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
mrg 5f8222cdb9 query the window size and use it instead of assuming 24 lines.
now the header isn't re-printed a lot of times in tall windows.
2015-09-20 00:30:04 +00:00
christos 8d365aaee5 revert previous, will fix differently. 2015-07-28 19:46:42 +00:00
christos 9495115b2a fix build (stdbool lossage) 2015-07-28 19:32:07 +00:00
christos ff53269704 fix some error handling. 2015-06-16 22:54:10 +00:00
joerg fc207b9190 Format-string related warnings work fine now with both GCC 4.8 and
Clang.
2015-06-06 13:48:37 +00:00
joerg d88f290a56 Drop assignment from uninitialized and otherwise unused variable. 2015-06-06 13:08:31 +00:00
manu cbae0e6269 Make sure netstat builds with -DSMALL
src/usr.bin/netstat relies on code from src/sbin/route. WHen building
with -DSMALL, some functions such as mpls_ntoa() or p_rtrmx() are not
built in src/sbin/route. We therefore have to make sure they are not
used in src/usr.bin/netstat.
2015-05-25 03:56:20 +00:00
ozaki-r 6011d36bd6 Fix rump.{netstat,route} shows host's interface names in link local addresses
Interface names of IPv6 link local addresses are resolved
by getnameinfo(3). So we need to rump-ify it as well as
if_indextoname and getifaddrs.
2015-05-15 06:58:59 +00:00
roy a37502b2b6 Add RTF_BROADCAST to mark routes used for the broadcast address when
they are created on the fly. This makes it clear what the route is for
and allows an optimisation in ip_output() by avoiding a call to
in_broadcast() because most of the time we do talk to a host.
It also avoids a needless allocation for the storage of llinfo_arp and
thus vanishes from arp(8) - it showed as incomplete anyway so this
is a nice side effect.

Guard against this and routes marked with RTF_BLACKHOLE in
ip_fastforward().
While here, guard against routes marked with RTF_BLACKHOLE in
ip6_fastforward().
RTF_BROADCAST is IPv4 only, so don't bother checking that here.
2015-03-23 18:33:17 +00:00
roy 81601736f6 Document RTF_LOCAL 2015-02-26 09:58:12 +00:00
christos 3934378a65 Allocate the right size for pcb blocks.
XXX: pullup-7!
2015-02-08 15:09:45 +00:00
christos b0698f50d1 print the timer flags. 2015-02-07 19:36:06 +00:00
christos f8128537a0 adjust to the netname4 prototype. 2015-01-07 22:43:01 +00:00
christos df51b41a7f PR/47704: Takahiro HAYASHI: Fix -L flag 2014-11-12 03:34:59 +00:00
christos e2c137d286 fix A,v,T with route display. 2014-11-07 12:42:27 +00:00
christos 34cb342199 use the common code from route.c 2014-11-06 21:30:09 +00:00
wiz 9ff8e27788 Give flag argument in description. Add two articles. 2014-10-11 09:23:32 +00:00
enami 2858bdfe72 - Explicitly describe that kvm(3) is used when -M/-N option is used since
nowadays sysctl(3) is the default information retrieval method.
- Fix description about default value for -N; it is no longer a single value
  these days, so just say see kvm_openfiles(3) rahter than repeating
  several lines description here.
2014-10-11 06:25:32 +00:00
enami 7bed5ae0f8 As described in kvm_openfiles(3), default core file is not /dev/kmem
but /dev/mem.  Actually, passing /dev/kmem to -M doesn't work.
2014-10-09 23:52:47 +00:00
enami e36fe94f89 Fix a bug introduced in rev. 1.62; it fails to negate (a && b). 2014-10-09 23:45:47 +00:00
dholland 0858ed9253 Fix snprintf usage; from Henning Petersen in PR 47976. 2014-07-27 04:26:23 +00:00
rmind 2286cc983b netstat(1) and ifmcstat(8): ifnet was renamed to ifnet_list, PR/48850. 2014-05-30 01:44:21 +00:00
christos 12014f31d7 use the same for the route metrics part, both in the sysctl and kmem paths.
From Takahiro HAYASHI
2014-04-28 15:41:15 +00:00
christos a2dd64f9b4 The sysctl code does not support verbose route printing that prints the
internal route statistics. Restore the old kmem route printing code that
was not just used for post-mortem displays. Reported by kardel@, test by
netstat -nrvf inet
2014-04-24 14:56:29 +00:00
christos 7cdbcec7f5 un __P 2014-04-24 14:54:51 +00:00
christos 30107bf0d8 Update for new pcb tailq's.
While here fix ipv6 pcb printing by making tcp6_dump with tcp.
XXX: Merge the inet and the inet6 code. It is silly to need to specify
-p tcp6 to print a tcp6 pcb, we already know what it is.
2013-11-23 22:01:12 +00:00
christos 04908d82dd use correct function and symbolic constants 2013-10-19 15:56:05 +00:00
christos 35be7e66a7 use new scopeid functions 2013-10-19 00:28:38 +00:00