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

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