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

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