Page MenuHomeFreeBSD

netstat: convert routing statistics to a sysctl
ClosedPublic

Authored by kevans on Oct 22 2024, 3:49 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 9, 2:51 AM
Unknown Object (File)
Wed, Dec 4, 1:47 AM
Unknown Object (File)
Sat, Nov 30, 2:34 PM
Unknown Object (File)
Nov 9 2024, 11:05 PM
Unknown Object (File)
Nov 9 2024, 3:20 AM
Unknown Object (File)
Nov 9 2024, 2:22 AM
Unknown Object (File)
Nov 8 2024, 11:49 PM
Unknown Object (File)
Nov 7 2024, 8:59 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 Skipped
Unit
Tests Skipped
Build Status
Buildable 60144
Build 57028: arc lint + arc unit

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
86

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

This revision is now accepted and ready to land.Oct 22 2024, 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
86

+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. :)