From ef209fd4f68fb90f85f89612ebbf9c3e8843f33c Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Tue, 19 Nov 2013 20:26:02 +0000 Subject: fipvlan: start VLAN interface from netlink handler Instead of starting the VLAN interface after the call to vlan_create() we should rather start it after the netlink message has been received. Otherwise we have a race window as we might try to start a network interface which isn't present yet. Signed-off-by: Hannes Reinecke Signed-off-by: Robert Love --- fipvlan.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fipvlan.c b/fipvlan.c index 4559e07..148d823 100644 --- a/fipvlan.c +++ b/fipvlan.c @@ -416,11 +416,16 @@ static void rtnl_recv_newlink(struct nlmsghdr *nh) parse_vlaninfo(vlan, linkinfo[IFLA_INFO_DATA]); iff->vid = *(int *)RTA_DATA(vlan[IFLA_VLAN_ID]); real_dev = find_vlan_real_dev(iff); - if (real_dev) - TAILQ_INSERT_TAIL(&real_dev->vlans, - iff, list_node); - else + if (!real_dev) { free(iff); + return; + } + TAILQ_INSERT_TAIL(&real_dev->vlans, iff, list_node); + if (!iff->running) { + FIP_LOG_DBG("vlan if %d not running, " + "starting", iff->ifindex); + rtnl_set_iff_up(iff->ifindex, NULL); + } return; } /* ignore bonding interfaces */ @@ -581,7 +586,6 @@ create_missing_vlans_list(struct fcf_list_head *list, const char *label) vlan_name, strerror(-rc)); else printf("Created VLAN device %s\n", vlan_name); - rtnl_set_iff_up(0, vlan_name); } printf("\n"); } -- 1.8.1.4