Auto sync2gitlab import of lldpad-1.0.1-17.git036e314.el8.src.rpm

This commit is contained in:
CentOS Sources 2022-08-24 10:14:26 +00:00
parent a89e154a1e
commit c6353f8b11
9 changed files with 554 additions and 1 deletions

View File

@ -0,0 +1,29 @@
From cadb2e55d3a751b4eb0e7c5b34ed037af43a164c Mon Sep 17 00:00:00 2001
From: Aaron Conole <aconole@redhat.com>
Date: Wed, 25 Aug 2021 10:19:16 -0400
Subject: [PATCH 1/8] vdp22: convert command parsing to null term
There is a theoretical buffer escape here.
closes https://github.com/intel/openlldp/issues/74
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
qbg/vdp22_cmds.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/qbg/vdp22_cmds.c b/qbg/vdp22_cmds.c
index a8025ee..0ded0f1 100644
--- a/qbg/vdp22_cmds.c
+++ b/qbg/vdp22_cmds.c
@@ -577,7 +577,7 @@ static int get_arg_vsi(struct cmd *cmd, char *arg, char *argvalue,
memset(&vsi, 0, sizeof(vsi));
memset(vsi_str, 0, sizeof(vsi_str));
vsi.request = cmd->tlvid;
- strncpy(vsi.ifname, cmd->ifname, sizeof(vsi.ifname));
+ STRNCPY_TERMINATED(vsi.ifname, cmd->ifname, sizeof(vsi.ifname));
good_cmd = cmd_failed;
if ((cmd->ops & op_config) && (cmd->ops & op_arg)) {
memset(&mac, 0, sizeof(mac));
--
2.31.1

View File

@ -0,0 +1,31 @@
From cf7e43786749fcb1325d5b8e4cf0816f0eed3556 Mon Sep 17 00:00:00 2001
From: Aaron Conole <aconole@redhat.com>
Date: Wed, 25 Aug 2021 10:22:20 -0400
Subject: [PATCH 2/8] macvtap: fix error condition
If the socket() call fails, we will jump to out and pass a
negative value to close() which is not allowed.
Fixes: d43abb0267f3 ("lldpad: do not use macv[tap/lan] interfaces as ports")
closes https://github.com/intel/openlldp/issues/75
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lldp_util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldp_util.c b/lldp_util.c
index 1e58b1e..be1333e 100644
--- a/lldp_util.c
+++ b/lldp_util.c
@@ -681,7 +681,7 @@ int is_macvtap(const char *ifname)
s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
if (s < 0) {
- goto out;
+ return false;
}
nlh = malloc(NLMSG_SIZE);
--
2.31.1

View File

@ -0,0 +1,31 @@
From ff70e2edbf79355527660c4df7a554bd66d3a1fb Mon Sep 17 00:00:00 2001
From: Aaron Conole <aconole@redhat.com>
Date: Wed, 25 Aug 2021 10:29:19 -0400
Subject: [PATCH 3/8] 8021qaz: squelch initialization errors
Some static analysis tools (like coverity) flag this array
as accessed without proper initialization. Squelch by forcing
initialization.
closes https://github.com/intel/openlldp/issues/77
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lldp_8021qaz_clif.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldp_8021qaz_clif.c b/lldp_8021qaz_clif.c
index f776392..9031cb0 100644
--- a/lldp_8021qaz_clif.c
+++ b/lldp_8021qaz_clif.c
@@ -253,7 +253,7 @@ static void ieee8021qaz_print_app_tlv(u16 len, char *info)
{
u8 app, app_idx, app_prio, app_sel;
u16 proto, offset = 2;
- u8 dscp[MAX_USER_PRIORITIES][MAX_APP_ENTRIES];
+ u8 dscp[MAX_USER_PRIORITIES][MAX_APP_ENTRIES] = {0};
u8 dscp_count[MAX_USER_PRIORITIES] = {0};
u8 i, j;
bool first_app = true;
--
2.31.1

View File

@ -0,0 +1,126 @@
From bcb3ef5ab848eb648f05a840030df1f230976a70 Mon Sep 17 00:00:00 2001
From: Aaron Conole <aconole@redhat.com>
Date: Wed, 25 Aug 2021 10:37:22 -0400
Subject: [PATCH 4/8] 8021Qaz: check for rx block validity
There is a slim but possible race in the 8021Qaz processing when handling
TLVs during ifdown windows. To address this, check for the rx block
before dereferencing it.
closes https://github.com/intel/openlldp/issues/78
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lldp_8021qaz.c | 41 ++++++++++++++++++++++++++++-------------
1 file changed, 28 insertions(+), 13 deletions(-)
diff --git a/lldp_8021qaz.c b/lldp_8021qaz.c
index 045bd45..8bb2bc9 100644
--- a/lldp_8021qaz.c
+++ b/lldp_8021qaz.c
@@ -1563,48 +1563,63 @@ static bool unpack_ieee8021qaz_tlvs(struct port *port,
/* Process */
switch (tlv->info[OUI_SIZE]) {
case IEEE8021QAZ_ETSCFG_TLV:
- if (tlvs->rx->etscfg == NULL) {
+ if (tlvs->rx && tlvs->rx->etscfg == NULL) {
tlvs->ieee8021qazdu |= RCVD_IEEE8021QAZ_TLV_ETSCFG;
tlvs->rx->etscfg = tlv;
- } else {
+ } else if (tlvs->rx) {
LLDPAD_WARN("%s: %s: 802.1Qaz Duplicate ETSCFG TLV\n",
__func__, port->ifname);
agent->rx.dupTlvs |= DUP_IEEE8021QAZ_TLV_ETSCFG;
return false;
+ } else {
+ LLDPAD_INFO("%s: %s: 802.1Qaz port IFDOWN\n",
+ __func__, port->ifname);
+ return false;
}
break;
case IEEE8021QAZ_ETSREC_TLV:
- if (tlvs->rx->etsrec == NULL) {
+ if (tlvs->rx && tlvs->rx->etsrec == NULL) {
tlvs->ieee8021qazdu |= RCVD_IEEE8021QAZ_TLV_ETSREC;
tlvs->rx->etsrec = tlv;
- } else {
+ } else if (tlvs->rx) {
LLDPAD_WARN("%s: %s: 802.1Qaz Duplicate ETSREC TLV\n",
__func__, port->ifname);
agent->rx.dupTlvs |= DUP_IEEE8021QAZ_TLV_ETSREC;
return false;
+ } else {
+ LLDPAD_INFO("%s: %s: 802.1Qaz port IFDOWN\n",
+ __func__, port->ifname);
+ return false;
}
break;
-
case IEEE8021QAZ_PFC_TLV:
- if (tlvs->rx->pfc == NULL) {
+ if (tlvs->rx && tlvs->rx->pfc == NULL) {
tlvs->ieee8021qazdu |= RCVD_IEEE8021QAZ_TLV_PFC;
tlvs->rx->pfc = tlv;
- } else {
+ } else if (tlvs->rx) {
LLDPAD_WARN("%s: %s: 802.1Qaz Duplicate PFC TLV\n",
__func__, port->ifname);
agent->rx.dupTlvs |= DUP_IEEE8021QAZ_TLV_PFC;
return false;
+ } else {
+ LLDPAD_INFO("%s: %s: 802.1Qaz port IFDOWN\n",
+ __func__, port->ifname);
+ return false;
}
break;
case IEEE8021QAZ_APP_TLV:
- if (tlvs->rx->app == NULL) {
+ if (tlvs->rx && tlvs->rx->app == NULL) {
tlvs->ieee8021qazdu |= RCVD_IEEE8021QAZ_TLV_APP;
tlvs->rx->app = tlv;
- } else {
+ } else if (tlvs->rx) {
LLDPAD_WARN("%s: %s: 802.1Qaz Duplicate APP TLV\n",
__func__, port->ifname);
agent->rx.dupTlvs |= DUP_IEEE8021QAZ_TLV_APP;
return false;
+ } else {
+ LLDPAD_INFO("%s: %s: 802.1Qaz port IFDOWN\n",
+ __func__, port->ifname);
+ return false;
}
break;
default:
@@ -1891,26 +1906,26 @@ static void ieee8021qaz_mibUpdateObjects(struct port *port)
tlvs = ieee8021qaz_data(port->ifname);
- if (tlvs->rx->etscfg) {
+ if (tlvs->rx && tlvs->rx->etscfg) {
process_ieee8021qaz_etscfg_tlv(port);
} else if (tlvs->ets->cfgr) {
free(tlvs->ets->cfgr);
tlvs->ets->cfgr = NULL;
}
- if (tlvs->rx->etsrec) {
+ if (tlvs->rx && tlvs->rx->etsrec) {
process_ieee8021qaz_etsrec_tlv(port);
} else if (tlvs->ets->recr) {
free(tlvs->ets->recr);
tlvs->ets->recr = NULL;
}
- if (tlvs->rx->pfc)
+ if (tlvs->rx && tlvs->rx->pfc)
process_ieee8021qaz_pfc_tlv(port);
else if (tlvs->pfc)
tlvs->pfc->remote_param = false;
- if (tlvs->rx->app)
+ if (tlvs->rx && tlvs->rx->app)
process_ieee8021qaz_app_tlv(port);
else
ieee8021qaz_app_reset(&tlvs->app_head);
--
2.31.1

View File

@ -0,0 +1,31 @@
From f1488bbb0991f99d823d384b00f6fb1de385baa3 Mon Sep 17 00:00:00 2001
From: Aaron Conole <aconole@redhat.com>
Date: Wed, 10 Nov 2021 16:40:20 -0500
Subject: [PATCH 5/8] basman: use return address when pulling address
The managed address pulling routine will fail to reset the return
value from a previous attempt if no IPv4 and IPv6 addresses are
available. Use the return address of the hwaddr fetch.
Resolves: https://github.com/intel/openlldp/issues/82
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lldp_basman.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldp_basman.c b/lldp_basman.c
index 25e7d9e..cb0c50c 100644
--- a/lldp_basman.c
+++ b/lldp_basman.c
@@ -515,7 +515,7 @@ static int basman_bld_manaddr_tlv(struct basman_data *bd,
if (rc) {
rc = basman_get_manaddr_sub(bd, agent, MANADDR_IPV6);
if (rc)
- basman_get_manaddr_sub(bd, agent, MANADDR_ALL802);
+ rc = basman_get_manaddr_sub(bd, agent, MANADDR_ALL802);
}
out_err:
return rc;
--
2.31.1

View File

@ -0,0 +1,30 @@
From fae175635442577605e06b10133306f86863f395 Mon Sep 17 00:00:00 2001
From: Rajesh B M <59466308+rajeshm-elisity@users.noreply.github.com>
Date: Mon, 8 Mar 2021 23:29:32 +0530
Subject: [PATCH 6/8] agent: reset frame status on message delete
Currently, when the agent state machine transitions out of
DELETE_INFO, it leaves the rcvFrame flag set. This flag should
be cleared since the frame info is no longer considered usable.
Signed-off-by: Rajesh B M <bmrajesh@gmail.com>
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
lldp/rx.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lldp/rx.c b/lldp/rx.c
index 9a0c758..f0c8002 100644
--- a/lldp/rx.c
+++ b/lldp/rx.c
@@ -568,6 +568,7 @@ void process_delete_info(struct port *port, struct lldp_agent *agent)
agent->rx.sizein = 0;
agent->rx.remoteChange = true;
+ agent->rx.rcvFrame = false;
return;
}
--
2.31.1

View File

@ -0,0 +1,71 @@
From 2a352d36e2ecc3df4b1c2155b3fd2fa11f95e0bc Mon Sep 17 00:00:00 2001
From: klebertarcisio <klebertarcisio@yahoo.com.br>
Date: Fri, 2 Apr 2021 19:54:03 -0300
Subject: [PATCH 7/8] Avoiding null pointer dereference
---
ctrl_iface.c | 2 ++
dcbtool_cmds.c | 2 ++
lldp_8021qaz.c | 4 ++++
lldp_dcbx.c | 4 ++++
4 files changed, 12 insertions(+)
diff --git a/ctrl_iface.c b/ctrl_iface.c
index 666f7c8..5f86fd2 100644
--- a/ctrl_iface.c
+++ b/ctrl_iface.c
@@ -180,6 +180,8 @@ int clif_iface_attach(struct clif_data *clifd,
} else {
tlv = strdup(ibuf);
str = tlv;
+ if (!str)
+ goto err_tlv;
str++;
/* Count number of TLV Modules */
tokenize = strtok(str, delim);
diff --git a/dcbtool_cmds.c b/dcbtool_cmds.c
index 0846f83..e1c76c4 100644
--- a/dcbtool_cmds.c
+++ b/dcbtool_cmds.c
@@ -373,6 +373,8 @@ int handle_dcb_cmds(struct clif *clif, int argc, char *argv[], int raw)
}
cmd_args = get_cmd_args();
+ if (!cmd_args)
+ return -1;
if (get_feature() == FEATURE_DCBX)
snprintf(cbuf, sizeof(cbuf), "%c%01x%02x%02x%s",
diff --git a/lldp_8021qaz.c b/lldp_8021qaz.c
index 8bb2bc9..5fccbe4 100644
--- a/lldp_8021qaz.c
+++ b/lldp_8021qaz.c
@@ -1959,6 +1959,10 @@ int ieee8021qaz_rchange(struct port *port, struct lldp_agent *agent,
if (tlv->type == TYPE_1) {
clear_ieee8021qaz_rx(qaz_tlvs);
rx = malloc(sizeof(*rx));
+ if (!rx) {
+ LLDPAD_INFO("failed malloc for rx\n");
+ return TLV_ERR;
+ }
memset(rx, 0, sizeof(*rx));
qaz_tlvs->rx = rx;
qaz_tlvs->ieee8021qazdu = 0;
diff --git a/lldp_dcbx.c b/lldp_dcbx.c
index 3567634..66df857 100644
--- a/lldp_dcbx.c
+++ b/lldp_dcbx.c
@@ -695,6 +695,10 @@ int dcbx_rchange(struct port *port, struct lldp_agent *agent, struct unpacked_tl
*/
if (tlv->type == TYPE_1) {
manifest = malloc(sizeof(*manifest));
+ if (!manifest) {
+ LLDPAD_INFO("failed malloc for manifest\n");
+ return TLV_ERR;
+ }
memset(manifest, 0, sizeof(*manifest));
dcbx->manifest = manifest;
dcbx->dcbdu = 0;
--
2.31.1

View File

@ -0,0 +1,192 @@
From 79658533561990d93a74fd25b4d1b26c01182a8e Mon Sep 17 00:00:00 2001
From: Aaron Conole <aconole@redhat.com>
Date: Mon, 20 Sep 2021 16:27:56 -0400
Subject: [PATCH 8/8] Revert "Use interface index instead of name in libconfig"
This reverts commit e272d34f45bc15d52424228f824c1ad96932867e.
During production, it was found that the ifindex can be unstable.
See discussion at https://github.com/intel/openlldp/pull/3
Signed-off-by: Aaron Conole <aconole@redhat.com>
(cherry picked from commit 2c7dd5e4a0db201a850f8037b957acbd14950297)
---
config.c | 35 ++++++++---------------------------
include/config.h | 3 ---
lldp_dcbx_cfg.c | 24 +++++++-----------------
3 files changed, 15 insertions(+), 47 deletions(-)
diff --git a/config.c b/config.c
index 41b5045..7e969b9 100644
--- a/config.c
+++ b/config.c
@@ -55,21 +55,6 @@
config_t lldpad_cfg;
-/*
- * config_ifkey - Generates a config key
- *
- * Given an interface name this functions generates
- * a key (based on interface's index) suitable
- * to pass to libconfig.
- *
- */
-void config_ifkey(const char *name, char *ifkey) {
- int index = if_nametoindex(name);
-
- if(index)
- sprintf(ifkey, "if%d", index);
-}
-
/*
* init_cfg - initialze the global lldpad_cfg via config_init
*
@@ -466,15 +451,14 @@ static int lookup_config_value(char *path, union cfg_get v, int type)
int get_config_setting(const char *ifname, int agenttype, char *path,
union cfg_get v, int type)
{
- char p[1024], ifkey[IFNAMSIZ];
+ char p[1024];
int rval = CONFIG_FALSE;
const char *section = agent_type2section(agenttype);
/* look for setting in section->ifname area first */
if (ifname) {
- config_ifkey(ifname, ifkey);
snprintf(p, sizeof(p), "%s.%s.%s",
- section, ifkey, path);
+ section, ifname, path);
rval = lookup_config_value(p, v, type);
}
@@ -491,16 +475,15 @@ int get_config_setting(const char *ifname, int agenttype, char *path,
int remove_config_setting(const char *ifname, int agenttype, char *parent,
char *name)
{
- char p[1024], ifkey[IFNAMSIZ];
+ char p[1024];
int rval = CONFIG_FALSE;
config_setting_t *setting = NULL;
const char *section = agent_type2section(agenttype);
/* look for setting in section->ifname area first */
- if (ifname) {
- config_ifkey(ifname, ifkey);
+ if (ifname) {
snprintf(p, sizeof(p), "%s.%s.%s",
- section, ifkey, parent);
+ section, ifname, parent);
setting = config_lookup(&lldpad_cfg, p);
}
@@ -587,17 +570,15 @@ int set_config_setting(const char *ifname, int agenttype, char *path,
union cfg_set v, int type)
{
config_setting_t *setting = NULL;
- char p[1024], ifkey[IFNAMSIZ];
+ char p[1024];
int rval = cmd_success;
const char *section = agent_type2section(agenttype);
LLDPAD_DBG("%s(%i): \n", __func__, __LINE__);
- if (strlen(ifname)){
- config_ifkey(ifname, ifkey);
+ if (strlen(ifname))
snprintf(p, sizeof(p), "%s.%s.%s",
- section, ifkey, path);
- }
+ section, ifname, path);
else
snprintf(p, sizeof(p), "%s.%s.%s",
section, LLDP_COMMON, path);
diff --git a/include/config.h b/include/config.h
index 3abf8e8..61cb5da 100644
--- a/include/config.h
+++ b/include/config.h
@@ -111,7 +111,4 @@ void destroy_cfg(void);
int check_cfg_file(void);
int check_for_old_file_format(void);
void init_ports(void);
-
-void config_ifkey(const char *name, char *ifkey);
-
#endif /* _CONFIG_H_ */
diff --git a/lldp_dcbx_cfg.c b/lldp_dcbx_cfg.c
index 40cabb2..ab9cc35 100644
--- a/lldp_dcbx_cfg.c
+++ b/lldp_dcbx_cfg.c
@@ -99,15 +99,12 @@ static config_setting_t *construct_new_setting(char *device_name)
config_setting_t *tmp2_setting = NULL;
char abuf[32];
int i;
- char device_name_sanitized[IFNAMSIZ];
dcbx_setting = config_lookup(&lldpad_cfg, DCBX_SETTING);
if (!dcbx_setting)
return NULL;
- config_ifkey(device_name, device_name_sanitized);
-
- eth_setting = config_setting_add(dcbx_setting, device_name_sanitized,
+ eth_setting = config_setting_add(dcbx_setting, device_name,
CONFIG_TYPE_GROUP);
if (!eth_setting)
goto set_error;
@@ -374,13 +371,11 @@ static int _set_persistent(char *device_name, int dcb_enable,
config_setting_t *setting_value = NULL;
char abuf[2*DCB_MAX_TLV_LENGTH + 1];
int result, i;
- char device_name_sanitized[IFNAMSIZ];
dcbx_setting = config_lookup(&lldpad_cfg, DCBX_SETTING);
- config_ifkey(device_name, device_name_sanitized);
if (dcbx_setting)
eth_settings = config_setting_get_member(dcbx_setting,
- device_name_sanitized);
+ device_name);
/* init the internal data store for device_name */
if (NULL == eth_settings) {
@@ -787,15 +782,13 @@ int get_persistent(char *device_name, full_dcb_attribs *attribs)
int result = cmd_failed, i;
int results[MAX_USER_PRIORITIES];
int len;
- char abuf[32], device_name_sanitized[IFNAMSIZ];
+ char abuf[32];
memset(attribs, 0, sizeof(*attribs));
dcbx_setting = config_lookup(&lldpad_cfg, DCBX_SETTING);
-
- config_ifkey(device_name, device_name_sanitized);
if (dcbx_setting)
- eth_settings = config_setting_get_member(dcbx_setting,
- device_name_sanitized);
+ eth_settings = config_setting_get_member(dcbx_setting,
+ device_name);
/* init the internal data store for device_name */
result = get_default_persistent(device_name, attribs);
@@ -1074,16 +1067,13 @@ int get_dcb_enable_state(char *ifname, int *result)
int rc = EINVAL;
config_setting_t *settings = NULL;
char path[sizeof(DCBX_SETTING) + IFNAMSIZ + 16];
- char ifkey[IFNAMSIZ];
-
- config_ifkey(ifname, ifkey);
memset(path, 0, sizeof(path));
- snprintf(path, sizeof(path), "%s.%s.dcb_enable", DCBX_SETTING, ifkey);
+ snprintf(path, sizeof(path), "%s.%s.dcb_enable", DCBX_SETTING, ifname);
settings = config_lookup(&lldpad_cfg, path);
if (!settings) {
LLDPAD_INFO("### %s:%s:failed on %s\n", __func__, ifname, path);
- snprintf(path, sizeof(path), "%s.dcb_enable", ifkey);
+ snprintf(path, sizeof(path), "%s.dcb_enable", ifname);
settings = config_lookup(&lldpad_cfg, path);
if (!settings) {
LLDPAD_INFO("### %s:%s:failed again %s\n", __func__, ifname, path);
--
2.31.1

View File

@ -7,7 +7,7 @@
Name: lldpad
Version: 1.0.1
Release: 16.git%{checkout}%{?dist}
Release: 17.git%{checkout}%{?dist}
Summary: Intel LLDP Agent
Group: System Environment/Daemons
License: GPLv2
@ -45,6 +45,15 @@ Patch29: open-lldp-v1.0.1-29-memleak-on-received-TLVs.patch
Patch30: open-lldp-v1.0.1-30-support-DSCP-selectors.patch
Patch31: open-lldp-v1.0.1-31-Rebase-to-open-lldp-branch-1.1.0.patch
Patch32: 0001-vdp22-convert-command-parsing-to-null-term.patch
Patch33: 0002-macvtap-fix-error-condition.patch
Patch34: 0003-8021qaz-squelch-initialization-errors.patch
Patch35: 0004-8021Qaz-check-for-rx-block-validity.patch
Patch36: 0005-basman-use-return-address-when-pulling-address.patch
Patch37: 0006-agent-reset-frame-status-on-message-delete.patch
Patch38: 0007-Avoiding-null-pointer-dereference.patch
Patch39: 0008-Revert-Use-interface-index-instead-of-name-in-libcon.patch
BuildRequires: automake autoconf libtool
BuildRequires: flex >= 2.5.33
BuildRequires: kernel-headers >= 2.6.32
@ -117,6 +126,9 @@ rm -f %{buildroot}%{_libdir}/liblldp_clif.la
%{_libdir}/liblldp_clif.so
%changelog
* Tue Jun 21 2022 Aaron Conole <aconole@redhat.com> - 1.0.1-17.git036e314
- Update to the latest branch-1.1, which includes config file fixes (#1997064)
* Wed Aug 04 2021 Aaron Conole <aconole@redhat.com> - 1.0.1-16.git036e314
- Update the changelog