Blame SOURCES/open-lldp-v1.0.1-21-lldpad-Fix-DCBX-event-generation-from-lldpad.patch

436175
From 9ad33e441e018352a95621f2cecfb31234bd6b00 Mon Sep 17 00:00:00 2001
436175
From: Neerav Parikh <Neerav.Parikh@intel.com>
436175
Date: Fri, 20 Mar 2015 05:38:09 +0000
436175
Subject: [PATCH] lldpad: Fix DCBX event generation from lldpad
436175
436175
Whenever there is a change in LLDP TLVs lldpad notifies clients that
436175
may have registered for event notification based on TLV type.
436175
For legacy clients like "fcoemon" lldpad by default registers them
436175
for any changes to CEE DCBX TLV type; when such clients attach to
436175
lldpad clif interface.
436175
436175
Now, the lldpad code that registers such clients for CEE DCBX TLV
436175
types is not generating correct DCBX TLV module id when it registers
436175
these clients for change event notification. Hence, whenever there
436175
is a change in such TLVs lldpad determines that the client is not
436175
registered for CEE DCBX TLV change notification and does not notify
436175
these clients.
436175
436175
These results in clients not taking appropriate actions based on
436175
changes to CEE DCBX TLVs.
436175
436175
The patch fixes the issue by setting the correct module id value for
436175
the CEE DCBX for legacy clients like "fcoemon".
436175
436175
Tested-by: Jack Morgan <jack.morgan@intel.com>
436175
Signed-off-by: Neerav Parikh <neerav.parikh@intel.com>
436175
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
436175
---
436175
 ctrl_iface.c | 68 +++++++++++++++++++++++++++++++-----------------------------
436175
 lldpad.c     |  2 ++
436175
 2 files changed, 37 insertions(+), 33 deletions(-)
436175
436175
diff --git a/ctrl_iface.c b/ctrl_iface.c
436175
index e4fd0b7..1734f49 100644
436175
--- a/ctrl_iface.c
436175
+++ b/ctrl_iface.c
436175
@@ -173,46 +173,44 @@ int clif_iface_attach(struct clif_data *clifd,
436175
 	 */
436175
 	/* set default string to DCBX Events */
436175
 	if (ibuf[1] == '\0') {
436175
-		u32 hex = LLDP_MOD_DCBX;
436175
-		tlv = malloc(sizeof(char) * (8 + 2));
436175
-		if (!tlv)
436175
+		dst->tlv_types = malloc(sizeof(u32) * 2);
436175
+		if (!dst->tlv_types)
436175
 			goto err_tlv;
436175
-		tlv[0] = 'A';
436175
-		tlv[9] = 0;
436175
-		bin2hexstr((u8*)&hex, 4, &tlv[1], 8);
436175
-	} else
436175
+		dst->tlv_types[0] = LLDP_MOD_DCBX;
436175
+		/* Insert Termination Pattern */
436175
+		dst->tlv_types[1] = ~0;
436175
+	} else {
436175
 		tlv = strdup(ibuf);
436175
-
436175
-	str = tlv;
436175
-	str++;
436175
-	/* Count number of TLV Modules */
436175
-	tokenize = strtok(str, delim);
436175
-	tlv_count++;
436175
-	do {
436175
-		tokenize = strtok(NULL, delim);
436175
+		str = tlv;
436175
+		str++;
436175
+		/* Count number of TLV Modules */
436175
+		tokenize = strtok(str, delim);
436175
 		tlv_count++;
436175
-	} while (tokenize);
436175
+		do {
436175
+			tokenize = strtok(NULL, delim);
436175
+			tlv_count++;
436175
+		} while (tokenize);
436175
 
436175
-	dst->tlv_types = malloc(sizeof(u32) * tlv_count);
436175
-	if (!dst->tlv_types)
436175
-		goto err_types;
436175
-	memset(dst->tlv_types, 0, sizeof(u32) * tlv_count);
436175
-
436175
-	/* Populate tlv_types from comma separated string */
436175
-	tokenize = strtok(str, delim);
436175
-	for (i=0; tokenize; i++) {
436175
-		char *myend;
436175
-
436175
-		dst->tlv_types[i] = strtol(tokenize, &myend, 16);
436175
-		if (*myend)		/* No hexnumber for module id */
436175
+		dst->tlv_types = malloc(sizeof(u32) * tlv_count);
436175
+		if (!dst->tlv_types)
436175
 			goto err_types;
436175
-		tokenize = strtok(NULL, delim);
436175
+		memset(dst->tlv_types, 0, sizeof(u32) * tlv_count);
436175
+
436175
+		/* Populate tlv_types from comma separated string */
436175
+		tokenize = strtok(str, delim);
436175
+		for (i = 0; tokenize; i++) {
436175
+			char *myend;
436175
+
436175
+			dst->tlv_types[i] = strtol(tokenize, &myend, 16);
436175
+			if (*myend)		/* No hexnumber for module id */
436175
+				goto err_types;
436175
+			tokenize = strtok(NULL, delim);
436175
+		}
436175
+		free(tlv);
436175
+		/* Insert Termination Pattern */
436175
+		dst->tlv_types[i] = ~0;
436175
 	}
436175
 
436175
-	/* Insert Termination Pattern */
436175
-	dst->tlv_types[i] = ~0;
436175
-	free(tlv);
436175
-
436175
 	/* Insert new node at beginning */
436175
 	dst->next = clifd->ctrl_dst;
436175
 	clifd->ctrl_dst = dst;
436175
@@ -595,6 +593,10 @@ void ctrl_iface_send(struct clif_data *clifd, int level, u32 moduleid,
436175
 						dst->addrlen);
436175
 				}
436175
 			} else {
436175
+				fprintf(stderr,
436175
+					"CTRL_IFACE monitor[%d][%d] %d:%s: ",
436175
+					idx, clifd->ctrl_sock, dst->addrlen,
436175
+					dst->addr.sun_path);
436175
 				dst->errors = 0;
436175
 			}
436175
 		}
436175
diff --git a/lldpad.c b/lldpad.c
436175
index 406dcd5..72ab69d 100644
436175
--- a/lldpad.c
436175
+++ b/lldpad.c
436175
@@ -150,6 +150,8 @@ void send_event(int level, u32 moduleid, char *msg)
436175
 {
436175
 	struct clif_data *cd = NULL;
436175
 
436175
+	LLDPAD_DBG("lldpad: send_event level=%d moduleid=%d msg=%s\n",
436175
+		   level, moduleid, msg);
436175
 	cd = (struct clif_data *) eloop_get_user_data();
436175
 	if (cd)
436175
 		ctrl_iface_send(cd, level, moduleid, msg, strlen(msg));
436175
-- 
436175
2.1.0
436175