[lldp-devel] [PATCH 4/8] some minor bugfixes

Jens Osterkamp jens at linux.vnet.ibm.com
Mon Aug 15 20:54:30 UTC 2011


This patch summarizes a number of minor bugfixes:

 - In case lldpad.conf cannot be created, add a line break to error message.

 - add IFLA_AF_SPEC and IFLA_GROUP from newer kernels to lldpad

 - consolidate  while (port != NULL) loops to port_find_by_name().

 - whitespace fixes in lldp_dcbx.c

Signed-off-by: Jens Osterkamp <jens at linux.vnet.ibm.com>
---
 config.c                |    2 +-
 event_iface.c           |    6 +++++
 include/linux/if_link.h |    2 +
 lldp/ports.c            |   51 ++++++----------------------------------------
 lldp_dcbx.c             |    4 +-
 5 files changed, 18 insertions(+), 47 deletions(-)

diff --git a/config.c b/config.c
index 4c82bb6..648f6f9 100644
--- a/config.c
+++ b/config.c
@@ -201,7 +201,7 @@ int check_cfg_file(void)
 				O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
 			if (fd < 0) {
 				retval = errno;
-				LLDPAD_ERR("error creating %s", cfg_file_name);
+				LLDPAD_ERR("error creating %s !\n", cfg_file_name);
 			} else {
 				close(fd);
 				create_default_cfg_file();
diff --git a/event_iface.c b/event_iface.c
index e581bce..1288fae 100644
--- a/event_iface.c
+++ b/event_iface.c
@@ -174,6 +174,12 @@ static void event_if_decode_rta(int type, struct rtattr *rta, int *ls, char *d)
 	case IFLA_PORT_SELF:
 		LLDPAD_DBG(" IFLA_PORT_SELF\n");
 		break;
+	case IFLA_AF_SPEC:
+		LLDPAD_DBG(" IFLA_AF_SPEC\n");
+		break;
+	case IFLA_GROUP:
+		LLDPAD_DBG(" IFLA_GROUP\n");
+		break;
 	default:
 		LLDPAD_DBG(" unknown type : 0x%02x\n", type);
 		break;
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index 2fc66dd..4fdfd38 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -116,6 +116,8 @@ enum {
 	IFLA_STATS64,
 	IFLA_VF_PORTS,
 	IFLA_PORT_SELF,
+        IFLA_AF_SPEC,
+        IFLA_GROUP,             /* Group the device belongs to */
 	__IFLA_MAX
 };
 
diff --git a/lldp/ports.c b/lldp/ports.c
index 925a2ad..596e68b 100644
--- a/lldp/ports.c
+++ b/lldp/ports.c
@@ -156,16 +156,10 @@ void set_lldp_port_enable_state(const char *ifname, int enable)
 {
 	struct port *port = NULL;
 
-	port = porthead;
-	while (port != NULL) {
-		if (!strncmp(ifname, port->ifname, IFNAMSIZ))
-			break;
-		port = port->next;
-	}
+	port = port_find_by_name(ifname);
 
-	if (port == NULL) {
+	if (port == NULL)
 		return;
-	}
 
 	port->portEnabled = (u8)enable;
 
@@ -178,14 +172,7 @@ void set_lldp_port_enable_state(const char *ifname, int enable)
 
 void set_port_oper_delay(const char *ifname)
 {
-	struct port *port = NULL;
-
-	port = porthead;
-	while (port != NULL) {
-		if (!strncmp(ifname, port->ifname, IFNAMSIZ))
-			break;
-		port = port->next;
-	}
+	struct port *port = port_find_by_name(ifname);
 
 	if (port == NULL)
 		return;
@@ -198,13 +185,7 @@ int set_port_hw_resetting(const char *ifname, int resetting)
 {
 	struct port *port = NULL;
 
-	port = porthead;
-	while (port != NULL) {
-		if (!strncmp(ifname, port->ifname, IFNAMSIZ)) {
-			break;
-		}
-		port = port->next;
-	}
+	port = port_find_by_name(ifname);
 
 	if (port == NULL)
 		return -1;
@@ -218,12 +199,7 @@ int get_port_hw_resetting(const char *ifname)
 {
 	struct port *port = NULL;
 
-	port = porthead;
-	while (port != NULL) {
-		if (!strncmp(ifname, port->ifname, IFNAMSIZ))
-			break;
-		port = port->next;
-	}
+	port = port_find_by_name(ifname);
 
 	if (port)
 		return port->hw_resetting;
@@ -235,12 +211,7 @@ int reinit_port(const char *ifname)
 {
 	struct port *port;
 
-	port = porthead;
-	while (port != NULL) {
-		if (!strncmp(ifname, port->ifname, IFNAMSIZ))
-			break;
-		port = port->next;
-	}
+	port = port_find_by_name(ifname);
 
 	if (!port)
 		return -1;
@@ -347,15 +318,7 @@ int remove_port(const char *ifname)
 	struct port *port = NULL;    /* Pointer to port to remove */
 	struct port *parent = NULL;  /* Pointer to previous on port stack */
 
-	port = porthead;
-	while (port != NULL) {
-		if (!strncmp(ifname, port->ifname, IFNAMSIZ)) {
-			LLDPAD_DBG("In remove_port: Found port %s\n",port->ifname);
-			break;
-		}
-		parent = port;
-		port = port->next;
-	}
+	port = port_find_by_name(ifname);
 
 	if (port == NULL) {
 		LLDPAD_DBG("remove_port: port not present\n");
diff --git a/lldp_dcbx.c b/lldp_dcbx.c
index 7949147..6ca290c 100644
--- a/lldp_dcbx.c
+++ b/lldp_dcbx.c
@@ -58,8 +58,8 @@ void dcbx_free_tlv(struct dcbx_tlvs *tlvs);
 static int dcbx_check_operstate(struct port *port);
 
 const struct lldp_mod_ops dcbx_ops = {
-	.lldp_mod_register 	= dcbx_register,
-	.lldp_mod_unregister 	= dcbx_unregister,
+	.lldp_mod_register	= dcbx_register,
+	.lldp_mod_unregister	= dcbx_unregister,
 	.lldp_mod_gettlv	= dcbx_gettlv,
 	.lldp_mod_rchange	= dcbx_rchange,
 	.lldp_mod_ifup		= dcbx_ifup,
-- 
1.7.4.4




More information about the lldp-devel mailing list