Page MenuHomeFreeBSD

netstat: Add -F support for -g
ClosedPublic

Authored by bnovkov on Tue, Mar 31, 8:20 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 21, 12:27 PM
Unknown Object (File)
Fri, Apr 17, 10:21 AM
Unknown Object (File)
Wed, Apr 15, 12:04 PM
Unknown Object (File)
Wed, Apr 15, 4:13 AM
Unknown Object (File)
Tue, Apr 14, 10:39 PM
Unknown Object (File)
Tue, Apr 14, 1:12 PM
Unknown Object (File)
Sun, Apr 12, 9:08 PM
Unknown Object (File)
Sat, Apr 11, 9:56 PM

Details

Summary

This change adds the ability to examine the contents of multicast
routing tables for other FIBs without the need for executing
netstat with setfib(1).

MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Stormshield

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Tue, Mar 31, 8:56 PM
zlei added inline comments.
usr.bin/netstat/main.c
553

The document does not say the -F option also applies to -gs ( multicast routing statistics ), but the implementation does.

I'm not familiar with multicast routing. Is the multicast routing statistics per fib ?

@markj has been working to make MROUTING multi-FIB.

When I first thread this, I thought mroute6pr() would need more work since it sadly still uses KVM to access some info. But I think it's okay after all, it reads the net.inet6.ip6.mf6ctable sysctl to get an array of kernel pointers and then uses libkvm to get each entry(!). The sysctl is FIB-aware so this works ok in practice.

usr.bin/netstat/main.c
553

I recently landed a set of changes to add per-FIB multicast routing tables, yes. See e.g., 4c486fe402673c49443293cfb70ad4da61d39916.

Looks good to me.

usr.bin/netstat/main.c
553

From the current code,

#define MRTSTAT_ADD(name, val)  \
    VNET_PCPUSTAT_ADD(struct mrtstat, mrtstat, name, (val))
#define MRTSTAT_INC(name)       MRTSTAT_ADD(name, 1)

...

VNET_PCPUSTAT_DEFINE_STATIC(struct mrtstat, mrtstat);
VNET_PCPUSTAT_SYSINIT(mrtstat);
VNET_PCPUSTAT_SYSUNINIT(mrtstat);
SYSCTL_VNET_PCPUSTAT(_net_inet_ip, OID_AUTO, mrtstat, struct mrtstat,
    mrtstat, "IPv4 Multicast Forwarding Statistics (struct mrtstat, "
    "netinet/ip_mroute.h)");

I think the multicast routing is now per-fib, but the statistics is global / per-vnet.

The net.inet6.ip6.mrt6stat is not VNETified yet.

static struct mrt6stat mrt6stat;
SYSCTL_STRUCT(_net_inet6_ip6, OID_AUTO, mrt6stat, CTLFLAG_RW,
    &mrt6stat, mrt6stat,
    "Multicast Routing Statistics (struct mrt6stat, netinet6/ip6_mroute.h)");

#define MRT6STAT_INC(name)      mrt6stat.name += 1

@markj Do you have WIP to convert mrt6stat a per-vnet one ?

usr.bin/netstat/main.c
553

@markj Do you have WIP to convert mrt6stat a per-vnet one ?

Hmm, no, I missed that when VNET-ifying ip6_mroute. I can write a patch but it'll take me some time to test it.

usr.bin/netstat/main.c
553
This revision was automatically updated to reflect the committed changes.