Make API around if_mtu, if_capabilities, if_capenable and if_hwassist
more strict. Disallow direct access to these fields at all.
o if_mtu
- Stack guarantees that any MTU change attempt is reported via SIOCSIFMTU, so drivers can store it in softc and don't need go to ifnet layer.
- Stack does the equal MTU check, drivers don't need to copy & paste it.
- If driver doesn't report error, then stack updates MTU.
o if_capabilities
- Drivers should init them in ifat_capabilities at if_attach(), and are not allowed to modify later. Stack neither.
o if_capenable
- Stack guarantees that any capenable change is reported via SIOCSIFCAP. Stack supplies current capabilities (in case if driver doesn't store them) in ifr_curcap, and requested capabilities in ifr_reqcap.
- Stack does the equal check, as well as that requested capenable are subset of interface capabilities. Drivers don't need to cut-n-paste that.
- Stack enforces IFCAP_VLAN_HWTAGGING in case of IFCAP_VLAN_HWTSO.
- Drivers may alter ifr_reqcap, as in some edge cases they could be actually not capable of running capabilities announced at if_attach.
- Drivers must either return error or, return 0 and in the latter case must initialize ifr_hwassist value in the ifreq.
o There are some edge cases when a driver may want to change its capenable
as result of MTU change. Or vice versa? In this case, the driver should call if_drvioctl() upon itself.
Sponsored by: Nginx, Inc.