lldpad: initial git commit

Initial git commit for open-lldp.

Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: consolidation of MIN and MAX macros

This patch consolidates a modified version of the already existing MIN
macro in lldpad and adds a MAX macro.

Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: BUGFIX: check for existence of ifup

added an additional check for existence of the ifup operation.
If it does not exist, just skip it.

Signed-off-by: Jens Osterkamp <jens at linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: implementation of IEEE 802.1Qbg in lldpad, part 1

This patch contains the first part of an initial implementation of the
IEEE 802.1Qbg standard: it implements code for the exchange of EVB
capabilities between a host with virtual machines and an adjacent switch.
For this it adds a new EVB TLV to LLDP.

Exchange of EVB TLV may be enabled or disabled on a per port basis.
Information about the information negotiated by the protocol can be
queried on the command line with lldptool.

This patch adds support for querying and setting parameters used in
the exchange of EVB TLV messages.
The parameters that can be set are:

	- forwarding mode
	- host protocol capabilities (RTE, ECP, VDP)
	- no. of supported VSIs
	- retransmission timer exponent (RTE)

The parameters are implemented as a local policy: all frames received by
an adjacent switch are validated against this policy and taken over where
appropriate. Negotiated parameters are stored in lldpads config, picked up
again and used at the next start.

The patch applies to lldpad 0.9.38 and still contains code to log protocol
activity more verbosely than it would be necessary in the final version.

Signed-off-by: Jens Osterkamp <jens at linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: implementation of IEEE 802.1Qbg in lldpad, part 2

This is the implementation of the edge control protocol (ECP) and VSI
discovery protocol (VDP) currently being specified in IEEE 802.1Qbg.

This implementation extends the infrastructure defined lldpad to send
and receive ECP frames with a new (yet to be defined) ethertype.
Received frames are validated and analyzed before the content is
handed to the upper layer protocol (ULP, VDP in this case) for
further processing. Frames to be transmitted are compiled from VSI
(guest interface) profiles registered on a interface. Reception and
transmission of ECP frames is controlled by RX and TX state machines,
timeouts are handled timeout functions. The patch still contains a
lot of debug code to allow low-level protocol analysis.

VDP serves as the upper layer protocol (ULP) for TLVs communicated
via the ECP protocol.

For this it registers as a new module in lldpad. The VDP module
supports a station and a bridge role. As a station, new VSI (virtual
station interface) profiles can be registered to the VDP module using
lldptool or libvirt. These profiles are then announced to an adjacent
switch. Transmitted profiles are processed to the desired state by
the VDP station state machine. As a bridge, the VDP module waits for
new profiles received in TLVs by ECP. The received profiles are
processed to the desired state by a VDP bridge state machine.

VDP module parameters are stored in the "vdp" section under the
appropriate interface.

The patch still contains a lot of debug code to allow analysis of VDP
protocol behavior.

Signed-off-by: Jens Osterkamp <jens at linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: VDP commandline interface

This patch implements the command line interface to control the VDP
module. In station role, it allows to register a new VSI (guest
interface) profile and query its state. In bridge role, it allows to
query the state of all registered profiles.

With lldptool it is possible to set the role from default "station" to
"bridge". The configuration of the role for a port is saved to lldpads
config file.

Signed-off-by: Jens Osterkamp <jens at linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: add libnl dependency to configure.ac

Adds libnl dependency.

Signed-off-by: Jens Osterkamp <jens at linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: use connect instead of bind on netlink socket

Modifies the setup of the netlink socket in drv_cfg.c to use pid 0
instead of the processes pid. Also replaces bind with connect to
allow the reception of netlink messages from libvirt. Preparation
patch for communication between libvirt and lldpad.

Signed-off-by: Gerhard Stenzel <gstenzel at linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: Support for libvirt netlink message

This code receives a IEEE 802.1Qbg virtual station instance from
libvirt in a SETLINK message. The parsed VSI is then handed over to
VDP for processing. The VDP state machine processes the VSI while
libvirt polls the result using GETLINK.

Requires at least Linux kernel 2.6.35-rc1.

Signed-off-by: Jens Osterkamp <jens at linux.vnet.ibm.com>
Signed-off-by: Gerhard Stenzel <gstenzel at linux.vnet.ibm.com>
Signed-off-by: Stefan Berger <stefanb at linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: do not use macv[tap/lan] interfaces as ports

At startup lldpad walks through all network interfaces in the system
and creates internal data structures for them. Some interfaces as
e.g. vlan and wlan are skipped in the walkthrough, some have to be
treated special (e.g. bond devices).

This patch adds macvtap and macvlan interfaces to the list of devices
that are skipped as we do not want to send out EVB/ECP frames on them.

Signed-off-by: Jens Osterkamp <jens at linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: Implement VDP keepalive

Once a VSI is associated with the adjacent switch, it needs to be
renewed in the switch from time to time. This patch implements the
renewal of the VSI. As a time base it uses the RTE (ReTransmission
Exponent) exchanged in the EVB TLV.

Signed-off-by: Jens Osterkamp <jens at linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: fix evb init segfault

If the evb tlv is not enabled then evb_bld_cfg_tlv fails. This is
not a critical failure it only means the TLV has been disabled by the
user.

Allow initialization to continue on ifup so users can dynamically
enable EVB on active devices. And do not post errors when evb_gettlv()
fails. This is expected when the tlv is disabled. Notice the other
case where the TLV is enabled on ifup but is later disabled.

Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: Make EVB less noisy for non-evb users

EVB outputs numerous messages regarding EVB policy even
when EVB is disabled. This makes EVB less noisy by setting
these to INFO messages.

Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: reduce DCB noise on init

DCB is somewhat noise on init and the following output

"get_dcb_enable_state:eth1:failed on dcbx.eth1.dcb_enable"

is arguably not very useful. Set these messages to INFO level to avoid
logging unneeded messages.

Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldp: fix Makefile for ecp.h and lldp_vdp_cmds.h

lldp_vdp_cmds.h had the wrong path and ecp.h was missing completely from the
lldpad_sources in Makefile.am. This would cause the build from a tarball
generated with "make dist" to fail.

Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
This patch adds newlines in event_iface.c and ecp/ecp_tx.c

to make debug output of the netlink interface and printout of outgoing
frames more readable.

Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: add sanitized netlink headers

lldpad needs to build across many kernel versions which
creates an issue when using netlink attributes that
are only available in later kernels. This leaves a few
options one is to maintain build flags for the various
kernel combinations. Or alternatively we can maintain
header files for lldpad that contain a copy of the
kernel attributes.

This patch adds the header files to "include/linux"
needed by lldpad to build. This allows lldpad to compile
across many kernel versions and eliminates the need to
update the userland header files.

Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad.conf is read already earlier on, so remove it from this comment.

Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
When receiving a msg over netlink, check wether the requested interface is
already up. Otherwise reject the request. This prevents a potential crash
when a SETLINK occurs right after lldpad has started and the vdp data
structures for this interface have not yet been properly set up.

Remove all init_cfg()'s and one destroy_cfg in evb and vdp code. There is no
need to re-init the config in module code, this should all be in place when
module code is called for the first time.

Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
lldpad: version bump 0.9.40 -> 0.9.41

Addition of EVB and sanitized headers warrants a version bump.

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