Yann Dirson [Fri, 24 Nov 2023 11:00:52 +0000 (12:00 +0100)]
net: prepare interface cache for name changing
While name changes do not necessarily have external impact (eg.
xenstore_schema_std does not expose those names), they are necessary
on Linux to know whether an iface is a VIF. This requires
NetInterface objects in the cache to be mutable.
Yann Dirson [Tue, 21 Nov 2023 13:55:17 +0000 (14:55 +0100)]
net: separate add/rm of interface and add/rm of MAC address
The current code would do nothing on interface removal, as we only
emit a `RmMac` event, with which xenstore_schema_std does nothing (we did
not add them in the first place).
An explicit `RmIface` allows for the removal of the full iface tree in
Xenstore, since there is no need to expose a mostly-empty tree.
Yann Dirson [Wed, 22 Nov 2023 16:11:57 +0000 (17:11 +0100)]
Drop unix_helper
We finally don't have a need for separately querying for an interface name
from its index, since we don't need to fetch this information every time a
packet arrives, netlink already gives us everything we need.
Yann Dirson [Thu, 23 Nov 2023 17:27:41 +0000 (18:27 +0100)]
pnet: keep a note on InterfaceInfo::name
Storage of interface name in pnet::InterfaceInfo would seem redundant
now, but we still need it stored temporarily, and this still looks
like the best place to do so.
Yann Dirson [Thu, 30 Nov 2023 16:45:00 +0000 (17:45 +0100)]
net: keep a cache of network interfaces
Collects in a central place a map of iface indices, their names, and their
toolstack interface if any.
Finally replaces add_vif_info() calls with get_toolstack_interface()
called once to populate the cache.
Finally the RmIp events can be applied when an interface disappears, which
essentially fixes #13.
Though this makes a new problem apparent: recreating the VIF sometimes
does not get caught on Linux, when the iface is created as eth0 and
then renamed by udev as enX0 in a subsequent Newlink message: since we
are now only attempting to identify the toolkit-interface once, if
when we try to access the /sys node for eth0 the renaming already
occured the toolkit-interface is frozen as None.
Yann Dirson [Thu, 30 Nov 2023 16:42:26 +0000 (17:42 +0100)]
netlink: refactor private funcs as methods
While there is no use for `self` today in there, we're going to need to
refer to an iface_cache in next commits, which gets much simplified if we
never have to borrow across method boundaries.
Yann Dirson [Wed, 22 Nov 2023 11:42:27 +0000 (12:42 +0100)]
net: rework toolstack-interface detection
Detection of toolstack-interface (and not only VIF) does not have to
be done on every NetEvent, but only once. To prepare for this,
introduce a new functional API that can be used instead of mutating a
NetEvent - this does not change call sites, which still make use of
the legacy API.
Yann Dirson [Mon, 20 Nov 2023 14:29:47 +0000 (15:29 +0100)]
netlink: use name from NLA in Link events
We were always calling `if_indextoname()` to get the interface name when
receiving a New/DelLink message. Just use the data we already received
instead.
On NewLink messages we just received the interface name, so we don't need
to make another query to get the information; on DelLink the sycall cannot
even give us this information any more.
Note at this point we still use "" to denote the lack of a name - it
seems unlikely to happen there anyway, and will be made cleaner next.
Yann Dirson [Tue, 21 Nov 2023 09:11:29 +0000 (10:11 +0100)]
xenstore_schema_std: index the iface address cache with OS index
Iface name is not always part of a Netlink message, as opposed to the
OS index of the interface, and looking up the name following reception of
an interface removal notification just does not work.
All supported and prospective platforms seem to have a concept of
interface OS index, so this should cause no problem and be more efficient.
Yann Dirson [Mon, 20 Nov 2023 15:26:13 +0000 (16:26 +0100)]
pnet: index NetworkView by interface index, not name
Current structure made us fill NetInterface with a dummy interface
number, and we want to use interface number in xenstore_schema_std to
fix #13.
Iface name becomes part of the associated data, bundle it into
InterfaceInfo for now (it will get redundant with introduction of a more
global interface cache).
Yann Dirson [Fri, 1 Dec 2023 09:57:38 +0000 (10:57 +0100)]
ci: make sure collapsed-section footer is always printed
In case of error the lack of footer would fool gitlab log display into
thinking error summary from git-rebase was part of the collapsible section,
which is confusing to the reader.
Yann Dirson [Fri, 24 Nov 2023 11:03:04 +0000 (12:03 +0100)]
ci: use stderr not stdout in build wrapper
The "Executing ..." lines from gitlab-ci occasionally got captured before
the footer of previous collapsed section, so hidden when said section is
collapsed.
Yann Dirson [Tue, 21 Nov 2023 12:31:14 +0000 (13:31 +0100)]
netlink: remove redundant traces
* separately logging header+nlas just duplicates with less info the
full message log
* the full message itself is already available from netlink crate, as now
described in the README
Yann Dirson [Thu, 2 Nov 2023 15:04:31 +0000 (16:04 +0100)]
Fix error messages not getting formatted
Errors that never happened, bugs that did not get caught, including
messages that did not get updated accross refactorings, and types not
implementing std::fmt::Debug.
Yann Dirson [Tue, 31 Oct 2023 17:17:13 +0000 (18:17 +0100)]
Propagate errors from get_available_kb()
It took me some time to identify a proper syntax to propagate the
error from a match branch, now we can be more specific about what we
ignore. Now log a warning once in the "Unsupported" case (when
fetching the total memory), and let other memory-collector errors
cause a fatal error.