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

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