implementation of IEEE 802.1Qbg in lldpad
Subsystems (2)
Hi,
This set of patches contains the initial implementation of the IEEE 802.1Qbg
standard: code for the exchange of EVB TLVs in LLDP frames to negotiate VSI capabalities as well as VDP VSI TLVs between a host with virtual machines and an adjacent switch.
It supports setting the parameters of the TLV exchange from the command line using lldptool.
VDP profiles consisting of mode,mgrid,typeid,typeidversion,instanceid,mac,vlan can be given to lldpad with lldptool or sent to lldpad via netlink messages from the kernel or another program, e.g. libvirt.
VDP profiles are processed through the VDP/VSI and ECP state machines and sent out in ECP frames.
ACK frames are received and processed through ECP and VDP/VSI state machines.
It implements a VDP bridge role for a port together with a lldptool command to switch a port to the bridge role.
The patches have been rebased to lldpad 0.9.38 and still contain code to log low-level protocol activity more verbosely than necessary.
For more information about lldpad take a look at
http://sourceforge.net/projects/e1000/files/DCB%20Tools/lldpad/
Please review and comment.
Thanks !
Jens
PATCH 1/17 consolidation of MIN and MAX macros in common.h
This patch consolidates a modified version of the already existing MIN macro in lldpad to include/common.h and add a MAX macro.
--- include/common.h | 14 ++++++++++++++ include/dcb_protocol.h | 4 ---- 2 files changed, 14 insertions(+), 4 deletions(-)
include/common.h +14 -0
@@ -387,4 +387,18 @@ typedef int socklen_t;const char *wpa_ssid_txt (u8 *ssid,size_t ssid_len); +#define MIN (x,y) \ + ({ \ + typeof (x) __x = (x); \ + typeof (y) __y = (y); \ + __x < __y ? __x : __y; \ + }) + +#define MAX (x,y) \ + ({ \ + typeof (x) __x = (x); \ + typeof (y) __y = (y); \ + __x > __y ? __x : __y; \ + }) +#endif /* COMMON_H */
include/dcb_protocol.h +0 -4
@@ -58,10 +58,6 @@ typedef enum {#define DUP_DCBX_TLV_LLINK 0x0020#define TOO_MANY_NGHBRS 0x0040 -//#ifndef min /*todo: change to min() -#define MIN (x, y) ((x) < (y) ? x : y) -//#endif -#define INIT_DCB_OUI {0x00,0x1b,0x21}int add_adapter (char *device_name);
Signature · 1 line
1.7.1
PATCH 2/17 implementation of IEEE 802.1Qbg in lldpad, part 1
In reply to Jens OsterkampThis patch contains the first part of an initial implementation of the IEEE 802.1Qbg standard: It contains code for the exchange of EVB TLV capabilities between a host with virtual machines and an adjacent switch.
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 commandline with lldptool.
The patch applies to lldpad 0.9.34 and still contains code to log protocol activity more verbosely than it would be necessary in the final version.
--- Makefile.am | 10 +- include/lldp.h | 20 ++ include/lldp_evb.h | 58 +++++ include/lldp_evb_clif.h | 33 +++ include/lldp_evb_cmds.h | 31 +++ include/lldp_tlv.h | 1 + lldp_evb.c | 567 +++++++++++++++++++++++++++++++++++++++++++++++ lldp_evb_clif.c | 232 +++++++++++++++++++ lldp_evb_cmds.c | 127 +++++++++++ lldpad.c | 2 + lldptool.c | 2 + 11 files changed, 1079 insertions(+), 4 deletions(-) create mode 100644 include/lldp_evb.h create mode 100644 include/lldp_evb_clif.h create mode 100644 include/lldp_evb_cmds.h create mode 100644 lldp_evb.c create mode 100644 lldp_evb_clif.c create mode 100644 lldp_evb_cmds.c
Makefile.am +6 -4
@@ -37,7 +37,7 @@ 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_med_cmds.h include/lldp_dcbx_cfg.h include/lldp_evb_cmds.h noinst_HEADERS = include/config.h include/ctrl_iface.h \ include/dcb_driver_if_types.h include/dcb_driver_interface.h \
@@ -47,7 +47,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_rtnl.h include/lldp_evb_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 \
@@ -62,10 +62,12 @@ 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_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_8023.c include/lldp_8023.h \ +lldp_evb.c include/lldp_evb.h
@@ -74,7 +76,7 @@ $(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 $(lldpad_include_HEADERS) $(noinst_HEADERS) +lldp_dcbx_clif.c lldp_evb_clif.c $(lldpad_include_HEADERS) $(noinst_HEADERS) nltest_SOURCES = nltest.c nltest.h
include/lldp.h +20 -0
@@ -45,6 +45,8 @@/* Telecommunications Industry Association TR-41 Committee */ #define OUI_TIA_TR41 0x0012bb +#define OUI_IEEE_8021Qbg 0x001b3f +/* IEEE 802.3AB Clause 9: TLV Types */ #define CHASSIS_ID_TLV 1#define PORT_ID_TLV 2
@@ -186,5 +188,23 @@ enum {#define LLDP_8023_LINKAGG_CAPABLE (1 << 0)#define LLDP_8023_LINKAGG_ENABLED (1 << 1) +/* IEEE 802.1Qbg subtype */ +#define LLDP_EVB_SUBTYPE 0 + +/* forwarding mode */ +#define LLDP_EVB_CAPABILITY_FORWARD_STANDARD (1 << 7) +#define LLDP_EVB_CAPABILITY_FORWARD_RELAXEDRELAY (1 << 6) + +/* EVB supported protocols */ +#define LLDP_EVB_CAPABILITY_PROTOCOL_RTE (1 << 3) +#define LLDP_EVB_CAPABILITY_PROTOCOL_ECP (1 << 2) +#define LLDP_EVB_CAPABILITY_PROTOCOL_VDPL (1 << 1) +#define LLDP_EVB_CAPABILITY_PROTOCOL_VDP (1 << 0) + +/* EVB specific values */ +#define LLDP_EVB_DEFAULT_MAX_VSI 4096 +#define LLDP_EVB_DEFAULT_SVSI 3295 +#define LLDP_EVB_DEFAULT_RTE 15 +void somethingChangedLocal (char *ifname);#endif /* _LLDP_H */
include/lldp_evb.h new file +58 -0
58 lines not on this page · raw message
include/lldp_evb_clif.h new file +33 -0
@@ -0,0 +1,33 @@ +/******************************************************************************* + +implementation of EVB TLVs for LLDP +(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_EVB_CLIF_H +#define _LLDP_EVB_CLIF_H + +struct lldp_module *evb_cli_register (void ); +void evb_cli_unregister (struct lldp_module *); +int evb_print_tlv (u32 ,u16 ,u8 *); + +#endif
include/lldp_evb_cmds.h new file +31 -0
@@ -0,0 +1,31 @@ +/******************************************************************************* + +implementation of EVB TLVs for LLDP +(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_EVB_CMDS_H +#define _LLDP_EVB_CMDS_H + +struct arg_handlers *evb_get_arg_handlers (); + +#endif
include/lldp_tlv.h +1 -0
@@ -144,6 +144,7 @@ int tlv_ok(struct unpacked_tlv *tlv);#define TLVID_8021 (sub) TLVID(OUI_IEEE_8021, (sub))#define TLVID_8023 (sub) TLVID(OUI_IEEE_8023, (sub))#define TLVID_MED (sub) TLVID(OUI_TIA_TR41, (sub)) +#define TLVID_8021Qbg (sub) TLVID(OUI_IEEE_8021Qbg, (sub))/* the size in bytes needed for a packed tlv from unpacked tlv */ #define TLVSIZE (t) ((t) ? (2 + (t)->length) : 0)
lldp_evb.c new file +567 -0
567 lines not on this page · raw message
lldp_evb_clif.c new file +232 -0
232 lines not on this page · raw message
lldp_evb_cmds.c new file +127 -0
127 lines not on this page · raw message
lldpad.c +2 -0
@@ -49,6 +49,7 @@#include "lldp_dcbx.h" #include "lldp_med.h" #include "lldp_8023.h" +#include "lldp_evb.h" #include "config.h" #include "lldpad_shm.h" #include "clif.h"
@@ -63,6 +64,7 @@ struct lldp_module *(*register_tlv_table[])(void) = { dcbx_register, med_register, ieee8023_register, + evb_register, NULL, };
lldptool.c +2 -0
@@ -39,6 +39,7 @@#include "lldp_med_clif.h" #include "lldp_8023_clif.h" #include "lldp_dcbx_clif.h" +#include "lldp_evb_clif.h" #include "lldptool.h" #include "lldptool_cli.h" #include "lldp_mod.h"
@@ -156,6 +157,7 @@ struct lldp_module *(*register_tlv_table[])(void) = { ieee8023_cli_register, med_cli_register, dcbx_cli_register, + evb_cli_register, NULL, };
Signature · 1 line
1.7.1
PATCH 3/17 support for getting and setting EVB TLV parameters
In reply to Jens OsterkampThis patch adds 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 and VDPL)
- no. of supported VSIs
- retransmission timer exponent (RTE)
To implement this, struct tlv_info_evb had to move to include/lldp_evb.h. Besides that, the patch contains some minor bugfixes.
--- include/lldp_evb.h | 20 +++ include/lldp_evb_clif.h | 18 +++ lldp_evb.c | 21 +--- lldp_evb_cmds.c | 335 ++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 372 insertions(+), 22 deletions(-)
include/lldp_evb.h +20 -0
@@ -37,6 +37,25 @@ typedef enum {EVB_CONFIRMATION } evb_state; +struct tlv_info_evb { +u8 oui[3 ]; +u8 sub; +/* supported forwarding mode */ +u8 smode; +/* supported capabilities */ +u8 scap; +/* currently configured forwarding mode */ +u8 cmode; +/* currently configured capabilities */ +u8 ccap; +/* supported no. of vsi */ +u16 svsi; +/* currently configured no. of vsi */ +u16 cvsi; +/* retransmission exponent */ +u8 rte; +} __attribute__ ((__packed__ )); +struct evb_data {char ifname[IFNAMSIZ ];struct unpacked_tlv *evb;
@@ -54,5 +73,6 @@ void evb_unregister(struct lldp_module *mod);struct packed_tlv *evb_gettlv (struct port *port);void evb_ifdown (char *);void evb_ifup (char *); +struct evb_data *evb_data (char *ifname);#endif /* _LLDP_EVB_H */
include/lldp_evb_clif.h +18 -0
@@ -30,4 +30,22 @@ struct lldp_module *evb_cli_register(void);void evb_cli_unregister (struct lldp_module *);int evb_print_tlv (u32 ,u16 ,u8 *); +#define EVB_BUF_SIZE 256 + +#define ARG_EVB_FORWARDING_MODE "fmode" + +#define VAL_EVB_FMODE_BRIDGE "bridge" +#define VAL_EVB_FMODE_RELAXEDRELAY "relaxedrelay" + +#define ARG_EVB_CAPABILITIES "capabilities" + +#define VAL_EVB_CAPA_RTE "rte" +#define VAL_EVB_CAPA_ECP "ecp" +#define VAL_EVB_CAPA_VDPL "vdpl" +#define VAL_EVB_CAPA_VDP "vdp" + +#define ARG_EVB_VSIS "vsis" + +#define ARG_EVB_RTE "rte" +#endif
lldp_evb.c +1 -20
@@ -39,26 +39,7 @@extern struct lldp_head lldp_head; -struct tlv_info_evb { -u8 oui[3 ]; -u8 sub; -/* supported forwarding mode */ -u8 smode; -/* supported capabilities */ -u8 scap; -/* currently configured forwarding mode */ -u8 cmode; -/* currently configured capabilities */ -u8 ccap; -/* supported no. of vsi */ -u16 svsi; -/* currently configured no. of vsi */ -u16 cvsi; -/* retransmission exponent */ -u8 rte; -} __attribute__ ((__packed__ )); - -static struct evb_data *evb_data (const char *ifname) +struct evb_data *evb_data (char *ifname) {struct evb_user_data *ud;struct evb_data *bd =NULL ;
lldp_evb_cmds.c +333 -2
360 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 4/17 BUGFIX: check in correct positions
In reply to Jens OsterkampThere was a bug in the print function for EVB TLVs that would cause the wrong values to be printed.
This patch corrects it and adds some debug statement to evb_print_cfg_tlv.
--- lldp_evb_clif.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
lldp_evb_clif.c +6 -6
@@ -108,7 +108,7 @@ void evb_print_cfg_tlv(u16 len, char *info) }if (!hexstr2bin (info, &smode,sizeof (smode))) { -printf ("supported forwarding mode:" ); +printf ("supported forwarding mode: (0x%02hhx)" , smode);if (smode &LLDP_EVB_CAPABILITY_FORWARD_RELAXEDRELAY )printf (" reflective relay" );
@@ -122,7 +122,7 @@ void evb_print_cfg_tlv(u16 len, char *info) }if (!hexstr2bin (info+2 , &scap,sizeof (scap))) { -printf ("\tsupported capabilities:" ); +printf ("\tsupported capabilities: (0x%02hhx)" , scap);if ( scap &LLDP_EVB_CAPABILITY_PROTOCOL_RTE )printf (" RTE" );
@@ -141,8 +141,8 @@ void evb_print_cfg_tlv(u16 len, char *info)printf ("Unable to decode scap !\n" ); } -if (!hexstr2bin (info, &cmode,sizeof (cmode))) { -printf ("\tconfigured forwarding mode:" ); +if (!hexstr2bin (info+4 , &cmode,sizeof (cmode))) { +printf ("\tconfigured forwarding mode: (0x%02hhx)" , cmode);if (cmode &LLDP_EVB_CAPABILITY_FORWARD_RELAXEDRELAY )printf (" reflective relay" );
@@ -155,8 +155,8 @@ void evb_print_cfg_tlv(u16 len, char *info)printf ("Unable to decode cmode !\n" ); } -if (!hexstr2bin (info+4 , &ccap,sizeof (ccap))) { -printf ("\tconfigured capabilities:" ); +if (!hexstr2bin (info+6 , &ccap,sizeof (ccap))) { +printf ("\tconfigured capabilities: (0x%02hhx)" , ccap);if ( ccap &LLDP_EVB_CAPABILITY_PROTOCOL_RTE )printf (" RTE" );
Signature · 1 line
1.7.1
PATCH 5/17 remove VDPL and proper config save and restore
In reply to Jens OsterkampThis patch contains multiple changes to the EVB protocol implementation:
- it completely removes the use of VDPL, which is no longer in the spec
- it introduces a mechanism for saving and restoring the EVB setting:
If lldpad is loaded, and no EVB settings can be loaded from the configuration file, reasonable default settings are taken. If EVB settings can be loaded from the config file, these are taken. If changes are made to the EVB settings, e.g. new values are received by an adjacent switch or new values are set on the command line using lldptool, these settings are saved into the configuration.
- it contains some janitorial changes for renaming the variable for evb_data to ed rather than bd for more consistent variable naming. It also renames the typo "relaxed relay" to the right "reflective relay".
- split out printing of tlv into a separate function evb_print_tlvinfo
--- include/lldp.h | 7 +- include/lldp_evb_clif.h | 5 +- lldp_evb.c | 223 +++++++++++++++++++++++------------------------ lldp_evb_clif.c | 10 +-- lldp_evb_cmds.c | 54 +++++++----- 5 files changed, 148 insertions(+), 151 deletions(-)
include/lldp.h +3 -4
@@ -193,12 +193,11 @@ enum {/* forwarding mode */ #define LLDP_EVB_CAPABILITY_FORWARD_STANDARD (1 << 7) -#define LLDP_EVB_CAPABILITY_FORWARD_RELAXEDRELAY (1 << 6) +#define LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY (1 << 6)/* EVB supported protocols */ -#define LLDP_EVB_CAPABILITY_PROTOCOL_RTE (1 << 3) -#define LLDP_EVB_CAPABILITY_PROTOCOL_ECP (1 << 2) -#define LLDP_EVB_CAPABILITY_PROTOCOL_VDPL (1 << 1) +#define LLDP_EVB_CAPABILITY_PROTOCOL_RTE (1 << 2) +#define LLDP_EVB_CAPABILITY_PROTOCOL_ECP (1 << 1)#define LLDP_EVB_CAPABILITY_PROTOCOL_VDP (1 << 0)/* EVB specific values */
include/lldp_evb_clif.h +2 -3
@@ -34,14 +34,13 @@ int evb_print_tlv(u32, u16, u8 *);#define ARG_EVB_FORWARDING_MODE "fmode" -#define VAL_EVB_FMODE_BRIDGE "bridge" -#define VAL_EVB_FMODE_RELAXEDRELAY "relaxedrelay" +#define VAL_EVB_FMODE_BRIDGE "bridge" +#define VAL_EVB_FMODE_REFLECTIVE_RELAY "reflectiverelay"#define ARG_EVB_CAPABILITIES "capabilities"#define VAL_EVB_CAPA_RTE "rte"#define VAL_EVB_CAPA_ECP "ecp" -#define VAL_EVB_CAPA_VDPL "vdpl"#define VAL_EVB_CAPA_VDP "vdp"#define ARG_EVB_VSIS "vsis"
lldp_evb.c +110 -113
416 lines not on this page · raw message
lldp_evb_clif.c +2 -8
@@ -110,7 +110,7 @@ void evb_print_cfg_tlv(u16 len, char *info)if (!hexstr2bin (info, &smode,sizeof (smode))) {printf ("supported forwarding mode: (0x%02hhx)" , smode); -if (smode &LLDP_EVB_CAPABILITY_FORWARD_RELAXEDRELAY ) +if (smode &LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY )printf (" reflective relay" );if (smode &LLDP_EVB_CAPABILITY_FORWARD_STANDARD )
@@ -130,9 +130,6 @@ void evb_print_cfg_tlv(u16 len, char *info)if ( scap &LLDP_EVB_CAPABILITY_PROTOCOL_ECP )printf (" ECP" ); -if ( scap &LLDP_EVB_CAPABILITY_PROTOCOL_VDPL ) -printf (" VDPL" ); -if ( scap &LLDP_EVB_CAPABILITY_PROTOCOL_VDP )printf (" VDP" );
@@ -144,7 +141,7 @@ void evb_print_cfg_tlv(u16 len, char *info)if (!hexstr2bin (info+4 , &cmode,sizeof (cmode))) {printf ("\tconfigured forwarding mode: (0x%02hhx)" , cmode); -if (cmode &LLDP_EVB_CAPABILITY_FORWARD_RELAXEDRELAY ) +if (cmode &LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY )printf (" reflective relay" );if (cmode &LLDP_EVB_CAPABILITY_FORWARD_STANDARD )
@@ -164,9 +161,6 @@ void evb_print_cfg_tlv(u16 len, char *info)if ( ccap &LLDP_EVB_CAPABILITY_PROTOCOL_ECP )printf (" ECP" ); -if ( ccap &LLDP_EVB_CAPABILITY_PROTOCOL_VDPL ) -printf (" VDPL" ); -if ( ccap &LLDP_EVB_CAPABILITY_PROTOCOL_VDP )printf (" VDP" );
lldp_evb_cmds.c +31 -23
108 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 6/17 BUGFIX: agree to max of rte
In reply to Jens Osterkampaccording to draft, both sides should agree on the maximum value of rte.
--- lldp_evb.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
lldp_evb.c +1 -1
@@ -281,7 +281,7 @@ int evb_check_and_fill(struct evb_data *ed, struct tlv_info_evb *tie)if ((tie->scap &LLDP_EVB_CAPABILITY_PROTOCOL_RTE ) && (ed->tie->scap &LLDP_EVB_CAPABILITY_PROTOCOL_RTE ) && (tie->rte >0 )) - ed->tie->rte =MIN (ed->tie->svsi,tie->rte); + ed->tie->rte =MAX (ed->tie->svsi,tie->rte);if (set_config_tlvinfo_bin (ed->ifname,TLVID_8021Qbg (LLDP_EVB_SUBTYPE ), (void *)ed->tie,sizeof (struct tlv_info_evb ))) {
Signature · 1 line
1.7.1
PATCH 7/17 BUGFIX: avoid compile warnings
In reply to Jens Osterkamp--- include/lldp_evb_clif.h | 2 +- lldp_evb_clif.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
include/lldp_evb_clif.h +1 -1
@@ -28,7 +28,7 @@struct lldp_module *evb_cli_register (void );void evb_cli_unregister (struct lldp_module *); -int evb_print_tlv (u32 ,u16 ,u8 *); +int evb_print_tlv (u32 ,u16 ,char *);#define EVB_BUF_SIZE 256
lldp_evb_clif.c +3 -3
@@ -169,13 +169,13 @@ void evb_print_cfg_tlv(u16 len, char *info)printf ("Unable to decode ccap !\n" ); } -if (!hexstr2bin (info+8 , (u16 *)&svsi,sizeof (svsi))) { +if (!hexstr2bin (info+8 , (u8 *)&svsi,sizeof (svsi))) {printf ("\tno. of supported VSIs: %04i\n" ,svsi); }else {printf ("Unable to decode svsi !\n" ); } -if (!hexstr2bin (info+12 , (u16 *)&cvsi,sizeof (cvsi))) { +if (!hexstr2bin (info+12 , (u8 *)&cvsi,sizeof (cvsi))) {printf ("\tno. of configured VSIs: %04i\n" ,cvsi); }else {printf ("Unable to decode cvsi !\n" );
@@ -193,7 +193,7 @@ void evb_print_cfg_tlv(u16 len, char *info)/* return 1: if it printed the TLV * 0: if it did not */ -int evb_print_tlv (u32 tlvid,u16 len,u8 *info) +int evb_print_tlv (u32 tlvid,u16 len,char *info) {struct type_name_info *tn = &evb_tlv_names[0 ];
Signature · 1 line
1.7.1
PATCH 8/17 BUGFIX: fix formatting in include/lldp_evb_clif.h
In reply to Jens Osterkamp--- include/lldp_evb_clif.h | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
include/lldp_evb_clif.h +4 -4
@@ -30,20 +30,20 @@ struct lldp_module *evb_cli_register(void);void evb_cli_unregister (struct lldp_module *);int evb_print_tlv (u32 ,u16 ,char *); -#define EVB_BUF_SIZE 256 +#define EVB_BUF_SIZE 256 -#define ARG_EVB_FORWARDING_MODE "fmode" +#define ARG_EVB_FORWARDING_MODE "fmode"#define VAL_EVB_FMODE_BRIDGE "bridge"#define VAL_EVB_FMODE_REFLECTIVE_RELAY "reflectiverelay" -#define ARG_EVB_CAPABILITIES "capabilities" +#define ARG_EVB_CAPABILITIES "capabilities"#define VAL_EVB_CAPA_RTE "rte"#define VAL_EVB_CAPA_ECP "ecp"#define VAL_EVB_CAPA_VDP "vdp" -#define ARG_EVB_VSIS "vsis" +#define ARG_EVB_VSIS "vsis"#define ARG_EVB_RTE "rte"
Signature · 1 line
1.7.1
PATCH 9/17 BUGFIX: check for existence of ifup
In reply to Jens Osterkampadded an additional check for existence of the ifup operation. If it does not exist, just skip it.
--- config.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
config.c +4 -2
@@ -370,8 +370,10 @@ void init_ports(void) }else if (check_link_status (p->if_name)) {add_adapter (p->if_name); -LIST_FOREACH (np, &lldp_head, lldp) - np->ops->lldp_mod_ifup(p->if_name); + LIST_FOREACH(np, &lldp_head, lldp) { +if (np->ops->lldp_mod_ifup) + np->ops->lldp_mod_ifup (p->if_name); + }set_lldp_port_enable_state (p->if_name,1 ); } p++;
Signature · 1 line
1.7.1
PATCH 10/17 allow to set both supported forwarding modes
In reply to Jens OsterkampIn the previous version of lldptool, only one setting of either bridge or reflective relay mode was allowed whereas both modes together should be settable.
This patch corrects it.
--- lldp_evb_cmds.c | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-)
lldp_evb_cmds.c +15 -5
@@ -194,6 +194,7 @@ static int get_arg_fmode(struct cmd *cmd, char *arg, char *argvalue,static int set_arg_fmode (struct cmd *cmd,char *arg,char *argvalue,char *obuf) { +u8 smode;char arg_path[EVB_BUF_SIZE ];struct evb_data *ed;
@@ -214,12 +215,21 @@ static int set_arg_fmode(struct cmd *cmd, char *arg, char *argvalue,if (!ed)return cmd_invalid; -if (!strcasecmp (argvalue,VAL_EVB_FMODE_BRIDGE )) - ed->tie->smode =LLDP_EVB_CAPABILITY_FORWARD_STANDARD ; -else if (!strcasecmp (argvalue,VAL_EVB_FMODE_REFLECTIVE_RELAY )) - ed->tie->smode =LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY ; -else + smode =0 ; + +if (strcasestr (argvalue,VAL_EVB_FMODE_BRIDGE )) { + smode |=LLDP_EVB_CAPABILITY_FORWARD_STANDARD ; + } + +if (strcasestr (argvalue,VAL_EVB_FMODE_REFLECTIVE_RELAY )) { + smode |=LLDP_EVB_CAPABILITY_FORWARD_REFLECTIVE_RELAY ; + } + +if (smode ==0 ) {return cmd_invalid; + }else { + ed->tie->smode = smode; + }evb_changed (cmd->ifname);
Signature · 1 line
1.7.1
PATCH 11/17 ECP implementation
In reply to Jens OsterkampThis 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
@@ -56,6 +56,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
@@ -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
@@ -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
@@ -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
@@ -354,6 +354,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
Re: [E1000-eedc] [PATCH 11/17] ECP implementation
Quoted 33 lines · Jens Osterkamp
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.Signed-off-by Jens Osterkamp <[email protected]>--- 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
snip
Quoted 58 lines
include/lldp_vdp.h new file +34
-0+ +struct vdp_user_data { + LIST_HEAD(vdp_head, vdp_data) head; +}; + +struct lldp_module *vdp_register (void ); +void vdp_unregister (struct lldp_module *mod); +struct vdp_data *vdp_data (char *ifname); +struct packed_tlv *vdp_gettlv (struct port *port,struct vsi_profile *profile); +void vdp_vsi_sm_station (struct vsi_profile *profile); +struct vsi_profile *vdp_add_profile (struct vsi_profile *profile); + +#define MAC_ADDR_STRLEN 18 +#define INSTANCE_STRLEN 32 + +#define PRINT_PROFILE (s, p) \ +{ int c; \ + c = sprintf(s, "\nmode: %i\n", p->mode); s += c; \ + c = sprintf(s, "response: %i\n", p->response); s += c; \ + c = sprintf(s, "state: %i\n", p->state); s += c; \ + c = sprintf(s, "mgrid: %i\n", p->mgrid); s += c; \ + c = sprintf(s, "id: %x%x%x\n", p->id[2], p->id[1], p->id[0]); \ + s += c; \ + c = sprintf(s, "version: %i\n", p->version); s += c; \ + char instance[INSTANCE_STRLEN+2]; \ + instance2str(p->instance, instance, sizeof(instance)); \ + c = sprintf(s, "instance: %s\n", &instance); s += c; \ + char macbuf[MAC_ADDR_STRLEN+1]; \ + mac2str(p->mac, macbuf, MAC_ADDR_STRLEN); \ + c = sprintf(s, "mac: %s\n", macbuf); s += c; \ + c = sprintf(s, "vlan: %i\n\n", p->vlan); s += c; \ +} + +#endif /* _LLDP_VDP_H */ lldp/l2_packet.h +2
-0@@ -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 1514lldp/ports.h +3
-0@@ -136,21 +136,40 @@ struct porttlvs{struct unpacked_tlv *last_peer; }; +struct ecp { +struct l2_packet_data *l2; +int sequence;
lldp/ports.h struct porttlvs{ · line 151
Quoted 10 lines
lldp/ports.h +10
-0+int retries; +int ackReceived; +int ackTimerExpired; +u16 lastSequence; +u16 seqECPDU; +struct portrx rx; +struct porttx tx; +struct portstats stats; +}; +
This structure is ecp specific and should be part of the ecp module. Not in ports.h.
Quoted 17 lines
lldp/ports.h +3
-3struct 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;
lldp/ports.h struct porttlvs{ · line 175
Quoted 10 lines
lldp/ports.h +6
-0+u16 lldpdu;struct msap msap; + +/* not sure */ +struct porttlvs tlvs; + +struct ecp ecp;struct port *next; };
This adds ecp knowledge into the generic port structure I want to keep the port structure module agnostic. dcbx addresses the same issue by using the module data space. evb should use a similar scheme and create this structure at ifup(). Any reason why this can't work?
Quoted 27 lines
lldp_evb.c +2
-1@@ -354,6 +354,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" ); --1.7.1
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
E1000-eedc mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-eedc
Re: [E1000-eedc] [PATCH 11/17] ECP implementation
Quoted 101 lines · John Fastabend
Quoted 33 lines · Jens Osterkamp
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.Signed-off-by Jens Osterkamp <[email protected]>--- 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.hsnip
Quoted 64 lines
include/lldp_vdp.h new file +34
-0+ +struct vdp_user_data { + LIST_HEAD(vdp_head, vdp_data) head; +}; + +struct lldp_module *vdp_register (void ); +void vdp_unregister (struct lldp_module *mod); +struct vdp_data *vdp_data (char *ifname); +struct packed_tlv *vdp_gettlv (struct port *port,struct vsi_profile *profile); +void vdp_vsi_sm_station (struct vsi_profile *profile); +struct vsi_profile *vdp_add_profile (struct vsi_profile *profile); + +#define MAC_ADDR_STRLEN 18 +#define INSTANCE_STRLEN 32 + +#define PRINT_PROFILE (s, p) \ +{ int c; \ + c = sprintf(s, "\nmode: %i\n", p->mode); s += c; \ + c = sprintf(s, "response: %i\n", p->response); s += c; \ + c = sprintf(s, "state: %i\n", p->state); s += c; \ + c = sprintf(s, "mgrid: %i\n", p->mgrid); s += c; \ + c = sprintf(s, "id: %x%x%x\n", p->id[2], p->id[1], p->id[0]); \ + s += c; \ + c = sprintf(s, "version: %i\n", p->version); s += c; \ + char instance[INSTANCE_STRLEN+2]; \ + instance2str(p->instance, instance, sizeof(instance)); \ + c = sprintf(s, "instance: %s\n", &instance); s += c; \ + char macbuf[MAC_ADDR_STRLEN+1]; \ + mac2str(p->mac, macbuf, MAC_ADDR_STRLEN); \ + c = sprintf(s, "mac: %s\n", macbuf); s += c; \ + c = sprintf(s, "vlan: %i\n\n", p->vlan); s += c; \ +} + +#endif /* _LLDP_VDP_H */ lldp/l2_packet.h +2
-0@@ -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 1514lldp/ports.h +9
-0@@ -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;
Quoted 8 lines
lldp/ports.h struct porttlvs{ · line 151
Quoted 4 lines
lldp/ports.h +4
-0+struct porttx tx; +struct portstats stats; +}; +This structure is ecp specific and should be part of the ecp module. Not in
ports.h.
Right, I will move it.
Quoted 25 lines
Quoted 25 lines
lldp/ports.h +9
-3struct 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;
Quoted 8 lines
lldp/ports.h struct porttlvs{ · line 175
Quoted 3 lines
lldp/ports.h +0
-0struct port *next; };This adds ecp knowledge into the generic port structure I want to keep the port structure module agnostic. dcbx addresses the same issue by using the module data space. evb should use a similar scheme and create this structure at
ifup(). Any reason why this can't work?
I will look into it and check if I can move it as well.
Quoted 30 lines
Quoted 28 lines
lldp_evb.c +2
-1@@ -354,6 +354,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" ); --1.7.1
------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
E1000-eedc mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/e1000-eedc
Signature · 9 lines
Best regards, Jens Osterkamp -------------------------------------------------------------------------------- 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
PATCH 12/17 implementation of vdp
In reply to Jens OsterkampThis 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
@@ -69,16 +69,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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH 13/17 VDP commandline interface
In reply to Jens OsterkampThis 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
@@ -37,7 +37,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 \
@@ -47,7 +48,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 \
@@ -64,20 +65,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
@@ -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
@@ -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
PATCH 14/17 add libnl dependency to configure.ac
In reply to Jens Osterkamp--- configure.ac | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
configure.ac +5 -0
@@ -12,6 +12,11 @@ PKG_CHECK_MODULES(LIBCONFIG, libconfig, AC_SUBST(LIBCONFIG_CFLAGS) AC_SUBST(LIBCONFIG_LIBS) +PKG_CHECK_MODULES(LIBNL, libnl-1 >= 1.1) +AC_SUBST(LIBNL_CFLAGS) +AC_SUBST(LIBNL_LIBS) + +AC_CHECK_LIB(nl, rtnl_link_get_by_name) AC_CONFIG_SUBDIRS([libconfig-1.3.2]) AC_CONFIG_FILES([Makefile include/version.h lldpad.spec lldpad.pc dcbd.pc]) AC_OUTPUT
Signature · 1 line
1.7.1
PATCH 15/17 use connect instead of bind
In reply to Jens Osterkampmodifies 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.
--- drv_cfg.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drv_cfg.c +3 -2
@@ -71,9 +71,9 @@ static int init_socket(void)memset ((void *)&snl,0 ,sizeof (struct sockaddr_nl )); snl.nl_family =AF_NETLINK ; - snl.nl_pid =getpid (); + snl.nl_pid =0 ; -if (bind (sd, (struct sockaddr *)&snl,sizeof (struct sockaddr_nl )) <0 ) { +if (connect (sd, (struct sockaddr *)&snl,sizeof (struct sockaddr_nl )) <0 ) {close (sd);return -EIO ; }
@@ -195,6 +195,7 @@ static struct nlmsghdr *get_msg(unsigned int seq) nlh =NULL ;break ; } +fprintf (stderr,"%s:%s: nlmsg_type: %d\n" , __FILE__, __FUNCTION__, nlh->nlmsg_type);if ((nlh->nlmsg_type ==RTM_GETDCB || nlh->nlmsg_type ==RTM_SETDCB ) && nlh->nlmsg_seq == seq) {
Signature · 1 line
1.7.1
PATCH 16/17 lldpad support for libvirt netlink message
In reply to Jens OsterkampThis 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.
--- event_iface.c | 617 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- lldp_vdp.c | 2 +- lldpad.c | 10 + 3 files changed, 622 insertions(+), 7 deletions(-)
event_iface.c +611 -6
@@ -3,6 +3,13 @@ LLDP Agent Daemon (LLDPAD) Software Copyright(c) 2007-2010 Intel Corporation. + implementation of libvirt netlink interface + (c) Copyright IBM Corp. 2010 + + Author(s): Jens Osterkamp <[email protected]> + Stefan Berger <[email protected]> + Gerhard Stenzel <[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.
@@ -31,12 +38,16 @@#include <sys/socket.h> #include <linux/rtnetlink.h> #include <linux/if.h> +#include <linux/if_link.h> #include <linux/if_vlan.h> #include <linux/sockios.h> #include <syslog.h> #include <unistd.h> +#include <linux/netlink.h> +#include <netlink/msg.h> #include "lldpad.h" #include "lldp_mod.h" +#include "lldp_vdp.h" #include "common.h" #include "eloop.h" #include "drv_cfg.h"
@@ -55,6 +66,39 @@ static void event_if_decode_rta(int type, struct rtattr *rta);static char *device_name =NULL ;static int link_status =0 ; +static struct nla_policy ifla_policy[IFLA_MAX +1 ] = +{ + [IFLA_VFINFO_LIST ] = { .type =NLA_NESTED }, + [IFLA_IFNAME ] = { .type =NLA_STRING }, + [IFLA_VF_PORTS ] = { .type =NLA_NESTED }, +}; + +static struct nla_policy ifla_vf_policy[IFLA_VF_MAX +1 ] = +{ + [IFLA_VF_MAC ] = { .minlen =sizeof (struct ifla_vf_mac ), + .maxlen =sizeof (struct ifla_vf_mac )}, + [IFLA_VF_VLAN ] = { .minlen =sizeof (struct ifla_vf_vlan ), + .maxlen =sizeof (struct ifla_vf_vlan )}, +}; + +static struct nla_policy ifla_vf_ports_policy[IFLA_VF_PORT_MAX +1 ] = +{ + [IFLA_VF_PORT ] = { .type =NLA_NESTED }, +}; + +static struct nla_policy ifla_port_policy[IFLA_PORT_MAX +1 ] = +{ + [IFLA_PORT_VF ] = { .type =NLA_U32 }, + [IFLA_PORT_PROFILE ] = { .type =NLA_STRING }, + [IFLA_PORT_VSI_TYPE ] = { .minlen =sizeof (struct ifla_port_vsi ) }, + [IFLA_PORT_INSTANCE_UUID ] = { .minlen =PORT_UUID_MAX , + .maxlen =PORT_UUID_MAX , }, + [IFLA_PORT_HOST_UUID ] = { .minlen =PORT_UUID_MAX , + .maxlen =PORT_UUID_MAX , }, + [IFLA_PORT_REQUEST ] = { .type =NLA_U8 }, + [IFLA_PORT_RESPONSE ] = { .type =NLA_U16 }, +}; +static void event_if_decode_rta (int type,struct rtattr *rta) {
@@ -220,15 +264,537 @@ static void event_if_decode_nlmsg(int route_type, void *data, int len) } } -static void event_if_process_recvmsg (struct nlmsghdr *nlmsg) {/* print out details */ +fprintf (stderr,"%s:%s: nlmsg_type: %d\n" , __FILE__, __FUNCTION__, nlmsg->nlmsg_type);event_if_decode_nlmsg (nlmsg->nlmsg_type,NLMSG_DATA (nlmsg),NLMSG_PAYLOAD (nlmsg,0 )); } +static int event_if_parse_getmsg (struct nlmsghdr *nlh,int *ifindex, +char *ifname) +{ +struct nlattr *tb[IFLA_MAX +1 ]; +struct ifinfomsg *ifinfo; + +fprintf (stderr,"%s:%s:%d\n" , __FILE__, __FUNCTION__, __LINE__); + +if (nlmsg_parse (nlh,sizeof (struct ifinfomsg ), + (struct nlattr **)&tb,IFLA_MAX ,NULL )) { +fprintf (stderr,"Error parsing request...\n" ); +return -EINVAL ; + } + +if (tb[IFLA_IFNAME ]) { + ifname = (char *)RTA_DATA (tb[IFLA_IFNAME ]); +fprintf (stderr,"IFLA_IFNAME=%s\n" , ifname); + }else { + ifinfo = (struct ifinfomsg *)NLMSG_DATA (nlh); + *ifindex = ifinfo->ifi_index; +fprintf (stderr,"interface index: %d\n" , ifinfo->ifi_index); + } + +return 0 ; +} + +static int event_if_parse_setmsg (struct nlmsghdr *nlh) +{ +struct nlattr *tb[IFLA_MAX +1 ], + *tb2[IFLA_VF_PORT_MAX +1 ], + *tb3[IFLA_PORT_MAX +1 ], + *tb_vfinfo[IFLA_VF_MAX +1 ], + *tb_vfinfo_list; +struct vsi_profile *profile, *p; +struct ifinfomsg *ifinfo; +char *ifname; +int rem; + +fprintf (stderr,"%s:%s:%d\n" , __FILE__, __FUNCTION__, __LINE__); + + profile =malloc (sizeof (struct vsi_profile )); +if (!profile) +return -ENOMEM ; +memset (profile,0 ,sizeof (struct vsi_profile )); + +if (nlmsg_parse (nlh,sizeof (struct ifinfomsg ), + (struct nlattr **)&tb,IFLA_MAX ,NULL )) { +fprintf (stderr,"Error parsing request...\n" ); +return -EINVAL ; + } + +fprintf (stderr,"%s(%d): nlmsg_len %i\n" , __FILE__, __LINE__, nlh->nlmsg_len); + +if (tb[IFLA_IFNAME ]) { + ifname = (char *)RTA_DATA (tb[IFLA_IFNAME ]); +fprintf (stderr,"IFLA_IFNAME=%s\n" , ifname); + }else { + ifinfo = (struct ifinfomsg *)NLMSG_DATA (nlh); +fprintf (stderr,"interface index: %d\n" , ifinfo->ifi_index); + } + +fprintf (stderr,"%s:%s:%d\n" , __FILE__, __FUNCTION__, __LINE__); + +if (!tb[IFLA_VFINFO_LIST ]) { +fprintf (stderr,"IFLA_VFINFO_LIST missing.\n" ); +return -EINVAL ; + }else { +fprintf (stderr,"FOUND IFLA_VFINFO_LIST!\n" ); + } + +nla_for_each_nested (tb_vfinfo_list, tb[IFLA_VFINFO_LIST ], rem) { +if (nla_type (tb_vfinfo_list) !=IFLA_VF_INFO ) { +fprintf (stderr,"nested parsing of IFLA_VFINFO_LIST failed.\n" ); +return -EINVAL ; + } + +if (nla_parse_nested (tb_vfinfo,IFLA_VF_MAX , tb_vfinfo_list, + ifla_vf_policy)) { +fprintf (stderr,"nested parsing of IFLA_VF_INFO failed.\n" ); +return -EINVAL ; + } + } + +if (tb_vfinfo[IFLA_VF_MAC ]) { +struct ifla_vf_mac *mac =RTA_DATA (tb_vfinfo[IFLA_VF_MAC ]); +u8 *m = mac->mac; +fprintf (stderr,"IFLA_VF_MAC=%2x:%2x:%2x:%2x:%2x:%2x\n" , + m[0 ], m[1 ], m[2 ], m[3 ], m[4 ], m[5 ]); +memcpy (&profile->mac, m,ETH_ALEN ); + } + +if (tb_vfinfo[IFLA_VF_VLAN ]) { +struct ifla_vf_vlan *vlan =RTA_DATA (tb_vfinfo[IFLA_VF_VLAN ]); +fprintf (stderr,"IFLA_VF_VLAN=%d\n" , vlan->vlan); + profile->vlan = (u16 ) vlan->vlan; + } + +if (tb[IFLA_VF_PORTS ]) { +struct nlattr *tb_vf_ports; + +fprintf (stderr,"FOUND IFLA_VF_PORTS\n" ); + +nla_for_each_nested (tb_vf_ports, tb[IFLA_VF_PORTS ], rem) { + +fprintf (stderr,"ITERATING\n" ); + +if (nla_type (tb_vf_ports) !=IFLA_VF_PORT ) { +fprintf (stderr,"not a IFLA_VF_PORT. skipping\n" ); +continue ; + } + +if (nla_parse_nested (tb3,IFLA_PORT_MAX , tb_vf_ports, + ifla_port_policy)) { +fprintf (stderr,"nested parsing on level 2 failed.\n" ); +return -EINVAL ; + } + +fprintf (stderr,"%s:%s:%d\n" , __FILE__, __FUNCTION__, __LINE__); + +if (tb3[IFLA_PORT_VF ]) { +fprintf (stderr,"IFLA_PORT_VF=%d\n" , *(uint32_t *)(RTA_DATA (tb3[IFLA_PORT_VF ]))); + } + +if (tb3[IFLA_PORT_PROFILE ]) { +fprintf (stderr,"IFLA_PORT_PROFILE=%s\n" , (char *)RTA_DATA (tb3[IFLA_PORT_PROFILE ])); + } + +if (tb3[IFLA_PORT_VSI_TYPE ]) { +struct ifla_port_vsi *pvsi; +int tid =0 ; + + pvsi = (struct ifla_port_vsi *)RTA_DATA (tb3[IFLA_PORT_VSI_TYPE ]); + tid = pvsi->vsi_type_id[2 ] <<16 | + pvsi->vsi_type_id[1 ] <<8 | + pvsi->vsi_type_id[0 ]; +fprintf (stderr,"mgr_id : %d\n" +"type_id : %d\n" +"type_version : %d\n" , + pvsi->vsi_mgr_id, + tid, + pvsi->vsi_type_version); + + profile->mgrid = pvsi->vsi_mgr_id; +memcpy (profile->id, pvsi->vsi_type_id,3 ); + profile->version = pvsi->vsi_type_version; + } + +if (tb3[IFLA_PORT_INSTANCE_UUID ]) { +int i; +unsigned char *uuid; + uuid = (unsigned char *)RTA_DATA (tb3[IFLA_PORT_INSTANCE_UUID ]); +fprintf (stderr,"IFLA_PORT_INSTANCE_UUID=" ); + +for (i =0 ; i <16 ; i++) { +fprintf (stderr,"%x" ,uuid[i]); + } + +fprintf (stderr,"\n" ); + +memcpy (&profile->instance, +RTA_DATA (tb3[IFLA_PORT_INSTANCE_UUID ]),16 ); + } + +if (tb3[IFLA_PORT_REQUEST ]) { +fprintf (stderr,"IFLA_PORT_REQUEST=%d\n" , + *(uint8_t *)RTA_DATA (tb3[IFLA_PORT_REQUEST ])); + profile->mode = *(uint8_t *)RTA_DATA (tb3[IFLA_PORT_REQUEST ]); + } + +if (tb3[IFLA_PORT_RESPONSE ]) { +fprintf (stderr,"IFLA_PORT_RESPONSE=%d\n" , + *(uint16_t *)RTA_DATA (tb3[IFLA_PORT_RESPONSE ])); + profile->response = *(uint16_t *)RTA_DATA (tb3[IFLA_PORT_RESPONSE ]); + } + } + } + +if (ifname) { +struct port *port =port_find_by_name (ifname); + +if (port) { + profile->port = port; + }else { +printf ("%s(%i): Could not find port for %s\n" , __func__, + __LINE__, ifname); +return -EEXIST ; + } + } + + p =vdp_add_profile (profile); + +if (!p) { +free (profile); +return -EINVAL ; + } + +vdp_somethingChangedLocal (profile,VDP_PROFILE_REQ ); +vdp_vsi_sm_station (p); + +return 0 ; +} + +static void event_if_parseResponseMsg (struct nlmsghdr *nlh) +{ +struct nlattr *tb[IFLA_MAX +1 ], + *tb2[IFLA_VF_PORT_MAX +1 ], + *tb3[IFLA_PORT_MAX +1 ], + *tb_vfinfo[IFLA_VF_MAX +1 ], + *tb_vfinfo_list; + +int rem; + +fprintf (stderr,"%s:%s:%d\n" , __FILE__, __FUNCTION__, __LINE__); + +if (nlmsg_parse (nlh,sizeof (struct ifinfomsg ), + (struct nlattr **)&tb,IFLA_MAX ,NULL )) { +fprintf (stderr,"Error parsing response...\n" ); +return ; + } + +if (tb[IFLA_IFNAME ]) { +fprintf (stderr,"IFLA_IFNAME=%s\n" , (char *)RTA_DATA (tb[IFLA_IFNAME ])); + }else { +struct ifinfomsg *ifinfo = (struct ifinfomsg *)NLMSG_DATA (nlh); +fprintf (stderr,"interface index: %d\n" , ifinfo->ifi_index); + } + +if (tb[IFLA_VF_PORTS ]) { +if (nla_parse_nested (tb2,IFLA_VF_PORT_MAX , tb[IFLA_VF_PORTS ], + ifla_vf_ports_policy)) { +fprintf (stderr,"nested parsing on level 1 failed.\n" ); +return ; + } + +if (tb2[IFLA_VF_PORT ]) { +if (nla_parse_nested (tb3,IFLA_PORT_MAX , tb2[IFLA_VF_PORT ], + ifla_port_policy)) { +fprintf (stderr,"nested parsing on level 2 failed.\n" ); +return ; + } + +if (tb3[IFLA_PORT_VF ]) { +fprintf (stderr,"IFLA_PORT_VF=%d\n" , *(uint32_t *)(RTA_DATA (tb3[IFLA_PORT_VF ]))); + } + +if (tb3[IFLA_PORT_PROFILE ]) { +fprintf (stderr,"IFLA_PORT_PROFILE=%s\n" , (char *)RTA_DATA (tb3[IFLA_PORT_PROFILE ])); + } + +if (tb3[IFLA_PORT_VSI_TYPE ]) { +struct ifla_port_vsi *pvsi; +int tid =0 ; + pvsi = (struct ifla_port_vsi *)RTA_DATA (tb3[IFLA_PORT_VSI_TYPE ]); + tid = pvsi->vsi_type_id[2 ] <<16 | + pvsi->vsi_type_id[1 ] <<8 | + pvsi->vsi_type_id[0 ]; +fprintf (stderr,"mgr_id : %d\n" +"type_id : %d\n" +"type_version : %d\n" , + pvsi->vsi_mgr_id, + tid, + pvsi->vsi_type_version); + } + +if (tb3[IFLA_PORT_INSTANCE_UUID ]) { +int i; +unsigned char *uuid; + uuid = (unsigned char *)RTA_DATA (tb3[IFLA_PORT_INSTANCE_UUID ]); + +fprintf (stderr,"IFLA_PORT_INSTANCE_UUID=" ); + +for (i =0 ; i <16 ; i++) { +fprintf (stderr,"%x" ,uuid[i]); + } + +fprintf (stderr,"\n" ); + } + +if (tb3[IFLA_PORT_REQUEST ]) { +fprintf (stderr,"IFLA_PORT_REQUEST=%d\n" , + *(uint8_t *)RTA_DATA (tb3[IFLA_PORT_REQUEST ])); + } + +if (tb3[IFLA_PORT_RESPONSE ]) { +fprintf (stderr,"IFLA_PORT_RESPONSE=%d\n" , + *(uint16_t *)RTA_DATA (tb3[IFLA_PORT_RESPONSE ])); + } + } + } +} + +struct nl_msg *event_if_constructResponse (struct nlmsghdr *nlh,int ifindex) +{ +struct nl_msg *nl_msg; +struct nlattr *vf_ports =NULL , *vf_port; +struct ifinfomsg ifinfo; +struct vdp_data *vd; +uint32_t pid = nlh->nlmsg_pid; +uint32_t seq = nlh->nlmsg_seq; +char *ifname =malloc (IFNAMSIZ ); +struct vsi_profile *p; + +fprintf (stderr,"%s:%s:%d\n" , __FILE__, __FUNCTION__, __LINE__); + + nl_msg =nlmsg_alloc (); + +if (!nl_msg) { +printf ("%s(%i): Unable to allocate netlink message !\n" , __func__, __LINE__); +return NULL ; + } + +if (!if_indextoname (ifindex, ifname)) { +printf ("%s(%i): No name found for interface with index %i !\n" , __func__, __LINE__, + ifindex); + } + + vd =vdp_data (ifname); +if (!vd) { +printf ("%s(%i): Could not find vdp_data for %i !\n" , __func__, __LINE__, + ifname); +return NULL ; + } + +if (nlmsg_put (nl_msg, pid, seq,NLMSG_DONE ,0 ,0 ) ==NULL ) + goto err_exit; + + ifinfo.ifi_index = ifindex; + +if (nlmsg_append (nl_msg, &ifinfo,sizeof (ifinfo),NLMSG_ALIGNTO ) <0 ) + goto err_exit; + + vf_ports =nla_nest_start (nl_msg,IFLA_VF_PORTS ); + +if (!vf_ports) + goto err_exit; + +/* loop over all existing profiles on this interface and +* put them into the nested IFLA_VF_PORT structure */ + LIST_FOREACH(p, &vd->profile_head, profile) { +if (p) { +vdp_print_profile (p); + + vf_port =nla_nest_start (nl_msg,IFLA_VF_PORT ); + +if (!vf_port) + goto err_exit; + +if (nla_put (nl_msg,IFLA_PORT_INSTANCE_UUID ,16 , p->instance) <0 ) + goto err_exit; + +if (nla_put_u32 (nl_msg,IFLA_PORT_VF ,PORT_SELF_VF ) <0 ) + goto err_exit; + +/* +if (nla_put_u16(nl_msg, IFLA_PORT_RESPONSE, p->response) < 0) +goto err_exit; +*/ + +if (nla_put_u16 (nl_msg,IFLA_PORT_RESPONSE ,PORT_VDP_RESPONSE_SUCCESS ) <0 ) + goto err_exit; + +nla_nest_end (nl_msg, vf_port); + } + } + +if (vf_ports) +nla_nest_end (nl_msg, vf_ports); + +return nl_msg; + +err_exit: +nlmsg_free (nl_msg); + +return NULL ; +} + +struct nl_msg *event_if_simpleResponse (uint32_t pid,uint32_t seq,int err) +{ +struct nl_msg *nl_msg =nlmsg_alloc (); +struct nlmsgerr nlmsgerr; + +memset (&nlmsgerr,0x0 ,sizeof (nlmsgerr)); + + nlmsgerr.error = err; +fprintf (stderr,"RESPONSE ERROR CODE: %d\n" ,err); + +if (nlmsg_put (nl_msg, pid, seq,NLMSG_ERROR ,0 ,0 ) ==NULL ) + goto err_exit; + +if (nlmsg_append (nl_msg, &nlmsgerr,sizeof (nlmsgerr),NLMSG_ALIGNTO ) <0 ) + goto err_exit; + +return nl_msg; + +err_exit: +nlmsg_free (nl_msg); + +return NULL ; +} + +static void event_iface_receive_user_space (int sock,void *eloop_ctx,void *sock_ctx) +{ +struct nlmsghdr *nlh; +struct nl_msg *nl_msg; +struct msghdr msg; +struct sockaddr_nl dest_addr; +char buf[MAX_MSG_SIZE ]; +socklen_t fromlen =sizeof (dest_addr); +struct iovec iov; +int result; +int err; +int ifindex; +char *ifname =NULL ; + + nlh = (struct nlmsghdr *)calloc (1 , +NLMSG_SPACE (MAX_PAYLOAD )); +if (!nlh) { +printf ("%s(%i): could not allocate nlh !\n" , __func__, + __LINE__); +return ; + } +memset (nlh,0 ,NLMSG_SPACE (MAX_PAYLOAD )); + +memset (&dest_addr,0 ,sizeof (dest_addr)); + iov.iov_base = (void *)nlh; + iov.iov_len =NLMSG_SPACE (MAX_PAYLOAD ); + msg.msg_name = (void *)&dest_addr; + msg.msg_namelen =sizeof (dest_addr); + msg.msg_iov = &iov; + msg.msg_iovlen =1 ; + msg.msg_control =NULL ; + msg.msg_controllen =0 ; + msg.msg_flags =0 ; + +fprintf (stderr,"Waiting for message \n" ); + result =recvmsg (sock, &msg,MSG_DONTWAIT ); + +fprintf (stderr,"%s:%s: recvmsg received %d bytes\n" , __FILE__, __FUNCTION__, result); + +if (result <0 ) { +fprintf (stderr,"Error receiving from netlink socket : %s\n" ,strerror (errno)); + } + +fprintf (stderr,"%s:%s: dest_addr.nl_pid: %d\n" , __FILE__, __FUNCTION__, dest_addr.nl_pid); +fprintf (stderr,"%s:%s: nlh.nl_pid: %d\n" , __FILE__, __FUNCTION__, nlh->nlmsg_pid); +fprintf (stderr,"%s:%s: nlh_type: %d\n" , __FILE__, __FUNCTION__, nlh->nlmsg_type); +fprintf (stderr,"%s:%s: nlh_seq: 0x%x\n" , __FILE__, __FUNCTION__, nlh->nlmsg_seq); +fprintf (stderr,"%s:%s: nlh_len: 0x%x\n" , __FILE__, __FUNCTION__, nlh->nlmsg_len); + +switch (nlh->nlmsg_type) { +case RTM_SETLINK : +fprintf (stderr,"--> RTM_SETLINK\n" ); + + err =event_if_parse_setmsg (nlh); + +/* send simple response wether profile was accepted +* or not */ + nl_msg =event_if_simpleResponse (nlh->nlmsg_pid, + nlh->nlmsg_seq, + err); + nlh =nlmsg_hdr (nl_msg); +break ; +case RTM_GETLINK : +fprintf (stderr,"--> RTM_GETLINK\n" ); + + err =event_if_parse_getmsg (nlh, &ifindex, ifname); + +if (err) { + nl_msg =event_if_simpleResponse (nlh->nlmsg_pid, + nlh->nlmsg_seq, + err); + }else if (ifname) { + ifindex =if_nametoindex (ifname); +printf ("%s(%i): ifname %s (%d)\n" , __func__, + __LINE__, ifname, ifindex); + }else { + ifname =malloc (IFNAMSIZ ); +printf ("%s(%i): ifindex %i\n" , __func__, + __LINE__, ifindex); +printf ("%s(%i): ifname %s\n" , __func__, + __LINE__,if_indextoname (ifindex, ifname)); + } + + nl_msg =event_if_constructResponse (nlh, ifindex); + +if (!nl_msg) { +printf ("%s(%i): Unable to construct response !\n" , + __func__, __LINE__); + goto out_err; + } + + nlh =nlmsg_hdr (nl_msg); + +fprintf (stderr,"------------\nRESPONSE:\n" ); + +event_if_parseResponseMsg (nlh); + +fprintf (stderr,"------------\n" ); +break ; + } + + iov.iov_base = (void *)nlh; + iov.iov_len = nlh->nlmsg_len; + + msg.msg_name = (void *)&dest_addr; + msg.msg_namelen =sizeof (dest_addr); + msg.msg_iov = &iov; + msg.msg_iovlen =1 ; + + result =sendmsg (sock, &msg,0 ); + +if (result <0 ) { +fprintf (stderr,"Error sending on netlink socket : %s\n" ,strerror (errno)); + }else { +fprintf (stderr,"sent %zd bytes!\n" ,result); + } + +out_err: +free (nlh); +nlmsg_free (nl_msg); +} +static void event_iface_receive (int sock,void *eloop_ctx,void *sock_ctx) {struct nlmsghdr *nlh;
@@ -236,10 +802,11 @@ static void event_iface_receive(int sock, void *eloop_ctx, void *sock_ctx)char buf[MAX_MSG_SIZE ];socklen_t fromlen =sizeof (dest_addr);int result; - + result =recvfrom (sock, buf,sizeof (buf),MSG_DONTWAIT , (struct sockaddr *) &dest_addr, &fromlen); +fprintf (stderr,"%s:%s: result: %d\n" , __FILE__, __FUNCTION__, result);if (result <0 ) {perror ("recvfrom(Event interface)" );if ((errno ==ENOBUFS ) || (errno ==EAGAIN ))
@@ -250,10 +817,14 @@ static void event_iface_receive(int sock, void *eloop_ctx, void *sock_ctx)TRACE ("PRINT BUF info.\n" ) - device_name =NULL ; - link_status =IF_OPER_UNKNOWN ; - nlh = (struct nlmsghdr *)buf; -event_if_process_recvmsg (nlh); + /* Separate handler for kernel messages from userspace messages*/ +fprintf (stderr,"%s:%s: dest_addr.nl_pid: %d\n" , __FILE__, __FUNCTION__, dest_addr.nl_pid); +if (dest_addr.nl_pid ==0 ) { + device_name =NULL ; + link_status =IF_OPER_UNKNOWN ; + nlh = (struct nlmsghdr *)buf; +event_if_process_recvmsg (nlh); + } }int event_iface_init ()
@@ -262,6 +833,7 @@ int event_iface_init()int rcv_size =MAX_MSG_SIZE ;struct sockaddr_nl snl; +fprintf (stderr,"%s:%s:%d\n" , __FILE__, __FUNCTION__, __LINE__); fd =socket (PF_NETLINK ,SOCK_RAW ,NETLINK_ROUTE );if (fd <0 )
@@ -282,6 +854,39 @@ int event_iface_init() }eloop_register_read_sock (fd, event_iface_receive,NULL ,NULL ); +// event_iface_init2(); +return 0 ; +} + +int event_iface_init_user_space () +{ +int fd; +int rcv_size =MAX_MSG_SIZE ; +struct sockaddr_nl snl; + +fprintf (stderr,"%s:%s:%d\n" , __FILE__, __FUNCTION__, __LINE__); + fd =socket (PF_NETLINK ,SOCK_RAW ,NETLINK_ROUTE ); + +if (fd <0 ) +return fd; + +if (setsockopt (fd,SOL_SOCKET ,SO_RCVBUF , &rcv_size,sizeof (int )) <0 ) { +close (fd); +return -EIO ; + } + +memset ((void *)&snl,0 ,sizeof (struct sockaddr_nl )); + snl.nl_family =AF_NETLINK ; + snl.nl_pid =getpid ();/* self pid */ + snl.nl_groups =0 ; + +if (bind (fd, (struct sockaddr *)&snl,sizeof (struct sockaddr_nl )) <0 ) { +close (fd); +fprintf (stderr,"Error binding to netlink socket : %s\n" ,strerror (errno)); +return -EIO ; + } + +eloop_register_read_sock (fd, event_iface_receive_user_space,NULL ,NULL );return 0 ; }
lldp_vdp.c +1 -1
@@ -104,7 +104,7 @@ static void vdp_free_data(struct vdp_user_data *ud)* prints the contents of a profile first to a string using the PRINT_PROFILE * macro, and then to the screen. Used for debug purposes. */ -static inline void vdp_print_profile (struct vsi_profile *profile) +void vdp_print_profile (struct vsi_profile *profile) {char *s, *t;
lldpad.c +10 -0
@@ -374,6 +374,16 @@ int main(int argc, char *argv[])exit (1 ); } +/* setup event netlink interface for user space processes. +* This needs to be setup first to ensure it gets lldpads +* pid as netlink address. +*/ +if (event_iface_init_user_space () <0 ) { +log_message (MSG_ERR_SERVICE_START_FAILURE , +"%s" ,"failed to register user space event interface" ); +exit (1 ); + } +init_modules ("" );
Signature · 1 line
1.7.1
Re: [E1000-eedc] [PATCH 16/17] lldpad support for libvirt netlink message
Quoted 7 lines · Jens Osterkamp
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.
Quoted 9 lines
Signed-off-by Jens Osterkamp <[email protected]>Signed-off-by Gerhard Stenzel <[email protected]>Signed-off-by Stefan Berger <[email protected]>--- event_iface.c | 617 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- lldp_vdp.c | 2 +- lldpad.c | 10 + 3 files changed, 622 insertions(+), 7 deletions(-)
Jens,
Can you explain why this interface is needed? There is already a kernel interface for this how come libvirt and lldpad can not use the kernel interface?
Thanks,
John.
Re: [E1000-eedc] [PATCH 16/17] lldpad support for libvirt netlink message
Quoted 18 lines · John Fastabend
Quoted 7 lines · Jens Osterkamp
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.
Quoted 9 lines
Signed-off-by Jens Osterkamp <[email protected]>Signed-off-by Gerhard Stenzel <[email protected]>Signed-off-by Stefan Berger <[email protected]>--- event_iface.c | 617 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- lldp_vdp.c | 2 +- lldpad.c | 10 + 3 files changed, 622 insertions(+), 7 deletions(-)
Quoted 3 lines
Jens,
Can you explain why this interface is needed? There is already a kernel
We needed a way in libvirt to associate the virtual network interface(s) of a guest with an adjacent switch. The protocol to do this could be implemented both in userspace (e.g. in lldpad) or in the adapter firmware. You could have different drivers for both ways in libvirt but to keep it simple we decided to use netlink for both.
The original mailthread on netdev started here
http://marc.info/?l=linux-netdev&m=127242976205746&w=2
Quoted 1 line
interface for this how come libvirt and lldpad can not use the kernel interface?
In fact we are using the kernel interface for this, e.g. the definitions of the netlink attributes are in the kernel header files.
The only difference is that in the userspace case, the netlink messages are addressed to the pid of lldpad whereas in the firmware case, the netlink messages go to pid 0 (kernel).
Best regards,
Jens Osterkamp
--------------------------------------------------------------------------------
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
PATCH 17/17 do not use macv[tap/lan] interfaces as ports
In reply to Jens OsterkampAt 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.
--- config.c | 2 + lldp_util.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 0 deletions(-)
config.c +2 -0
@@ -365,6 +365,8 @@ void init_ports(void) p->if_name); }else if (is_vlan (p->if_name)) { ; + }else if (is_macvtap (p->if_name)) { + ; }else if (is_bridge (p->if_name)) { ;/* ignore bridge device */ }else if (check_link_status (p->if_name)) {
lldp_util.c +86 -0
110 lines not on this page · raw message
Signature · 1 line
1.7.1