This patch fixes a warning issued when building the lexer generated file
parse_cli.c:

parse_cli.c:2147: warning: ‘input’ defined but not used

Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: Avoid possible resource leak in get_bcn()

Signed-off-by: Petr Sabata <contyk@redhat.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Avoid possible resource leaks

This patch prevents possible resource leaks in mand_clif_cmd().

Signed-off-by: Petr Sabata <contyk@redhat.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: Fix logging to no longer use message IDs

lldpad's logging was overloading the first parameter to the log_message
function as both a logging level and a message ID. There are really not
many message IDs in use, so resolve the conflict by using only log level.
This also adds a proper printf-attribute to the logging function so
that arguments can be checked and resolve those as well. A few messages
that were changed now have more useful content.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Tested-by: Ross Brattain <ross.b.brattain@intel.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: Fix error path in save_dcbx_version

One error path would not return an error indication to the caller.
Fix that and eliminate the useless rval variable.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Tested-by: Ross Brattain <ross.b.brattain@intel.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
bugfix to print all profiles

In an earlier patch a bug had been introduced which prevented all profiles
from being printed into the assigned buffer. Instead, only the last profile
for an interface would be printed in there and shown with lldptool.

Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
prevent crash on invalid response code

If an unknown response code was received for a profile, the lookup of the
error string could cause a crash.

Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
bugfix: go to VSI_EXIT immediately on neg response

If a vsi_profile receives a negative response while in ASSOCIATED state,
it has to go to VSI_EXIT immediately to avoid sitting in DEASSOC_PROCESSING
before timing out.

Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
some minor bugfixes

This patch summarizes a number of minor bugfixes:

 - In case lldpad.conf cannot be created, add a line break to error message.

 - add IFLA_AF_SPEC and IFLA_GROUP from newer kernels to lldpad

 - consolidate  while (port != NULL) loops to port_find_by_name().

 - whitespace fixes in lldp_dcbx.c

Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
bugfix: vdp must be enabled on interface

For vdp to be usable, enabletx must be set to true. The check for enabletx
needs to be made before checking if vdp_data for this ifname already exists.
Otherwise VDP is running even though enabletx is false.

Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: Do not send lldp packets if the driver has offloaded dcbx stack

If the dcb capabilities indicate that the DCBX negotiation is not performed by
host, abort further initialization.

Signed-off-by: Shmulik Ravid <shmulikr@broadcom.com>
Signed-off-by: Bhanu Prakash Gollapudi <bprakash@broadcom.com>
lldpad: Introduce support for multiple agents per port

This patch introduces support for multiple agents per port.
Each agent sends and receives frames to and from different group mac
addresses. Right now these are nearest bridge, nearest customer bridge and
nearest non-twoport mac-relaying bridge.

It splits out most of the agent specific variables from the port structure
to an agent structure. This requires changes in the rx and tx state
machines.

With the changes for the multi-agent support, adminStatus has moved from the
port to the agent. As port->adminStatus has been used to control the VDP
state machines as well, a new mechanism was needed here.
The VDP module does not have agent support, so port->adminStatus is replaced
by the vdp->enableTx flag. If this is set to yes by lldptool, VDP will be
active, and will be inactive if set to no.

JF: fixed some minor nit issues and a few real bugs as well as
    some style items.

Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: Introduce changed config file interface

This patch modifies all interface functions to get and set config file
values to use the agent type. The agent type will determine in which section
of the config file the values are located. The result is that now there are 3
sections in lldpad.conf for LLDP:

	- "lldp" or "nearest_bridge" (if newly created)
	- "nearest_customer_bridge"
	- "nearest_nontpmr_bridge"

So lldpad.conf will look similar like

	lldp {
		...
	}
	nearest_customer_bridge {
		...
	}
	nearest_nontmpr_bridge {
		...
	}

It also introduces a new lldptool parameter -g <agent>. Valid values for
<agent> are

	- "nearest_bridge" or "nb"
	- "nearest_customer_bridge" or "ncb"
	- "neareast_nontpmr_bridge" or "nntpmrb"

E.g. to enable the evbCfg TLV for the agent "nearest customer bridge" one
would use

	"lldptool -T -i eth8 -g ncb -V evbCfg -c enableTx=yes"

If no -g parameter is specified, this is assumed to remain "nearest bridge"
to preserve the existing behaviour.

It modifies the lldp_mod_* functions to supply the agent where appropriate.

JF: updated to default to nearest bridge if '-g' is not specified.

Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldptool: document new agent parameter in lldptool man page

Add a brief description of the new "-g" parameter in lldptool to the man
page.

Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: changes to the lldp command ctrl interface

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 an informated "deprecated version" message if the version
is not current. This warns users about lack of agent support.

Suggested-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: vdp ifup, ifdown excessive print messages

Set VDP ifup and ifdown print message to INFO these always occur
when VDP is disabled.

Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: run dcbx on nearest bridge only

DCBx should only be run on nearest bridge. The existing kernel
infrastructure does not allow configuring DCB attributes on
non-nb. Additionally, CEE and IEEE802.1Qaz transition logic
fails.

Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: README updates for required libraries

Update README to note dependencies on libtool, libconfig-devel
and libnl-devel.

Signed-off-by: Joshua, Hay <joshua.a.hay@intel.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: 8021qaz, demote unknown subtype to INFO level

Receiving an unknown 802.1Qaz subtype although peculiar
because we support all IEEE802.1Qaz defined subtype's is
not warning worthy demote it to INFO status as no harm
comes from it. User can query strange TLV with lldptool
anyways.

'lldptool -t -i ethx -n'

Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldptool: Set stdout to line buffered when in interactive mode

Force line buffering when in interactive mode, so that pipes and
other wrappers can receive event output as it occurs.

Signed-off-by: John Fastabend <john.r.fastabend@intel.com>