Page MenuHomeFreeBSD

Reduce the vnet_set module size of ip_mroute to allow loading as a module.
ClosedPublic

Authored by bz on Nov 19 2019, 1:53 PM.

Details

Summary

With VIMAGE kernels modules get special treatment as they need
to also keep the original values and make copies for each instance.
For that a few pages of vnet modspace are provided and the
kernel-linker and the VNET framework know how to deal with things.
When the modspace is (almost) full, other modules which would
overflow the modspace cannot be loaded and kldload will fail.

ip_mroute uses a lot of variable space, mostly be four big arrays:
set_vnet 0000000000000510 vnet_entry_multicast_register_if
set_vnet 0000000000000700 vnet_entry_viftable
set_vnet 0000000000002000 vnet_entry_bw_meter_timers
set_vnet 0000000000002800 vnet_entry_bw_upcalls

Dynamically malloc the three big ones for each instance we need
and free them again on vnet teardown (the 4th is an ifnet).
That way they only need module space for a single pointer and
allow a lot more modules using virtualized variables to be loaded
on a VNET kernel.

PR: 206583

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

bz created this revision.Nov 19 2019, 1:53 PM
kp added a subscriber: kp.Nov 19 2019, 2:02 PM
kp added inline comments.
sys/netinet/ip_mroute.c
189 ↗(On Diff #64571)

Doesn't this change the sizeof() to be sizeof(struct vif) where it used to be sizeof(struct vif) * MAXVIFS?

bz updated this revision to Diff 64572.Nov 19 2019, 2:13 PM

Address kp's catch of the SYSCTL_OPAQUE size.

bz marked an inline comment as done.Nov 19 2019, 2:14 PM
bz added inline comments.
sys/netinet/ip_mroute.c
189 ↗(On Diff #64571)

Good catch. Fixed.

Sorry, I won’t be able to help with testing this, as I no longer have the multicast routing setup that I previously had when I reported this bug. Thanks for following up on it though!

hselasky accepted this revision.Nov 19 2019, 2:24 PM

Looks good to me.

Technically you could put all the fixed-size fields into a single structure and allocate all at once.

This revision is now accepted and ready to land.Nov 19 2019, 2:24 PM
kp accepted this revision.Nov 19 2019, 2:37 PM
This revision was automatically updated to reflect the committed changes.
bz marked an inline comment as done.