diff mbox

[2/2] test: verify correct vlan operation in multi-bss multi-vlan case

Message ID 4e624bcbcd827e14e284ee4673ee8e98@fami-braun.de
State Superseded
Headers show

Commit Message

michael-dev May 6, 2015, 11:24 a.m. UTC
Am 03.05.2015 20:37, schrieb Jouni Malinen:
> Any idea what would be causing this? I already had to add 
> CONFIG_DUMMY=y
> to get even this far, but that did not seem to be enough to make the
> test case work for me.

you'll need CONFIG_VLAN_8021Q support in the kernel.

In addition to this, adding the link could fail if there is another vlan 
interface around that has the same vid (1) and parent (dummy0) assigned 
- for example a left over vlan1 interface.

Please find attached a patch that prints the error message into the log.

I'm running Ubuntu Trusty with mainline 3.19.3 where the testcase works 
with and without hostapd CONFIG_VLAN_NETLINK set.

Regards,
  M. Braun
diff mbox

Patch

commit 502a4a98c9c533dfb11b3a37298fc3a6141df68a
Author: Michael Braun <michael-dev@fami-braun.de>
Date:   Wed May 6 13:14:03 2015 +0200

    vlan: print libnl error message on vlan_add

diff --git a/src/ap/vlan_util.c b/src/ap/vlan_util.c
index cc54051..b1facfa 100644
--- a/src/ap/vlan_util.c
+++ b/src/ap/vlan_util.c
@@ -31,7 +31,7 @@ 
 */
 int vlan_add(const char *if_name, int vid, const char *vlan_if_name)
 {
-	int ret = -1;
+	int err, ret = -1;
 	struct nl_sock *handle = NULL;
 	struct nl_cache *cache = NULL;
 	struct rtnl_link *rlink = NULL;
@@ -58,21 +58,23 @@  int vlan_add(const char *if_name, int vid, const char *vlan_if_name)
 		goto vlan_add_error;
 	}
 
-	if (nl_connect(handle, NETLINK_ROUTE) < 0) {
-		wpa_printf(MSG_ERROR, "VLAN: failed to connect to netlink");
+	if ((err = nl_connect(handle, NETLINK_ROUTE)) < 0) {
+		wpa_printf(MSG_ERROR, "VLAN: failed to connect to netlink: %s",
+			   nl_geterror(err));
 		goto vlan_add_error;
 	}
 
-	if (rtnl_link_alloc_cache(handle, AF_UNSPEC, &cache) < 0) {
+	if ((err = rtnl_link_alloc_cache(handle, AF_UNSPEC, &cache)) < 0) {
 		cache = NULL;
-		wpa_printf(MSG_ERROR, "VLAN: failed to alloc cache");
+		wpa_printf(MSG_ERROR, "VLAN: failed to alloc cache: %s",
+			   nl_geterror(err));
 		goto vlan_add_error;
 	}
 
 	if (!(if_idx = rtnl_link_name2i(cache, if_name))) {
 		/* link does not exist */
-		wpa_printf(MSG_ERROR, "VLAN: interface %s does not exist",
-			   if_name);
+		wpa_printf(MSG_ERROR, "VLAN: interface %s does not exist: %s",
+			   if_name, nl_geterror(err));
 		goto vlan_add_error;
 	}
 
@@ -92,23 +94,26 @@  int vlan_add(const char *if_name, int vid, const char *vlan_if_name)
 		goto vlan_add_error;
 	}
 
-	if (rtnl_link_set_type(rlink, "vlan") < 0) {
-		wpa_printf(MSG_ERROR, "VLAN: failed to set link type");
+	if ((err = rtnl_link_set_type(rlink, "vlan")) < 0) {
+		wpa_printf(MSG_ERROR, "VLAN: failed to set link type: %s",
+			   nl_geterror(err));
 		goto vlan_add_error;
 	}
 
 	rtnl_link_set_link(rlink, if_idx);
 	rtnl_link_set_name(rlink, vlan_if_name);
 
-	if (rtnl_link_vlan_set_id(rlink, vid) < 0) {
-		wpa_printf(MSG_ERROR, "VLAN: failed to set link vlan id");
+	if ((err = rtnl_link_vlan_set_id(rlink, vid)) < 0) {
+		wpa_printf(MSG_ERROR, "VLAN: failed to set link vlan id: %s",
+			   nl_geterror(err));
 		goto vlan_add_error;
 	}
 
-	if (rtnl_link_add(handle, rlink, NLM_F_CREATE) < 0) {
+	if ((err = rtnl_link_add(handle, rlink, NLM_F_CREATE)) < 0) {
 		wpa_printf(MSG_ERROR, "VLAN: failed to create link %s for "
-			   "vlan %d on %s (%d)",
-			   vlan_if_name, vid, if_name, if_idx);
+			   "vlan %d on %s (%d): %s",
+			   vlan_if_name, vid, if_name, if_idx,
+			   nl_geterror(err));
 		goto vlan_add_error;
 	}
 
@@ -127,7 +132,7 @@  vlan_add_error:
 
 int vlan_rem(const char *if_name)
 {
-	int ret = -1;
+	int err, ret = -1;
 	struct nl_sock *handle = NULL;
 	struct nl_cache *cache = NULL;
 	struct rtnl_link *rlink = NULL;
@@ -140,14 +145,16 @@  int vlan_rem(const char *if_name)
 		goto vlan_rem_error;
 	}
 
-	if (nl_connect(handle, NETLINK_ROUTE) < 0) {
-		wpa_printf(MSG_ERROR, "VLAN: failed to connect to netlink");
+	if ((err = nl_connect(handle, NETLINK_ROUTE)) < 0) {
+		wpa_printf(MSG_ERROR, "VLAN: failed to connect to netlink: %s",
+			   nl_geterror(err));
 		goto vlan_rem_error;
 	}
 
-	if (rtnl_link_alloc_cache(handle, AF_UNSPEC, &cache) < 0) {
+	if ((err = rtnl_link_alloc_cache(handle, AF_UNSPEC, &cache)) < 0) {
 		cache = NULL;
-		wpa_printf(MSG_ERROR, "VLAN: failed to alloc cache");
+		wpa_printf(MSG_ERROR, "VLAN: failed to alloc cache: %s",
+			   nl_geterror(err));
 		goto vlan_rem_error;
 	}
 
@@ -158,9 +165,9 @@  int vlan_rem(const char *if_name)
 		goto vlan_rem_error;
 	}
 
-	if (rtnl_link_delete(handle, rlink) < 0) {
-		wpa_printf(MSG_ERROR, "VLAN: failed to remove link %s",
-			   if_name);
+	if ((err = rtnl_link_delete(handle, rlink)) < 0) {
+		wpa_printf(MSG_ERROR, "VLAN: failed to remove link %s: %s",
+			   if_name, nl_geterror(err));
 		goto vlan_rem_error;
 	}