Skip to content

Commit 5d74f1b

Browse files
rjarrychristophefontaine
authored andcommitted
ctlplane: only mirror valid MTU or MAC values
When creating an interface, its MTU or MAC may still be undetermined because it hasn't finished its initialization. For instance, when creating a new port, since commit 05f811a ("iface: make sure to deallocate resources on init failure"), GR_EVENT_IFACE_ADD is triggered *before* calling iface_set_mtu() which resolves the mtu field value. Since the creation of the control plane linux tap interface is triggered by GR_EVENT_IFACE_ADD, cp_update calls netlink_link_set_mtu(ifindex, 0) which causes this error log: ERR: GROUT: cp_update: netlink_link_set_mtu: Invalid argument Make sure to only mirror the MTU and MAC address to linux when we have determined values. Fixes: 05f811a ("iface: make sure to deallocate resources on init failure") Signed-off-by: Robin Jarry <rjarry@redhat.com> Reviewed-by: Christophe Fontaine <cfontain@redhat.com>
1 parent 2aa2ad6 commit 5d74f1b

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

modules/infra/control/ctlplane.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,23 @@ static void cp_update(struct iface *iface) {
388388
strerror(errno));
389389
}
390390

391-
if (netlink_link_set_mtu(iface->cp_id, iface->mtu) < 0)
392-
LOG(ERR, "netlink_link_set_mtu: %s", strerror(errno));
391+
if (iface->mtu != 0) {
392+
if (netlink_link_set_mtu(iface->cp_id, iface->mtu) < 0)
393+
LOG(ERR,
394+
"netlink_link_set_mtu(%s, %u): %s",
395+
iface->name,
396+
iface->mtu,
397+
strerror(errno));
398+
}
393399

394-
iface_get_eth_addr(iface, &mac);
395-
if (netlink_link_set_mac(iface->cp_id, &mac) < 0)
396-
LOG(ERR, "netlink_link_set_mac: %s", strerror(errno));
400+
if (iface_get_eth_addr(iface, &mac) == 0) {
401+
if (netlink_link_set_mac(iface->cp_id, &mac) < 0)
402+
LOG(ERR,
403+
"netlink_link_set_mac(%s, " ETH_F "): %s",
404+
iface->name,
405+
&mac,
406+
strerror(errno));
407+
}
397408
}
398409

399410
static void iface_event(uint32_t event, const void *obj) {

0 commit comments

Comments
 (0)