Skip to contentSkip to conversation

implementation of IEEE 802.1Qbg in lldpad, part2

PATCH New Jens Osterkamp 1 participant 4 messages Jun 17, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

This series of patches contains the second part of an initial implementation of the IEEE 802.1Qbg standard: code for the exchange of VDP VSI TLVs between a host with virtual machines and an adjacent switch.

VDP profiles consisting of mode,mgrid,typeid,typeidversion,instanceid,mac,vlan can be given to lldpad with lldptool.
A way to deliver profiles to lldpad from libvirt using netlink messages is currently under development and not yet included in this series.

The profiles are then processed through the VDP/VSI and ECP state machines and sent out as ECP frames.
ACK frames are received and processed through ECP and VDP/VSI state machines.

It implements a bridge role for a port together with a lldptool command to switch a port to the bridge role.

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

Things that are still missing but planned:

   - adapt to final ECP ethertype. code currently uses extended ethertype (0x88b7) plus OUI.
   - more testing

Next steps

   - interface to allow registration of profiles with libvirt
   - implementation of CDCP

Please review and comment !

Thanks !

            Jens

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/virtualization

#1 lore raw

PATCH 1/3 ECP implementation

This is the implementation of the edge control protocol (ECP) as specified in IEEE 802.1Qbg.

For this it 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.

---
 Makefile.am        |    2 +
 ecp/ecp.c          |   77 +++++++
 ecp/ecp.h          |   92 ++++++++
 ecp/ecp_rx.c       |  597 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 ecp/ecp_tx.c       |  467 ++++++++++++++++++++++++++++++++++++++++
 include/lldp_evb.h |    6 +
 include/lldp_vdp.h |  157 ++++++++++++++
 lldp/l2_packet.h   |    2 +
 lldp/ports.h       |   25 ++-
 lldp_evb.c         |    2 +
 10 files changed, 1424 insertions(+), 3 deletions(-)
 create mode 100644 ecp/ecp.c
 create mode 100644 ecp/ecp.h
 create mode 100644 ecp/ecp_rx.c
 create mode 100644 ecp/ecp_tx.c
 create mode 100644 include/lldp_vdp.h
Makefile.am +2 -0
index 554baec..693e57d 100644
@@ -58,6 +58,8 @@ $(lldpad_include_HEADERS) $(noinst_HEADERS) \
 lldp/ports.c lldp/agent.c lldp/l2_packet_linux.c lldp/tx.c \
 lldp/rx.c lldp/agent.h lldp/l2_packet.h lldp/mibdata.h lldp/ports.h \
 lldp/states.h \
+ecp/ecp.c ecp/ecp_tx.c \
+ecp/ecp_rx.c \
 include/lldp.h include/lldp_mod.h \
 lldp_dcbx.c include/lldp_dcbx.h tlv_dcbx.c include/tlv_dcbx.h \
 lldp_dcbx_cfg.c include/lldp_dcbx_cfg.h \
ecp/ecp.c new file +77 -0

77 lines not on this page · raw message

ecp/ecp.h new file +92 -0

92 lines not on this page · raw message

ecp/ecp_rx.c new file +597 -0

597 lines not on this page · raw message

ecp/ecp_tx.c new file +467 -0

467 lines not on this page · raw message

include/lldp_evb.h +6 -0
index de39fd3..3ca7aa9 100644
@@ -37,6 +37,12 @@ typedef enum {
 	EVB_CONFIRMATION
 } evb_state;
 
