Apply various upstream 0.9.43 bugfixes

This commit is contained in:
Petr Sabata 2011-09-08 08:34:30 +02:00
parent e1e874c9cf
commit b7210ab7a2
32 changed files with 2940 additions and 6 deletions

View File

@ -0,0 +1,33 @@
From e81f41287bbdb61da21b51e1e75423ad188003ca Mon Sep 17 00:00:00 2001
From: Petr Sabata <contyk@redhat.com>
Date: Mon, 15 Aug 2011 18:13:42 -0700
Subject: [PATCH 23/29] Avoid possible resource leaks
This patch prevents possible resource leaks in mand_clif_cmd().
Signed-off-by: Petr Sabata <contyk@redhat.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
lldp_mand_cmds.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/lldp_mand_cmds.c b/lldp_mand_cmds.c
index d09d6a5..264d836 100644
--- a/lldp_mand_cmds.c
+++ b/lldp_mand_cmds.c
@@ -492,8 +492,11 @@ int mand_clif_cmd(void *data,
/* Confirm port is a lldpad managed port */
port = port_find_by_name(cmd.ifname);
- if (!port)
+ if (!port) {
+ free(argvals);
+ free(args);
return cmd_device_not_found;
+ }
switch (cmd.cmd) {
case cmd_getstats:
--
1.7.6

View File

@ -0,0 +1,177 @@
From 489085ba1ea0c12216d941d238af16b49c14174b Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 27 Jul 2011 15:03:51 -0700
Subject: [PATCH 09/29] Create man page for MED usage.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
Makefile.am | 2 +-
docs/lldptool-med.8 | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++
docs/lldptool.8 | 1 +
3 files changed, 131 insertions(+), 1 deletions(-)
create mode 100644 docs/lldptool-med.8
diff --git a/Makefile.am b/Makefile.am
index 4bf9566..63cfb93 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -69,7 +69,7 @@ nltest_SOURCES = nltest.c nltest.h
## man pages
dist_man_MANS = docs/lldpad.8 docs/dcbtool.8 docs/lldptool.8 \
docs/lldptool-ets.8 docs/lldptool-pfc.8 docs/lldptool-app.8 \
- docs/lldptool-evb.8 docs/lldptool-vdp.8
+ docs/lldptool-evb.8 docs/lldptool-vdp.8 docs/lldptool-med.8
## force the creation of an empty configuration directory at install time
lldpadconfigdir = /var/lib/lldpad
diff --git a/docs/lldptool-med.8 b/docs/lldptool-med.8
new file mode 100644
index 0000000..687175c
--- /dev/null
+++ b/docs/lldptool-med.8
@@ -0,0 +1,129 @@
+.TH lldptool 8 "June 2011" "open-lldp" "Linux"
+.SH NAME
+LLDP-MED \- Show / manipulate MED TLV configurations
+.SH SYNOPSIS
+.B lldptool -t -i ethx -V
+.RI "[ " TLV_TYPE " ]"
+.B enableTx
+.sp
+.B lldptool -T -i ethx -V
+.RI "[ " TLV_TYPE " ]"
+.B enableTx =
+{ yes | no }
+.sp
+.B lldptool -T -i ethx -V
+LLDP-MED
+.B devtype =
+{ class1 | class2 | class3 }
+.sp
+.B lldptool -t -i ethx -V
+LLDP-MED
+.B devtype
+.sp
+.ti -8
+.IR TLV_TYPE " : = {LLDP-MED | medCap | medPolicy | medLoc | medPower | medHwRev | medFwRev | medSwRev | medSerNum | medManuf | medModel | medAssetID }"
+
+.SH DESCRIPTION
+
+The
+.B LLDP-MED
+extensions support the Link Layer Discovery Protocol for
+.B Media Endpoint Devices
+defined in the
+.B ANSI/TIA-1057-2006
+document. Each TLV can be configured as a
+.B class1
+,
+.B class2
+or
+.B class3
+device. Class I devices are the most basic class of Endpoint Device, Class II devices support media stream capabilities and Class III devices directly support end users of the IP communication system. See
+.B ANS-TIA-1057
+for clarification of class types.
+
+
+.SH ARGUMENTS
+.TP
+.B enableTx
+Enables the TLV to be transmitted
+.TP
+.B devtype
+Set or query the class type of the device.
+
+.SH TLV_TYPE
+List of supported TLV specifiers applicable to Media Endpoint Devices.
+
+.TP
+.BR LLDP-MED
+apply arguments to all supported MED TLVs.
+
+.TP
+.BR medCAP
+LLDP-MED Capabilities TLV
+
+.TP
+.BR medPolicy
+LLDP-MED Network Policy TLV
+
+.TP
+.BR medLoc
+LLDP-MED Location TLV
+
+.TP
+.BR medPower
+LLDP-MED Extended Power-via-MDI TLV
+
+.TP
+.BR medHwRev
+LLDP-MED Hardware Revision TLV
+
+.TP
+.BR medFwRev
+LLDP-MED Firmware Revision TLV
+
+.TP
+.BR medSwRev
+LLDP-MED Software Revision TLV
+
+.TP
+.BR medSerNum
+LLDP-MED Serial Number TLV
+
+.TP
+.BR medManuf
+LLDP-MED Manufacturer Name TL
+
+.TP
+.BR medModel
+LLDP-MED Model Name TLV
+
+.TP
+.BR medAssetID
+LLDP-MED Asset ID TLV
+
+.SH EXAMPLE & USAGE
+.TP
+Enable class1 MED device on \fIeth2\fR
+.B lldptool -T -i eth2 -V LLDP-MED enableTx=yes devtype=class1
+.TP
+Query class type of MED on \fIeth2\fR
+.B lldptool -t -i eth2 -V LLDP-MED -c devtype
+.TP
+Query transmit state of medPolicy on device \fIeth2\fR
+.B lldptool -t -i eth2 -V medPolicy -c enableTx
+.TP
+
+.SH SOURCE
+.TP
+o
+Link Layer Discovery Protocol for Media Endpoint Devices (http://www.tiaonline.org/standards/technology/voip/documents/ANSI-TIA-1057_final_for_publication.pdf)
+
+.SH NOTES
+
+.SH SEE ALSO
+.BR lldptool (8),
+.BR lldpad (8)
+
+.SH AUTHOR
+John Fastabend
+
diff --git a/docs/lldptool.8 b/docs/lldptool.8
index ea5787d..5ad7b50 100644
--- a/docs/lldptool.8
+++ b/docs/lldptool.8
@@ -223,6 +223,7 @@ Configurations per port have higher precedence than global configurations.
.BR lldptool-ets (8),
.BR lldptool-pfc (8),
.BR lldptool-app (8),
+.BR lldptool-med (8),
.BR dcbtool (8),
.BR lldpad (8)
.br
--
1.7.6

View File

@ -0,0 +1,33 @@
From 106310e4027e8cd86305d9948a2cf0f537d0781f Mon Sep 17 00:00:00 2001
From: Jens Osterkamp <jens@linux.vnet.ibm.com>
Date: Tue, 9 Aug 2011 21:41:35 -0700
Subject: [PATCH 21/29] This patch fixes a warning issued when building the
lexer generated file parse_cli.c:
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
parse_cli.c:2147: warning: input defined but not used
Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
parse_cli.l | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/parse_cli.l b/parse_cli.l
index fd481bb..53dd83a 100644
--- a/parse_cli.l
+++ b/parse_cli.l
@@ -25,6 +25,7 @@
*******************************************************************************/
%option nounput
+%option noinput
%{
#include <string.h>
--
1.7.6

View File

@ -0,0 +1,148 @@
From 2b2b5b038f97ed111e0ae52af7bcec78636610f8 Mon Sep 17 00:00:00 2001
From: Jens Osterkamp <jens@linux.vnet.ibm.com>
Date: Tue, 12 Jul 2011 00:42:18 -0700
Subject: [PATCH 01/29] add man page for EVB TLV
This add a man page for the EVB TLV similar to the already existing ones.
Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
docs/lldptool-evb.8 | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 124 insertions(+), 0 deletions(-)
create mode 100644 docs/lldptool-evb.8
diff --git a/docs/lldptool-evb.8 b/docs/lldptool-evb.8
new file mode 100644
index 0000000..f62dce2
--- /dev/null
+++ b/docs/lldptool-evb.8
@@ -0,0 +1,124 @@
+.TH lldptool 8 "February 2010" "open-lldp" "Linux"
+.SH NAME
+evb \- Show / manipulate EVB TLV configuration
+.SH SYNOPSIS
+.B lldptool -t -i ethx -V evbCfg -c enableTx
+.sp
+.B lldptool -T -i ethx -V evbCfg -c enableTx=[yes|no]
+.sp
+.B lldptool -t -i ethx -V evbCfg -c fmode
+.sp
+.B lldptool -T -i ethx -V evbCfg -c fmode=[bridge|reflectiverelay]
+.sp
+.B lldptool -t -i ethx -V evbCfg -c capabilities
+.sp
+.B lldptool -T -i ethx -V evbCfg -c capabilities=[rte|ecp|vdp|none]
+.sp
+.B lldptool -t -i ethx -V evbCfg -c rte
+.sp
+.B lldptool -T -i ethx -V evbCfg -c rte=[<rte>]
+.sp
+.B lldptool -t -i ethx -V evbCfg -c vsis
+.sp
+.B lldptool -T -i ethx -V evbCfg -c vsis=[<number of vsis>]
+.sp
+.SH DESCRIPTION
+The EVB TLV is a TLV to announce the station and bridge's edge virtual
+bridging (evb) capabilities and request the bridge forwarding mode. If both
+sides have agree on edge control protocol (ECP), VSI discovery protocol (VDP)
+capabilities, both sides can exchange VDP TLV using ECP frames.
+The vsis parameter will set the maximum number of VSIs and show the number
+of currently configured VSIs.
+
+.SH ARGUMENTS
+.TP
+.B enableTx
+Enables the EVB TLV to be transmitted
+.TP
+.B fmode
+shows or sets the forwarding mode between bridge (default) or
+reflectiverelay (RR).
+.TP
+.B capabilities
+shows or sets the local capabilities that are announced to the adjacent
+switch in the TLV. This parameter will accept any combination of rte, vdp or
+ecp, separated by ",". Use the keyword "none" if you do not want to set any
+capabilities.
+.TP
+.B rte
+shows or set the local run time exponent (RTE). The RTE will be used as the
+base for the timing of the ECP and VDP protocols.
+.TP
+.B vsis
+shows or sets the number of virtual station interfaces (VSIs) that are
+announced to the adjacent switch in the TLV. This parameter expects a number
+between 0 and 65535.
+
+.SH Theory of Operation
+The EVB TLV is used to announce and exchange supported parameters between
+the station and an adjacent switch.
+
+If "reflectiverelay" is set as forwarding mode, the switch will allow
+"reflection" of frames coming from different sources at the same port back
+to the port. This will allow communication between virtual machines on the
+same host via the switch.
+
+The capabilities parameter is used to set RTE, ECP and VDP support. VDP TLVs
+in ECP frames can only be exchanged if both sides agree on ECP and VDP as
+capabilities. RTE will be used as the base timing parameter for ECP and VDP.
+
+.SH EXAMPLE & USAGE
+.TP
+Display locally configured values for \fIeth8\fR
+.B lldptool -t -i eth8 -V evbCfg
+.TP
+Display remotely configured values for \fIeth8\fR
+.B lldptool -n -t -i eth8 -V evbCfg
+.TP
+Display wether evb tlv is configured for tx on \fIeth8\fR
+.B lldptool -t -i eth8 -V evbCfg -c enableTx
+.TP
+Display the currently requested forwarding mode for \fIeth8\fR
+.B lldptool -t -i eth8 -V evbCfg -c fmode
+.TP
+Set the forwarding mode to reflective relay
+.B lldptool -T -i eth8 -V evbCfg -c fmode=reflectiverelay
+.TP
+Display the currently configured capabilities
+.B lldptool -t -i ethx -V evbCfg -c capabilities
+.TP
+Set the locally possible capabilities to RTE, ECP and VDP
+.B lldptool -T -i ethx -V evbCfg -c capabilities=rte,ecp,vdp
+.TP
+Resets the locally possible capabilities to "none"
+.B lldptool -T -i ethx -V evbCfg -c capabilities=none
+.TP
+Display the locally configured value for RTE
+.B lldptool -t -i ethx -V evbCfg -c rte
+.TP
+Set the value for RTE
+.B lldptool -T -i ethx -V evbCfg -c rte=[<rte>]
+.TP
+Display the configured maximum number of VSIs
+.B lldptool -t -i ethx -V evbCfg -c vsis
+.TP
+Set the maximum number of VSIs
+.B lldptool -T -i ethx -V evbCfg -c vsis=[<number of vsis>]
+.sp
+
+.SH SOURCE
+.TP
+o
+IEEE 802.1Qbg (http://www.ieee802.org/1/pages/802.1bg.html)
+
+.SH NOTES
+Currently the code in lldpad reflects draft 0 of the upcoming standard. EVB
+TLVs on the wire can be decoded with wireshark > v1.6.
+
+.SH SEE ALSO
+.BR lldptool-vdp (8),
+.BR lldptool (8),
+.BR lldpad (8)
+
+.SH AUTHOR
+Jens Osterkamp
--
1.7.6

View File

@ -0,0 +1,124 @@
From 708db0bc2ca085cf25f1421b6d7258a6132abb9b Mon Sep 17 00:00:00 2001
From: Jens Osterkamp <jens@linux.vnet.ibm.com>
Date: Tue, 12 Jul 2011 00:54:50 -0700
Subject: [PATCH 02/29] add man page for VDP
This adds a man page for the VDP similar to the already
existing ones.
Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
docs/lldptool-vdp.8 | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 99 insertions(+), 0 deletions(-)
create mode 100644 docs/lldptool-vdp.8
diff --git a/docs/lldptool-vdp.8 b/docs/lldptool-vdp.8
new file mode 100644
index 0000000..6b254ad
--- /dev/null
+++ b/docs/lldptool-vdp.8
@@ -0,0 +1,99 @@
+.TH lldptool 8 "February 2010" "open-lldp" "Linux"
+.SH NAME
+vdp \- Show / manipulate VDP TLV configuration
+.SH SYNOPSIS
+.B lldptool -t -i ethx -V vdp -c enableTx
+.sp
+.B lldptool -T -i ethx -V vdp -c enableTx=[yes|no]
+.sp
+.B lldptool -t -i ethx -V vdp -c mode
+.sp
+.B lldptool -T -i ethx -V vdp -c mode=<mode>,<mgrid>,<typeid>,<typeidversion>,<instanceid>,<mac>,<vlan>
+.sp
+.B lldptool -t -i ethx -V vdp -c role
+.sp
+.B lldptool -T -i ethx -V vdp -c role=[station|bridge]
+.sp
+.SH DESCRIPTION
+The VSI discovery protocol (VDP) is \fINOT\fR a TLV in the LLDP sense but
+rather a protocol to manage the association and deassociation of virtual
+station interfaces (VSIs) between the station and an adjacent switch. VDP
+uses ECP as transport for VDP TLVs. An ECP frame may contain multiple VDP
+TLVs. Each VDP TLVs contains a mode, typeid, version, instanceid, mac and
+vlan for a VSI.
+
+.SH ARGUMENTS
+.TP
+.B enableTx
+Enables or disables VDP
+.TP
+.B mode
+shows or sets modes for VSIs with the following parameters:
+.RS
+.IP <mode>
+mode (0=preassociate, 1=preassociate with RR, 2=associate, 3=deassociate)
+.IP <mgrid>
+manager (database) id
+.IP <typeid>
+VSI type id
+.IP <version>
+VSI type id version
+.IP <instanceid>
+VSI instance id
+.IP <mac>
+VSI mac address
+.IP <vlan>
+VSI vlan id
+.RE
+
+.TP
+.B role
+shows or sets the role of the local machine to act as either station
+(default) or bridge.
+
+.SH Theory of Operation
+The VDP protocol is used to pre-associate, associate or deassociate VSIs to
+and adjacent switch. Information about the VSIs is formatted into VDP TLVs
+which are then handed to ECP for lower-level transport. Each ECP frame may
+contain multiple VDP TLVs.
+
+Two ways to receive VSI information exist in llpdad: via netlink or with
+lldptool. netlink is used by libvirt to communicate VSIs to lldpad. lldptool
+can be used to associate/deassociate VSIs from the command line. This is
+especially helpful for testing purposes.
+
+.SH EXAMPLE & USAGE
+.TP
+Display if vdp is enabled on \fIeth8\fR
+.B lldptool -t -i eth8 -V vdp -c enableTx
+.TP
+Enable vdp on \fIeth8\fR
+.B lldptool -T -i eth8 -V vdp -c enableTx=yes
+.TP
+Display the currently configured VSIs for \fIeth8\fR
+.B lldptool -t -i eth8 -V vdp -c mode
+.TP
+Associate a VSI on \fIeth8\fR
+.B lldptool -T -i eth8 -V vdp -c mode=2,12,1193046,1,fa9b7fff-b0a0-4893-8e0e-beef4ff18f8f,52:54:00:C7:3E:CE,3
+.TP
+Display the locally configured role for VDP on \fIeth8\fR
+.B lldptool -t -i eth8 -V vdp -c role
+.TP
+Set the local role for VDP on \fIeth8\fR
+.B lldptool -T -i eth8 -V vdp -c role=bridge
+
+.SH SOURCE
+.TP
+o
+IEEE 802.1Qbg (http://www.ieee802.org/1/pages/802.1bg.html)
+
+.SH NOTES
+Currently the code in lldpad reflects draft 0 of the upcoming standard.
+
+.SH SEE ALSO
+.BR lldptool-evb (8),
+.BR lldptool (8),
+.BR lldpad (8)
+
+.SH AUTHOR
+Jens Osterkamp
--
1.7.6

View File

@ -0,0 +1,32 @@
From 594f95bfb30ff0dbdd0d6402a67ac4717ef574ac Mon Sep 17 00:00:00 2001
From: Jens Osterkamp <jens@linux.vnet.ibm.com>
Date: Tue, 12 Jul 2011 01:02:17 -0700
Subject: [PATCH 03/29] add some files in include/linux/ to inst_SOURCES
Add some files in include/linux/ to inst_SOURCES in Makefile.am to avoid rpm
build problems later.
Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
Makefile.am | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index cb192fa..30284e6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -21,7 +21,8 @@ include/lldpad.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_util.h \
include/lldp_evb_cmds.h include/lldp_vdp_cmds.h include/lldp_8021qaz_cmds.h \
-include/clif_sock.h
+include/clif_sock.h include/linux/dcbnl.h \
+include/linux/netlink.h include/linux/rtnetlink.h
noinst_HEADERS = include/config.h include/ctrl_iface.h \
include/dcb_driver_interface.h \
--
1.7.6

View File

@ -0,0 +1,33 @@
From 08e34a83dd1415f2b4127665639011975ce91465 Mon Sep 17 00:00:00 2001
From: Jens Osterkamp <jens@linux.vnet.ibm.com>
Date: Mon, 15 Aug 2011 18:17:29 -0700
Subject: [PATCH 28/29] bugfix: go to VSI_EXIT immediately on neg response
If a vsi_profile receives a negative response while in ASSOCIATED state,
it has to go to VSI_EXIT immediately to avoid sitting in DEASSOC_PROCESSING
before timing out.
Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
lldp_vdp.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/lldp_vdp.c b/lldp_vdp.c
index 15fed51..646105a 100644
--- a/lldp_vdp.c
+++ b/lldp_vdp.c
@@ -573,8 +573,7 @@ static bool vdp_vsi_set_station_state(struct vsi_profile *profile)
vdp_vsi_change_station_state(profile, VSI_DEASSOC_PROCESSING);
return true;
} else if (vdp_vsi_negative_response(profile)) {
- vdp_vsi_change_station_state(profile, VSI_DEASSOC_PROCESSING);
- vdp_somethingChangedLocal(profile, true);
+ vdp_vsi_change_station_state(profile, VSI_EXIT);
return true;
} else if (vdp_keepaliveTimer_expired(profile)) {
vdp_stop_keepaliveTimer(profile);
--
1.7.6

View File

@ -0,0 +1,111 @@
From 2c9ec8e6d4e7240e9a6ccc8fce7572f78752db6f Mon Sep 17 00:00:00 2001
From: Jens Osterkamp <jens@linux.vnet.ibm.com>
Date: Mon, 15 Aug 2011 18:16:42 -0700
Subject: [PATCH 26/29] bugfix to print all profiles
In an earlier patch a bug had been introduced which prevented all profiles
from being printed into the assigned buffer. Instead, only the last profile
for an interface would be printed in there and shown with lldptool.
Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
lldp_vdp_cmds.c | 25 +++++++++++++------------
1 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/lldp_vdp_cmds.c b/lldp_vdp_cmds.c
index 8660f98..8cc871f 100644
--- a/lldp_vdp_cmds.c
+++ b/lldp_vdp_cmds.c
@@ -84,43 +84,44 @@ static char *check_and_update(size_t *total, size_t *length, char *s, int c)
return s + c;
}
-static void print_profile(char *s, size_t length, struct vsi_profile *p)
+static char * print_profile(char *s, size_t length, struct vsi_profile *p)
{
int c;
size_t total = 0;
+ char *r = s;
c = snprintf(s, length, "\nmode: %i (%s)\n",
p->mode, vsi_modes[p->mode]);
s = check_and_update(&total, &length, s, c);
if (!s)
- return;
+ return r;
c = snprintf(s, length, "response: %i (%s)\n", p->response,
vsi_responses[p->response]);
s = check_and_update(&total, &length, s, c);
if (!s)
- return;
+ return r;
c = snprintf(s, length, "state: %i (%s)\n",
p->state, vsi_states[p->state]);
s = check_and_update(&total, &length, s, c);
if (!s)
- return;
+ return r;
c = snprintf(s, length, "mgrid: %i\n", p->mgrid);
s = check_and_update(&total, &length, s, c);
if (!s)
- return;
+ return r;
c = snprintf(s, length, "id: %i (0x%x)\n", p->id, p->id);
s = check_and_update(&total, &length, s, c);
if (!s)
- return;
+ return r;
c = snprintf(s, length, "version: %i\n", p->version);
s = check_and_update(&total, &length, s, c);
if (!s)
- return;
+ return r;
{
char instance[INSTANCE_STRLEN + 2];
@@ -130,7 +131,7 @@ static void print_profile(char *s, size_t length, struct vsi_profile *p)
}
s = check_and_update(&total, &length, s, c);
if (!s)
- return;
+ return r;
{
char macbuf[MAC_ADDR_STRLEN + 1];
@@ -140,14 +141,14 @@ static void print_profile(char *s, size_t length, struct vsi_profile *p)
}
s = check_and_update(&total, &length, s, c);
if (!s)
- return;
+ return r;
c = snprintf(s, length, "vlan: %i\n\n", p->vlan);
s = check_and_update(&total, &length, s, c);
if (!s)
- return;
+ return r;
- return;
+ return s;
}
static int get_arg_tlvtxenable(struct cmd *cmd, char *arg, char *argvalue,
@@ -271,7 +272,7 @@ static int get_arg_mode(struct cmd *cmd, char *arg, char *argvalue,
memset(s, 0, (count+1)*VDP_BUF_SIZE);
LIST_FOREACH(np, &vd->profile_head, profile) {
- print_profile(t, (count + 1) * VDP_BUF_SIZE, np);
+ t = print_profile(t, (count + 1) * VDP_BUF_SIZE, np);
}
snprintf(obuf, obuf_len, "%02x%s%04x%s",
--
1.7.6

View File

@ -0,0 +1,51 @@
From dcb32bd003d89158b5b82296116690d57ca0338d Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 27 Jul 2011 15:05:24 -0700
Subject: [PATCH 11/29] dcbtool: return different error codes for invalid
device and IEEE
dcbtool currently returns the same error code for an invalid
device name and a device in IEEE mode. This results in
the tool printing an output that gives an error about IEEE
mode in both cases.
This patch separates the two cases and additionally allows
sets and gets to occur. Oper mode calls should still fail
device in IEEE mode errors. This is more inline with the
current lldptool behavior and supports users configuring
CEE mode before switching DCBX mode.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
lldp_dcbx_cmds.c | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/lldp_dcbx_cmds.c b/lldp_dcbx_cmds.c
index bbfbcf6..7799557 100644
--- a/lldp_dcbx_cmds.c
+++ b/lldp_dcbx_cmds.c
@@ -533,15 +533,14 @@ int dcbx_clif_cmd(void *data,
if (!port)
return dcb_device_not_found;
- /* DCBTOOL is not applicable in IEEE-DCBX modes */
dcbx = dcbx_data(port->ifname);
- if (!dcbx || dcbx->active == 0)
- return cmd_not_applicable;
-
- /* check that DCB features is supported and in DCB state */
- if (feature != FEATURE_DCB && check_port_dcb_mode(port_id) == false)
+ if (!dcbx)
return dcb_device_not_found;
+ /* OPER and PEER cmd not applicable while in IEEE-DCBX modes */
+ if (dcbx->active == 0 && (cmd == CMD_GET_PEER || cmd == CMD_GET_OPER))
+ return cmd_not_applicable;
+
switch(feature) {
case FEATURE_DCB:
if (cmd == CMD_SET_CONFIG)
--
1.7.6

View File

@ -0,0 +1,56 @@
From 63d97a836870bf106488efccee29d9f0ed606389 Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 27 Jul 2011 15:08:10 -0700
Subject: [PATCH 18/29] lldapd: 802.1Qaz, add output buffer response to set
pfc
All other 802.1Qaz set commands report set values except
pfc enabled.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
lldp_8021qaz_cmds.c | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/lldp_8021qaz_cmds.c b/lldp_8021qaz_cmds.c
index 4dd8042..04556c2 100644
--- a/lldp_8021qaz_cmds.c
+++ b/lldp_8021qaz_cmds.c
@@ -780,7 +780,8 @@ static int _set_arg_enabled(struct cmd *cmd, char *args,
char *priority, *parse;
char arg_path[256];
long mask = 0;
- int err = cmd_success;
+ bool first;
+ int i, err = cmd_success;
if (cmd->cmd != cmd_settlv)
return cmd_invalid;
@@ -823,6 +824,23 @@ static int _set_arg_enabled(struct cmd *cmd, char *args,
return cmd_success;
}
+ first = true;
+ strncat(obuf, "prio = ", obuf_len - strlen(obuf) - 1);
+ for (i = 0; i < 8; i++) {
+ if (mask & (1 << i)) {
+ char val[3];
+
+ if (first) {
+ snprintf(val, sizeof(val), "%i", i);
+ first = false;
+ } else {
+ snprintf(val, sizeof(val), ",%i", i);
+ }
+ strncat(obuf, val, obuf_len - strlen(obuf) - 1);
+ }
+ }
+ strncat(obuf, "\n", obuf_len - strlen(obuf) - 1);
+
/* Set configuration */
snprintf(arg_path, sizeof(arg_path),
"%s%08x.%s", TLVID_PREFIX, cmd->tlvid, args);
--
1.7.6

View File

@ -0,0 +1,46 @@
From b62545fac8f28c63460e4e932a526280884d0200 Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Tue, 12 Jul 2011 09:21:21 -0700
Subject: [PATCH 05/29] lldpad: 802.1Qaz PFC TLV incorrectly sets willing,
cap, and mac bits
The willing, capabilities and MACSec enabled bits are incorrectly
set to peer's value in the PFC TLV.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
lldp_8021qaz.c | 15 ++++++---------
1 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/lldp_8021qaz.c b/lldp_8021qaz.c
index c146d4a..adeb0eb 100644
--- a/lldp_8021qaz.c
+++ b/lldp_8021qaz.c
@@ -1192,17 +1192,14 @@ bld_ieee8021qaz_pfc_tlv(struct ieee8021qaz_tlvs *tlvs)
hton24(pfc->oui, OUI_IEEE_8021);
pfc->subtype = LLDP_8021QAZ_PFC;
- if (tlvs->pfc->current_state == INIT) {
- pfc->wmrc = tlvs->pfc->local.willing << 7 |
- tlvs->pfc->local.mbc << 6 |
- tlvs->pfc->local.pfc_cap;
+ pfc->wmrc = tlvs->pfc->local.willing << 7 |
+ tlvs->pfc->local.mbc << 6 |
+ tlvs->pfc->local.pfc_cap;
+
+ if (tlvs->pfc->current_state == INIT)
pfc->pfc_enable = tlvs->pfc->local.pfc_enable;
- } else {
- pfc->wmrc = tlvs->pfc->remote.willing << 7 |
- tlvs->pfc->remote.mbc << 6 |
- tlvs->pfc->remote.pfc_cap;
+ else
pfc->pfc_enable = tlvs->pfc->remote.pfc_enable;
- }
tlv->type = ORG_SPECIFIC_TLV;
tlv->length = sizeof(struct ieee8021qaz_tlv_pfc);
--
1.7.6

View File

@ -0,0 +1,97 @@
From b2050baf30c4c1a9e6aa4142a340dd9e9f5b0d1b Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 27 Jul 2011 15:07:11 -0700
Subject: [PATCH 12/29] lldpad: 802.1Qaz, make ETS-CFG willing {yes|no} values
valid
Currently, the willing option to ETS-CFG takes a 0 or 1 value
while all other attributes use "yes" or "no".
So make ETS-CFG willing follow the trend and use "yes" or "no"
as well.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
docs/lldptool-ets.8 | 4 ++--
lldp_8021qaz_cmds.c | 28 ++++++++++++++++++++++++++--
2 files changed, 28 insertions(+), 4 deletions(-)
diff --git a/docs/lldptool-ets.8 b/docs/lldptool-ets.8
index 2b76b9c..16fdba9 100644
--- a/docs/lldptool-ets.8
+++ b/docs/lldptool-ets.8
@@ -19,7 +19,7 @@ ETS-{CFG|REC} \- Show / manipulate ETS TLV configuration
.sp
.BR enableTx " = " {yes|no} " | "
.sp
-.BR willing " = " {0|1} " | "
+.BR willing " = " {yes|no} " | "
.sp
.BR tsa " = " tc:{ets|strict|vendor},... " | "
.sp
@@ -107,7 +107,7 @@ have support for specific protocols ie Fiber Channel over Ethernet (FCoE).
.SH EXAMPLE & USAGE
.TP
Configure willing bit for interface \fIeth2\fR
-.B lldptool -T -i eth2 -V ETS-CFG willing=1
+.B lldptool -T -i eth2 -V ETS-CFG willing=yes
.TP
Configure traffic classes for ETS and strict priority on \fIeth2\fR
.B lldptool -T -i eth2 -V ETS-CFG tsa=0:ets,1:ets,2:ets,3:ets,4:strict,5:strict
diff --git a/lldp_8021qaz_cmds.c b/lldp_8021qaz_cmds.c
index 1ee733e..4dd8042 100644
--- a/lldp_8021qaz_cmds.c
+++ b/lldp_8021qaz_cmds.c
@@ -142,7 +142,7 @@ static int get_arg_willing(struct cmd *cmd, char *args,
static int _set_arg_willing(struct cmd *cmd, char *args,
char *arg_value, char *obuf, int obuf_len, bool test)
{
- long willing = strtol(arg_value, NULL, 10);
+ long willing;
struct ieee8021qaz_tlvs *tlvs;
char arg_path[256];
@@ -153,6 +153,29 @@ static int _set_arg_willing(struct cmd *cmd, char *args,
if (!tlvs)
return cmd_device_not_found;
+
+
+ /* To remain backward compatible and make it easier
+ * for everyone use to {0|1} notation we still support
+ * this but also support english variants as well
+ */
+ if (!strcasecmp(arg_value, VAL_YES))
+ willing = 1;
+ else if (!strcasecmp(arg_value, VAL_NO))
+ willing = 0;
+ else {
+ char *end;
+
+ errno = 0;
+ willing = strtol(arg_value, &end, 10);
+
+ if (end == arg_value || *end != '\0')
+ return cmd_invalid;
+
+ if (errno || willing < 0)
+ return cmd_invalid;
+ }
+
switch (cmd->tlvid) {
case (OUI_IEEE_8021 << 8) | LLDP_8021QAZ_ETSCFG:
if (!test)
@@ -171,7 +194,8 @@ static int _set_arg_willing(struct cmd *cmd, char *args,
if (test)
return cmd_success;
- snprintf(obuf, obuf_len, "willing = %i\n", !!willing);
+ snprintf(obuf, obuf_len, "willing = %s\n",
+ !!willing ? VAL_YES : VAL_NO);
snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX,
cmd->tlvid, args);
--
1.7.6

View File

@ -0,0 +1,33 @@
From 5002608af85c5efe92005f839d7417ee5c0a7cf9 Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 27 Jul 2011 15:05:19 -0700
Subject: [PATCH 10/29] lldpad: 802.1Qaz resolve incorrect tcbw memcpy
The tcbw attributes were not being correctly configured on
32bit archs because of incorrect sizeof() usage in argument
handlers. x86_64 happened to work by chance.
This patch resolves the issue.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
lldp_8021qaz_cmds.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lldp_8021qaz_cmds.c b/lldp_8021qaz_cmds.c
index 7ddb22b..1ee733e 100644
--- a/lldp_8021qaz_cmds.c
+++ b/lldp_8021qaz_cmds.c
@@ -471,7 +471,7 @@ static int _set_arg_tcbw(struct cmd *cmd, char *args,
free(parse);
return cmd_success;
} else {
- memcpy(tcbw, percent, sizeof(tcbw));
+ memcpy(tcbw, percent, sizeof(*tcbw) * MAX_TCS);
}
strncat(obuf, "tcbw = ", obuf_len - strlen(obuf) - 1);
--
1.7.6

View File

@ -0,0 +1,30 @@
From 217a30cffb9041831f0a9ea92916bea4439d2f92 Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Tue, 12 Jul 2011 01:07:30 -0700
Subject: [PATCH 04/29] lldpad: Add EVB and VDP man pages to install path
EVB and VDP man pages need to be added to Makefile.am install.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
Makefile.am | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 30284e6..4bf9566 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -68,7 +68,8 @@ nltest_SOURCES = nltest.c nltest.h
## man pages
dist_man_MANS = docs/lldpad.8 docs/dcbtool.8 docs/lldptool.8 \
- docs/lldptool-ets.8 docs/lldptool-pfc.8 docs/lldptool-app.8
+ docs/lldptool-ets.8 docs/lldptool-pfc.8 docs/lldptool-app.8 \
+ docs/lldptool-evb.8 docs/lldptool-vdp.8
## force the creation of an empty configuration directory at install time
lldpadconfigdir = /var/lib/lldpad
--
1.7.6

View File

@ -0,0 +1,44 @@
From 215fa56eb62adcf5cfd757c2f226c58de3f07180 Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 27 Jul 2011 15:03:33 -0700
Subject: [PATCH 06/29] lldpad: Add ports even w/out link at init time
It may be helpful to configure devices even before the device
has link. To facilitate this add ports to port list regardless
of link status.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
config.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/config.c b/config.c
index 4d42581..a8ebe17 100644
--- a/config.c
+++ b/config.c
@@ -358,14 +358,16 @@ void init_ports(void)
;
} else if (is_bridge(p->if_name)) {
; /* ignore bridge device */
- } else if (check_link_status(p->if_name)) {
+ } else {
add_port(p->if_name);
- LIST_FOREACH(np, &lldp_head, lldp) {
- if (np->ops->lldp_mod_ifup)
- np->ops->lldp_mod_ifup(p->if_name);
+ if (check_link_status(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);
}
- set_lldp_port_enable_state(p->if_name, 1);
}
p++;
}
--
1.7.6

View File

@ -0,0 +1,33 @@
From d56a0ea97410f341f8892204ca6cfad02519e8bf Mon Sep 17 00:00:00 2001
From: Petr Sabata <contyk@redhat.com>
Date: Mon, 15 Aug 2011 18:13:40 -0700
Subject: [PATCH 22/29] lldpad: Avoid possible resource leak in get_bcn()
Signed-off-by: Petr Sabata <contyk@redhat.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
nltest.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/nltest.c b/nltest.c
index 2ae2212..e350ca9 100644
--- a/nltest.c
+++ b/nltest.c
@@ -781,12 +781,14 @@ static int get_bcn(char *ifname, bcn_cfg *bcn_data)
if (d->cmd != DCB_CMD_BCN_GCFG) {
printf("Hmm, this is not the message we were expecting.\n");
+ free(nlh);
return -EIO;
}
if (rta_parent->rta_type != DCB_ATTR_BCN) {
/* Do we really want to code up an attribute parser?? */
printf("A full libnetlink (with rtnl and attribute support) "
"would sure be nice.\n");
+ free(nlh);
return -EIO;
}
rta_child = NLA_DATA(rta_parent);
--
1.7.6

View File

@ -0,0 +1,83 @@
From 527ac435e46c59f9ee83aced36ccf83a0518f7fe Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 27 Jul 2011 15:08:04 -0700
Subject: [PATCH 17/29] lldpad: Do not enable CEE mode if explicitly disabled
Do not re-enable CEE mode by default after it has been
explicitly disabled.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
lldp_dcbx.c | 15 ++++++++++++---
lldp_dcbx_cmds.c | 11 ++---------
2 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/lldp_dcbx.c b/lldp_dcbx.c
index 4cf2cb5..7949147 100644
--- a/lldp_dcbx.c
+++ b/lldp_dcbx.c
@@ -563,10 +563,15 @@ initialized:
/* if the dcbx field is not filled in by the capabilities
* query, then the kernel is older and does not support
- * IEEE mode, so make CEE DCBX active by default.
+ * IEEE mode, so make CEE DCBX active by default. Unless
+ * the dcb state has been disabled from command line.
*/
get_dcb_capabilities(ifname, &dcb_support);
- if (!dcb_support.dcbx || (gdcbx_subtype & ~MASK_DCBX_FORCE)) {
+
+ exists = get_dcb_enable_state(ifname, &dcb_enable);
+
+ if ((exists < 0 || dcb_enable) &&
+ (!dcb_support.dcbx || (gdcbx_subtype & ~MASK_DCBX_FORCE))) {
set_dcbx_mode(tlvs->ifname,
DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_CEE);
set_hw_state(ifname, 1);
@@ -719,8 +724,12 @@ int dcbx_rchange(struct port *port, struct unpacked_tlv *tlv)
}
if (tlv->type == TYPE_0) {
+ int enabled;
+ int exists = get_dcb_enable_state(dcbx->ifname, &enabled);
+
if (!dcbx->active && !ieee8021qaz_tlvs_rxed(dcbx->ifname) &&
- dcbx->rxed_tlvs) {
+ dcbx->rxed_tlvs &&
+ (exists < 0 || enabled)) {
LLDPAD_INFO("CEE DCBX %s going ACTIVE\n", dcbx->ifname);
set_dcbx_mode(port->ifname,
DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_CEE);
diff --git a/lldp_dcbx_cmds.c b/lldp_dcbx_cmds.c
index 7799557..9ec671e 100644
--- a/lldp_dcbx_cmds.c
+++ b/lldp_dcbx_cmds.c
@@ -245,7 +245,6 @@ static int get_dcb_state(char *port_id, char *rbuf)
static dcb_result set_dcb_state(char *port_id, char *ibuf, int ilen)
{
bool state;
- int tmp;
int off;
int plen;
dcb_result rval = dcb_success;
@@ -255,14 +254,8 @@ static dcb_result set_dcb_state(char *port_id, char *ibuf, int ilen)
if (ilen == (off + CFG_DCB_DLEN)) {
state = (*(ibuf+off+DCB_STATE)) ^ '0';
- /* if get_hw_state fails, then don't bother
- * trying to set the state.
- */
- if (get_hw_state(port_id, &tmp) ||
- set_hw_state(port_id, state))
- rval = dcb_failed;
- else
- rval = save_dcb_enable_state(port_id, state);
+ set_hw_state(port_id, state);
+ rval = save_dcb_enable_state(port_id, state);
} else {
printf("error - setcommand has invalid argument length\n");
rval = dcb_bad_params;
--
1.7.6

View File

@ -0,0 +1,32 @@
From 7b99aaad22128c4a2b66d7bc36697dca6eaae96d Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 27 Jul 2011 15:08:15 -0700
Subject: [PATCH 19/29] lldpad: ETS add another example to man page
Add another example to ETS man page.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
docs/lldptool-ets.8 | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/docs/lldptool-ets.8 b/docs/lldptool-ets.8
index 16fdba9..7433a42 100644
--- a/docs/lldptool-ets.8
+++ b/docs/lldptool-ets.8
@@ -120,6 +120,11 @@ Display local configured ETS-CFG parameters for tcbw
.TP
Display last transmitted ETS-CFG TLV
.B lldptool -t -i eth2 -V ETS-CFG
+.TP
+Configure ETS-CFG and ETS-REC for default DCB on \fIeth2\fR
+.B lldptool -T -i eth2 -V ETS-CFG tsa=0:ets,1:ets,2:ets,3:ets,4:ets,5:ets,6:ets,7:ets up2tc=0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7 tcbw=12,12,12,12,13,13,13,13
+
+.B lldptool -T -i eth2 -V ETS-REC tsa=0:ets,1:ets,2:ets,3:ets,4:ets,5:ets,6:ets,7:ets up2tc=0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7 tcbw=12,12,12,12,13,13,13,13
.SH SOURCE
.TP
--
1.7.6

View File

@ -0,0 +1,46 @@
From 411d6db2c59d4658088a20ae4fc21b04b28059c7 Mon Sep 17 00:00:00 2001
From: Mark Rustad <mark.d.rustad@intel.com>
Date: Mon, 15 Aug 2011 18:14:38 -0700
Subject: [PATCH 25/29] lldpad: Fix error path in save_dcbx_version
One error path would not return an error indication to the caller.
Fix that and eliminate the useless rval variable.
Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Tested-by: Ross Brattain <ross.b.brattain@intel.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
lldp_dcbx_cfg.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/lldp_dcbx_cfg.c b/lldp_dcbx_cfg.c
index 0477c54..7a447e3 100644
--- a/lldp_dcbx_cfg.c
+++ b/lldp_dcbx_cfg.c
@@ -612,19 +612,17 @@ int save_dcb_enable_state(char *device_name, int dcb_enable)
int save_dcbx_version(int dcbx_version)
{
- config_setting_t *dcbx_setting = NULL;
- config_setting_t *setting = NULL;
- int rval = dcb_success;
+ config_setting_t *dcbx_setting;
+ config_setting_t *setting;
dcbx_setting = config_lookup(&lldpad_cfg, DCBX_SETTING);
if (!dcbx_setting)
return 1;
setting = config_setting_get_member(dcbx_setting, "dcbx_version");
-
if (!setting || !config_setting_set_int(setting, dcbx_version) ||
!config_write_file(&lldpad_cfg, cfg_file_name))
- rval = dcb_failed;
+ return 1;
return 0;
}
--
1.7.6

View File

@ -0,0 +1,489 @@
From a7542456c40a9943a92daf6c7b6fcbd520ed023e Mon Sep 17 00:00:00 2001
From: Mark Rustad <mark.d.rustad@intel.com>
Date: Mon, 15 Aug 2011 18:14:26 -0700
Subject: [PATCH 24/29] lldpad: Fix logging to no longer use message IDs
lldpad's logging was overloading the first parameter to the log_message
function as both a logging level and a message ID. There are really not
many message IDs in use, so resolve the conflict by using only log level.
This also adds a proper printf-attribute to the logging function so
that arguments can be checked and resolve those as well. A few messages
that were changed now have more useful content.
Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Tested-by: Ross Brattain <ross.b.brattain@intel.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
ecp/ecp.c | 4 +-
ecp/ecp_rx.c | 12 ++--
ecp/ecp_tx.c | 13 ++---
include/messages.h | 30 +----------
lldp/rx.c | 4 +-
lldp_evb.c | 8 +--
lldp_mand.c | 4 +-
lldp_vdp.c | 24 ++++-----
lldpad.c | 6 +--
log.c | 150 ++--------------------------------------------------
10 files changed, 38 insertions(+), 217 deletions(-)
diff --git a/ecp/ecp.c b/ecp/ecp.c
index 7d9be89..638a8cb 100644
--- a/ecp/ecp.c
+++ b/ecp/ecp.c
@@ -118,9 +118,9 @@ void ecp_ack_timeout_handler(void *eloop_data, void *user_ctx)
__func__, __LINE__, vd->ifname, vd->ecp.ackTimer);
ecp_tx_run_sm(vd);
} else {
- LLDPAD_DBG("%s(%i)-%s: BUG ! handler called but"
+ LLDPAD_DBG("%s-%s: BUG ! handler called but"
"vdp->ecp.ackTimer not expired (%i) !\n",
- __func__, __LINE__, vd->ecp.ackTimer);
+ __func__, vd->ifname, vd->ecp.ackTimer);
}
}
diff --git a/ecp/ecp_rx.c b/ecp/ecp_rx.c
index 74e9f32..a56cd3b 100644
--- a/ecp/ecp_rx.c
+++ b/ecp/ecp_rx.c
@@ -513,8 +513,8 @@ void ecp_rx_change_state(struct vdp_data *vd, u8 newstate)
assert(vd->ecp.rx.state == ECP_RX_RECEIVE_ECPDU);
break;
default:
- LLDPAD_ERR("ERROR: The ECP_RX State Machine is broken!\n");
- log_message(MSG_ERR_RX_SM_INVALID, "%s", vd->ifname);
+ LLDPAD_ERR("%s: LLDP rx state machine setting invalid state %d\n",
+ vd->ifname, newstate);
}
LLDPAD_DBG("%s(%i)-%s: state change %s -> %s\n", __func__, __LINE__,
@@ -585,8 +585,8 @@ bool ecp_set_rx_state(struct vdp_data *vd)
ecp_rx_change_state(vd, ECP_RX_RECEIVE_WAIT);
return false;
default:
- LLDPAD_ERR("ERROR: The ECP_RX State Machine is broken!\n");
- log_message(MSG_ERR_RX_SM_INVALID, "%s", vd->ifname);
+ LLDPAD_ERR("%s: LLDP RX state machine in invalid state %d\n",
+ vd->ifname, vd->ecp.rx.state);
return false;
}
}
@@ -628,8 +628,8 @@ void ecp_rx_run_sm(struct vdp_data *vd)
}
break;
default:
- LLDPAD_ERR("ERROR: The ECP_RX State Machine is broken!\n");
- log_message(MSG_ERR_TX_SM_INVALID, "%s", vd->ifname);
+ LLDPAD_ERR("%s: LLDP RX state machine in invalid state %d\n",
+ vd->ifname, vd->ecp.rx.state);
}
} while (ecp_set_rx_state(vd) == true);
diff --git a/ecp/ecp_tx.c b/ecp/ecp_tx.c
index f9ee3d7..c81e101 100644
--- a/ecp/ecp_tx.c
+++ b/ecp/ecp_tx.c
@@ -377,8 +377,8 @@ static void ecp_tx_change_state(struct vdp_data *vd, u8 newstate)
assert(vd->ecp.tx.state == ECP_TX_WAIT_FOR_ACK);
break;
default:
- LLDPAD_ERR("ERROR: The ECP_TX State Machine is broken!\n");
- log_message(MSG_ERR_TX_SM_INVALID, "%s", vd->ifname);
+ LLDPAD_ERR("%s: LLDP TX state machine setting invalid state %d\n",
+ vd->ifname, newstate);
}
LLDPAD_DBG("%s(%i)-%s: state change %s -> %s\n", __func__, __LINE__,
@@ -462,8 +462,8 @@ static bool ecp_set_tx_state(struct vdp_data *vd)
}
return false;
default:
- LLDPAD_ERR("ERROR: The TX State Machine is broken!\n");
- log_message(MSG_ERR_TX_SM_INVALID, "%s", vd->ifname);
+ LLDPAD_ERR("%s: LLDP TX state machine in invalid state %d\n",
+ vd->ifname, vd->ecp.tx.state);
return false;
}
}
@@ -506,9 +506,8 @@ void ecp_tx_run_sm(struct vdp_data *vd)
vd->ifname, vd->ecp.lastSequence);
break;
default:
- LLDPAD_ERR("%s(%i): ERROR The TX State Machine is broken!\n", __func__,
- __LINE__);
- log_message(MSG_ERR_TX_SM_INVALID, "%s", vd->ifname);
+ LLDPAD_ERR("%s: LLDP TX state machine in invalid state %d\n",
+ vd->ifname, vd->ecp.tx.state);
}
} while (ecp_set_tx_state(vd) == true);
diff --git a/include/messages.h b/include/messages.h
index 795a0df..2991d33 100644
--- a/include/messages.h
+++ b/include/messages.h
@@ -29,37 +29,11 @@
#include <syslog.h>
#include <stdbool.h>
-#define MSG_INFO_DEBUG_STRING 1
-
-#define MSG_ERR_SERVICE_START_FAILURE 14
-#define MSG_ERR_RESOURCE_MEMORY 15
-#define MSG_ERR_ADD_CARD_FAILURE 16
-#define MSG_ERR_DCB_INVALID_TX_TOTAL_BWG 17
-#define MSG_ERR_DCB_INVALID_RX_TOTAL_BWG 18
-#define MSG_ERR_DCB_INVALID_TX_BWG_IDX 19
-#define MSG_ERR_DCB_INVALID_RX_BWG_IDX 20
-#define MSG_ERR_DCB_INVALID_TX_LSP_NZERO_BW_TC 21
-#define MSG_ERR_DCB_INVALID_RX_LSP_NZERO_BW_TC 22
-#define MSG_ERR_DCB_TOO_MANY_LSP_PGIDS 23
-#define MSG_ERR_DCB_INVALID_TX_ZERO_BW_TC 24
-#define MSG_ERR_DCB_INVALID_RX_ZERO_BW_TC 25
-#define MSG_ERR_DCB_INVALID_TX_LSP_NZERO_BWG 26
-#define MSG_ERR_DCB_INVALID_RX_LSP_NZERO_BWG 27
-#define MSG_ERR_DCB_INVALID_TX_BWG 28
-#define MSG_ERR_DCB_INVALID_RX_BWG 29
-#define MSG_ERR_TX_SM_INVALID 30
-#define MSG_ERR_RX_SM_INVALID 31
-#define MSG_ERR_DCB_INVALID_CONFIG_FILE 32
-
-#define MSG_INFO_LLINK_DISABLED 37
-#define MSG_INFO_LLINK_ENABLED 38
-#define MSG_INFO_LLINK_OPER 39
-#define MSG_ERR_LLINK_NONOPER 40
-
extern bool daemonize;
extern int loglvl;
-void log_message(__u32 dwMsgId, const char *pFormat, ...);
+void log_message(int loglvl, const char *pFormat, ...)
+ __attribute__((__format__(__printf__, 2, 3)));
#define LLDPAD_ERR(...) log_message(LOG_ERR, __VA_ARGS__)
#define LLDPAD_WARN(...) log_message(LOG_WARNING, __VA_ARGS__)
diff --git a/lldp/rx.c b/lldp/rx.c
index bbb2e2f..3954808 100644
--- a/lldp/rx.c
+++ b/lldp/rx.c
@@ -375,8 +375,8 @@ void rxProcessFrame(struct port * port)
}
if (!tlv_stored) {
- LLDPAD_INFO("\nrxProcessFrame: allocated TLV (%lu) "
- " was not stored! (%p)\n", tlv->type, tlv);
+ LLDPAD_INFO("%s: allocated TLV %u was not stored! %p\n",
+ __func__, tlv->type, tlv);
tlv = free_unpkd_tlv(tlv);
port->stats.statsTLVsUnrecognizedTotal++;
}
diff --git a/lldp_evb.c b/lldp_evb.c
index fe43af5..3895d71 100644
--- a/lldp_evb.c
+++ b/lldp_evb.c
@@ -648,17 +648,13 @@ struct lldp_module *evb_register(void)
mod = malloc(sizeof(*mod));
if (!mod) {
- LLDPAD_ERR("failed to malloc module data\n");
- log_message(MSG_ERR_SERVICE_START_FAILURE,
- "%s", "failed to malloc module data");
+ LLDPAD_ERR("lldpad failed to start - failed to malloc module data\n");
goto out_err;
}
ud = malloc(sizeof(struct evb_user_data));
if (!ud) {
free(mod);
- LLDPAD_ERR("failed to malloc module user data\n");
- log_message(MSG_ERR_SERVICE_START_FAILURE,
- "%s", "failed to malloc module user data");
+ LLDPAD_ERR("lldpad failed to start - failed to malloc module user data\n");
goto out_err;
}
LIST_INIT(&ud->head);
diff --git a/lldp_mand.c b/lldp_mand.c
index b5e8092..1bc4358 100644
--- a/lldp_mand.c
+++ b/lldp_mand.c
@@ -211,7 +211,7 @@ bld_config:
/* if invalid subtype, fall back to build */
if (!CHASSIS_ID_INVALID(chassis.sub)) {
- LLDPAD_DBG("%s:%s:from config %d bytes:str=%s\n",
+ LLDPAD_DBG("%s:%s:from config %zd bytes:str=%s\n",
__func__, md->ifname, length, chastr);
/* TODO: validate the loaded tlv */
goto bld_tlv;
@@ -358,7 +358,7 @@ bld_config:
/* if invalid subtype, fall back to build */
if (!PORT_ID_INVALID(portid.sub)) {
- LLDPAD_DBG("%s:%s:from config %d bytes:str=%s\n",
+ LLDPAD_DBG("%s:%s:from config %zd bytes:str=%s\n",
__func__, md->ifname, length, porstr);
/* TODO: validate the loaded tlv */
goto bld_tlv;
diff --git a/lldp_vdp.c b/lldp_vdp.c
index 2875bf5..5b8ce46 100644
--- a/lldp_vdp.c
+++ b/lldp_vdp.c
@@ -596,8 +596,8 @@ static bool vdp_vsi_set_station_state(struct vsi_profile *profile)
case VSI_EXIT:
return false;
default:
- LLDPAD_ERR("ERROR: The VSI RX State Machine is broken!\n");
- log_message(MSG_ERR_RX_SM_INVALID, "");
+ LLDPAD_ERR("%s: VSI state machine in invalid state %d\n",
+ profile->port->ifname, profile->state);
return false;
}
}
@@ -668,8 +668,8 @@ void vdp_vsi_sm_station(struct vsi_profile *profile)
vdp_remove_profile(profile);
break;
default:
- LLDPAD_ERR("ERROR: The VSI RX station State Machine is broken!\n");
- log_message(MSG_ERR_TX_SM_INVALID, "");
+ LLDPAD_ERR("%s: VSI state machine in invalid state %d\n",
+ vd->ifname, profile->state);
}
} while (vdp_vsi_set_station_state(profile) == true);
@@ -792,8 +792,8 @@ static bool vdp_vsi_set_bridge_state(struct vsi_profile *profile)
case VSI_EXIT:
return false;
default:
- LLDPAD_ERR("ERROR: The VSI RX State Machine (bridge) is broken!\n");
- log_message(MSG_ERR_RX_SM_INVALID, "");
+ LLDPAD_ERR("%s: VSI state machine (bridge) in invalid state %d\n",
+ profile->port->ifname, profile->state);
return false;
}
}
@@ -850,8 +850,8 @@ static void vdp_vsi_sm_bridge(struct vsi_profile *profile)
vdp_remove_profile(profile);
break;
default:
- LLDPAD_ERR("ERROR: The VSI RX bridge State Machine is broken!\n");
- log_message(MSG_ERR_TX_SM_INVALID, "");
+ LLDPAD_ERR("%s: VSI state machine in invalid state %d\n",
+ vd->ifname, profile->state);
}
} while (vdp_vsi_set_bridge_state(profile) == true);
@@ -1454,17 +1454,13 @@ struct lldp_module *vdp_register(void)
mod = malloc(sizeof(*mod));
if (!mod) {
- LLDPAD_ERR("failed to malloc module data\n");
- log_message(MSG_ERR_SERVICE_START_FAILURE,
- "%s", "failed to malloc module data");
+ LLDPAD_ERR("lldpad failed to start - failed to malloc module data\n");
goto out_err;
}
ud = malloc(sizeof(struct vdp_user_data));
if (!ud) {
free(mod);
- LLDPAD_ERR("failed to malloc module user data\n");
- log_message(MSG_ERR_SERVICE_START_FAILURE,
- "%s", "failed to malloc module user data");
+ LLDPAD_ERR("lldpad failed to start - failed to malloc module user data\n");
goto out_err;
}
LIST_INIT(&ud->head);
diff --git a/lldpad.c b/lldpad.c
index 6105985..a1a7ac1 100644
--- a/lldpad.c
+++ b/lldpad.c
@@ -370,8 +370,7 @@ int main(int argc, char *argv[])
* 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");
+ LLDPAD_ERR("lldpad failed to start - failed to register user space event interface\n");
exit(1);
}
@@ -398,8 +397,7 @@ int main(int argc, char *argv[])
if (ctrl_iface_register(clifd) < 0) {
if (!daemonize)
fprintf(stderr, "failed to register control interface\n");
- log_message(MSG_ERR_SERVICE_START_FAILURE,
- "%s", "failed to register control interface");
+ LLDPAD_ERR("lldpad failed to start - failed to register control interface\n");
exit(1);
}
diff --git a/log.c b/log.c
index e0aa3e5..57ac256 100644
--- a/log.c
+++ b/log.c
@@ -27,160 +27,18 @@
#include <stdio.h>
#include <syslog.h>
#include <stdarg.h>
-#include "dcb_protocol.h"
#include "messages.h"
-#include "lldpad.h"
-
-void log_message(u32 msgid, const char *format, ...)
+void log_message(int level, const char *format, ...)
{
- int a, b;
- char fmt[256];
-
va_list va, vb;
va_start(va, format);
va_copy(vb, va);
- if (!daemonize && loglvl >= msgid) {
+ if (daemonize)
+ vsyslog(level, format, vb);
+ else if (loglvl >= level)
vprintf(format, vb);
- va_end(va);
- return;
- } else if (!daemonize) {
- va_end(va);
- return;
- }
-
- switch(msgid) {
- case MSG_INFO_DEBUG_STRING:
- vsyslog(LOG_DEBUG, format, vb);
- break;
- case MSG_ERR_SERVICE_START_FAILURE:
- snprintf(fmt, sizeof(fmt), "lldpad failed to start - %s", format);
- syslog(LOG_ERR, fmt, va_arg(va, char *));
- break;
- case MSG_ERR_RESOURCE_MEMORY:
- break;
- case MSG_ERR_ADD_CARD_FAILURE:
- syslog(LOG_ERR,
- "failed to add interface %s",
- va_arg(va, char *));
- break;
- case MSG_ERR_DCB_INVALID_TX_TOTAL_BWG:
- syslog(LOG_ERR,
- "invalid total priority group bandwidth for tx [%d%%]",
- va_arg(va, int));
- break;
- case MSG_ERR_DCB_INVALID_RX_TOTAL_BWG:
- syslog(LOG_ERR,
- "invalid total priority group bandwidth for rx [%d%%]",
- va_arg(va, int));
- break;
- case MSG_ERR_DCB_INVALID_TX_BWG_IDX:
- syslog(LOG_ERR,
- "invalid transmit priority group index [%d]",
- va_arg(va, int));
- break;
- case MSG_ERR_DCB_INVALID_RX_BWG_IDX:
- syslog(LOG_ERR,
- "invalid receive priority group index [%d]",
- va_arg(va, int));
- break;
- case MSG_ERR_DCB_INVALID_TX_LSP_NZERO_BW_TC:
- a = va_arg(va, int);
- b = va_arg(va, int);
- syslog(LOG_ERR,
- "transmit link strict user priority[%d] has non-zero "
- "bandwidth [%d%%]", a, b);
- break;
- case MSG_ERR_DCB_INVALID_RX_LSP_NZERO_BW_TC:
- a = va_arg(va, int);
- b = va_arg(va, int);
- syslog(LOG_ERR,
- "receive link strict user priority[%d] has non-zero "
- "bandwidth [%d%%]", a, b);
- break;
- case MSG_ERR_DCB_TOO_MANY_LSP_PGIDS:
- syslog(LOG_ERR,
- "only one link strict priority group is allowed [%d%%]",
- va_arg(va, int));
- break;
- case MSG_ERR_DCB_INVALID_TX_ZERO_BW_TC:
- syslog(LOG_ERR,
- "transmit user priority[%d] has zero bandwidth",
- va_arg(va, int));
- break;
- case MSG_ERR_DCB_INVALID_RX_ZERO_BW_TC:
- syslog(LOG_ERR,
- "receive user priority[%d] has zero bandwidth",
- va_arg(va, int));
- break;
- case MSG_ERR_DCB_INVALID_TX_LSP_NZERO_BWG:
- a = va_arg(va, int);
- b = va_arg(va, int);
- syslog(LOG_ERR,
- "transmit link strict priority group [%d] has a "
- "non-zero bandwidth [%d%%]", a, b);
- break;
- case MSG_ERR_DCB_INVALID_RX_LSP_NZERO_BWG:
- a = va_arg(va, int);
- b = va_arg(va, int);
- syslog(LOG_ERR,
- "receive link strict priority group [%d] has a "
- "non-zero bandwidth [%d%%]", a, b);
- break;
- case MSG_ERR_DCB_INVALID_TX_BWG:
- a = va_arg(va, int);
- b = va_arg(va, int);
- syslog(LOG_ERR,
- "transmit priority group [%d] has invalid total "
- "bandwidth [%d%%], should be 0 or 100", a, b);
- break;
- case MSG_ERR_DCB_INVALID_RX_BWG:
- a = va_arg(va, int);
- b = va_arg(va, int);
- syslog(LOG_ERR,
- "receive priority group [%d] has invalid total "
- "bandwidth [%d%%], should be 0 or 100", a, b);
- break;
- case MSG_ERR_TX_SM_INVALID:
- syslog(LOG_ERR,
- "LLDP transmit state machine encountered an invalid "
- "state.");
- break;
- case MSG_ERR_RX_SM_INVALID:
- syslog(LOG_ERR,
- "LLDP receive state machine encountered an invalid "
- "state.");
- break;
- case MSG_ERR_DCB_INVALID_CONFIG_FILE:
- syslog(LOG_ERR,
- "lldpad failed to read config file - %s",
- va_arg(va, char *));
- break;
- case MSG_INFO_LLINK_DISABLED:
- syslog(LOG_INFO,
- "FCoE logical link on %s is disabled",
- va_arg(va, char *));
- break;
- case MSG_INFO_LLINK_ENABLED:
- syslog(LOG_INFO,
- "FCoE logical link on %s is enabled",
- va_arg(va, char *));
- break;
- case MSG_INFO_LLINK_OPER:
- syslog(LOG_INFO,
- "FCoE logical link on %s is operational",
- va_arg(va, char *));
- break;
- case MSG_ERR_LLINK_NONOPER:
- syslog(LOG_ERR,
- "FCoE logical link on %s is not operational",
- va_arg(va, char *));
- break;
- default:
- vsyslog(msgid, format, vb);
- break;
- }
va_end(va);
}
--
1.7.6

