diff -Nru lldpad-1.0.1+git20200210.2022b0c/ChangeLog lldpad-1.1/ChangeLog --- lldpad-1.0.1+git20200210.2022b0c/ChangeLog 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/ChangeLog 2020-10-30 13:37:52.000000000 +0000 @@ -1,3 +1,18 @@ +Changes from 1.1.0 to +Changes from 1.0.1 to 1.1 +- VDP: introduce vdptool +- VDP: support retrieving vsi parameter +- VDP: TLV support +- VDP: Support OUI infrastructure +- Switch from SysV to posix shared memory +- DCBX: ignore PG configurations +- DCBX: Allow for read-only LLDP configuration +- Support multicast MAC +- autoconf: Suport systemd or sysv for init system +- 802.1qaz: print prio map +- lldptool: Allow to modify optional TLV content +- CVE-2018-10932: Don't print raw bytes from mngAddr +- Misc. bug fixes Changes from 0.9.46 to 1.0.1 Mostly fixes and man page updates Added more testing infrastructure mostly for EVB diff -Nru lldpad-1.0.1+git20200210.2022b0c/config.c lldpad-1.1/config.c --- lldpad-1.0.1+git20200210.2022b0c/config.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/config.c 2020-10-30 13:37:52.000000000 +0000 @@ -185,7 +185,7 @@ LIST_FOREACH(agent, &port->agent_head, entry) { LLDPAD_DBG("%s: calling ifdown for agent %p.\n", __func__, agent); - LIST_FOREACH(np, &lldp_head, lldp) { + LIST_FOREACH(np, &lldp_mod_head, lldp) { ops = np->ops; if (ops->lldp_mod_ifdown) ops->lldp_mod_ifdown(ifname, agent); @@ -234,7 +234,7 @@ } } else { retval = errno; - LLDPAD_ERR("%s is not readable and writeable", + LLDPAD_ERR("%s is not readable and writeable\n", cfg_file_name); } } @@ -310,7 +310,7 @@ } if (!rval) - LLDPAD_ERR("invalid value for %s", attr); + LLDPAD_ERR("invalid value for %s\n", attr); return rval; } @@ -354,7 +354,7 @@ } if (!rval) - LLDPAD_ERR("invalid setting for %s", attr); + LLDPAD_ERR("invalid setting for %s\n", attr); return rval; } @@ -394,7 +394,7 @@ LIST_FOREACH(agent, &port->agent_head, entry) { LLDPAD_DBG("%s: calling ifup for agent %p.\n", __func__, agent); - LIST_FOREACH(np, &lldp_head, lldp) { + LIST_FOREACH(np, &lldp_mod_head, lldp) { if (np->ops->lldp_mod_ifup) np->ops->lldp_mod_ifup(p->if_name, agent); } diff -Nru lldpad-1.0.1+git20200210.2022b0c/configure.ac lldpad-1.1/configure.ac --- lldpad-1.0.1+git20200210.2022b0c/configure.ac 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/configure.ac 2020-10-30 13:37:52.000000000 +0000 @@ -1,4 +1,4 @@ -AC_INIT([lldpad], [1.0.1], [lldp-devel@open-lldp.org]) +AC_INIT([lldpad], [1.1.0], [lldp-devel@open-lldp.org]) AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects]) m4_pattern_allow([AM_PROG_AR]) @@ -28,6 +28,10 @@ dnl Begin determine the systemd use and location PKG_CHECK_MODULES([SYSTEMD], [systemd], use_systemd=yes, use_systemd=no) +dnl Configure developer type flags +OPENLLDP_CHECK_WARNINGS +OPENLLDP_CHECK_ERROR + dnl Set sysvinit values, if system has systemd it will be rewritten AC_SUBST(SPEC_BUILD_REQUIRES_POST, "chkconfig") AC_SUBST(SPEC_BUILD_REQUIRES_PREUN, "chkconfig initscripts") diff -Nru lldpad-1.0.1+git20200210.2022b0c/ctrl_iface.c lldpad-1.1/ctrl_iface.c --- lldpad-1.0.1+git20200210.2022b0c/ctrl_iface.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/ctrl_iface.c 2020-10-30 13:37:52.000000000 +0000 @@ -53,8 +53,6 @@ #include "lldp_util.h" #include "messages.h" -extern struct lldp_head lldp_head; - struct ctrl_dst { struct ctrl_dst *next; struct sockaddr_un addr; @@ -116,7 +114,7 @@ return cmd_invalid; } - mod = find_module_by_id(&lldp_head, module_id); + mod = find_module_by_id(&lldp_mod_head, module_id); if (mod && mod->ops && mod->ops->client_cmd) return (mod->ops->client_cmd)(clifd, from, fromlen, cmd_start, cmd_len, rbuf+strlen(rbuf), rlen); diff -Nru lldpad-1.0.1+git20200210.2022b0c/dcb_protocol.c lldpad-1.1/dcb_protocol.c --- lldpad-1.0.1+git20200210.2022b0c/dcb_protocol.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/dcb_protocol.c 2020-10-30 13:37:52.000000000 +0000 @@ -2257,13 +2257,8 @@ if ((it != NULL) && (bwgid < it->second->max_pgid_desc)) { - size = (int)strlen(it->second->pgid_desc[bwgid]) + - sizeof(char); /* Localization OK */ - *name = (char*)malloc(size); - if (*name != NULL) { - strncpy(*name, it->second->pgid_desc[bwgid], - size); /* Localization OK */ - } else { + *name = strdup(it->second->pgid_desc[bwgid]); + if (*name == NULL) { goto Error; } } else { @@ -2272,9 +2267,9 @@ size = (int)strlen( attribs.descript.pgid_desc[bwgid]) + sizeof(char); - *name = (char*)malloc(size); + *name = (char*)calloc(size, sizeof(char)); if (*name != NULL) { - memcpy(*name, attribs.descript.pgid_desc[bwgid], size); /* Localization OK */ + memcpy(*name, attribs.descript.pgid_desc[bwgid], size - 1); /* Localization OK */ } else { goto Error; } diff -Nru lldpad-1.0.1+git20200210.2022b0c/dcb_rule_chk.c lldpad-1.1/dcb_rule_chk.c --- lldpad-1.0.1+git20200210.2022b0c/dcb_rule_chk.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/dcb_rule_chk.c 2020-10-30 13:37:52.000000000 +0000 @@ -206,6 +206,8 @@ strict = 0; if (be == cbe) be = 0; + if (pgid < 0) + continue; } if (pg_done[i] == false) { diff -Nru lldpad-1.0.1+git20200210.2022b0c/dcbtool.c lldpad-1.1/dcbtool.c --- lldpad-1.0.1+git20200210.2022b0c/dcbtool.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/dcbtool.c 2020-10-30 13:37:52.000000000 +0000 @@ -47,6 +47,7 @@ #define UNUSED __attribute__((__unused__)) static int show_raw; +extern void close_history(void); static const char *cli_version = "dcbtool v" DCBTOOL_VERSION "\n" @@ -460,6 +461,7 @@ request(clif_conn, argc, argv, raw); free(cmd); } while (!cli_quit); + close_history(); } static void cli_terminate(UNUSED int sig) diff -Nru lldpad-1.0.1+git20200210.2022b0c/dcbtool_cmds.c lldpad-1.1/dcbtool_cmds.c --- lldpad-1.0.1+git20200210.2022b0c/dcbtool_cmds.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/dcbtool_cmds.c 2020-10-30 13:37:52.000000000 +0000 @@ -27,6 +27,7 @@ #include #include #include +#include #include "clif.h" #include "dcbtool.h" #include "lldp_dcbx_cmds.h" diff -Nru lldpad-1.0.1+git20200210.2022b0c/debian/changelog lldpad-1.1/debian/changelog --- lldpad-1.0.1+git20200210.2022b0c/debian/changelog 2020-05-09 17:57:19.000000000 +0000 +++ lldpad-1.1/debian/changelog 2020-12-16 21:08:15.000000000 +0000 @@ -1,3 +1,14 @@ +lldpad (1.1-1) unstable; urgency=medium + + * New upstream version 1.1 + * Refresh patches for new version + * Use Standards-Version 4.5.1 + * Update watch file version to 4 + * Add lintian override for additional manpages + * Remove Liang Guo from Uploaders (Closes: #961614) + + -- Valentin Vidic Wed, 16 Dec 2020 22:08:15 +0100 + lldpad (1.0.1+git20200210.2022b0c-2) unstable; urgency=medium * Fix GCC 10 build errors (Closes: #957494) diff -Nru lldpad-1.0.1+git20200210.2022b0c/debian/control lldpad-1.1/debian/control --- lldpad-1.0.1+git20200210.2022b0c/debian/control 2020-05-09 17:55:32.000000000 +0000 +++ lldpad-1.1/debian/control 2020-12-16 20:59:42.000000000 +0000 @@ -2,7 +2,7 @@ Section: net Priority: optional Maintainer: Debian FCoE Maintainers -Uploaders: Liang Guo , +Uploaders: Jacob Luna Lundberg , Valentin Vidic , tony mancill @@ -14,7 +14,7 @@ flex, libreadline-dev, dpkg-dev (>= 1.16.1~) -Standards-Version: 4.5.0 +Standards-Version: 4.5.1 Rules-Requires-Root: no Homepage: https://github.com/intel/openlldp Vcs-Browser: https://salsa.debian.org/fcoe-team/lldpad diff -Nru lldpad-1.0.1+git20200210.2022b0c/debian/lldpad.lintian-overrides lldpad-1.1/debian/lldpad.lintian-overrides --- lldpad-1.0.1+git20200210.2022b0c/debian/lldpad.lintian-overrides 2020-02-17 18:37:25.000000000 +0000 +++ lldpad-1.1/debian/lldpad.lintian-overrides 2020-12-16 21:06:28.000000000 +0000 @@ -1,3 +1,13 @@ # The name of the package has changed but the binaries # have not yet changed, so for now override... lldpad binary: package-name-doesnt-match-sonames liblldp-clif1 + +# Additional lldptool manpages. +spare-manual-page usr/share/man/man8/lldptool-app.8.gz +spare-manual-page usr/share/man/man8/lldptool-dcbx.8.gz +spare-manual-page usr/share/man/man8/lldptool-ets.8.gz +spare-manual-page usr/share/man/man8/lldptool-evb.8.gz +spare-manual-page usr/share/man/man8/lldptool-evb22.8.gz +spare-manual-page usr/share/man/man8/lldptool-med.8.gz +spare-manual-page usr/share/man/man8/lldptool-pfc.8.gz +spare-manual-page usr/share/man/man8/lldptool-vdp.8.gz diff -Nru lldpad-1.0.1+git20200210.2022b0c/debian/patches/fix-gcc-10-build.patch lldpad-1.1/debian/patches/fix-gcc-10-build.patch --- lldpad-1.0.1+git20200210.2022b0c/debian/patches/fix-gcc-10-build.patch 2020-05-09 17:54:10.000000000 +0000 +++ lldpad-1.1/debian/patches/fix-gcc-10-build.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,144 +0,0 @@ -Description: Fix GCC 10 build errors -Author: Valentin Vidic -Last-Update: 2020-05-09 ---- a/lldp_evb_cmds.c -+++ b/lldp_evb_cmds.c -@@ -163,7 +163,7 @@ - return is_tlv_txenabled(ifname, type, TLVID_8021Qbg(LLDP_EVB_SUBTYPE)); - } - --static int evb_cmdok(struct cmd *cmd, cmd_status expected) -+static int evb_cmdok(struct cmd *cmd, lldp_cmd expected) - { - if (cmd->cmd != expected) - return cmd_invalid; ---- a/lldp_evb22_cmds.c -+++ b/lldp_evb22_cmds.c -@@ -225,7 +225,7 @@ - TLVID(OUI_IEEE_8021Qbg22, LLDP_EVB22_SUBTYPE)); - } - --static int evb22_cmdok(struct cmd *cmd, cmd_status expected) -+static int evb22_cmdok(struct cmd *cmd, lldp_cmd expected) - { - if (cmd->cmd != expected) - return cmd_invalid; ---- a/qbg/vdp22_cmds.c -+++ b/qbg/vdp22_cmds.c -@@ -296,7 +296,7 @@ - return 0; - } - --static int vdp22_cmdok(struct cmd *cmd, cmd_status expected) -+static int vdp22_cmdok(struct cmd *cmd, vdp22_cmd expected) - { - if (cmd->cmd != expected) - return cmd_invalid; ---- a/qbg/vdp_cmds.c -+++ b/qbg/vdp_cmds.c -@@ -85,7 +85,7 @@ - return s; - } - --static int vdp_cmdok(struct cmd *cmd, cmd_status expected) -+static int vdp_cmdok(struct cmd *cmd, lldp_cmd expected) - { - if (cmd->cmd != expected) - return cmd_invalid; ---- a/vdptool.c -+++ b/vdptool.c -@@ -141,7 +141,7 @@ - str = "TLV does not support agent type"; - break; - default: -- str = print_vdp_status(status); -+ str = print_vdp_status((enum vdp22_cmd_status)status); - break; - } - return str; -@@ -781,6 +781,7 @@ - static struct clif *clif_conn; - static int cli_quit; - static int cli_attached; -+struct lldp_head lldp_head; - - /* - * insert to head, so first one is last ---- a/lldp/ports.c -+++ b/lldp/ports.c -@@ -264,7 +264,7 @@ - memset(newport, 0, sizeof(*newport)); - newport->ifindex = ifindex; - newport->next = NULL; -- strncpy(newport->ifname, ifname, IFNAMSIZ); -+ strncpy(newport->ifname, ifname, sizeof(newport->ifname) - 1); - - newport->bond_master = is_bond(ifname); - /* Initialize relevant port variables */ ---- a/include/lldp_mod.h -+++ b/include/lldp_mod.h -@@ -96,7 +96,7 @@ - }; - - LIST_HEAD(lldp_head, lldp_module); --struct lldp_head lldp_head; -+extern struct lldp_head lldp_head; - - static inline struct lldp_module *find_module_by_id(struct lldp_head *head, int id) - { ---- a/include/lldptool.h -+++ b/include/lldptool.h -@@ -29,7 +29,7 @@ - - #include "clif.h" - --struct lldp_head lldp_cli_head; -+extern struct lldp_head lldp_cli_head; - - int clif_command(struct clif *clif, char *cmd, int raw); - void print_raw_message(char *msg, int print); ---- a/lldptool.c -+++ b/lldptool.c -@@ -169,6 +169,9 @@ - static int cli_quit = 0; - static int cli_attached = 0; - -+struct lldp_head lldp_head; -+struct lldp_head lldp_cli_head; -+ - /* - * insert to head, so first one is last - */ ---- a/lldp/l2_packet.h -+++ b/lldp/l2_packet.h -@@ -63,7 +63,7 @@ - u8 h_dest[ETH_ALEN]; - u8 h_source[ETH_ALEN]; - u16 h_proto; --} STRUCT_PACKED; -+}; - - /** - * l2_packet_init - Initialize l2_packet interface ---- a/include/qbg_ecp22.h -+++ b/include/qbg_ecp22.h -@@ -52,7 +52,7 @@ - enum { - ECP22_REQUEST = 0, - ECP22_ACK --} ecp22_mode; -+}; - - struct ecp22_hdr { /* ECP22 header */ - u16 ver_op_sub; /* ECP22 version, operation, subtype */ ---- a/lldp_8021qaz.c -+++ b/lldp_8021qaz.c -@@ -49,7 +49,7 @@ - - - struct lldp_head lldp_head; --struct config_t lldpad_cfg; -+extern struct config_t lldpad_cfg; - extern bool read_only_8021qaz; - - static int ieee8021qaz_check_pending(struct port *port, struct lldp_agent *); diff -Nru lldpad-1.0.1+git20200210.2022b0c/debian/patches/fix-hardening-flags.patch lldpad-1.1/debian/patches/fix-hardening-flags.patch --- lldpad-1.0.1+git20200210.2022b0c/debian/patches/fix-hardening-flags.patch 2020-02-17 18:37:25.000000000 +0000 +++ lldpad-1.1/debian/patches/fix-hardening-flags.patch 2020-12-16 18:41:37.000000000 +0000 @@ -12,5 +12,5 @@ -parse_cli.o: CFLAGS+=-U_FORTIFY_SOURCE -Wno-error - ## system requires a shared libconfig - AM_CFLAGS = -Wall -Werror -Wextra -Wformat=2 $(LIBCONFIG_CFLAGS) $(LIBNL_CFLAGS) + AM_CFLAGS = $(LIBCONFIG_CFLAGS) $(LIBNL_CFLAGS) AM_LDFLAGS = $(LIBCONFIG_LIBS) $(LIBNL_LIBS) -lrt diff -Nru lldpad-1.0.1+git20200210.2022b0c/debian/patches/series lldpad-1.1/debian/patches/series --- lldpad-1.0.1+git20200210.2022b0c/debian/patches/series 2020-05-08 20:00:47.000000000 +0000 +++ lldpad-1.1/debian/patches/series 2020-12-16 20:53:28.000000000 +0000 @@ -9,4 +9,3 @@ spelling-fixes.patch add-lldpad-service-documentation.patch fix-hardening-flags.patch -fix-gcc-10-build.patch diff -Nru lldpad-1.0.1+git20200210.2022b0c/debian/patches/spelling-fixes.patch lldpad-1.1/debian/patches/spelling-fixes.patch --- lldpad-1.0.1+git20200210.2022b0c/debian/patches/spelling-fixes.patch 2020-02-17 18:37:25.000000000 +0000 +++ lldpad-1.1/debian/patches/spelling-fixes.patch 2020-12-16 18:41:33.000000000 +0000 @@ -145,7 +145,7 @@ static bool ecp_set_rx_state(struct vdp_data *vd) --- a/qbg/ecp22.c +++ b/qbg/ecp22.c -@@ -310,7 +310,7 @@ +@@ -312,7 +312,7 @@ * returns true or false * * switches the state machine to the next state depending on the input @@ -154,7 +154,7 @@ * can be run again with the new state or can stop at the current state. */ static bool ecp22_set_tx_state(struct ecp22 *ecp) -@@ -550,7 +550,7 @@ +@@ -552,7 +552,7 @@ * returns true or false * * switches the state machine to the next state depending on the input diff -Nru lldpad-1.0.1+git20200210.2022b0c/debian/watch lldpad-1.1/debian/watch --- lldpad-1.0.1+git20200210.2022b0c/debian/watch 2020-02-17 18:37:25.000000000 +0000 +++ lldpad-1.1/debian/watch 2020-12-16 21:07:50.000000000 +0000 @@ -1,2 +1,2 @@ -version=3 +version=4 https://github.com/intel/openlldp/releases/ .*archive/v([\d\.]*.*)\.tar\.gz diff -Nru lldpad-1.0.1+git20200210.2022b0c/docs/liblldp_clif-vdp22.3 lldpad-1.1/docs/liblldp_clif-vdp22.3 --- lldpad-1.0.1+git20200210.2022b0c/docs/liblldp_clif-vdp22.3 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/docs/liblldp_clif-vdp22.3 2020-10-30 13:37:52.000000000 +0000 @@ -1,6 +1,6 @@ .TH liblldp_clif 3 "February 2014" "open-lldp" "Linux" .SH NAME -clif_vsi,clif_vsievt,clif_vsiwait \- Manipulate VDP IEEE 802.1 Ratified Standard Assocications +clif_vsi,clif_vsievt,clif_vsiwait \- Manipulate VDP IEEE 802.1 Ratified Standard Associations .SH SYNOPSIS #include "include/clif.h" .sp 1 diff -Nru lldpad-1.0.1+git20200210.2022b0c/docs/lldptool.8 lldpad-1.1/docs/lldptool.8 --- lldpad-1.0.1+git20200210.2022b0c/docs/lldptool.8 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/docs/lldptool.8 2020-10-30 13:37:52.000000000 +0000 @@ -160,9 +160,9 @@ .TP Query the LLDP statistics for interface \fIeth3\fR -.B lldptool -S -i eth3 adminStatus +.B lldptool -S -i eth3 .br -.B lldptool stats -i eth3 adminStatus +.B lldptool stats -i eth3 .TP Query the local TLVs which are being transmitted for a given interface: diff -Nru lldpad-1.0.1+git20200210.2022b0c/event_iface.c lldpad-1.1/event_iface.c --- lldpad-1.0.1+git20200210.2022b0c/event_iface.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/event_iface.c 2020-10-30 13:37:52.000000000 +0000 @@ -216,7 +216,7 @@ LIST_FOREACH(agent, &port->agent_head, entry) { LLDPAD_DBG("%s: calling ifup for agent %p.\n", __func__, agent); - LIST_FOREACH(np, &lldp_head, lldp) { + LIST_FOREACH(np, &lldp_mod_head, lldp) { if (np->ops->lldp_mod_ifup) np->ops->lldp_mod_ifup(device_name, agent); } @@ -283,7 +283,7 @@ LIST_FOREACH(agent, &port->agent_head, entry) { LLDPAD_DBG("%s: calling ifdown for agent %p.\n", __func__, agent); - LIST_FOREACH(np, &lldp_head, lldp) { + LIST_FOREACH(np, &lldp_mod_head, lldp) { ops = np->ops; if (ops->lldp_mod_ifdown) ops->lldp_mod_ifdown(device_name, diff -Nru lldpad-1.0.1+git20200210.2022b0c/include/lldp.h lldpad-1.1/include/lldp.h --- lldpad-1.0.1+git20200210.2022b0c/include/lldp.h 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/include/lldp.h 2020-10-30 13:37:52.000000000 +0000 @@ -255,5 +255,11 @@ #define LLDP_EVB_DEFAULT_RTE 15 #define LLDP_EVB_DEFAULT_MAX_RTE 31 +#ifndef _MSC_VER +#define STRUCT_PACKED(STRUCT) STRUCT __attribute__((__packed__)) +#else +#define STRUCT_PACKED(STRUCT) __pragma(pack(push, 1)) STRUCT __pragma(pack(pop)) +#endif + void somethingChangedLocal(const char *ifname, int type); #endif /* _LLDP_H */ diff -Nru lldpad-1.0.1+git20200210.2022b0c/include/lldp_mod.h lldpad-1.1/include/lldp_mod.h --- lldpad-1.0.1+git20200210.2022b0c/include/lldp_mod.h 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/include/lldp_mod.h 2020-10-30 13:37:52.000000000 +0000 @@ -96,7 +96,7 @@ }; LIST_HEAD(lldp_head, lldp_module); -struct lldp_head lldp_head; +extern struct lldp_head lldp_mod_head; static inline struct lldp_module *find_module_by_id(struct lldp_head *head, int id) { diff -Nru lldpad-1.0.1+git20200210.2022b0c/include/lldp_tlv.h lldpad-1.1/include/lldp_tlv.h --- lldpad-1.0.1+git20200210.2022b0c/include/lldp_tlv.h 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/include/lldp_tlv.h 2020-10-30 13:37:52.000000000 +0000 @@ -104,8 +104,8 @@ struct unpacked_tlv *unpack_tlv(struct packed_tlv *tlv); int pack_tlv_after(struct unpacked_tlv *, struct packed_tlv *, int); -struct unpacked_tlv *free_unpkd_tlv(struct unpacked_tlv *tlv); -struct packed_tlv *free_pkd_tlv(struct packed_tlv *tlv); +void free_unpkd_tlv(struct unpacked_tlv *tlv); +void free_pkd_tlv(struct packed_tlv *tlv); struct unpacked_tlv *create_tlv(void); struct packed_tlv *create_ptlv(void); struct unpacked_tlv *bld_end_tlv(void); @@ -115,14 +115,18 @@ #define FREE_UNPKD_TLV(d, f) \ { \ - if ((d)->f) \ - (d)->f = free_unpkd_tlv((d)->f); \ + if ((d)->f) { \ + free_unpkd_tlv((d)->f); \ + (d)->f = NULL; \ + } \ } #define FREE_PKD_TLV(d, f) \ { \ - if ((d)->f) \ - (d)->f = free_pkd_tlv((d)->f); \ + if ((d)->f) { \ + free_pkd_tlv((d)->f); \ + (d)->f = NULL; \ + } \ } #define PACK_TLV_AFTER(t, p, l, g) \ diff -Nru lldpad-1.0.1+git20200210.2022b0c/include/lldptool.h lldpad-1.1/include/lldptool.h --- lldpad-1.0.1+git20200210.2022b0c/include/lldptool.h 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/include/lldptool.h 2020-10-30 13:37:52.000000000 +0000 @@ -29,7 +29,7 @@ #include "clif.h" -struct lldp_head lldp_cli_head; +extern struct lldp_head lldp_cli_head; int clif_command(struct clif *clif, char *cmd, int raw); void print_raw_message(char *msg, int print); diff -Nru lldpad-1.0.1+git20200210.2022b0c/include/qbg_ecp22.h lldpad-1.1/include/qbg_ecp22.h --- lldpad-1.0.1+git20200210.2022b0c/include/qbg_ecp22.h 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/include/qbg_ecp22.h 2020-10-30 13:37:52.000000000 +0000 @@ -49,10 +49,10 @@ ECP22_TX_ERROR }; -enum { +enum ecp22_mode { ECP22_REQUEST = 0, ECP22_ACK -} ecp22_mode; +}; struct ecp22_hdr { /* ECP22 header */ u16 ver_op_sub; /* ECP22 version, operation, subtype */ diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp/agent.c lldpad-1.1/lldp/agent.c --- lldpad-1.0.1+git20200210.2022b0c/lldp/agent.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp/agent.c 2020-10-30 13:37:52.000000000 +0000 @@ -163,7 +163,7 @@ run_rx_sm(port, agent); update_rx_timers(agent); - LIST_FOREACH(n, &lldp_head, lldp) { + LIST_FOREACH(n, &lldp_mod_head, lldp) { if (n->ops && n->ops->timer) n->ops->timer(port, agent); } diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp/l2_packet.h lldpad-1.1/lldp/l2_packet.h --- lldpad-1.0.1+git20200210.2022b0c/lldp/l2_packet.h 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp/l2_packet.h 2020-10-30 13:37:52.000000000 +0000 @@ -58,12 +58,11 @@ */ struct l2_packet_data; - -struct l2_ethhdr { +STRUCT_PACKED(struct l2_ethhdr { u8 h_dest[ETH_ALEN]; u8 h_source[ETH_ALEN]; u16 h_proto; -} STRUCT_PACKED; +}); /** * l2_packet_init - Initialize l2_packet interface diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp/ports.c lldpad-1.1/lldp/ports.c --- lldpad-1.0.1+git20200210.2022b0c/lldp/ports.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp/ports.c 2020-10-30 13:37:52.000000000 +0000 @@ -264,7 +264,7 @@ memset(newport, 0, sizeof(*newport)); newport->ifindex = ifindex; newport->next = NULL; - strncpy(newport->ifname, ifname, IFNAMSIZ); + strncpy(newport->ifname, ifname, IFNAMSIZ - 1); newport->bond_master = is_bond(ifname); /* Initialize relevant port variables */ diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp/rx.c lldpad-1.1/lldp/rx.c --- lldpad-1.0.1+git20200210.2022b0c/lldp/rx.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp/rx.c 2020-10-30 13:37:52.000000000 +0000 @@ -139,7 +139,16 @@ int err; struct lldp_module *np; - assert(agent->rx.framein && agent->rx.sizein); + if (!agent->rx.framein) { + LLDPAD_DBG("ERROR - agent framein not set, " + "has the neighbour MAC changed? " + "Ignoring packet.\n"); + return; + } + if (!agent->rx.sizein) { + LLDPAD_DBG("Size-0 packet received, ignoring packet\n"); + return; + } agent->lldpdu = 0; agent->rx.dupTlvs = 0; @@ -359,7 +368,7 @@ } /* rx per lldp module */ - LIST_FOREACH(np, &lldp_head, lldp) { + LIST_FOREACH(np, &lldp_mod_head, lldp) { if (!np->ops || !np->ops->lldp_mod_rchange) continue; @@ -377,7 +386,7 @@ if (!tlv_stored) { LLDPAD_INFO("%s: allocated TLV %u was not stored! %p\n", __func__, tlv->type, tlv); - tlv = free_unpkd_tlv(tlv); + free_unpkd_tlv(tlv); agent->stats.statsTLVsUnrecognizedTotal++; } tlv = NULL; @@ -402,7 +411,7 @@ { struct lldp_module *np; - LIST_FOREACH(np, &lldp_head, lldp) { + LIST_FOREACH(np, &lldp_mod_head, lldp) { if (!np->ops || !np->ops->lldp_mod_mibdelete) continue; np->ops->lldp_mod_mibdelete(port, agent); @@ -638,29 +647,21 @@ void clear_manifest(struct lldp_agent *agent) { if (agent->rx.manifest->mgmtadd) - agent->rx.manifest->mgmtadd = - free_unpkd_tlv(agent->rx.manifest->mgmtadd); + free_unpkd_tlv(agent->rx.manifest->mgmtadd); if (agent->rx.manifest->syscap) - agent->rx.manifest->syscap = - free_unpkd_tlv(agent->rx.manifest->syscap); + free_unpkd_tlv(agent->rx.manifest->syscap); if (agent->rx.manifest->sysdesc) - agent->rx.manifest->sysdesc = - free_unpkd_tlv(agent->rx.manifest->sysdesc); + free_unpkd_tlv(agent->rx.manifest->sysdesc); if (agent->rx.manifest->sysname) - agent->rx.manifest->sysname = - free_unpkd_tlv(agent->rx.manifest->sysname); + free_unpkd_tlv(agent->rx.manifest->sysname); if (agent->rx.manifest->portdesc) - agent->rx.manifest->portdesc = - free_unpkd_tlv(agent->rx.manifest->portdesc); + free_unpkd_tlv(agent->rx.manifest->portdesc); if (agent->rx.manifest->ttl) - agent->rx.manifest->ttl = - free_unpkd_tlv(agent->rx.manifest->ttl); + free_unpkd_tlv(agent->rx.manifest->ttl); if (agent->rx.manifest->portid) - agent->rx.manifest->portid = - free_unpkd_tlv(agent->rx.manifest->portid); + free_unpkd_tlv(agent->rx.manifest->portid); if (agent->rx.manifest->chassis) - agent->rx.manifest->chassis = - free_unpkd_tlv(agent->rx.manifest->chassis); + free_unpkd_tlv(agent->rx.manifest->chassis); free(agent->rx.manifest); agent->rx.manifest = NULL; } diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp/tx.c lldpad-1.1/lldp/tx.c --- lldpad-1.0.1+git20200210.2022b0c/lldp/tx.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp/tx.c 2020-10-30 13:37:52.000000000 +0000 @@ -71,7 +71,7 @@ fb_offset += sizeof(struct l2_ethhdr); /* Generic TLV Pack */ - LIST_FOREACH(np, &lldp_head, lldp) { + LIST_FOREACH(np, &lldp_mod_head, lldp) { if (!np->ops || !np->ops->lldp_mod_gettlv) continue; @@ -83,7 +83,7 @@ ptlv->tlv, ptlv->size); datasize += ptlv->size; fb_offset += ptlv->size; - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); } } @@ -94,7 +94,7 @@ memcpy(agent->tx.frameout + fb_offset, ptlv->tlv, ptlv->size); datasize += ptlv->size; fb_offset += ptlv->size; - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); if (datasize < ETH_MIN_DATA_LEN) agent->tx.sizeout = ETH_ZLEN; @@ -104,7 +104,7 @@ return true; error: - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); if (agent->tx.frameout) free(agent->tx.frameout); agent->tx.frameout = NULL; @@ -206,7 +206,7 @@ memcpy(agent->tx.frameout, (void *)ð, sizeof(struct l2_ethhdr)); fb_offset += sizeof(struct l2_ethhdr); - np = find_module_by_id(&lldp_head, LLDP_MOD_MAND); + np = find_module_by_id(&lldp_mod_head, LLDP_MOD_MAND); if (!np) goto error; if (!np->ops || !np->ops->lldp_mod_gettlv) @@ -220,7 +220,7 @@ memcpy(agent->tx.frameout + fb_offset, ptlv->tlv, ptlv->size); datasize += ptlv->size; fb_offset += ptlv->size; - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); } /* The End TLV marks the end of the LLDP PDU */ @@ -230,7 +230,7 @@ memcpy(agent->tx.frameout + fb_offset, ptlv->tlv, ptlv->size); datasize += ptlv->size; fb_offset += ptlv->size; - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); if (datasize < ETH_MIN_DATA_LEN) agent->tx.sizeout = ETH_ZLEN; @@ -239,7 +239,7 @@ return true; error: - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); if (agent->tx.frameout) free(agent->tx.frameout); agent->tx.frameout = NULL; diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp_8021qaz.c lldpad-1.1/lldp_8021qaz.c --- lldpad-1.0.1+git20200210.2022b0c/lldp_8021qaz.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp_8021qaz.c 2020-10-30 13:37:52.000000000 +0000 @@ -48,8 +48,7 @@ #include "lldp_dcbx.h" -struct lldp_head lldp_head; -struct config_t lldpad_cfg; +extern config_t lldpad_cfg; extern bool read_only_8021qaz; static int ieee8021qaz_check_pending(struct port *port, struct lldp_agent *); @@ -84,7 +83,7 @@ if (!port->portEnabled) return 0; - iud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_8021QAZ); + iud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_8021QAZ); if (iud) { LIST_FOREACH(tlv, &iud->head, entry) { if (!strncmp(port->ifname, tlv->ifname, IFNAMSIZ)) { @@ -112,14 +111,14 @@ mod = malloc(sizeof(*mod)); if (!mod) { - LLDPAD_ERR("Failed to malloc LLDP-8021QAZ module data"); + LLDPAD_ERR("Failed to malloc LLDP-8021QAZ module data\n"); goto out_err; } iud = malloc(sizeof(*iud)); if (!iud) { free(mod); - LLDPAD_ERR("Failed to malloc LLDP-8021QAZ module user data"); + LLDPAD_ERR("Failed to malloc LLDP-8021QAZ module user data\n"); goto out_err; } memset((void *) iud, 0, sizeof(struct ieee8021qaz_user_data)); @@ -143,7 +142,7 @@ struct ieee8021qaz_user_data *iud; struct ieee8021qaz_tlvs *tlv = NULL; - iud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_8021QAZ); + iud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_8021QAZ); if (iud) { LIST_FOREACH(tlv, &iud->head, entry) { if (!strncmp(tlv->ifname, ifname, IFNAMSIZ)) @@ -204,37 +203,36 @@ free(argcpy); } -bool read_cfg_file_willing(char *ifname, struct lldp_agent *agent, int tlv_type) -{ - char arg_path[256]; - int res, willing = 0; - - snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX, - TLVID_8021(tlv_type), ARG_WILLING); - res = get_config_setting(ifname, agent->type, arg_path, &willing, - CONFIG_TYPE_INT); - - return (res == 0 ? willing == 1 : true); -} - static int read_cfg_file(char *ifname, struct lldp_agent *agent, struct ieee8021qaz_tlvs *tlvs) { const char *arg = NULL; char arg_path[256]; int res = 0, i; - int pfc_mask, delay; + int willing, pfc_mask, delay; if (agent->type != NEAREST_BRIDGE) return 0; /* Read ETS-CFG willing bit -- default willing enabled */ - tlvs->ets->cfgl->willing = read_cfg_file_willing( - ifname, agent, LLDP_8021QAZ_ETSCFG); + snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX, + TLVID_8021(LLDP_8021QAZ_ETSCFG), ARG_WILLING); + res = get_config_setting(ifname, agent->type, arg_path, &willing, + CONFIG_TYPE_INT); + if (!res) + tlvs->ets->cfgl->willing = !!willing; + else + tlvs->ets->cfgl->willing = 1; /* Read PFC willing bit -- default willing enabled */ - tlvs->pfc->local.willing = read_cfg_file_willing( - ifname, agent, LLDP_8021QAZ_PFC); + snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", TLVID_PREFIX, + TLVID_8021(LLDP_8021QAZ_PFC), ARG_WILLING); + res = get_config_setting(ifname, agent->type, arg_path, &willing, + CONFIG_TYPE_INT); + if (!res) + tlvs->pfc->local.willing = !!willing; + else + tlvs->pfc->local.willing = 1; /* Read and parse ETS-CFG priority map -- * default all priorities TC0 @@ -398,7 +396,7 @@ return 0; } -inline int get_prio_map(u32 prio_map, int prio) +static int get_prio_map(u32 prio_map, int prio) { if (prio > 7) return 0; @@ -406,7 +404,7 @@ return (prio_map >> (4 * (7-prio))) & 0xF; } -inline void set_prio_map(u32 *prio_map, u8 prio, int tc) +static void set_prio_map(u32 *prio_map, u8 prio, int tc) { u32 mask = ~(0xffffffff & (0xF << (4 * (7-prio)))); *prio_map &= mask; @@ -630,7 +628,7 @@ LIST_INIT(&tlvs->app_head); read_cfg_file(port->ifname, agent, tlvs); - iud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_8021QAZ); + iud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_8021QAZ); LIST_INSERT_HEAD(&iud->head, tlvs, entry); initialized: @@ -1186,10 +1184,9 @@ void run_all_sm(struct port *port, struct lldp_agent *agent) { struct ieee8021qaz_tlvs *tlvs; - struct ieee_ets *ets = NULL; - struct ieee_pfc *pfc = NULL; + struct ieee_ets *ets; + struct ieee_pfc *pfc; struct pfc_obj *pfc_obj; - bool willing; if (agent->type != NEAREST_BRIDGE) return; @@ -1200,50 +1197,40 @@ ets_sm(tlvs->ets->cfgl, tlvs->ets->recr, &tlvs->ets->current_state); - willing = read_cfg_file_willing(port->ifname, agent, - LLDP_8021QAZ_ETSCFG); - - if(willing) { - ets = malloc(sizeof(*ets)); - if (!ets) { - LLDPAD_WARN("%s: %s: ets malloc failed\n", - __func__, port->ifname); - return; - } - - memset(ets, 0, sizeof(*ets)); - - if (tlvs->ets->current_state == RX_RECOMMEND) - ets_rec_to_ieee(ets, tlvs->ets->recr); - else - ets_cfg_to_ieee(ets, tlvs->ets->cfgl); + ets = malloc(sizeof(*ets)); + if (!ets) { + LLDPAD_WARN("%s: %s: ets malloc failed\n", + __func__, port->ifname); + return; } + memset(ets, 0, sizeof(*ets)); + + if (tlvs->ets->current_state == RX_RECOMMEND) + ets_rec_to_ieee(ets, tlvs->ets->recr); + else + ets_cfg_to_ieee(ets, tlvs->ets->cfgl); + pfc_sm(tlvs); - willing = read_cfg_file_willing(port->ifname, agent, - LLDP_8021QAZ_PFC); + if (tlvs->pfc->current_state == RX_RECOMMEND) + pfc_obj = &tlvs->pfc->remote; + else + pfc_obj = &tlvs->pfc->local; - if(willing) { - if (tlvs->pfc->current_state == RX_RECOMMEND) - pfc_obj = &tlvs->pfc->remote; - else - pfc_obj = &tlvs->pfc->local; - - pfc = malloc(sizeof(*pfc)); - if (!pfc) { - LLDPAD_WARN("%s: %s: pfc malloc failed\n", - __func__, port->ifname); - goto out; - } - - memset(pfc, 0, sizeof(*pfc)); - - pfc->pfc_en = pfc_obj->pfc_enable; - pfc->mbc = pfc_obj->mbc; - pfc->delay = pfc_obj->delay; + pfc = malloc(sizeof(*pfc)); + if (!pfc) { + LLDPAD_WARN("%s: %s: pfc malloc failed\n", + __func__, port->ifname); + goto out; } + memset(pfc, 0, sizeof(*pfc)); + + pfc->pfc_en = pfc_obj->pfc_enable; + pfc->mbc = pfc_obj->mbc; + pfc->delay = pfc_obj->delay; + if (ieee8021qaz_check_active(port->ifname)) { set_dcbx_mode(port->ifname, DCB_CAP_DCBX_VER_IEEE | DCB_CAP_DCBX_HOST); @@ -1637,15 +1624,15 @@ return; if (tlvs->rx->ieee8021qaz) - tlvs->rx->ieee8021qaz = free_unpkd_tlv(tlvs->rx->ieee8021qaz); + free_unpkd_tlv(tlvs->rx->ieee8021qaz); if (tlvs->rx->etscfg) - tlvs->rx->etscfg = free_unpkd_tlv(tlvs->rx->etscfg); + free_unpkd_tlv(tlvs->rx->etscfg); if (tlvs->rx->etsrec) - tlvs->rx->etsrec = free_unpkd_tlv(tlvs->rx->etsrec); + free_unpkd_tlv(tlvs->rx->etsrec); if (tlvs->rx->pfc) - tlvs->rx->pfc = free_unpkd_tlv(tlvs->rx->pfc); + free_unpkd_tlv(tlvs->rx->pfc); if (tlvs->rx->app) - tlvs->rx->app = free_unpkd_tlv(tlvs->rx->app); + free_unpkd_tlv(tlvs->rx->app); free(tlvs->rx); tlvs->rx = NULL; @@ -2033,13 +2020,13 @@ return; if (rx->etscfg) - rx->etscfg = free_unpkd_tlv(rx->etscfg); + free_unpkd_tlv(rx->etscfg); if (rx->etsrec) - rx->etsrec = free_unpkd_tlv(rx->etsrec); + free_unpkd_tlv(rx->etsrec); if (rx->pfc) - rx->pfc = free_unpkd_tlv(rx->pfc); + free_unpkd_tlv(rx->pfc); if (rx->app) - rx->app = free_unpkd_tlv(rx->app); + free_unpkd_tlv(rx->app); return; } @@ -2125,9 +2112,9 @@ return; if (tlvs->ets) - tlvs->ets = free_ets_tlv(tlvs->ets); + free_ets_tlv(tlvs->ets); if (tlvs->pfc) - tlvs->pfc = free_pfc_tlv(tlvs->pfc); + free_pfc_tlv(tlvs->pfc); /* Remove _all_ existing application data */ LIST_FOREACH(np, &tlvs->app_head, entry) @@ -2191,7 +2178,7 @@ struct ieee8021qaz_user_data *iud; struct ieee8021qaz_tlvs *tlv = NULL; - iud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_8021QAZ); + iud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_8021QAZ); if (iud) { LIST_FOREACH(tlv, &iud->head, entry) { if (!strncmp(tlv->ifname, ifname, IFNAMSIZ)) @@ -2210,7 +2197,7 @@ struct ieee8021qaz_user_data *iud; struct ieee8021qaz_tlvs *tlv = NULL; - iud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_8021QAZ); + iud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_8021QAZ); if (iud) { LIST_FOREACH(tlv, &iud->head, entry) { if (!strncmp(tlv->ifname, ifname, IFNAMSIZ)) diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp_8023.c lldpad-1.1/lldp_8023.c --- lldpad-1.0.1+git20200210.2022b0c/lldp_8023.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp_8023.c 2020-10-30 13:37:52.000000000 +0000 @@ -39,8 +39,6 @@ #include "lldp_8023_clif.h" #include "lldp_8023_cmds.h" -extern struct lldp_head lldp_head; - struct tlv_info_8023_maccfg { u8 oui[3]; u8 sub; @@ -84,7 +82,7 @@ struct ieee8023_user_data *ud; struct ieee8023_data *bd = NULL; - ud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_8023); + ud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_8023); if (ud) { LIST_FOREACH(bd, &ud->head, entry) { if (!strncmp(ifname, bd->ifname, IFNAMSIZ) && @@ -401,7 +399,7 @@ PACK_TLV_AFTER(bd->maxfs, ptlv, size, out_free); return ptlv; out_free: - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); out_err: LLDPAD_DBG("%s:%s: failed\n", __func__, port->ifname); return NULL; @@ -456,7 +454,7 @@ goto out_err; } - ud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_8023); + ud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_8023); LIST_INSERT_HEAD(&ud->head, bd, entry); LLDPAD_INFO("%s:port %s added\n", __func__, ifname); return; @@ -472,13 +470,13 @@ mod = malloc(sizeof(*mod)); if (!mod) { - LLDPAD_ERR("failed to malloc LLDP 802.3 module data"); + LLDPAD_ERR("failed to malloc LLDP 802.3 module data\n"); goto out_err; } ud = malloc(sizeof(struct ieee8023_user_data)); if (!ud) { free(mod); - LLDPAD_ERR("failed to malloc LLDP 802.3 module user data"); + LLDPAD_ERR("failed to malloc LLDP 802.3 module user data\n"); goto out_err; } LIST_INIT(&ud->head); diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldpad.c lldpad-1.1/lldpad.c --- lldpad-1.0.1+git20200210.2022b0c/lldpad.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldpad.c 2020-10-30 13:37:52.000000000 +0000 @@ -80,6 +80,8 @@ NULL, }; +struct lldp_head lldp_mod_head; + char *cfg_file_name = NULL; bool daemonize = 0; int loglvl = LOG_WARNING; @@ -98,7 +100,7 @@ struct lldp_module *premod = NULL; int i = 0; - LIST_INIT(&lldp_head); + LIST_INIT(&lldp_mod_head); for (i = 0; register_tlv_table[i]; i++) { module = register_tlv_table[i](); if (!module) @@ -106,7 +108,7 @@ if (premod) LIST_INSERT_AFTER(premod, module, lldp); else - LIST_INSERT_HEAD(&lldp_head, module, lldp); + LIST_INSERT_HEAD(&lldp_mod_head, module, lldp); premod = module; } } @@ -115,9 +117,9 @@ { struct lldp_module *module; - while (lldp_head.lh_first != NULL) { - module = lldp_head.lh_first; - LIST_REMOVE(lldp_head.lh_first, lldp); + while (lldp_mod_head.lh_first != NULL) { + module = lldp_mod_head.lh_first; + LIST_REMOVE(lldp_mod_head.lh_first, lldp); module->ops->lldp_mod_unregister(module); } } diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp_basman.c lldpad-1.1/lldp_basman.c --- lldpad-1.0.1+git20200210.2022b0c/lldp_basman.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp_basman.c 2020-10-30 13:37:52.000000000 +0000 @@ -75,8 +75,6 @@ struct tlv_info_maoid o; } __attribute__ ((__packed__)); -extern struct lldp_head lldp_head; - static const struct lldp_mod_ops basman_ops = { .lldp_mod_register = basman_register, .lldp_mod_unregister = basman_unregister, @@ -91,7 +89,7 @@ struct basman_user_data *bud; struct basman_data *bd = NULL; - bud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_BASIC); + bud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_BASIC); if (bud) { LIST_FOREACH(bd, &bud->head, entry) { if (!strncmp(ifname, bd->ifname, IFNAMSIZ) && @@ -636,7 +634,7 @@ PACK_TLV_AFTER(bd->manaddr[i], ptlv, size, out_free); return ptlv; out_free: - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); out_err: LLDPAD_DBG("%s:%s: failed\n", __func__, port->ifname); return NULL; @@ -688,7 +686,7 @@ goto out_err; } - bud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_BASIC); + bud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_BASIC); LIST_INSERT_HEAD(&bud->head, bd, entry); LLDPAD_DBG("%s:port %s added\n", __func__, ifname); return; diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp_dcbx.c lldpad-1.1/lldp_dcbx.c --- lldpad-1.0.1+git20200210.2022b0c/lldp_dcbx.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp_dcbx.c 2020-10-30 13:37:52.000000000 +0000 @@ -129,7 +129,7 @@ struct dcbd_user_data *dud; struct dcbx_tlvs *tlv = NULL; - dud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_DCBX); + dud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_DCBX); if (dud) { LIST_FOREACH(tlv, &dud->head, entry) { if (!strncmp(tlv->ifname, ifname, IFNAMSIZ)) @@ -148,7 +148,7 @@ if (agent->type != NEAREST_BRIDGE) return 0; - dud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_DCBX); + dud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_DCBX); if (dud) { LIST_FOREACH(tlv, &dud->head, entry) { if (!strncmp(tlv->ifname, ifname, IFNAMSIZ)) @@ -172,7 +172,7 @@ struct dcbd_user_data *dud; struct dcbx_tlvs *tlv = NULL; - dud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_DCBX); + dud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_DCBX); if (dud) { LIST_FOREACH(tlv, &dud->head, entry) { if (!strncmp(tlv->ifname, ifname, IFNAMSIZ)) @@ -285,20 +285,20 @@ return; if (manifest->dcbx1) - manifest->dcbx1 = free_unpkd_tlv(manifest->dcbx1); + free_unpkd_tlv(manifest->dcbx1); if (manifest->dcbx2) - manifest->dcbx2 = free_unpkd_tlv(manifest->dcbx2); + free_unpkd_tlv(manifest->dcbx2); if (manifest->dcbx_ctrl) - manifest->dcbx_ctrl = free_unpkd_tlv(manifest->dcbx_ctrl); + free_unpkd_tlv(manifest->dcbx_ctrl); if (manifest->dcbx_pg) - manifest->dcbx_pg = free_unpkd_tlv(manifest->dcbx_pg); + free_unpkd_tlv(manifest->dcbx_pg); if (manifest->dcbx_pfc) - manifest->dcbx_pfc = free_unpkd_tlv(manifest->dcbx_pfc); + free_unpkd_tlv(manifest->dcbx_pfc); if (manifest->dcbx_app) - manifest->dcbx_app = free_unpkd_tlv(manifest->dcbx_app); + free_unpkd_tlv(manifest->dcbx_app); if (manifest->dcbx_llink) - manifest->dcbx_llink = free_unpkd_tlv(manifest->dcbx_llink); - + free_unpkd_tlv(manifest->dcbx_llink); + free(manifest); return; } @@ -307,44 +307,27 @@ if (!tlvs) return; - if (tlvs->control != NULL) { - tlvs->control = free_unpkd_tlv(tlvs->control); - } - - if (tlvs->pg1 != NULL) { - tlvs->pg1 = free_unpkd_tlv(tlvs->pg1); - } - - if (tlvs->pg2 != NULL) { - tlvs->pg2 = free_unpkd_tlv(tlvs->pg2); - } - - if (tlvs->pfc1 != NULL) { - tlvs->pfc1 = free_unpkd_tlv(tlvs->pfc1); - } - - if (tlvs->pfc2 != NULL) { - tlvs->pfc2 = free_unpkd_tlv(tlvs->pfc2); - } - - if (tlvs->app1 != NULL) { - tlvs->app1 = free_unpkd_tlv(tlvs->app1); - } + if (tlvs->control) + free_unpkd_tlv(tlvs->control); + if (tlvs->pg1) + free_unpkd_tlv(tlvs->pg1); + if (tlvs->pg2) + free_unpkd_tlv(tlvs->pg2); + if (tlvs->pfc1) + free_unpkd_tlv(tlvs->pfc1); + if (tlvs->pfc2) + free_unpkd_tlv(tlvs->pfc2); + if (tlvs->app1) + free_unpkd_tlv(tlvs->app1); + if (tlvs->app2) + free_unpkd_tlv(tlvs->app2); + if (tlvs->llink) + free_unpkd_tlv(tlvs->llink); + if (tlvs->dcbx1) + free_unpkd_tlv(tlvs->dcbx1); + if (tlvs->dcbx2) + free_unpkd_tlv(tlvs->dcbx2); - if (tlvs->app2 != NULL) - tlvs->app2 = free_unpkd_tlv(tlvs->app2); - - if (tlvs->llink != NULL) { - tlvs->llink = free_unpkd_tlv(tlvs->llink); - } - - if (tlvs->dcbx1 != NULL) { - tlvs->dcbx1 = free_unpkd_tlv(tlvs->dcbx1); - } - - if (tlvs->dcbx2 != NULL) { - tlvs->dcbx2 = free_unpkd_tlv(tlvs->dcbx2); - } return; } @@ -364,6 +347,7 @@ return NULL; dcbx_free_tlv(tlvs); + memset(tlvs, 0, sizeof(struct dcbx_tlvs)); dcbx_bld_tlv(port, agent); if (tlvs->dcbx_st == DCBX_SUBTYPE2) { @@ -388,7 +372,6 @@ LIST_REMOVE(dd, entry); dcbx_free_tlv(dd); dcbx_free_manifest(dd->manifest); - free(dd->manifest); free(dd); } } @@ -410,7 +393,7 @@ if (get_dcbx_version(&dcbx_version)) { gdcbx_subtype = dcbx_version; } else { - LLDPAD_ERR("failed to get DCBX version"); + LLDPAD_ERR("failed to get DCBX version\n"); goto out_err; } @@ -507,7 +490,7 @@ ifindex = get_ifidx(ifname); port = port_find_by_ifindex(ifindex); - dud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_DCBX); + dud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_DCBX); tlvs = dcbx_data(ifname); if (!port) @@ -656,7 +639,6 @@ LIST_REMOVE(tlvs, entry); dcbx_free_tlv(tlvs); dcbx_free_manifest(tlvs->manifest); - free(tlvs->manifest); free(tlvs); } @@ -666,26 +648,19 @@ return; if (dcbx->manifest->dcbx_llink) - dcbx->manifest->dcbx_llink = - free_unpkd_tlv(dcbx->manifest->dcbx_llink); + free_unpkd_tlv(dcbx->manifest->dcbx_llink); if (dcbx->manifest->dcbx_app) - dcbx->manifest->dcbx_app = - free_unpkd_tlv(dcbx->manifest->dcbx_app); + free_unpkd_tlv(dcbx->manifest->dcbx_app); if (dcbx->manifest->dcbx_pfc) - dcbx->manifest->dcbx_pfc = - free_unpkd_tlv(dcbx->manifest->dcbx_pfc); + free_unpkd_tlv(dcbx->manifest->dcbx_pfc); if (dcbx->manifest->dcbx_pg) - dcbx->manifest->dcbx_pg = - free_unpkd_tlv(dcbx->manifest->dcbx_pg); + free_unpkd_tlv(dcbx->manifest->dcbx_pg); if (dcbx->manifest->dcbx_ctrl) - dcbx->manifest->dcbx_ctrl = - free_unpkd_tlv(dcbx->manifest->dcbx_ctrl); + free_unpkd_tlv(dcbx->manifest->dcbx_ctrl); if (dcbx->manifest->dcbx1) - dcbx->manifest->dcbx1 = - free_unpkd_tlv(dcbx->manifest->dcbx1); + free_unpkd_tlv(dcbx->manifest->dcbx1); if (dcbx->manifest->dcbx2) - dcbx->manifest->dcbx2 = - free_unpkd_tlv(dcbx->manifest->dcbx2); + free_unpkd_tlv(dcbx->manifest->dcbx2); free(dcbx->manifest); dcbx->manifest = NULL; } diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp_dcbx_cfg.c lldpad-1.1/lldp_dcbx_cfg.c --- lldpad-1.0.1+git20200210.2022b0c/lldp_dcbx_cfg.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp_dcbx_cfg.c 2020-10-30 13:37:52.000000000 +0000 @@ -703,7 +703,7 @@ return 0; set_error: - LLDPAD_ERR("update of config file %s failed for %s", + LLDPAD_ERR("update of config file %s failed for %s\n", cfg_file_name, device_name); return cmd_failed; } @@ -799,12 +799,8 @@ /* init the internal data store for device_name */ result = get_default_persistent(device_name, attribs); - if (NULL == eth_settings) { - assert(memcmp(device_name, DEF_CFG_STORE, - strlen(DEF_CFG_STORE))); - + if (NULL == eth_settings) return result; - } /* Read pfc setting */ if (get_int_config(eth_settings, "pfc_enable", TYPE_BOOL, diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp_dcbx_nl.c lldpad-1.1/lldp_dcbx_nl.c --- lldpad-1.0.1+git20200210.2022b0c/lldp_dcbx_nl.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp_dcbx_nl.c 2020-10-30 13:37:52.000000000 +0000 @@ -152,16 +152,17 @@ { struct sockaddr_nl nladdr; void *buf = (void *)nlh; - int r, len = nlh->nlmsg_len; + int r; if (nlh == NULL) return 1; memset(&nladdr, 0, sizeof(nladdr)); nladdr.nl_family = AF_NETLINK; - + do { - r = sendto(nl_sd, buf, len, 0, (struct sockaddr *)&nladdr, + r = sendto(nl_sd, buf, nlh->nlmsg_len, 0, + (struct sockaddr *)&nladdr, sizeof(nladdr)); LLDPAD_DBG("send_msg: sendto = %d\n", r); diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp_evb22.c lldpad-1.1/lldp_evb22.c --- lldpad-1.0.1+git20200210.2022b0c/lldp_evb22.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp_evb22.c 2020-10-30 13:37:52.000000000 +0000 @@ -37,14 +37,12 @@ #include "messages.h" #include "config.h" -extern struct lldp_head lldp_head; - struct evb22_data *evb22_data(char *ifname, enum agent_type type) { struct evb22_user_data *ud; struct evb22_data *ed = NULL; - ud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_EVB22); + ud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_EVB22); if (ud) { LIST_FOREACH(ed, &ud->head, entry) { if (!strncmp(ifname, ed->ifname, IFNAMSIZ) && @@ -453,7 +451,7 @@ STRNCPY_TERMINATED(ed->ifname, ifname, IFNAMSIZ); ed->agenttype = agent->type; evb22_init_tlv(ed, agent); - ud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_EVB22); + ud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_EVB22); LIST_INSERT_HEAD(&ud->head, ed, entry); LLDPAD_DBG("%s:%s agent %d added\n", __func__, ifname, agent->type); } diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp_evb22_cmds.c lldpad-1.1/lldp_evb22_cmds.c --- lldpad-1.0.1+git20200210.2022b0c/lldp_evb22_cmds.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp_evb22_cmds.c 2020-10-30 13:37:52.000000000 +0000 @@ -225,7 +225,7 @@ TLVID(OUI_IEEE_8021Qbg22, LLDP_EVB22_SUBTYPE)); } -static int evb22_cmdok(struct cmd *cmd, cmd_status expected) +static int evb22_cmdok(struct cmd *cmd, int expected) { if (cmd->cmd != expected) return cmd_invalid; diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp_evb.c lldpad-1.1/lldp_evb.c --- lldpad-1.0.1+git20200210.2022b0c/lldp_evb.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp_evb.c 2020-10-30 13:37:52.000000000 +0000 @@ -36,14 +36,12 @@ #include "messages.h" #include "config.h" -extern struct lldp_head lldp_head; - struct evb_data *evb_data(char *ifname, enum agent_type type) { struct evb_user_data *ud; struct evb_data *ed = NULL; - ud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_EVB); + ud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_EVB); if (ud) { LIST_FOREACH(ed, &ud->head, entry) { if (!strncmp(ifname, ed->ifname, IFNAMSIZ) && @@ -347,7 +345,7 @@ evb_init_tlv(ed, agent); - ud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_EVB); + ud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_EVB); LIST_INSERT_HEAD(&ud->head, ed, entry); LLDPAD_DBG("%s:%s agent %d added\n", __func__, ifname, agent->type); } diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp_evb_cmds.c lldpad-1.1/lldp_evb_cmds.c --- lldpad-1.0.1+git20200210.2022b0c/lldp_evb_cmds.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp_evb_cmds.c 2020-10-30 13:37:52.000000000 +0000 @@ -163,7 +163,7 @@ return is_tlv_txenabled(ifname, type, TLVID_8021Qbg(LLDP_EVB_SUBTYPE)); } -static int evb_cmdok(struct cmd *cmd, cmd_status expected) +static int evb_cmdok(struct cmd *cmd, int expected) { if (cmd->cmd != expected) return cmd_invalid; diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp_mand.c lldpad-1.1/lldp_mand.c --- lldpad-1.0.1+git20200210.2022b0c/lldp_mand.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp_mand.c 2020-10-30 13:37:52.000000000 +0000 @@ -42,8 +42,6 @@ #include "lldp/l2_packet.h" #include "lldp_tlv.h" -extern struct lldp_head lldp_head; - static const struct lldp_mod_ops mand_ops = { .lldp_mod_register = mand_register, .lldp_mod_unregister = mand_unregister, @@ -59,7 +57,7 @@ struct mand_user_data *mud; struct mand_data *md = NULL; - mud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_MAND); + mud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_MAND); if (mud) { LIST_FOREACH(md, &mud->head, entry) { if (!strncmp(ifname, md->ifname, IFNAMSIZ) && @@ -517,9 +515,11 @@ } err = mand_bld_tlv(md, agent); - if (err) + if (err) { LLDPAD_DBG("%s:%s: building mandotory TLV error.\n", __func__, port->ifname); + goto out_err; + } size = TLVSIZE(md->chassis) + TLVSIZE(md->portid) @@ -541,7 +541,7 @@ PACK_TLV_AFTER(md->ttl, ptlv, size, out_free); return ptlv; out_free: - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); out_err: LLDPAD_DBG("%s:%s: failed\n", __func__, port->ifname); return NULL; @@ -608,7 +608,7 @@ STRNCPY_TERMINATED(md->ifname, ifname, IFNAMSIZ); md->agenttype = agent->type; - mud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_MAND); + mud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_MAND); LIST_INSERT_HEAD(&mud->head, md, entry); } @@ -636,7 +636,7 @@ LLDPAD_ERR("failed to malloc LLDP Mandatory module data\n"); goto out_err; } - mud = malloc(sizeof(struct mand_user_data)); + mud = malloc(sizeof(struct mand_user_data)); if (!mud) { free(mod); LLDPAD_ERR("failed to malloc LLDP Mandatory module user data\n"); @@ -644,8 +644,8 @@ } LIST_INIT(&mud->head); mod->id = LLDP_MOD_MAND; + mod->data = mud; mod->ops = &mand_ops; - mod->data = mud; LLDPAD_INFO("%s:done\n", __func__); return mod; out_err: diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp_mand_cmds.c lldpad-1.1/lldp_mand_cmds.c --- lldpad-1.0.1+git20200210.2022b0c/lldp_mand_cmds.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp_mand_cmds.c 2020-10-30 13:37:52.000000000 +0000 @@ -466,7 +466,7 @@ nbuf = obuf; nbuf_len = obuf_len; - LIST_FOREACH(np, &lldp_head, lldp) { + LIST_FOREACH(np, &lldp_mod_head, lldp) { if (!np->ops->get_arg_handler) continue; if (!(ah = np->ops->get_arg_handler())) @@ -496,7 +496,7 @@ struct arg_handlers *ah; int rval, status = cmd_not_applicable; - LIST_FOREACH(np, &lldp_head, lldp) { + LIST_FOREACH(np, &lldp_mod_head, lldp) { if (!np->ops->get_arg_handler) continue; if (!(ah = np->ops->get_arg_handler())) @@ -593,7 +593,7 @@ struct arg_handlers *ah; int rval, status = cmd_not_applicable; - LIST_FOREACH(np, &lldp_head, lldp) { + LIST_FOREACH(np, &lldp_mod_head, lldp) { if (!np->ops->get_arg_handler) continue; if (!(ah = np->ops->get_arg_handler())) @@ -626,7 +626,7 @@ struct arg_handlers *ah; int rval, status = cmd_not_applicable; - LIST_FOREACH(np, &lldp_head, lldp) { + LIST_FOREACH(np, &lldp_mod_head, lldp) { if (!np->ops->get_arg_handler) continue; if (!(ah = np->ops->get_arg_handler())) diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp_med.c lldpad-1.1/lldp_med.c --- lldpad-1.0.1+git20200210.2022b0c/lldp_med.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp_med.c 2020-10-30 13:37:52.000000000 +0000 @@ -40,8 +40,6 @@ #include "lldp_mand_clif.h" #include "lldp_med_cmds.h" -extern struct lldp_head lldp_head; - struct tlv_info_medcaps { u8 oui[OUI_SIZE]; u8 subtype; @@ -95,7 +93,7 @@ struct med_user_data *mud; struct med_data *md = NULL; - mud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_MED); + mud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_MED); if (mud) { LIST_FOREACH(md, &mud->head, entry) { if (!strncmp(ifname, md->ifname, IFNAMSIZ) && @@ -914,7 +912,7 @@ free(md); goto out_err; } - mud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_MED); + mud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_MED); LIST_INSERT_HEAD(&mud->head, md, entry); LLDPAD_INFO("%s:port %s added\n", __func__, ifname); return; diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp_rtnl.c lldpad-1.1/lldp_rtnl.c --- lldpad-1.0.1+git20200210.2022b0c/lldp_rtnl.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp_rtnl.c 2020-10-30 13:37:52.000000000 +0000 @@ -103,7 +103,8 @@ rta->rta_type = type; rta->rta_len = len; - memcpy(RTA_DATA(rta), data, alen); + if (data) + memcpy(RTA_DATA(rta), data, alen); n->nlmsg_len = NLMSG_ALIGN(n->nlmsg_len) + RTA_ALIGN(len); } diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldp_tlv.c lldpad-1.1/lldp_tlv.c --- lldpad-1.0.1+git20200210.2022b0c/lldp_tlv.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldp_tlv.c 2020-10-30 13:37:52.000000000 +0000 @@ -112,13 +112,13 @@ return -1; if (ptlv->size + mtlv->size > length) { - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); return -1; } memcpy(&mtlv->tlv[mtlv->size], ptlv->tlv, ptlv->size); mtlv->size += ptlv->size; - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); return 0; } @@ -158,7 +158,7 @@ return upkd_tlv; } -struct unpacked_tlv *free_unpkd_tlv(struct unpacked_tlv *tlv) +void free_unpkd_tlv(struct unpacked_tlv *tlv) { if (tlv != NULL) { if (tlv->info != NULL) { @@ -166,12 +166,10 @@ tlv->info = NULL; } free(tlv); - tlv = NULL; } - return NULL; } -struct packed_tlv *free_pkd_tlv(struct packed_tlv *tlv) +void free_pkd_tlv(struct packed_tlv *tlv) { if (tlv != NULL) { if (tlv->tlv != NULL) { @@ -179,9 +177,7 @@ tlv->tlv = NULL; } free(tlv); - tlv = NULL; } - return NULL; } struct packed_tlv *create_ptlv() diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldptool.c lldpad-1.1/lldptool.c --- lldpad-1.0.1+git20200210.2022b0c/lldptool.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldptool.c 2020-10-30 13:37:52.000000000 +0000 @@ -64,6 +64,9 @@ #include "lldp_util.h" #include "lldpad_status.h" +struct lldp_head lldp_cli_head; +struct lldp_head lldp_mod_head; +extern void close_history(void); static int show_raw; static const char *cli_version = @@ -199,7 +202,7 @@ if (premod) LIST_INSERT_AFTER(premod, module, lldp); else - LIST_INSERT_HEAD(&lldp_head, module, lldp); + LIST_INSERT_HEAD(&lldp_mod_head, module, lldp); premod = module; } } @@ -208,9 +211,9 @@ { struct lldp_module *module; - while (lldp_head.lh_first != NULL) { - module = lldp_head.lh_first; - LIST_REMOVE(lldp_head.lh_first, lldp); + while (lldp_mod_head.lh_first != NULL) { + module = lldp_mod_head.lh_first; + LIST_REMOVE(lldp_mod_head.lh_first, lldp); module->ops->lldp_mod_unregister(module); } } @@ -346,7 +349,7 @@ printf("%s\n%s\n%s", commands_usage, commands_options, commands_help); printf("\nTLV identifiers:\n"); - LIST_FOREACH(np, &lldp_head, lldp) + LIST_FOREACH(np, &lldp_mod_head, lldp) if (np->ops->print_help) np->ops->print_help(); return 0; @@ -406,7 +409,7 @@ struct lldp_module *np; u32 tlvid = INVALID_TLVID; - LIST_FOREACH(np, &lldp_head, lldp) { + LIST_FOREACH(np, &lldp_mod_head, lldp) { if (np->ops->lookup_tlv_name) { tlvid = np->ops->lookup_tlv_name(tlvid_str); if (tlvid != INVALID_TLVID) @@ -689,6 +692,7 @@ } free(cmd); } while (!cli_quit); + close_history(); } static void cli_terminate(UNUSED int sig) diff -Nru lldpad-1.0.1+git20200210.2022b0c/lldptool_cmds.c lldpad-1.1/lldptool_cmds.c --- lldpad-1.0.1+git20200210.2022b0c/lldptool_cmds.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/lldptool_cmds.c 2020-10-30 13:37:52.000000000 +0000 @@ -27,6 +27,7 @@ #include #include #include +#include #include "clif.h" #include "dcb_types.h" #include "lldptool.h" @@ -464,7 +465,7 @@ offset += 8; printed = 0; - LIST_FOREACH(np, &lldp_head, lldp) { + LIST_FOREACH(np, &lldp_mod_head, lldp) { if (np->ops->print_tlv(tlvid, tlv_len, ibuf+offset)) { printed = 1; break; diff -Nru lldpad-1.0.1+git20200210.2022b0c/log.c lldpad-1.1/log.c --- lldpad-1.0.1+git20200210.2022b0c/log.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/log.c 2020-10-30 13:37:52.000000000 +0000 @@ -65,4 +65,5 @@ bypass_time = strchr(format, '\n') == 0; } va_end(va); + va_end(vb); } diff -Nru lldpad-1.0.1+git20200210.2022b0c/m4/openlldp.m4 lldpad-1.1/m4/openlldp.m4 --- lldpad-1.0.1+git20200210.2022b0c/m4/openlldp.m4 1970-01-01 00:00:00.000000000 +0000 +++ lldpad-1.1/m4/openlldp.m4 2020-10-30 13:37:52.000000000 +0000 @@ -0,0 +1,66 @@ +# -*- autoconf -*- + +# Copyright (c) 2020 Red Hat, Inc. +# +# 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". + +dnl Check for C compiler support of specific flags +AC_DEFUN([_CHECK_C_COMPILER_FLAG], [ + AC_LANG_PUSH([C]) + AC_MSG_CHECKING(for $CC support of $1) + old_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $1" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no) + CFLAGS="$old_CFLAGS") + AC_LANG_POP() +]) + +dnl Check for the various warning flags +AC_DEFUN([OPENLLDP_CHECK_WARNINGS], [ + AC_MSG_CHECKING([checking for warnings flag]) + AC_ARG_ENABLE([warnings], + AS_HELP_STRING([--enable-warnings], + [Add various warning flags to the build]),, + enable_warnings=yes) + AM_CONDITIONAL([WARNINGS_ENABLED], [test "x$enable_warnings" = "xyes"]) + AC_SUBST([WARNINGS_ENABLED], [$enable_warnings]) + AC_MSG_RESULT($enable_warnings) + + AS_IF([ test "x$enable_warnings" = "xyes"], [ + _CHECK_C_COMPILER_FLAG([-Wall]) + _CHECK_C_COMPILER_FLAG([-Wextra]) + _CHECK_C_COMPILER_FLAG([-Wformat=2]) + ]) +]) + +dnl Checks for whether to set -Werror +AC_DEFUN([OPENLLDP_CHECK_ERROR], [ + AC_MSG_CHECKING([checking for errors flag]) + AC_ARG_ENABLE([errors], + AS_HELP_STRING([--enable-errors], + [Add -Werror to build flags]),, + enable_errors=no) + AM_CONDITIONAL([ERRORS_ENABLED], [test "x$enable_errors" = "xyes"]) + AC_SUBST([ERRORS_ENABLED], [$enable_errors]) + AC_MSG_RESULT($enable_errors) + + AS_IF([ test "x$enable_errors" = "xyes"], [ + _CHECK_C_COMPILER_FLAG([-Werror]) + ]) +]) diff -Nru lldpad-1.0.1+git20200210.2022b0c/Makefile.am lldpad-1.1/Makefile.am --- lldpad-1.0.1+git20200210.2022b0c/Makefile.am 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/Makefile.am 2020-10-30 13:37:52.000000000 +0000 @@ -19,7 +19,7 @@ parse_cli.o: CFLAGS+=-U_FORTIFY_SOURCE -Wno-error ## system requires a shared libconfig -AM_CFLAGS = -Wall -Werror -Wextra -Wformat=2 $(LIBCONFIG_CFLAGS) $(LIBNL_CFLAGS) +AM_CFLAGS = $(LIBCONFIG_CFLAGS) $(LIBNL_CFLAGS) AM_LDFLAGS = $(LIBCONFIG_LIBS) $(LIBNL_LIBS) -lrt ## header files to be installed, for programs using the client interface to lldpad @@ -149,3 +149,14 @@ lldp_clif_test_SOURCES = test/lldp_clif_test.c lldp_basman_clif.c lldp_util.c \ lldp_rtnl.c lldp_clif_test_LDFLAGS = -lrt $(LIBNL_LIBS) + +RPMBUILD_TOP = $(abs_top_builddir)/rpm/rpmbuild +RPMBUILD_OPT ?= --without check + +# Build user-space RPMs +rpm: dist $(srcdir)/lldpad.spec + ${MKDIR_P} ${RPMBUILD_TOP}/SOURCES + cp ${DIST_ARCHIVES} ${RPMBUILD_TOP}/SOURCES + rpmbuild ${RPMBUILD_OPT} \ + -D "_topdir ${RPMBUILD_TOP}" \ + -ba $(srcdir)/lldpad.spec diff -Nru lldpad-1.0.1+git20200210.2022b0c/parse_cli.l lldpad-1.1/parse_cli.l --- lldpad-1.0.1+git20200210.2022b0c/parse_cli.l 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/parse_cli.l 2020-10-30 13:37:52.000000000 +0000 @@ -494,7 +494,8 @@ yyless(0); } -[0-7] { up2tc_a[up2tc_idx++] = atoi(yytext); +[0-7] { up2tc_a[up2tc_idx] = atoi(yytext); + up2tc_idx++; if (up2tc_idx == 8) { BEGIN(getpgargs); } diff -Nru lldpad-1.0.1+git20200210.2022b0c/qbg/ecp22.c lldpad-1.1/qbg/ecp22.c --- lldpad-1.0.1+git20200210.2022b0c/qbg/ecp22.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/qbg/ecp22.c 2020-10-30 13:37:52.000000000 +0000 @@ -119,7 +119,8 @@ */ void ecp22_putnode(struct ecp22_freelist *list, struct ecp22_payload_node *elm) { - elm->ptlv = free_pkd_tlv(elm->ptlv); + free_pkd_tlv(elm->ptlv); + elm->ptlv = NULL; if (list->freecnt > ecp22_maxpayload) free(elm); else { @@ -154,6 +155,7 @@ memset(ecp->tx.frame, 0, sizeof ecp->tx.frame); ecp22_append(ecp->tx.frame, &fb_offset, (void *)ð, sizeof eth); + memset(&ecph, 0, sizeof(struct ecp22_hdr)); ecp22_hdr_set_version(&ecph, 1); ecp22_hdr_set_op(&ecph, ECP22_REQUEST); ecp22_hdr_set_subtype(&ecph, ECP22_VDP); @@ -774,7 +776,7 @@ struct ecp22 *ecp; LLDPAD_DBG("%s:%s start ecp\n", __func__, ifname); - eud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_ECP22); + eud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_ECP22); if (!eud) { LLDPAD_DBG("%s:%s no ECP module\n", __func__, ifname); return; @@ -807,7 +809,7 @@ while ((np = LIST_FIRST(ptr))) { LIST_REMOVE(np, node); - np->ptlv = free_pkd_tlv(np->ptlv); + free_pkd_tlv(np->ptlv); free(np); } } @@ -837,7 +839,7 @@ struct ecp22 *ecp; LLDPAD_DBG("%s:%s stop ecp\n", __func__, ifname); - eud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_ECP22); + eud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_ECP22); ecp = find_ecpdata(ifname, eud); if (ecp) ecp22_remove(ecp); @@ -852,7 +854,7 @@ struct ecp22_user_data *eud; struct ecp22 *ecp; - eud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_ECP22); + eud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_ECP22); ecp = find_ecpdata(ifname, eud); if (ecp) { ecp->max_rte = ptr->max_rte; @@ -930,7 +932,7 @@ LLDPAD_DBG("%s:%s subtype:%d\n", __func__, ifname, subtype); - eud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_ECP22); + eud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_ECP22); ecp = find_ecpdata(ifname, eud); if (!ecp) { rc = -ENODEV; diff -Nru lldpad-1.0.1+git20200210.2022b0c/qbg/ecp.c lldpad-1.1/qbg/ecp.c --- lldpad-1.0.1+git20200210.2022b0c/qbg/ecp.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/qbg/ecp.c 2020-10-30 13:37:52.000000000 +0000 @@ -299,7 +299,7 @@ rc = ecp_append(vd->ecp.tx.frame, &fb_offset, ptlv->tlv, ptlv->size); - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); if (rc) p->seqnr = vd->ecp.lastSequence; else @@ -682,7 +682,7 @@ } if (hdr->h_proto != example_hdr.h_proto) { - LLDPAD_ERR("%s:%s ERROR ethertype %#x not ECP ethertype", + LLDPAD_ERR("%s:%s ERROR ethertype %#x not ECP ethertype\n", __func__, vd->ecp.ifname, htons(hdr->h_proto)); frame_error++; return; @@ -969,7 +969,7 @@ if ((tlv->type != TYPE_0) && !tlv_stored) { LLDPAD_DBG("%s:%s TLV (%u) was not stored (%p)\n", __func__, vd->ecp.ifname, tlv->type, tlv); - tlv = free_unpkd_tlv(tlv); + free_unpkd_tlv(tlv); vd->ecp.stats.statsTLVsUnrecognizedTotal++; } tlv = NULL; diff -Nru lldpad-1.0.1+git20200210.2022b0c/qbg/vdp22.c lldpad-1.1/qbg/vdp22.c --- lldpad-1.0.1+git20200210.2022b0c/qbg/vdp22.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/qbg/vdp22.c 2020-10-30 13:37:52.000000000 +0000 @@ -694,7 +694,7 @@ struct vdp22 *vdp = 0; if (!ud) { - ud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_VDP22); + ud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_VDP22); if (!ud) LLDPAD_DBG("%s:%s no VDP22 module\n", __func__, ifname); @@ -794,7 +794,7 @@ struct vsi22 *vsi; LLDPAD_DBG("%s:%s stop vdp\n", __func__, ifname); - vud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_VDP22); + vud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_VDP22); if (!vud) { LLDPAD_ERR("%s:%s no VDP22 module\n", __func__, ifname); return; @@ -874,7 +874,7 @@ struct vsi22 *vsi; LLDPAD_DBG("%s:%s start vdp\n", __func__, ifname); - vud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_VDP22); + vud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_VDP22); if (!vud) { LLDPAD_ERR("%s:%s no VDP22 module\n", __func__, ifname); return; diff -Nru lldpad-1.0.1+git20200210.2022b0c/qbg/vdp22_cmds.c lldpad-1.1/qbg/vdp22_cmds.c --- lldpad-1.0.1+git20200210.2022b0c/qbg/vdp22_cmds.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/qbg/vdp22_cmds.c 2020-10-30 13:37:52.000000000 +0000 @@ -57,7 +57,7 @@ { struct lldp_module *np = NULL; - LIST_FOREACH(np, &lldp_head, lldp) + LIST_FOREACH(np, &lldp_mod_head, lldp) if (thisid == np->id) break; return np; @@ -296,7 +296,7 @@ return 0; } -static int vdp22_cmdok(struct cmd *cmd, cmd_status expected) +static int vdp22_cmdok(struct cmd *cmd, int expected) { if (cmd->cmd != expected) return cmd_invalid; diff -Nru lldpad-1.0.1+git20200210.2022b0c/qbg/vdp22sm.c lldpad-1.1/qbg/vdp22sm.c --- lldpad-1.0.1+git20200210.2022b0c/qbg/vdp22sm.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/qbg/vdp22sm.c 2020-10-30 13:37:52.000000000 +0000 @@ -1768,7 +1768,7 @@ break; case VDP22_BR_END: vdp22br_end(p); - break; + return; } } while (vdp22br_move_state(p) == true); } diff -Nru lldpad-1.0.1+git20200210.2022b0c/qbg/vdp.c lldpad-1.1/qbg/vdp.c --- lldpad-1.0.1+git20200210.2022b0c/qbg/vdp.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/qbg/vdp.c 2020-10-30 13:37:52.000000000 +0000 @@ -188,7 +188,7 @@ struct vdp_user_data *ud; struct vdp_data *vd = NULL; - ud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_VDP02); + ud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_VDP02); if (ud) { LIST_FOREACH(vd, &ud->head, entry) { if (!strncmp(ifname, vd->ifname, IFNAMSIZ)) @@ -1198,9 +1198,9 @@ /* put it in the list */ profile->state = VSI_UNASSOCIATED; LIST_INSERT_HEAD(&vd->profile_head, profile, profile); - } - vdp_vsi_sm_bridge(profile); + vdp_vsi_sm_bridge(profile); + } } return 0; @@ -1357,7 +1357,7 @@ return ptlv; out_free: - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); out_err: LLDPAD_ERR("%s: %s failed\n", __func__, vd->ifname); return NULL; @@ -1624,7 +1624,7 @@ LIST_INIT(&vd->profile_head); - ud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_VDP02); + ud = find_module_user_data_by_id(&lldp_mod_head, LLDP_MOD_VDP02); LIST_INSERT_HEAD(&ud->head, vd, entry); out_start_again: diff -Nru lldpad-1.0.1+git20200210.2022b0c/qbg/vdp_cmds.c lldpad-1.1/qbg/vdp_cmds.c --- lldpad-1.0.1+git20200210.2022b0c/qbg/vdp_cmds.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/qbg/vdp_cmds.c 2020-10-30 13:37:52.000000000 +0000 @@ -85,7 +85,7 @@ return s; } -static int vdp_cmdok(struct cmd *cmd, cmd_status expected) +static int vdp_cmdok(struct cmd *cmd, int expected) { if (cmd->cmd != expected) return cmd_invalid; diff -Nru lldpad-1.0.1+git20200210.2022b0c/qbg_utils.c lldpad-1.1/qbg_utils.c --- lldpad-1.0.1+git20200210.2022b0c/qbg_utils.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/qbg_utils.c 2020-10-30 13:37:52.000000000 +0000 @@ -36,7 +36,6 @@ #include "qbg_utils.h" extern int loglvl; /* Global lldpad log level */ -extern struct lldp_head lldp_head; /* * hexdump_frame - print raw evb/ecp/vdp frame @@ -73,7 +72,7 @@ */ int modules_notify(int id, int sender_id, char *ifname, void *data) { - struct lldp_module *mp = find_module_by_id(&lldp_head, id); + struct lldp_module *mp = find_module_by_id(&lldp_mod_head, id); int rc = 0; if (mp && mp->ops->lldp_mod_notify) diff -Nru lldpad-1.0.1+git20200210.2022b0c/tlv_dcbx.c lldpad-1.1/tlv_dcbx.c --- lldpad-1.0.1+git20200210.2022b0c/tlv_dcbx.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/tlv_dcbx.c 2020-10-30 13:37:52.000000000 +0000 @@ -154,7 +154,8 @@ goto error; memcpy(&tlv->info[offset], ptlv->tlv, ptlv->size); offset += ptlv->size; - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); + ptlv = NULL; } if (tlv_ok(dcbx->pg1)) { ptlv = pack_tlv(dcbx->pg1); @@ -162,7 +163,8 @@ goto error; memcpy(&tlv->info[offset], ptlv->tlv, ptlv->size); offset += ptlv->size; - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); + ptlv = NULL; } if (tlv_ok(dcbx->pfc1)) { ptlv = pack_tlv(dcbx->pfc1); @@ -170,7 +172,8 @@ goto error; memcpy(&tlv->info[offset], ptlv->tlv, ptlv->size); offset += ptlv->size; - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); + ptlv = NULL; } if (tlv_ok(dcbx->app1)) { ptlv = pack_tlv(dcbx->app1); @@ -178,7 +181,8 @@ goto error; memcpy(&tlv->info[offset], ptlv->tlv, ptlv->size); offset += ptlv->size; - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); + ptlv = NULL; } if (tlv_ok(dcbx->llink)) { @@ -187,7 +191,8 @@ goto error; memcpy(&tlv->info[offset], ptlv->tlv, ptlv->size); offset += ptlv->size; - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); + ptlv = NULL; } if (offset != tlv->length) @@ -196,7 +201,8 @@ return tlv; error: - ptlv = free_pkd_tlv(ptlv); + if (ptlv) + free_pkd_tlv(ptlv); if (tlv) { if (tlv->info) free(tlv->info); @@ -254,7 +260,8 @@ goto error; memcpy(&tlv->info[offset], ptlv->tlv, ptlv->size); offset += ptlv->size; - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); + ptlv = NULL; } if (tlv_ok(dcbx->pg2)) { ptlv = pack_tlv(dcbx->pg2); @@ -262,7 +269,8 @@ goto error; memcpy(&tlv->info[offset], ptlv->tlv, ptlv->size); offset += ptlv->size; - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); + ptlv = NULL; } if (tlv_ok(dcbx->pfc2)) { ptlv = pack_tlv(dcbx->pfc2); @@ -270,7 +278,8 @@ goto error; memcpy(&tlv->info[offset], ptlv->tlv, ptlv->size); offset += ptlv->size; - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); + ptlv = NULL; } if (tlv_ok(dcbx->app2)) { ptlv = pack_tlv(dcbx->app2); @@ -278,7 +287,8 @@ goto error; memcpy(&tlv->info[offset], ptlv->tlv, ptlv->size); offset += ptlv->size; - ptlv = free_pkd_tlv(ptlv); + free_pkd_tlv(ptlv); + ptlv = NULL; } if (offset != tlv->length) @@ -287,7 +297,8 @@ return tlv; error: - ptlv = free_pkd_tlv(ptlv); + if (ptlv) + free_pkd_tlv(ptlv); if (tlv) { if (tlv->info) free(tlv->info); diff -Nru lldpad-1.0.1+git20200210.2022b0c/.travis.yml lldpad-1.1/.travis.yml --- lldpad-1.0.1+git20200210.2022b0c/.travis.yml 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/.travis.yml 2020-10-30 13:37:52.000000000 +0000 @@ -3,7 +3,7 @@ #before_install: sudo apt-get update install: sudo apt-get install -y libconfig-dev libnl-3-dev rpm before_script: ./bootstrap.sh -script: ./contrib/build-rpm.sh && ./configure && make && make test && sudo make install #&& rpmbuild -ba lldpad.spec +script: ./contrib/build-rpm.sh && ./configure --enable-errors && make && make check && sudo make install matrix: include: @@ -47,3 +47,12 @@ - gcc-9 env: - CC="gcc-9" + - addons: + apt: + sources: + - sourceline: 'ppa:ubuntu-toolchain-r/test' + packages: + - gcc-10 + env: + - CC="gcc-10" + dist: bionic diff -Nru lldpad-1.0.1+git20200210.2022b0c/vdptool.c lldpad-1.1/vdptool.c --- lldpad-1.0.1+git20200210.2022b0c/vdptool.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/vdptool.c 2020-10-30 13:37:52.000000000 +0000 @@ -61,6 +61,8 @@ #define OUI_ENCODE_HNDLR(name) name##_oui_encode_hndlr #define OUI_PRNT_DECODE_HNDLR(name) name##_oui_print_decode_hndlr +struct lldp_head lldp_mod_head; + #define EXTERN_OUI_FN(name) \ extern bool name##_oui_encode_hndlr(char *, char *, size_t); \ extern void name##_oui_print_decode_hndlr(char *) @@ -141,7 +143,7 @@ str = "TLV does not support agent type"; break; default: - str = print_vdp_status(status); + str = print_vdp_status((enum vdp22_cmd_status)status); break; } return str; @@ -588,7 +590,7 @@ size_t ilen = strlen(ibuf); u16 vsi_len; int offset = 0, vsi_cnt = 0; - char tmp_ibuf[strlen(ibuf)]; + char tmp_ibuf[strlen(ibuf) + 1]; while (ilen > 0) { vsi_len = hex2u16(ibuf + offset); @@ -796,13 +798,13 @@ struct lldp_module *premod = NULL; int i = 0; - LIST_INIT(&lldp_head); + LIST_INIT(&lldp_mod_head); for (i = 0; register_tlv_table[i]; i++) { module = register_tlv_table[i](); if (premod) LIST_INSERT_AFTER(premod, module, lldp); else - LIST_INSERT_HEAD(&lldp_head, module, lldp); + LIST_INSERT_HEAD(&lldp_mod_head, module, lldp); premod = module; } } @@ -811,9 +813,9 @@ { struct lldp_module *module; - while (lldp_head.lh_first != NULL) { - module = lldp_head.lh_first; - LIST_REMOVE(lldp_head.lh_first, lldp); + while (lldp_mod_head.lh_first != NULL) { + module = lldp_mod_head.lh_first; + LIST_REMOVE(lldp_mod_head.lh_first, lldp); module->ops->lldp_mod_unregister(module); } } @@ -953,7 +955,7 @@ printf("%s\n%s\n%s", commands_usage, commands_options, commands_help); printf("\nTLV identifiers:\n"); - LIST_FOREACH(np, &lldp_head, lldp) + LIST_FOREACH(np, &lldp_mod_head, lldp) if (np->ops->print_help) np->ops->print_help(); return 0; @@ -1006,7 +1008,7 @@ struct lldp_module *np; u32 tlvid = INVALID_TLVID; - LIST_FOREACH(np, &lldp_head, lldp) { + LIST_FOREACH(np, &lldp_mod_head, lldp) { if (np->ops->lookup_tlv_name) { tlvid = np->ops->lookup_tlv_name(tlvid_str); if (tlvid != INVALID_TLVID) diff -Nru lldpad-1.0.1+git20200210.2022b0c/vdptool_cisco_oui.c lldpad-1.1/vdptool_cisco_oui.c --- lldpad-1.0.1+git20200210.2022b0c/vdptool_cisco_oui.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/vdptool_cisco_oui.c 2020-10-30 13:37:52.000000000 +0000 @@ -28,7 +28,7 @@ #include "lldp_util.h" #include "vdp_cisco.h" -bool cisco_oui_encode_hndlr(char *dst, char *src, int len) +bool cisco_oui_encode_hndlr(char *dst, char *src, size_t len) { char *src_temp = strdup(src); char *key, *data; diff -Nru lldpad-1.0.1+git20200210.2022b0c/weak_readline.c lldpad-1.1/weak_readline.c --- lldpad-1.0.1+git20200210.2022b0c/weak_readline.c 2020-02-10 18:33:06.000000000 +0000 +++ lldpad-1.1/weak_readline.c 2020-10-30 13:37:52.000000000 +0000 @@ -30,6 +30,9 @@ #include static int inited; +static void *hist_handle; +static void *rl_handle; + static char *(*readline_p)(const char *); static void (*using_history_p)(void); @@ -38,9 +41,6 @@ static void weak_readline_init(void) { - void *hist_handle; - void *rl_handle; - inited = 1; hist_handle = dlopen("libhistory.so", RTLD_LAZY | RTLD_GLOBAL); if (!hist_handle) @@ -77,6 +77,16 @@ using_history_p(); } +void close_history(void) +{ + if (inited) { + dlclose(rl_handle); + rl_handle = NULL; + dlclose(hist_handle); + hist_handle = NULL; + } +} + void stifle_history(int max) { if (!inited)