+#define	RTE		13
+/* retransmission granularity (RTG) in microseconds */
+#define EVB_RTG		10
+/* retransmission multiplier (RTM) */
+#define EVB_RTM(rte)	(2<<(RTE-1))
+
 struct tlv_info_evb {
 	u8 oui[3];
 	u8 sub;
include/lldp_vdp.h new file +157 -0

157 lines not on this page · raw message

lldp/l2_packet.h +2 -0
index 16f3683..0962429 100644
@@ -36,6 +36,8 @@
 
 #define ETH_P_LLDP 0x88cc
 
+/* TODO: use extended ethertype until final ethertype is available */
+#define ETH_P_ECP 0x88b7
 
 #define ETH_FRAME_LEN   1514
 
lldp/ports.h +22 -3
index 51de561..2c6969c 100644
@@ -136,21 +136,40 @@ struct porttlvs{
 	struct unpacked_tlv *last_peer;
 };
 
+struct ecp {
+	struct l2_packet_data *l2;
+	int sequence;
+	int retries;
+	int ackReceived;
+	int ackTimerExpired;
+	u16 lastSequence;
+	u16 seqECPDU;
+	struct portrx rx;
+	struct porttx tx;
+	struct portstats stats;
+};
+
 struct port {
 	char *ifname;
 	u8 hw_resetting;
 	u8 portEnabled;
 	u8 prevPortEnabled;
 	u8 adminStatus;
-	u8 rxChanges;
-	u16   lldpdu;
+
+	/* protocol specific */
 	struct l2_packet_data *l2;
 	struct portrx rx;
 	struct porttx tx;
-	struct porttlvs tlvs;
 	struct portstats stats;
 	struct porttimers timers;
+	u8 rxChanges;
+	u16   lldpdu;
 	struct msap msap;
+
+	/* not sure */
+	struct porttlvs tlvs;
+
+	struct ecp ecp;
 	struct port *next;
 };
 
lldp_evb.c +2 -0
index 74cfa34..22a95af 100644
@@ -360,6 +360,8 @@ static void evb_statemachine(struct evb_data *ed, struct tlv_info_evb *tie)
 		 * different parameters ? Check parameters. switch state back to
 		 * EVB_CONFIGURE ? */
 		printf("%s: state -> EVB_CONFIRMATION\n", __func__);
+		if (ed->tie->scap & LLDP_EVB_CAPABILITY_PROTOCOL_ECP)
+			ecp_init(ed->ifname);
 		break;
 	default:
 		fprintf(stderr, "EVB statemachine reached invalid state !\n");
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/3 implementation of vdp

In reply to Jens Osterkamp

This patch contains an initial implemention of VDP as specified in IEEE 802.1Qbg. 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 (at a later point in time). These profiles are then announced to an adjacent bridge. 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.

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

---
 Makefile.am    |    8 +-
 ecp/ecp_rx.c   |    9 +-
 ecp/ecp_tx.c   |   36 ++-
 include/lldp.h |    1 +
 lldp_vdp.c     | 1140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lldpad.c       |    2 +
 6 files changed, 1190 insertions(+), 6 deletions(-)
 create mode 100644 lldp_vdp.c
Makefile.am +4 -4
index 693e57d..e2ecce4 100644
@@ -71,16 +71,16 @@ lldp_tlv.c include/lldp_tlv.h \
 lldp_basman.c include/lldp_basman.h	\
 lldp_med.c include/lldp_med.h \
 lldp_8023.c include/lldp_8023.h \
-lldp_evb.c include/lldp_evb.h
-
-
+lldp_evb.c include/lldp_evb.h \
+lldp_vdp.c include/lldp_vdp.h
 
 dcbtool_SOURCES = dcbtool.c clif.c dcbtool_cmds.c parse_cli.l \
 $(lldpad_include_HEADERS) $(noinst_HEADERS)
 
 lldptool_SOURCES = lldptool.c clif.c lldptool_cmds.c common.c os_unix.c \
 lldp_mand_clif.c lldp_basman_clif.c lldp_med_clif.c lldp_8023_clif.c \
-lldp_dcbx_clif.c lldp_evb_clif.c $(lldpad_include_HEADERS) $(noinst_HEADERS)
+lldp_dcbx_clif.c lldp_evb_clif.c $(lldpad_include_HEADERS) \
+$(noinst_HEADERS)
 
 nltest_SOURCES = nltest.c nltest.h
 
ecp/ecp_rx.c +8 -1
index d8c050f..cc54377 100644
@@ -420,7 +420,14 @@ void ecp_rx_ProcessFrame(struct port * port)
 		tlv_offset += sizeof(*tlv_head_ptr) + tlv_length;
 
 		if (tlv->type == TYPE_127) { /* private TLV */
-			/* TODO: give VSI TLV to VDP */
+			/* give VSI TLV to VDP */
+			if (!vdp_indicate(port, tlv, ecp_hdr->mode))
+				tlv_stored = true;
+			else {
+				/* TODO: put it in a list and try again later until
+				 * timer and retries have expired */
+				tlv_stored = false;
+			}
 		}
 
 		if ((tlv->type != TYPE_0) && !tlv_stored) {
ecp/ecp_tx.c +35 -1
index d31edba..78a61ca 100644
@@ -98,6 +98,13 @@ bool ecp_build_ECPDU(struct port *port, int mode)
 	struct vdp_data *vd;
 	struct vsi_profile *p;
 
+	vd = vdp_data(port->ifname);
+	if (!vd) {
+		printf("%s(%i): could not find vdp_data for %s !\n", __func__, __LINE__,
+		       port->ifname);
+		goto error;
+	}
+
 	if (port->ecp.tx.frameout) {
 		free(port->ecp.tx.frameout);
 		port->ecp.tx.frameout = NULL;
@@ -145,7 +152,34 @@ bool ecp_build_ECPDU(struct port *port, int mode)
 	datasize += sizeof(struct ecp_hdr);
 	fb_offset += sizeof(struct ecp_hdr);
 
-	/* TODO: create tlvs from profiles here */
+	/* create packed_tlvs for all profiles on this interface */
+	LIST_FOREACH(p, &vd->profile_head, profile) {
+		if(!p) {
+			printf("%s(%i): list vd->profile_head empty !\n", __func__, __LINE__);
+			continue;
+		}
+
+		if (p->localChange != mode) {
+			printf("%s(%i): not sending out profile !\n", __func__, __LINE__);
+			continue;
+		}
+
+		ptlv = vdp_gettlv(port, p);
+
+		if(!ptlv) {
+			printf("%s(%i): ptlv not created !\n", __func__, __LINE__);
+			continue;
+		}
+
+		if (ptlv) {
+			if ((ptlv->size+fb_offset) > ETH_MAX_DATA_LEN)
+				goto error;
+			memcpy(port->ecp.tx.frameout+fb_offset,
+			       ptlv->tlv, ptlv->size);
+			datasize += ptlv->size;
+			fb_offset += ptlv->size;
+		}
+	}
 
 	/* The End TLV marks the end of the LLDP PDU */
 	ptlv = pack_end_tlv();
include/lldp.h +1 -0
index 21347b0..7af4149 100644
@@ -190,6 +190,7 @@ enum {
 
 /* IEEE 802.1Qbg subtype */
 #define LLDP_EVB_SUBTYPE		0
+#define LLDP_VDP_SUBTYPE		0
 
 /* forwarding mode */
 #define LLDP_EVB_CAPABILITY_FORWARD_STANDARD		(1 << 7)
lldp_vdp.c new file +1140 -0

1,140 lines not on this page · raw message

lldpad.c +2 -0
index 711a995..7a8b75b 100644
@@ -50,6 +50,7 @@
 #include "lldp_med.h"
 #include "lldp_8023.h"
 #include "lldp_evb.h"
+#include "lldp_vdp.h"
 #include "config.h"
 #include "lldpad_shm.h"
 #include "clif.h"
@@ -65,6 +66,7 @@ struct lldp_module *(*register_tlv_table[])(void) = {
 	med_register,
 	ieee8023_register,
 	evb_register,
+	vdp_register,
 	NULL,
 };
 
Signature · 1 line
1.7.1
#3 lore raw

PATCH 3/3 VDP commandline interface

In reply to Jens Osterkamp

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.

---
 Makefile.am             |   12 +-
 include/lldp_vdp_clif.h |   38 +++++
 include/lldp_vdp_cmds.h |   44 ++++++
 lldp_vdp_clif.c         |  136 ++++++++++++++++
 lldp_vdp_cmds.c         |  392 +++++++++++++++++++++++++++++++++++++++++++++++
 lldptool.c              |    2 +
 6 files changed, 619 insertions(+), 5 deletions(-)
 create mode 100644 include/lldp_vdp_clif.h
 create mode 100644 include/lldp_vdp_cmds.h
 create mode 100644 lldp_vdp_clif.c
 create mode 100644 lldp_vdp_cmds.c
Makefile.am +7 -5
index e2ecce4..d16f9f2 100644
@@ -39,7 +39,8 @@ lldpad_include_HEADERS = include/dcb_types.h include/dcbtool.h \
 include/dcb_osdep.h include/clif.h include/lldp_dcbx_cmds.h include/common.h \
 include/lldpad.h include/os.h include/includes.h include/lldp_mand_cmds.h \
 include/clif_msgs.h include/lldp_basman_cmds.h include/lldp_8023_cmds.h \
-include/lldp_med_cmds.h include/lldp_dcbx_cfg.h include/lldp_evb_cmds.h
+include/lldp_med_cmds.h include/lldp_dcbx_cfg.h include/lldp_evb_cmds.h \
+include/lldp_vdp_cmds.h
 
 noinst_HEADERS = include/config.h include/ctrl_iface.h \
 include/dcb_driver_if_types.h include/dcb_driver_interface.h \
@@ -49,7 +50,7 @@ include/event_iface.h include/messages.h include/parse_cli.h include/version.h \
 include/lldptool_cli.h include/list.h \
 include/lldp_mand_clif.h include/lldp_basman_clif.h include/lldp_med_clif.h \
 include/lldp_8023_clif.h include/lldp_dcbx_clif.h include/lldptool.h \
-include/lldp_rtnl.h include/lldp_evb_clif.h
+include/lldp_rtnl.h include/lldp_evb_clif.h include/lldp_vdp_clif.h
 
 lldpad_SOURCES = lldpad.c config.c  drv_cfg.c ctrl_iface.c event_iface.c eloop.c \
 common.c os_unix.c lldp_dcbx_cmds.c log.c lldpad_shm.c \
@@ -66,20 +67,21 @@ lldp_dcbx_cfg.c include/lldp_dcbx_cfg.h \
 lldp_util.c include/lldp_util.h \
 lldp_mand.c include/lldp_mand.h \
 lldp_mand_cmds.c lldp_basman_cmds.c lldp_8023_cmds.c lldp_med_cmds.c \
-lldp_evb_cmds.c \
+lldp_evb_cmds.c lldp_vdp_cmds.c \
 lldp_tlv.c include/lldp_tlv.h \
 lldp_basman.c include/lldp_basman.h	\
 lldp_med.c include/lldp_med.h \
 lldp_8023.c include/lldp_8023.h \
 lldp_evb.c include/lldp_evb.h \
-lldp_vdp.c include/lldp_vdp.h
+lldp_vdp.c include/lldp_vdp.h \
+lldp_vdp_cmds.h
 
 dcbtool_SOURCES = dcbtool.c clif.c dcbtool_cmds.c parse_cli.l \
 $(lldpad_include_HEADERS) $(noinst_HEADERS)
 
 lldptool_SOURCES = lldptool.c clif.c lldptool_cmds.c common.c os_unix.c \
 lldp_mand_clif.c lldp_basman_clif.c lldp_med_clif.c lldp_8023_clif.c \
-lldp_dcbx_clif.c lldp_evb_clif.c $(lldpad_include_HEADERS) \
+lldp_dcbx_clif.c lldp_evb_clif.c lldp_vdp_clif.c $(lldpad_include_HEADERS) \
 $(noinst_HEADERS)
 
 nltest_SOURCES = nltest.c nltest.h
include/lldp_vdp_clif.h new file +38 -0
new file mode 100644
index 0000000..9fcfacb
@@ -0,0 +1,38 @@
+/*******************************************************************************
+
+  implementation of VDP according to IEEE 802.1Qbg
+  (c) Copyright IBM Corp. 2010
+
+  Author(s): Jens Osterkamp <[email protected]>
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms and conditions of the GNU General Public License,
+  version 2, as published by the Free Software Foundation.
+
+  This program is distributed in the hope it will be useful, but WITHOUT
+  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+  more details.
+
+  You should have received a copy of the GNU General Public License along with
+  this program; if not, write to the Free Software Foundation, Inc.,
+  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+
+  The full GNU General Public License is included in this distribution in
+  the file called "COPYING".
+
+*******************************************************************************/
+
+#ifndef _LLDP_VDP_CLIF_H
+#define _LLDP_VDP_CLIF_H
+
+struct lldp_module *vdp_cli_register(void);
+void vdp_cli_unregister(struct lldp_module *);
+int vdp_print_tlv(u32, u16, char *);
+
+#define VDP_BUF_SIZE			256
+
+#define ARG_VDP_MODE			"mode"
+#define ARG_VDP_ROLE			"role"
+
+#endif
include/lldp_vdp_cmds.h new file +44 -0

44 lines not on this page · raw message

lldp_vdp_clif.c new file +136 -0

136 lines not on this page · raw message

lldp_vdp_cmds.c new file +392 -0

392 lines not on this page · raw message

lldptool.c +2 -0
index a06a279..97b097d 100644
@@ -40,6 +40,7 @@
 #include "lldp_8023_clif.h"
 #include "lldp_dcbx_clif.h"
 #include "lldp_evb_clif.h"
+#include "lldp_vdp_clif.h"
 #include "lldptool.h"
 #include "lldptool_cli.h"
 #include "lldp_mod.h"
@@ -158,6 +159,7 @@ struct lldp_module *(*register_tlv_table[])(void) = {
 	med_cli_register,
 	dcbx_cli_register,
 	evb_cli_register,
+	vdp_cli_register,
 	NULL,
 };
 
Signature · 1 line
1.7.1