[lldp-devel] [PATCH v3 9/9] [RFC] changes to the lldp command ctrl interface

Jens Osterkamp jens at linux.vnet.ibm.com
Mon Aug 15 15:19:29 UTC 2011


This patch bumps the msg version number to reflect the addition of the agent
type to the clif command message.

It adds a check for the CLIF_MSG_VERSION to the lldp clif command processing
which will output a message and return cmd_ctrl_vers_not_compatible in case
the version numbers do not match.

It corrects the error code for the version check in the dcb clif command
processing to return dcb_ctrl_vers_not_compatible instead of dcb_invalid_cmd
to give the user a better hint on whats actually wrong.

Signed-off-by: Jens Osterkamp <jens at linux.vnet.ibm.com>
---
 include/clif_msgs.h |    2 +-
 lldp_dcbx_cmds.c    |    2 +-
 lldp_mand_cmds.c    |   14 +++++++++++++-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/include/clif_msgs.h b/include/clif_msgs.h
index 0fa000a..d853119 100644
--- a/include/clif_msgs.h
+++ b/include/clif_msgs.h
@@ -41,7 +41,7 @@
  *   Priority Flow Control feature adds 'number of TC's supported'
 */
 #define CLIF_EV_VERSION 2
-#define CLIF_MSG_VERSION 2
+#define CLIF_MSG_VERSION 3
 #define CLIF_RSP_VERSION CLIF_MSG_VERSION
 
 /* Client interface global command codes */
diff --git a/lldp_dcbx_cmds.c b/lldp_dcbx_cmds.c
index 5cb38e4..f38514f 100644
--- a/lldp_dcbx_cmds.c
+++ b/lldp_dcbx_cmds.c
@@ -507,7 +507,7 @@ int dcbx_clif_cmd(void *data,
 	if (ibuf[DCB_VER_OFF] != (CLIF_MSG_VERSION | 0x30)) {
 		printf("unsupported client interface message version %x\n",
 			ibuf[DCB_VER_OFF]);
-		return dcb_invalid_cmd;
+		return dcb_ctrl_vers_not_compatible;
 	}
 
 	if (ilen < DCB_PORT_OFF+plen) {
diff --git a/lldp_mand_cmds.c b/lldp_mand_cmds.c
index d9055d3..42e53a7 100644
--- a/lldp_mand_cmds.c
+++ b/lldp_mand_cmds.c
@@ -426,7 +426,7 @@ int mand_clif_cmd(void  *data,
 {
 	struct cmd cmd;
 	struct port *port;
-	u8 len;
+	u8 len, version;
 	int ioff, roff;
 	int rstatus = cmd_invalid;
 	char **args;
@@ -436,6 +436,8 @@ int mand_clif_cmd(void  *data,
 	int i, offset;
 
 	/* pull out the command elements of the command message */
+	hexstr2bin(ibuf+MSG_VER, (u8 *)&version, sizeof(u8));
+	version = version >> 4;
 	hexstr2bin(ibuf+CMD_CODE, (u8 *)&cmd.cmd, sizeof(cmd.cmd));
 	hexstr2bin(ibuf+CMD_OPS, (u8 *)&cmd.ops, sizeof(cmd.ops));
 	cmd.ops = ntohl(cmd.ops);
@@ -460,6 +462,16 @@ int mand_clif_cmd(void  *data,
 		cmd.tlvid = INVALID_TLVID;
 	}
 
+	if (version != CLIF_MSG_VERSION) {
+		snprintf(rbuf, rlen, "%c%1x%02x%08x%02x%s",
+			 CMD_REQUEST, CLIF_MSG_VERSION,
+			 cmd.cmd, cmd.ops,
+			 (unsigned int)strlen(cmd.ifname), cmd.ifname);
+		printf("unsupported client interface message version %x\n",
+		       version);
+		return cmd_ctrl_vers_not_compatible;
+	}
+
 	/* count args and argvalus */
 	offset = ioff;
 	for (numargs = 0; (ilen - offset) > 2; numargs++) {
-- 
1.7.4.4




More information about the lldp-devel mailing list