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

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