aboutgitcodebugslistschat
path: root/netlink.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-08-03 17:19:40 +1000
committerStefano Brivio <sbrivio@redhat.com>2023-08-04 01:18:14 +0200
commite96182e9c28197a8f868df5d2a9975bc51a090e9 (patch)
treea32642485b62dcf69846504b5fba7b9d95e7b368 /netlink.h
parent0cf7bf31f6ef6aa301542445208c973e620bb8cd (diff)
downloadpasst-e96182e9c28197a8f868df5d2a9975bc51a090e9.tar
passt-e96182e9c28197a8f868df5d2a9975bc51a090e9.tar.gz
passt-e96182e9c28197a8f868df5d2a9975bc51a090e9.tar.bz2
passt-e96182e9c28197a8f868df5d2a9975bc51a090e9.tar.lz
passt-e96182e9c28197a8f868df5d2a9975bc51a090e9.tar.xz
passt-e96182e9c28197a8f868df5d2a9975bc51a090e9.tar.zst
passt-e96182e9c28197a8f868df5d2a9975bc51a090e9.zip
netlink: Split up functionality of nl_link()
nl_link() performs a number of functions: it can bring links up, set MAC address and MTU and also retrieve the existing MAC. This makes for a small number of lines of code, but high conceptual complexity: it's quite hard to follow what's going on both in nl_link() itself and it's also not very obvious which function its callers are intending to use. Clarify this, by splitting nl_link() into nl_link_up(), nl_link_set_mac(), and nl_link_get_mac(). The first brings up a link, optionally setting the MTU, the others get or set the MAC address. This fixes an arguable bug in pasta_ns_conf(): it looks as though that was intended to retrieve the guest MAC whether or not c->pasta_conf_ns is set. However, it only actually does so in the !c->pasta_conf_ns case: the fact that we set up==1 means we would only ever set, never get, the MAC in the nl_link() call in the other path. We get away with this because the MAC will quickly be discovered once we receive packets on the tap interface. Still, it's neater to always get the MAC address here. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'netlink.h')
-rw-r--r--netlink.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/netlink.h b/netlink.h
index cd0e666..980ac44 100644
--- a/netlink.h
+++ b/netlink.h
@@ -18,6 +18,8 @@ void nl_route(enum nl_op op, unsigned int ifi, unsigned int ifi_ns,
sa_family_t af, void *gw);
void nl_addr(enum nl_op op, unsigned int ifi, unsigned int ifi_ns,
sa_family_t af, void *addr, int *prefix_len, void *addr_l);
-void nl_link(int ns, unsigned int ifi, void *mac, int up, int mtu);
+void nl_link_get_mac(int ns, unsigned int ifi, void *mac);
+void nl_link_set_mac(int ns, unsigned int ifi, void *mac);
+void nl_link_up(int ns, unsigned int ifi, int mtu);
#endif /* NETLINK_H */