View File

@ -0,0 +1,41 @@
From 8d52cc5868799831315f12df20be3ea304e367ba Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 27 Jul 2011 15:07:53 -0700
Subject: [PATCH 15/29] lldpad: dcbx mode needs to be set before set_state()
cmd
lldp_dcbx issues a set_state() command before setting the dcbx
mode. In almost all cases this is OK because we don't use dcbx
mode unless the driver is already setup this way or we received
a CEE DCBX frame which already set the mode.
The corner case being when the user manually forces CEE mode
in this case the driver may be in IEEE mode and we need to
set the mode before issueing CEE commands otherwise the driver
may be expecting IEEE cmds or the driver and lldpad can become
out of sync.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
lldp_dcbx.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lldp_dcbx.c b/lldp_dcbx.c
index efde957..4cf2cb5 100644
--- a/lldp_dcbx.c
+++ b/lldp_dcbx.c
@@ -567,9 +567,9 @@ initialized:
*/
get_dcb_capabilities(ifname, &dcb_support);
if (!dcb_support.dcbx || (gdcbx_subtype & ~MASK_DCBX_FORCE)) {
- set_hw_state(ifname, 1);
set_dcbx_mode(tlvs->ifname,
DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_CEE);
+ set_hw_state(ifname, 1);
tlvs->active = true;
} else {
tlvs->active = false;
--
1.7.6

View File

@ -0,0 +1,35 @@
From 9def6743917089885f5135c9d244361fff2b8326 Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 27 Jul 2011 15:07:58 -0700
Subject: [PATCH 16/29] lldpad: fix compile warnings in 802.1Qaz debug code
802.1Qaz debug print code contains some compile warnings.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
lldp_8021qaz.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lldp_8021qaz.c b/lldp_8021qaz.c
index adeb0eb..2a6685b 100644
--- a/lldp_8021qaz.c
+++ b/lldp_8021qaz.c
@@ -645,12 +645,12 @@ void print_pfc(struct ieee_pfc *pfc)
printf("\t requests: ");
for (i = 0; i < 8; i++)
- printf("%i ", pfc->requests[i]);
+ printf("%llu ", pfc->requests[i]);
printf("\n");
printf("\t indications: ");
for (i = 0; i < 8; i++)
- printf("%i ", pfc->indications[i]);
+ printf("%llu ", pfc->indications[i]);
printf("\n");
}
#endif
--
1.7.6

