Page MenuHomeFreeBSD

linux: store Linux Ethernet interface number in struct ifnet
Needs ReviewPublic

Authored by glebius on Thu, Dec 4, 8:29 PM.

Details

Reviewers
dchagin
melifaro
Group Reviewers
network
Summary

The old approach where we go through the list of interfaces and count them
has bugs. One obvious bug with this dynamic translation is that once an
Ethernet interface in the middle of the list goes away, all interfaces
following it would change their Linux names.

A bigger problem is the ifnet arrival and departure times. For example
linsysfs has event handler for ifnet_arrival_event, and of course it wants
to resolve the name. This accidentially works, due to a bug in
if_attach() where we call if_link_ifnet() before invoking all the event
handlers. Once the bug is fixed linsysfs won't be able to resolve the old
way. The other side is ifnet_departure_event, where there is no bug, the
eventhandlers are called after the if_unlink_ifnet(). This means old
translation won't work for departure event handlers. One example is
netlink. This change gives the Netlink a chance to emit a proper Linux
interface departure message.

However, there is another problem in Netlink, that the ifnet pointer is
lost in the Netlink translation layer. Plug this with a cookie in netlink
writer structure that can be set by the route layer and used by the Netlink
Linux translation layer. This part of the diff seems unrelated, but it is
hard to make it a separate change, as the old KPI goes away and to use the
new one we need the pointer.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 69061
Build 65944: arc lint + arc unit

Event Timeline

sys/netlink/route/iface.c
366

If we pretend that linux_cookie is abstract, then here we should call some function from linux translation layer that does it. Otherwise, let's make name and type explicit

bz added inline comments.
sys/netlink/netlink_message_writer.h
57

I would call it by its name; it's an ifp and not some random "private" data. I cannot see how it can be anything else in this code, so it's not a cookie or there's not enough Шоколад in that cookie ;-)

  • Make the netlink_writer cookie an honest const ifnet pointer.
  • Refactor some code to provide the new constness constraint.