Blame SOURCES/open-lldp-v1.0.1-26-lldpad-system-capability-incorrect-advertised-as-sta.patch

74731f
From 036e314bd93602f7388262cc37faf8b626980af1 Mon Sep 17 00:00:00 2001
74731f
From: Gary Loughnane <gary.loughnane@intel.com>
74731f
Date: Mon, 17 Aug 2015 21:19:24 +0000
74731f
Subject: [PATCH] lldpad: system capability incorrect advertised as station
74731f
 only
74731f
74731f
Fix system capability TLV on switch. On our switches we have found
74731f
that the system capability was being advertised as Station Only. This
74731f
patch changes the capability to Bridge.
74731f
74731f
Signed-off-by: Gary Loughnane <gary.loughnane@intel.com>
74731f
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
74731f
---
74731f
 include/lldp_util.h |  1 +
74731f
 lldp_util.c         | 22 +++++++++++++++++++++-
74731f
 2 files changed, 22 insertions(+), 1 deletion(-)
74731f
74731f
diff --git a/include/lldp_util.h b/include/lldp_util.h
74731f
index 878426b..69b67b1 100644
74731f
--- a/include/lldp_util.h
74731f
+++ b/include/lldp_util.h
74731f
@@ -125,6 +125,7 @@ int is_active(const char *ifname);
74731f
 int is_bond(const char *ifname);
74731f
 int is_san_mac(u8 *addr);
74731f
 int is_bridge(const char *ifname);
74731f
+int is_bridge_port(const char *ifname);
74731f
 int is_vlan(const char *ifname);
74731f
 int is_vlan_capable(const char *ifname);
74731f
 int is_wlan(const char *ifname);
74731f
diff --git a/lldp_util.c b/lldp_util.c
74731f
index f1fb7b9..62f0af8 100644
74731f
--- a/lldp_util.c
74731f
+++ b/lldp_util.c
74731f
@@ -580,6 +580,26 @@ int is_bridge(const char *ifname)
74731f
 	return rc;
74731f
 }
74731f
 
74731f
+int is_bridge_port(const char *ifname)
74731f
+{
74731f
+	int rc = 0;
74731f
+	char path[256];
74731f
+	DIR *dirp;
74731f
+
74731f
+	if (!is_ether(ifname)) {
74731f
+		return 0;
74731f
+	}
74731f
+	/* check if the given ifname is a bridge port in sysfs */
74731f
+	snprintf(path, sizeof(path), "/sys/class/net/%s/brport/", ifname);
74731f
+	dirp = opendir(path);
74731f
+	if (dirp) {
74731f
+		closedir(dirp);
74731f
+		rc = 1;
74731f
+	}
74731f
+
74731f
+	return rc;
74731f
+}
74731f
+
74731f
 int is_vlan(const char *ifname)
74731f
 {
74731f
 	int fd;
74731f
@@ -942,7 +962,7 @@ u16 get_caps(const char *ifname)
74731f
 	if (is_vlan(ifname))
74731f
 		caps |= SYSCAP_CVLAN;
74731f
 
74731f
-	if (is_bridge(ifname))
74731f
+	if (is_bridge_port(ifname))
74731f
 		caps |= SYSCAP_BRIDGE;
74731f
 
74731f
 	if (is_router())
74731f
-- 
74731f
2.5.0
74731f