Some Linux programs require it to exist before installation.
Details
- Reviewers
melifaro - Group Reviewers
Linux Emulation - Commits
- rGdab4775da308: linprocfs: Add net/route.
rG4c9db9566e67: linprocfs: Add net/route.
Load the new linprocfs module, mount it and cat {mountpoint}/proc/net/route.
The content should be very similar to Linux proc/net/route.
I've tested this module in both 14.0-CURRENT and 13.1-RELEASE with success.
Verified with GitHub pre-commit checks here: https://github.com/freebsd/freebsd-src/pull/616
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 47883 Build 44770: arc lint + arc unit
Event Timeline
sys/compat/linprocfs/linprocfs.c | ||
---|---|---|
1608 | btw, Is that enough? rtsock messages can be up to 64k |
Ideally, I'd like to only malloc only the amount of memory needed for the sysctl results. This works in user sysctl by passing a NULL to oldp but the kernel_sysctl function doesn't appear to work the same way.
sys/compat/linprocfs/linprocfs.c | ||
---|---|---|
1614 | I’d rather use ‘rib_walk(fibnum, af, linux_route_print)’ public KPI instead of using it indirectly via sysctl. |
sys/compat/linprocfs/linprocfs.c | ||
---|---|---|
1614 | Ah, thank you. rib_walk was my first inclination but I wasn't sure if it'd return the information I needed. netstat(1) uses sysctl and thus provided an example on how to decode the results. |
sys/compat/linprocfs/linprocfs.c | ||
---|---|---|
1614 | It does. You'll get 'struct rtentry' in the iterator, which allows extracting prefix data via |
Thanks again for the reviews. The rib_walk function is indeed much better than a kernel sysctl! Not sure if Linux outputs multipath routes in proc/net/route, I'll take a look at its source.
Thank you for providing the updated version w/ rib_walk!
Looks good to me, please see some minor comments inline. Once addressed, it should be good to land.
sys/compat/linprocfs/linprocfs.c | ||
---|---|---|
94 | You shouldn’t include it, that’s a private header for the routing code. | |
1557 | Probably worth using ‘struct in_addr’ here | |
1575 | Re multipath: to be safe probably worth using nhop_select(raw_nhop, 0) to ensure it doesnt crash with multipath routes | |
1578 | ||
1587 | I’d suggest defining 0xF explicitely as a flag combination | |
1588 | You shouldn’t access rtentry fields directly, use rt_get_weight(). | |
1605 | Worth using c11 initialisers: | |
1620 | You don’t need to hold ifnet lock, but you need to be in network epoch (NET_EPOCH_ENTER()) |
sys/compat/linprocfs/linprocfs.c | ||
---|---|---|
1620 | Without the ifnet lock, linux_ifname() panics due to IFNET_RLOCK_ASSERT() panic: Lock (sx) ifnet_sx not locked |
sys/compat/linprocfs/linprocfs.c | ||
---|---|---|
1557 | No good reason. :) |