Page MenuHomeFreeBSD

netstat: convert routing statistics to a sysctl
ClosedPublic

Authored by kevans on Tue, Oct 22, 3:49 AM.
Tags
None
Referenced Files
F102030230: D47231.diff
Wed, Nov 6, 5:40 PM
Unknown Object (File)
Sat, Oct 26, 10:48 AM
Unknown Object (File)
Sat, Oct 26, 10:48 AM
Unknown Object (File)
Sat, Oct 26, 10:48 AM
Unknown Object (File)
Sat, Oct 26, 10:47 AM
Unknown Object (File)
Sat, Oct 26, 10:29 AM
Unknown Object (File)
Sat, Oct 26, 1:14 AM
Unknown Object (File)
Thu, Oct 24, 3:16 AM
Subscribers

Details

Summary

Exporting the relevant pcpustat is trivial, so let's do that. Use it
for netstat operation to avoid having to dig around in mem(4) for live
kernel statistics. Based on callers of kresolve_list(), this is the
last live path using mem(4) that could be functional today.

Tested both with netstat -rs and netstat -rs -M.

Diff Detail

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

Event Timeline

zlei added inline comments.
sys/net/route.c
77

This line seems wrong to me. The following line 80~81 looks good.

sys/net/route.c
77

Whoops, forgot to clear out a stale version of the patch on the machine I send them from. Will update in a few hours- this line disappears, the two below remain.

Fix the diff; locally, I split this up into

Author: Kyle Evans <kevans@FreeBSD.org>
Date:   Mon Oct 21 22:44:59 2024 -0500

    net: route: convert routing statistics to a sysctl
    
    Exporting the relevant pcpustat is trivial, so let's do that.  We will
    use it in a near-future change in netstat to avoid having to dig around
    in mem(4) for live kernel statistics.
    
    Differential Revision:  https://reviews.freebsd.org/D47231
Author: Kyle Evans <kevans@FreeBSD.org>
Date:   Tue Oct 22 08:33:35 2024 -0500

    netstat: switch to using the sysctl-exported stats for live stats
    
    Now that we export the relevant stats via the net.route.stats sysctl,
    switch to using that to avoid having to dig around in mem(4) for live
    kernel statistics.  Based on callers of kresolve_list(), this is the
    last live path using mem(4) that could be functional today.
    
    Tested both with `netstat -rs` and `netstat -rs -M`.
    
    Differential Revision:  https://reviews.freebsd.org/D47231

I'll commit the first one then wait a week or so to commit the second.

Looks good to me.

...

I'll commit the first one then wait a week or so to commit the second.

Why wait a week for the second commit ? Have it in main so it could be get tested as early as possible.

sys/net/route.c
80

A nit here. I'd prefer no period for the description of sysctl vars.

This revision is now accepted and ready to land.Tue, Oct 22, 1:59 PM

Looks good to me.

...

I'll commit the first one then wait a week or so to commit the second.

Why wait a week for the second commit ? Have it in main so it could be get tested as early as possible.

Just to be nicer to folks wanting to bisect and use netstat -rs for a little bit; you can still -M /dev/mem until we strip setgid in another change.

Also, I can probably get away with landing a small/quick sysctl during stabweek but probably better to be conservatie about its use.

I wonder if we want to add some spare fields to struct rtstat before making it part of the user ABI?

sys/net/route.c
80

+1

I wonder if we want to add some spare fields to struct rtstat before making it part of the user ABI?

Sure; maybe drop a uint64_t[3] in at the end to round up to a cool 14? Additions are fairly far and few between.

I wonder if we want to add some spare fields to struct rtstat before making it part of the user ABI?

Sure; maybe drop a uint64_t[3] in at the end to round up to a cool 14? Additions are fairly far and few between.

I'd make it an even 16 but it's up to you. :)