Patchwork [Open-FCoE,02/14] fipvlan: start VLAN interface from netlink handler

login
register
mail settings
Submitter Hannes Reinecke
Date Nov. 19, 2013, 12:26 p.m.
Message ID <1384863974-27096-3-git-send-email-hare@suse.de>
Download mbox | patch
Permalink /patch/116/
State Accepted
Headers show

Comments

Hannes Reinecke - Nov. 19, 2013, 12:26 p.m.
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 <hare@suse.de>
---
 fipvlan.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

Patch

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");
 }