View File

@ -0,0 +1,66 @@
From 4825abfcadd579b3603994f2e98487ee3b14ef26 Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 27 Jul 2011 15:03:39 -0700
Subject: [PATCH 07/29] lldpad: remove app data on CEE unregister
When CEE is unregistered the CEE app data should be removed.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
dcb_protocol.c | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/dcb_protocol.c b/dcb_protocol.c
index 0bb13b9..310b071 100644
--- a/dcb_protocol.c
+++ b/dcb_protocol.c
@@ -1243,6 +1243,35 @@ dcb_result save_dcbx_state(const char *device_name)
return dcb_failed;
}
+static int dcbx_free_app_config(char *device_name)
+{
+ app_it Oper, Local;
+ appgroup_attribs app_data;
+
+ /* Free FCoE APP data */
+ Oper = apptlv_find(&oper_apptlv, device_name, APP_FCOE_STYPE);
+ Local = apptlv_find(&apptlv, device_name, APP_FCOE_STYPE);
+ if (Oper || Local) {
+ app_data.dcb_app_idtype = DCB_APP_IDTYPE_ETHTYPE;
+ app_data.dcb_app_id = APP_FCOE_ETHTYPE;
+ app_data.dcb_app_priority = 0;
+ set_hw_app(device_name, &app_data);
+ }
+
+ /* Free iSCSI APP data */
+ Oper = apptlv_find(&oper_apptlv, device_name, APP_ISCSI_STYPE);
+ Local = apptlv_find(&apptlv, device_name, APP_ISCSI_STYPE);
+ if (Oper || Local) {
+ app_data.dcb_app_idtype = DCB_APP_IDTYPE_PORTNUM;
+ app_data.dcb_app_id = APP_ISCSI_PORT;
+ app_data.dcb_app_priority = 0;
+
+ set_hw_app(device_name, &app_data);
+ }
+
+ return 0;
+}
+
int dcbx_remove_all(void)
{
pg_it it;
@@ -1258,6 +1287,9 @@ int dcbx_remove_all(void)
save_dcbx_state(it->ifname);
+ /* Remove kernel APP entries */
+ dcbx_free_app_config(it->ifname);
+
/* prepare sTmp in case of error */
snprintf(sTmp, MAX_DEVICE_NAME_LEN*2, /* Localization OK */
"Remove_all_adapters error: Bad device name: %.*s\n",
--
1.7.6

View File

@ -0,0 +1,150 @@
From 5620244e0e10af4d3ab65d039ee2ae3f2f08181b Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 27 Jul 2011 15:03:46 -0700
Subject: [PATCH 08/29] lldpad: remove unused exported DCBX routines
Remove various DCBX routines that are not actually used.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
dcb_protocol.c | 71 ------------------------------------------------
include/dcb_protocol.h | 6 ----
2 files changed, 0 insertions(+), 77 deletions(-)
diff --git a/dcb_protocol.c b/dcb_protocol.c
index 310b071..fec437d 100644
--- a/dcb_protocol.c
+++ b/dcb_protocol.c
@@ -1380,21 +1380,6 @@ bool add_pg_defaults()
return result;
}
-bool remove_pg_defaults()
-{
- char sTmp[MAX_DESCRIPTION_LEN];
-
- snprintf(sTmp, MAX_DESCRIPTION_LEN, DEF_CFG_STORE);
- pg_it itpg = pg_find(&pg, sTmp);
- if (itpg == NULL)
- return false;
-
- /* erase and free memory */
- pg_erase(&itpg);
-
- return true;
-}
-
bool add_pfc_defaults()
{
pfc_attribs pfc_data;
@@ -1427,21 +1412,6 @@ bool add_pfc_defaults()
return result;
}
-bool remove_pfc_defaults()
-{
- char sTmp[MAX_DESCRIPTION_LEN];
-
- snprintf(sTmp, MAX_DESCRIPTION_LEN, DEF_CFG_STORE);
- pfc_it itpfc = pfc_find(&pfc, sTmp);
- if (itpfc == NULL)
- return false;
-
- /* erase and free memory */
- pfc_erase(&itpfc);
-
- return true;
-}
-
bool add_app_defaults(u32 subtype)
{
app_attribs app_data;
@@ -1484,22 +1454,6 @@ bool add_app_defaults(u32 subtype)
return result;
}
-bool remove_app_defaults(u32 subtype)
-{
- char sTmp[MAX_DESCRIPTION_LEN];
-
- snprintf(sTmp, MAX_DESCRIPTION_LEN, "%s", DEF_CFG_STORE);
- app_it it = apptlv_find(&apptlv, sTmp, subtype);
-
- if (it == NULL)
- return false;
-
- /* erase and free memory */
- apptlv_erase(&it);
-
- return true;
-}
-
bool add_llink_defaults(u32 subtype)
{
llink_attribs llink_data;
@@ -1529,21 +1483,6 @@ bool add_llink_defaults(u32 subtype)
return result;
}
-bool remove_llink_defaults(u32 subtype)
-{
- char sTmp[MAX_DESCRIPTION_LEN];
-
- snprintf(sTmp, MAX_DESCRIPTION_LEN, "%s", DEF_CFG_STORE);
- llink_it itllink = llink_find(&llink, sTmp, subtype);
- if (itllink == NULL)
- return false;
-
- /* erase and free memory */
- llink_erase(&itllink);
-
- return true;
-}
-
dcb_result get_pg(char *device_name, pg_attribs *pg_data)
{
dcb_result result = dcb_success;
@@ -1566,16 +1505,6 @@ dcb_result get_pg(char *device_name, pg_attribs *pg_data)
return result;
}
-dcb_result test_device_dstore(char *device_name)
-{
- pg_it it = pg_find(&pg, device_name);
- if (it != NULL) {
- return dcb_success;
- } else {
- return dcb_device_not_found;
- }
-}
-
dcb_result get_oper_pg(char *device_name, pg_attribs *pg_data)
{
dcb_result result = dcb_success;
diff --git a/include/dcb_protocol.h b/include/dcb_protocol.h
index c7b4d6d..19b1bad 100644
--- a/include/dcb_protocol.h
+++ b/include/dcb_protocol.h
@@ -78,18 +78,12 @@ void remove_dcb_support(void);
bool add_pg_defaults(void);
bool add_pfc_defaults(void);
bool add_app_defaults(u32 subtype);
-bool remove_pg_defaults(void);
-bool remove_pfc_defaults(void);
-bool remove_app_defaults(u32 subtype);
void mark_pg_sent(char *device_name);
void mark_pfc_sent(char *device_name);
void mark_app_sent(char *device_name, u32 subtype);
bool add_llink_defaults(u32 subtype);
-bool remove_llink_defaults(u32 subtype);
void mark_llink_sent(char *device_name, u32 subtype);
-dcb_result test_device_dstore(char *device_name);
-
dcb_result get_control(char *device_name,
control_protocol_attribs *control_data);
dcb_result get_peer_control(char *device_name,
--
1.7.6

View File

@ -0,0 +1,91 @@
From 4c0e75a22638da49dbbe78e46e61a334ada721b1 Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 27 Jul 2011 15:07:48 -0700
Subject: [PATCH 14/29] lldpad: resolve segfault with ECP and bonding
A segfault occurs with ECP and bonded devices because
the port lookup fails on bonds. ECP does not verify
the port lookup is successful.
I do not believe VDP should run over the bonded interface
so this patch aborts VDP initialization on bond devices
and avoids port lookup completely.
Also add checks for null pointers in ECP.
CC: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
ecp/ecp_rx.c | 7 ++++++-
ecp/ecp_tx.c | 6 +++++-
lldp_vdp.c | 4 ++++
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/ecp/ecp_rx.c b/ecp/ecp_rx.c
index bd5a1e1..74e9f32 100644
--- a/ecp/ecp_rx.c
+++ b/ecp/ecp_rx.c
@@ -211,7 +211,9 @@ void ecp_rx_ReceiveFrame(void *ctx, unsigned int ifindex, const u8 *buf, size_t
LLDPAD_DBG("%s(%i)-%s: received packet with size %i\n", __func__, __LINE__,
vd->ifname, (int) len);
- if (port->adminStatus == disabled || port->adminStatus == enabledTxOnly)
+ if (!port ||
+ port->adminStatus == disabled ||
+ port->adminStatus == enabledTxOnly)
return;
if (vd->ecp.rx.framein &&
@@ -534,6 +536,9 @@ bool ecp_set_rx_state(struct vdp_data *vd)
{
struct port *port = port_find_by_name(vd->ifname);
+ if (!port)
+ return false;
+
if (port->portEnabled == false) {
ecp_rx_change_state(vd, ECP_RX_IDLE);
}
diff --git a/ecp/ecp_tx.c b/ecp/ecp_tx.c
index cbf2e11..f9ee3d7 100644
--- a/ecp/ecp_tx.c
+++ b/ecp/ecp_tx.c
@@ -236,6 +236,11 @@ error:
*/
void ecp_tx_Initialize(struct vdp_data *vd)
{
+ struct port *port = port_find_by_name(vd->ifname);
+
+ if (!port)
+ return;
+
if (vd->ecp.tx.frameout) {
free(vd->ecp.tx.frameout);
vd->ecp.tx.frameout = NULL;
@@ -246,7 +251,6 @@ void ecp_tx_Initialize(struct vdp_data *vd)
vd->ecp.ackTimer = ECP_ACK_TIMER_STOPPED;
vd->ecp.retries = 0;
- struct port *port = port_find_by_name(vd->ifname);
l2_packet_get_port_state(vd->ecp.l2, (u8 *)&(port->portEnabled));
return;
diff --git a/lldp_vdp.c b/lldp_vdp.c
index 5a8ab55..2875bf5 100644
--- a/lldp_vdp.c
+++ b/lldp_vdp.c
@@ -1349,6 +1349,10 @@ void vdp_ifup(char *ifname)
struct port *port;
struct vsi_profile *p;
+ /* VDP does not support bonded devices */
+ if (is_bond(ifname))
+ return;
+
LLDPAD_DBG("%s(%i): starting VDP for if %s !\n", __func__, __LINE__, ifname);
vd = vdp_data(ifname);
--
1.7.6

View File

@ -0,0 +1,74 @@
From e126f697e635eb83410003e99c905ebd1788f149 Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 27 Jul 2011 15:07:43 -0700
Subject: [PATCH 13/29] lldpad: use is_valid_lldp_device() in scan path
lldpad can miss netlink events when this occurs we do
an explicit scan of the ports and set them to the
correct state.
This replaces a series of if/else statements with
the is_valid_lldp_device() call.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
config.c | 40 ++++++++++++++++++++--------------------
1 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/config.c b/config.c
index a8ebe17..4c82bb6 100644
--- a/config.c
+++ b/config.c
@@ -346,28 +346,28 @@ void init_ports(void)
p = nameidx;
while (p->if_index != 0) {
- if (is_loopback(p->if_name)) {
- ;
- } else if (is_bond(p->if_name)) {
- if (add_bond_port(p->if_name) < 0)
- syslog(LOG_ERR, "failed to register port %s",
- 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 {
- add_port(p->if_name);
+ int valid = is_valid_lldp_device(p->if_name);
+ int err;
- if (check_link_status(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);
+ if (!valid) {
+ p++;
+ continue;
+ }
+
+ if (is_bond(p->if_name))
+ err = add_bond_port(p->if_name);
+ else
+ err = add_port(p->if_name);
+
+ if (err) {
+ LLDPAD_ERR("%s: Error adding device %s\n",
+ __func__, p->if_name);
+ } else if (check_link_status(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++;
}
--
1.7.6

View File

@ -0,0 +1,51 @@
From 97cee02130b395a7c98616b916c9c0e5eae126d4 Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 27 Jul 2011 15:20:06 -0700
Subject: [PATCH 20/29] lldptool: better TLV_ID validation
Wire up 'strtoul' so that input TLV_ID must be an exact match.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
lldptool.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/lldptool.c b/lldptool.c
index 26e6d1a..db77a6e 100644
--- a/lldptool.c
+++ b/lldptool.c
@@ -35,6 +35,7 @@
#include <unistd.h>
#include <signal.h>
#include <ctype.h>
+#include <errno.h>
#include "clif.h"
#include "lldp_mand_clif.h"
@@ -437,7 +438,7 @@ static int request(struct clif *clif, int argc, char *argv[])
int newraw = 0;
int numargs = 0;
char **argptr = &argv[0];
-
+ char *end;
int c;
memset((void *)&command, 0, sizeof(command));
@@ -470,8 +471,11 @@ static int request(struct clif *clif, int argc, char *argv[])
}
/* Currently tlvid unset lookup and verify parameter */
- command.tlvid = strtoul(optarg, (char **) NULL, 0);
- if (!command.tlvid) {
+ errno = 0;
+ command.tlvid = strtoul(optarg, &end, 0);
+
+ if (!command.tlvid || errno || *end != '\0' ||
+ end == optarg) {
command.tlvid = lookup_tlvid(optarg);
}
--
1.7.6

View File

@ -0,0 +1,102 @@
From de767ee03e6c0c4b0d7bb7df4c8c97c656cd955f Mon Sep 17 00:00:00 2001
From: Jens Osterkamp <jens@linux.vnet.ibm.com>
Date: Mon, 15 Aug 2011 18:17:05 -0700
Subject: [PATCH 27/29] prevent crash on invalid response code
If an unknown response code was received for a profile, the lookup of the
error string could cause a crash.
Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
include/lldp_vdp.h | 2 ++
lldp_vdp.c | 24 +++++++++++++++++++++++-
lldp_vdp_cmds.c | 2 +-
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/include/lldp_vdp.h b/include/lldp_vdp.h
index 2f6adf8..b9fd37f 100644
--- a/include/lldp_vdp.h
+++ b/include/lldp_vdp.h
@@ -43,6 +43,7 @@
#define VDP_RESPONSE_VTID_VIOLATION 0x4
#define VDP_RESPONSE_VTID_VER_VIOLATION 0x5
#define VDP_RESPONSE_OUT_OF_SYNC 0x6
+#define VDP_RESPONSE_UNKNOWN 0xfe
#define VDP_RESPONSE_NO_RESPONSE 0xff
extern const char * const vsi_responses[];
@@ -137,6 +138,7 @@ void vdp_ack_profiles(struct vdp_data *vd, int seqnr);
int vdp_indicate(struct vdp_data *vd, struct unpacked_tlv *tlv, int ecp_mode);
int vdp_vsis_pending(struct vdp_data *vd);
int vdp_vsis(char *ifname);
+const char *vdp_response2str(int);
void vdp_print_profile(struct vsi_profile *);
void ecp_somethingChangedLocal(struct vdp_data *vd, bool flag);
void ecp_rx_send_ack_frame(struct vdp_data *vd);
diff --git a/lldp_vdp.c b/lldp_vdp.c
index 5b8ce46..15fed51 100644
--- a/lldp_vdp.c
+++ b/lldp_vdp.c
@@ -51,6 +51,8 @@ const char * const vsi_responses[] = {
[VDP_RESPONSE_VTID_VIOLATION] = "VTID violation",
[VDP_RESPONSE_VTID_VER_VIOLATION] = "VTID version violation",
[VDP_RESPONSE_OUT_OF_SYNC] = "out of sync",
+ [VDP_RESPONSE_UNKNOWN] = "unknown response",
+ [VDP_RESPONSE_NO_RESPONSE] = "no response",
};
const char * const vsi_states[] = {
@@ -124,6 +126,26 @@ static void vdp_free_data(struct vdp_user_data *ud)
}
}
+/* vdp_response2str - map response to string
+ * @response: response received
+ *
+ * no return value
+ *
+ * maps VDP response received for a profile to human readable string for
+ * printing.
+ */
+const char *vdp_response2str(int response)
+{
+ if ((response >= VDP_RESPONSE_SUCCESS) &&
+ (response <= VDP_RESPONSE_OUT_OF_SYNC))
+ return vsi_responses[response];
+
+ if (response == VDP_RESPONSE_NO_RESPONSE)
+ return vsi_responses[VDP_RESPONSE_NO_RESPONSE];
+
+ return vsi_responses[VDP_RESPONSE_UNKNOWN];
+}
+
/* vdp_print_profile - print a vsi profile
* @profile: profile to print
*
@@ -990,7 +1012,7 @@ int vdp_indicate(struct vdp_data *vd, struct unpacked_tlv *tlv, int ecp_mode)
LLDPAD_DBG("%s(%i): profile response: %s (%i) "
"for profile 0x%02x at state %s.\n",
__func__, __LINE__,
- vsi_responses[p->response],
+ vdp_response2str(p->response),
p->response, p->instance[15],
vsi_states[p->state]);
free(profile);
diff --git a/lldp_vdp_cmds.c b/lldp_vdp_cmds.c
index 8cc871f..04f6fc1 100644
--- a/lldp_vdp_cmds.c
+++ b/lldp_vdp_cmds.c
@@ -97,7 +97,7 @@ static char * print_profile(char *s, size_t length, struct vsi_profile *p)
return r;
c = snprintf(s, length, "response: %i (%s)\n", p->response,
- vsi_responses[p->response]);
+ vdp_response2str(p->response));
s = check_and_update(&total, &length, s, c);
if (!s)
return r;
--
1.7.6

View File

@ -0,0 +1,186 @@
From 384ba242de2b71c42f90e8451e01bbded47dcc8c Mon Sep 17 00:00:00 2001
From: Jens Osterkamp <jens@linux.vnet.ibm.com>
Date: Mon, 15 Aug 2011 18:18:06 -0700
Subject: [PATCH 29/29] some minor bugfixes
This patch summarizes a number of minor bugfixes:
- In case lldpad.conf cannot be created, add a line break to error message.
- add IFLA_AF_SPEC and IFLA_GROUP from newer kernels to lldpad
- consolidate while (port != NULL) loops to port_find_by_name().
- whitespace fixes in lldp_dcbx.c
Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <contyk@redhat.com>
---
config.c | 2 +-
event_iface.c | 6 +++++
include/linux/if_link.h | 2 +
lldp/ports.c | 51 ++++++----------------------------------------
lldp_dcbx.c | 4 +-
5 files changed, 18 insertions(+), 47 deletions(-)
diff --git a/config.c b/config.c
index 4c82bb6..648f6f9 100644
--- a/config.c
+++ b/config.c
@@ -201,7 +201,7 @@ int check_cfg_file(void)
O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (fd < 0) {
retval = errno;
- LLDPAD_ERR("error creating %s", cfg_file_name);
+ LLDPAD_ERR("error creating %s !\n", cfg_file_name);
} else {
close(fd);
create_default_cfg_file();
diff --git a/event_iface.c b/event_iface.c
index e581bce..1288fae 100644
--- a/event_iface.c
+++ b/event_iface.c
@@ -174,6 +174,12 @@ static void event_if_decode_rta(int type, struct rtattr *rta, int *ls, char *d)
case IFLA_PORT_SELF:
LLDPAD_DBG(" IFLA_PORT_SELF\n");
break;
+ case IFLA_AF_SPEC:
+ LLDPAD_DBG(" IFLA_AF_SPEC\n");
+ break;
+ case IFLA_GROUP:
+ LLDPAD_DBG(" IFLA_GROUP\n");
+ break;
default:
LLDPAD_DBG(" unknown type : 0x%02x\n", type);
break;
diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index 2fc66dd..4fdfd38 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -116,6 +116,8 @@ enum {
IFLA_STATS64,
IFLA_VF_PORTS,
IFLA_PORT_SELF,
+ IFLA_AF_SPEC,
+ IFLA_GROUP, /* Group the device belongs to */
__IFLA_MAX
};
diff --git a/lldp/ports.c b/lldp/ports.c
index 925a2ad..596e68b 100644
--- a/lldp/ports.c
+++ b/lldp/ports.c
@@ -156,16 +156,10 @@ void set_lldp_port_enable_state(const char *ifname, int enable)
{
struct port *port = NULL;
- port = porthead;
- while (port != NULL) {
- if (!strncmp(ifname, port->ifname, IFNAMSIZ))
- break;
- port = port->next;
- }
+ port = port_find_by_name(ifname);
- if (port == NULL) {
+ if (port == NULL)
return;
- }
port->portEnabled = (u8)enable;
@@ -178,14 +172,7 @@ void set_lldp_port_enable_state(const char *ifname, int enable)
void set_port_oper_delay(const char *ifname)
{
- struct port *port = NULL;
-
- port = porthead;
- while (port != NULL) {
- if (!strncmp(ifname, port->ifname, IFNAMSIZ))
- break;
- port = port->next;
- }
+ struct port *port = port_find_by_name(ifname);
if (port == NULL)
return;
@@ -198,13 +185,7 @@ int set_port_hw_resetting(const char *ifname, int resetting)
{
struct port *port = NULL;
- port = porthead;
- while (port != NULL) {
- if (!strncmp(ifname, port->ifname, IFNAMSIZ)) {
- break;
- }
- port = port->next;
- }
+ port = port_find_by_name(ifname);
if (port == NULL)
return -1;
@@ -218,12 +199,7 @@ int get_port_hw_resetting(const char *ifname)
{
struct port *port = NULL;
- port = porthead;
- while (port != NULL) {
- if (!strncmp(ifname, port->ifname, IFNAMSIZ))
- break;
- port = port->next;
- }
+ port = port_find_by_name(ifname);
if (port)
return port->hw_resetting;
@@ -235,12 +211,7 @@ int reinit_port(const char *ifname)
{
struct port *port;
- port = porthead;
- while (port != NULL) {
- if (!strncmp(ifname, port->ifname, IFNAMSIZ))
- break;
- port = port->next;
- }
+ port = port_find_by_name(ifname);
if (!port)
return -1;
@@ -347,15 +318,7 @@ int remove_port(const char *ifname)
struct port *port = NULL; /* Pointer to port to remove */
struct port *parent = NULL; /* Pointer to previous on port stack */
- port = porthead;
- while (port != NULL) {
- if (!strncmp(ifname, port->ifname, IFNAMSIZ)) {
- LLDPAD_DBG("In remove_port: Found port %s\n",port->ifname);
- break;
- }
- parent = port;
- port = port->next;
- }
+ port = port_find_by_name(ifname);
if (port == NULL) {
LLDPAD_DBG("remove_port: port not present\n");
diff --git a/lldp_dcbx.c b/lldp_dcbx.c
index 7949147..6ca290c 100644
--- a/lldp_dcbx.c
+++ b/lldp_dcbx.c
@@ -58,8 +58,8 @@ void dcbx_free_tlv(struct dcbx_tlvs *tlvs);
static int dcbx_check_operstate(struct port *port);
const struct lldp_mod_ops dcbx_ops = {
- .lldp_mod_register = dcbx_register,
- .lldp_mod_unregister = dcbx_unregister,
+ .lldp_mod_register = dcbx_register,
+ .lldp_mod_unregister = dcbx_unregister,
.lldp_mod_gettlv = dcbx_gettlv,
.lldp_mod_rchange = dcbx_rchange,
.lldp_mod_ifup = dcbx_ifup,
--
1.7.6

View File

@ -0,0 +1,169 @@
For vdp to be usable, enabletx must be set to true. The check for enabletx
needs to be made before checking if vdp_data for this ifname already exists.
Otherwise VDP is running even though enabletx is false.
Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
---
ecp/ecp_rx.c | 10 +++-------
ecp/ecp_tx.c | 7 +++----
include/lldp_vdp.h | 1 +
lldp_vdp.c | 38 ++++++++++++++++++++++----------------
4 files changed, 29 insertions(+), 27 deletions(-)
diff --git a/ecp/ecp_rx.c b/ecp/ecp_rx.c
index a56cd3b..182b911 100644
--- a/ecp/ecp_rx.c
+++ b/ecp/ecp_rx.c
@@ -211,9 +211,7 @@ void ecp_rx_ReceiveFrame(void *ctx, unsigned int ifindex, const u8 *buf, size_t
LLDPAD_DBG("%s(%i)-%s: received packet with size %i\n", __func__, __LINE__,
vd->ifname, (int) len);
- if (!port ||
- port->adminStatus == disabled ||
- port->adminStatus == enabledTxOnly)
+ if (vd->enabletx == false)
return;
if (vd->ecp.rx.framein &&
@@ -551,15 +549,13 @@ bool ecp_set_rx_state(struct vdp_data *vd)
}
return false;
case ECP_RX_INIT_RECEIVE:
- if ((port->adminStatus == enabledRxTx) ||
- (port->adminStatus == enabledRxOnly)) {
+ if (vd->enabletx == true) {
ecp_rx_change_state(vd, ECP_RX_RECEIVE_WAIT);
return true;
}
return false;
case ECP_RX_RECEIVE_WAIT:
- if ((port->adminStatus == disabled) ||
- (port->adminStatus == enabledTxOnly)) {
+ if (vd->enabletx == false) {
ecp_rx_change_state(vd, ECP_RX_IDLE);
return true;
}
diff --git a/ecp/ecp_tx.c b/ecp/ecp_tx.c
index c81e101..8a9d2b0 100644
--- a/ecp/ecp_tx.c
+++ b/ecp/ecp_tx.c
@@ -414,15 +414,14 @@ static bool ecp_set_tx_state(struct vdp_data *vd)
switch (vd->ecp.tx.state) {
case ECP_TX_INIT_TRANSMIT:
- if (port->portEnabled && ((port->adminStatus == enabledRxTx) ||
- (port->adminStatus == enabledTxOnly)) && vd->ecp.tx.localChange) {
+ if (port->portEnabled && (vd->enabletx == true)
+ && vd->ecp.tx.localChange) {
ecp_tx_change_state(vd, ECP_TX_TRANSMIT_ECPDU);
return true;
}
return false;
case ECP_TX_TRANSMIT_ECPDU:
- if ((port->adminStatus == disabled) ||
- (port->adminStatus == enabledRxOnly)) {
+ if (vd->enabletx == false) {
ecp_tx_change_state(vd, ECP_TX_INIT_TRANSMIT);
return true;
}
diff --git a/include/lldp_vdp.h b/include/lldp_vdp.h
index b9fd37f..1192364 100644
--- a/include/lldp_vdp.h
+++ b/include/lldp_vdp.h
@@ -112,6 +112,7 @@ struct vsi_profile {
struct vdp_data {
char ifname[IFNAMSIZ];
+ u8 enabletx;
struct ecp ecp;
struct unpacked_tlv *vdp;
int role;
diff --git a/lldp_vdp.c b/lldp_vdp.c
index 646105a..424bcbe 100644
--- a/lldp_vdp.c
+++ b/lldp_vdp.c
@@ -42,6 +42,8 @@
#include "config.h"
#include "lldp_tlv.h"
#include "lldp_vdp_cmds.h"
+#include "lldp_vdp_clif.h"
+#include "lldp_mand_clif.h"
const char * const vsi_responses[] = {
[VDP_RESPONSE_SUCCESS] = "success",
@@ -1365,10 +1367,11 @@ out_err:
void vdp_ifup(char *ifname)
{
char *string;
+ char config_path[16];
struct vdp_data *vd;
struct vdp_user_data *ud;
- struct port *port;
struct vsi_profile *p;
+ int enabletx = false;
/* VDP does not support bonded devices */
if (is_bond(ifname))
@@ -1376,9 +1379,25 @@ void vdp_ifup(char *ifname)
LLDPAD_DBG("%s(%i): starting VDP for if %s !\n", __func__, __LINE__, ifname);
+ snprintf(config_path, sizeof(config_path), "%s.%s",
+ VDP_PREFIX, ARG_TLVTXENABLE);
+
+ if (get_config_setting(ifname, config_path, (void *)&enabletx,
+ CONFIG_TYPE_BOOL))
+ enabletx = false;
+
+ if (enabletx == false) {
+ LLDPAD_WARN("%s(%i): port %s not enabled for VDP (%i) !\n",
+ __func__, __LINE__, ifname, enabletx);
+ return;
+ }
+
vd = vdp_data(ifname);
if (vd) {
- LLDPAD_WARN("%s:%s vdp data already exists !\n", __func__, ifname);
+ vd->enabletx = enabletx;
+
+ LLDPAD_WARN("%s:%s vdp data already exists !\n",
+ __func__, ifname);
goto out_start_again;
}
@@ -1392,6 +1411,7 @@ void vdp_ifup(char *ifname)
strncpy(vd->ifname, ifname, IFNAMSIZ);
vd->role = VDP_ROLE_STATION;
+ vd->enabletx = enabletx;
if (!get_cfg(ifname, "vdp.role", (void *)&string,
CONFIG_TYPE_STRING)) {
@@ -1408,20 +1428,6 @@ void vdp_ifup(char *ifname)
ud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_VDP);
LIST_INSERT_HEAD(&ud->head, vd, entry);
- port = port_find_by_name(ifname);
-
- if (!port) {
- LLDPAD_ERR("%s(%i): could not find port for %s!\n",
- __func__, __LINE__, ifname);
- goto out_err;
- }
-
- if (port->adminStatus != enabledRxTx) {
- LLDPAD_WARN("%s(%i): port %s not enabled for RxTx (%i) !\n",
- __func__, __LINE__, ifname, port->adminStatus);
- return;
- }
-
out_start_again:
if (ecp_init(ifname)) {
LLDPAD_ERR("%s:%s unable to init ecp !\n", __func__, ifname);
--
1.7.4.4
_______________________________________________
lldp-devel mailing list
lldp-devel@open-lldp.org
https://lists.open-fcoe.org/mailman/listinfo/lldp-devel

View File

@ -0,0 +1,169 @@
For vdp to be usable, enabletx must be set to true. The check for enabletx
needs to be made before checking if vdp_data for this ifname already exists.
Otherwise VDP is running even though enabletx is false.
Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
---
ecp/ecp_rx.c | 10 +++-------
ecp/ecp_tx.c | 7 +++----
include/lldp_vdp.h | 1 +
lldp_vdp.c | 38 ++++++++++++++++++++++----------------
4 files changed, 29 insertions(+), 27 deletions(-)
diff --git a/ecp/ecp_rx.c b/ecp/ecp_rx.c
index a56cd3b..182b911 100644
--- a/ecp/ecp_rx.c
+++ b/ecp/ecp_rx.c
@@ -211,9 +211,7 @@ void ecp_rx_ReceiveFrame(void *ctx, unsigned int ifindex, const u8 *buf, size_t
LLDPAD_DBG("%s(%i)-%s: received packet with size %i\n", __func__, __LINE__,
vd->ifname, (int) len);
- if (!port ||
- port->adminStatus == disabled ||
- port->adminStatus == enabledTxOnly)
+ if (vd->enabletx == false)
return;
if (vd->ecp.rx.framein &&
@@ -551,15 +549,13 @@ bool ecp_set_rx_state(struct vdp_data *vd)
}
return false;
case ECP_RX_INIT_RECEIVE:
- if ((port->adminStatus == enabledRxTx) ||
- (port->adminStatus == enabledRxOnly)) {
+ if (vd->enabletx == true) {
ecp_rx_change_state(vd, ECP_RX_RECEIVE_WAIT);
return true;
}
return false;
case ECP_RX_RECEIVE_WAIT:
- if ((port->adminStatus == disabled) ||
- (port->adminStatus == enabledTxOnly)) {
+ if (vd->enabletx == false) {
ecp_rx_change_state(vd, ECP_RX_IDLE);
return true;
}
diff --git a/ecp/ecp_tx.c b/ecp/ecp_tx.c
index c81e101..8a9d2b0 100644
--- a/ecp/ecp_tx.c
+++ b/ecp/ecp_tx.c
@@ -414,15 +414,14 @@ static bool ecp_set_tx_state(struct vdp_data *vd)
switch (vd->ecp.tx.state) {
case ECP_TX_INIT_TRANSMIT:
- if (port->portEnabled && ((port->adminStatus == enabledRxTx) ||
- (port->adminStatus == enabledTxOnly)) && vd->ecp.tx.localChange) {
+ if (port->portEnabled && (vd->enabletx == true)
+ && vd->ecp.tx.localChange) {
ecp_tx_change_state(vd, ECP_TX_TRANSMIT_ECPDU);
return true;
}
return false;
case ECP_TX_TRANSMIT_ECPDU:
- if ((port->adminStatus == disabled) ||
- (port->adminStatus == enabledRxOnly)) {
+ if (vd->enabletx == false) {
ecp_tx_change_state(vd, ECP_TX_INIT_TRANSMIT);
return true;
}
diff --git a/include/lldp_vdp.h b/include/lldp_vdp.h
index b9fd37f..1192364 100644
--- a/include/lldp_vdp.h
+++ b/include/lldp_vdp.h
@@ -112,6 +112,7 @@ struct vsi_profile {
struct vdp_data {
char ifname[IFNAMSIZ];
+ u8 enabletx;
struct ecp ecp;
struct unpacked_tlv *vdp;
int role;
diff --git a/lldp_vdp.c b/lldp_vdp.c
index 646105a..424bcbe 100644
--- a/lldp_vdp.c
+++ b/lldp_vdp.c
@@ -42,6 +42,8 @@
#include "config.h"
#include "lldp_tlv.h"
#include "lldp_vdp_cmds.h"
+#include "lldp_vdp_clif.h"
+#include "lldp_mand_clif.h"
const char * const vsi_responses[] = {
[VDP_RESPONSE_SUCCESS] = "success",
@@ -1365,10 +1367,11 @@ out_err:
void vdp_ifup(char *ifname)
{
char *string;
+ char config_path[16];
struct vdp_data *vd;
struct vdp_user_data *ud;
- struct port *port;
struct vsi_profile *p;
+ int enabletx = false;
/* VDP does not support bonded devices */
if (is_bond(ifname))
@@ -1376,9 +1379,25 @@ void vdp_ifup(char *ifname)
LLDPAD_DBG("%s(%i): starting VDP for if %s !\n", __func__, __LINE__, ifname);
+ snprintf(config_path, sizeof(config_path), "%s.%s",
+ VDP_PREFIX, ARG_TLVTXENABLE);
+
+ if (get_config_setting(ifname, config_path, (void *)&enabletx,
+ CONFIG_TYPE_BOOL))
+ enabletx = false;
+
+ if (enabletx == false) {
+ LLDPAD_WARN("%s(%i): port %s not enabled for VDP (%i) !\n",
+ __func__, __LINE__, ifname, enabletx);
+ return;
+ }
+
vd = vdp_data(ifname);
if (vd) {
- LLDPAD_WARN("%s:%s vdp data already exists !\n", __func__, ifname);
+ vd->enabletx = enabletx;
+
+ LLDPAD_WARN("%s:%s vdp data already exists !\n",
+ __func__, ifname);
goto out_start_again;
}
@@ -1392,6 +1411,7 @@ void vdp_ifup(char *ifname)
strncpy(vd->ifname, ifname, IFNAMSIZ);
vd->role = VDP_ROLE_STATION;
+ vd->enabletx = enabletx;
if (!get_cfg(ifname, "vdp.role", (void *)&string,
CONFIG_TYPE_STRING)) {
@@ -1408,20 +1428,6 @@ void vdp_ifup(char *ifname)
ud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_VDP);
LIST_INSERT_HEAD(&ud->head, vd, entry);
- port = port_find_by_name(ifname);
-
- if (!port) {
- LLDPAD_ERR("%s(%i): could not find port for %s!\n",
- __func__, __LINE__, ifname);
- goto out_err;
- }
-
- if (port->adminStatus != enabledRxTx) {
- LLDPAD_WARN("%s(%i): port %s not enabled for RxTx (%i) !\n",
- __func__, __LINE__, ifname, port->adminStatus);
- return;
- }
-
out_start_again:
if (ecp_init(ifname)) {
LLDPAD_ERR("%s:%s unable to init ecp !\n", __func__, ifname);
--
1.7.4.4
_______________________________________________
lldp-devel mailing list
lldp-devel@open-lldp.org
https://lists.open-fcoe.org/mailman/listinfo/lldp-devel

View File

@ -1,6 +1,6 @@
Name: lldpad
Version: 0.9.43
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Intel LLDP Agent
Group: System Environment/Daemons
License: GPLv2
@ -8,7 +8,38 @@ URL: http://open-lldp.org/
Source0: %{name}-%{version}.tar.gz
Patch0: lldpad-0.9.41-make.patch
Patch1: lldpad-0.9.41-lldptool-invalid-pointer.patch
# Patchwork
Patch50: lldpad-0.9.43-vdp-must-be-enabled-on-interface.patch
# Upstream, 0.9.43+
Patch100: lldpad-0.9.43-add-man-page-for-EVB-TLV.patch
Patch101: lldpad-0.9.43-add-man-page-for-VDP.patch
Patch102: lldpad-0.9.43-add-some-files-in-include-linux-to-inst_SOURCES.patch
Patch103: lldpad-0.9.43-lldpad-Add-EVB-and-VDP-man-pages-to-install-path.patch
Patch104: lldpad-0.9.43-lldpad-802.1Qaz-PFC-TLV-incorrectly-sets-willing-cap.patch
Patch105: lldpad-0.9.43-lldpad-Add-ports-even-w-out-link-at-init-time.patch
Patch106: lldpad-0.9.43-lldpad-remove-app-data-on-CEE-unregister.patch
Patch107: lldpad-0.9.43-lldpad-remove-unused-exported-DCBX-routines.patch
Patch108: lldpad-0.9.43-Create-man-page-for-MED-usage.patch
Patch109: lldpad-0.9.43-lldpad-802.1Qaz-resolve-incorrect-tcbw-memcpy.patch
Patch110: lldpad-0.9.43-dcbtool-return-different-error-codes-for-invalid-dev.patch
Patch111: lldpad-0.9.43-lldpad-802.1Qaz-make-ETS-CFG-willing-yes-no-values-v.patch
Patch112: lldpad-0.9.43-lldpad-use-is_valid_lldp_device-in-scan-path.patch
Patch113: lldpad-0.9.43-lldpad-resolve-segfault-with-ECP-and-bonding.patch
Patch114: lldpad-0.9.43-lldpad-dcbx-mode-needs-to-be-set-before-set_state-cm.patch
Patch115: lldpad-0.9.43-lldpad-fix-compile-warnings-in-802.1Qaz-debug-code.patch
Patch116: lldpad-0.9.43-lldpad-Do-not-enable-CEE-mode-if-explicitly-disabled.patch
Patch117: lldpad-0.9.43-lldapd-802.1Qaz-add-output-buffer-response-to-set-pf.patch
Patch118: lldpad-0.9.43-lldpad-ETS-add-another-example-to-man-page.patch
Patch119: lldpad-0.9.43-lldptool-better-TLV_ID-validation.patch
Patch120: lldpad-0.9.43-This-patch-fixes-a-warning-issued-when-building-the-.patch
Patch121: lldpad-0.9.43-lldpad-Avoid-possible-resource-leak-in-get_bcn.patch
Patch122: lldpad-0.9.43-Avoid-possible-resource-leaks.patch
Patch123: lldpad-0.9.43-lldpad-Fix-logging-to-no-longer-use-message-IDs.patch
Patch124: lldpad-0.9.43-lldpad-Fix-error-path-in-save_dcbx_version.patch
Patch125: lldpad-0.9.43-bugfix-to-print-all-profiles.patch
Patch126: lldpad-0.9.43-prevent-crash-on-invalid-response-code.patch
Patch127: lldpad-0.9.43-bugfix-go-to-VSI_EXIT-immediately-on-neg-response.patch
Patch128: lldpad-0.9.43-some-minor-bugfixes.patch
Requires: kernel >= 2.6.32
BuildRequires: systemd-units
BuildRequires: libconfig-devel >= 1.3.2 kernel-headers >= 2.6.32
@ -32,12 +63,45 @@ Requires: %{name} = %{version}-%{release}
Provides: dcbd-devel = %{version}-%{release}
Obsoletes: dcbd-devel < 0.9.26
%description devel
%description devel
The %{name}-devel package contains header files for developing applications
that use %{name}.
%prep
%setup -q -n open-lldp
# Upstream patches
%patch100 -p1
%patch101 -p1
%patch102 -p1
%patch103 -p1
%patch104 -p1
%patch105 -p1
%patch106 -p1
%patch107 -p1
%patch108 -p1
%patch109 -p1
%patch110 -p1
%patch111 -p1
%patch112 -p1
%patch113 -p1
%patch114 -p1
%patch115 -p1
%patch116 -p1
%patch117 -p1
%patch118 -p1
%patch119 -p1
%patch120 -p1
%patch121 -p1
%patch122 -p1
%patch123 -p1
%patch124 -p1
%patch125 -p1
%patch126 -p1
%patch127 -p1
%patch128 -p1
# Submitted (not yet accepted upstream) patches
%patch50 -p1
# Fedora patches
%patch0 -p1 -b .make
%patch1 -p1 -b .invalid-pointer
@ -60,13 +124,13 @@ fi
%preun
if [ $1 -eq 0 ]; then
systemctl stop %{name}.service
systemctl disable %{name}.service
systemctl stop %{name}.service
systemctl disable %{name}.service
fi
%postun
if [ $1 -eq 1 ]; then
systemctl try-restart %{name}.service
systemctl try-restart %{name}.service
fi
%post devel
@ -98,6 +162,11 @@ fi
%{_libdir}/pkgconfig/*.pc
%changelog
* Tue Aug 30 2011 Petr Sabata <contyk@redhat.com> - 0.9.43-2
- Apply various upstream 0.9.43 bugfixes
- Include not yet accepted Jens Osterkamp's patch to fix bug #720080
- Whitespace cleanup, phew
* Thu Jul 07 2011 Petr Sabata <contyk@redhat.com> - 0.9.43-1
- 0.9.43 bump
- Drop the the clean exit patch and our unit file, both are now included upstream