[lldp-devel] [PATCH 4/8] changes to the lldp command ctrl interface

Jens Osterkamp jens at linux.vnet.ibm.com
Mon Aug 15 14:00:25 UTC 2011


On Wednesday 10 August 2011, John Fastabend wrote:
> On 8/5/2011 8:35 AM, Jens Osterkamp wrote:
> > 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>
> > ---
> 
> This seems a bit heavy handed. In the case where the msg version number is
> not correct could we just use the default 'nearest bridge' agent. This will
> avoid having to synchronize this change with other apps that communicate
> directly to lldpad. For example fcoe-utils.

The new MSG version is needed to distinguish the newer lldptool messages with 
the additional agent type field from the older ones. Without the next value in the
message would be misintrepreted as agent type.
For DCBX commands there is no field for the agent type in the messages and for the
called functions it is currently hardcoded to NEAREST_BRIDGE.

One solution could be to split up CLIF_MSG_VERSION between DCBX and
LLDP and leave the DCBX MSG VERSION with 2 as no changes have been made and
increase the LLDP MSG VERSION and use NEAREST BRIDGE as default for the older
versions like you proposed. This also reflects the actual changes best.

Jens

> 
> >  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++) {
> 
> 


-- 

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294



More information about the lldp-devel mailing list