Page MenuHomeFreeBSD

netstat: Add -F support for -g
AcceptedPublic

Authored by bnovkov on Tue, Mar 31, 8:20 PM.

Details

Reviewers
glebius
markj
zlei
Group Reviewers
Klara
network
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 71883
Build 68766: arc lint + arc unit

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
555

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
555

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
555

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
555

@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.