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 <[email protected]>
---
 fipvlan.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/fipvlan.c b/fipvlan.c
index 3c786fe..910f24b 100644
--- a/fipvlan.c
+++ b/fipvlan.c
@@ -394,11 +394,16 @@ 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 */
@@ -544,7 +549,6 @@ void create_missing_vlans()
                               vlan_name, strerror(-rc));
                else
                        printf("Created VLAN device %s\n", vlan_name);
-               rtnl_set_iff_up(0, vlan_name);
        }
        printf("\n");
 }
-- 
1.7.10.4

_______________________________________________
fcoe-devel mailing list
[email protected]
http://lists.open-fcoe.org/mailman/listinfo/fcoe-devel

Reply via email to