Compare commits

...

No commits in common. "c8s" and "c9s" have entirely different histories.
c8s ... c9s

13 changed files with 501 additions and 96 deletions

5
.gitignore vendored
View File

@ -1,4 +1,7 @@
SOURCES/lldpd-1.0.1.tar.gz
/lldpd-0.9.7.tar.gz
/lldpd-0.9.8.tar.gz
/lldpd-1.0.1.tar.gz
/lldpd-1.0.4-free.tar.gz
/lldpd-1.0.17.tar.gz
/lldpd-1.0.17-free.tar.gz
/lldpd-1.0.18-free.tar.gz

View File

@ -0,0 +1,96 @@
From 7b9abb819337dd50583350105afbdc82302f00ff Mon Sep 17 00:00:00 2001
From: Hangbin Liu <liuhangbin@gmail.com>
Date: Wed, 10 Jul 2024 15:32:01 +0800
Subject: [PATCH 1/2] client: add range restriction for tx hold and interval
Based on IEEE 802.1AB(2016) 9.2.5. The valid range of tx hold is 1-100,
the valid range of tx interval is 1-3600.
Reported-by: Matt Lucius <malucius@redhat.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
src/client/lldpcli.8.in | 15 ++++++++-------
src/lib/atoms/config.c | 13 +++++++++----
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/src/client/lldpcli.8.in b/src/client/lldpcli.8.in
index 74a07eb4b806..39f936d1ceae 100644
--- a/src/client/lldpcli.8.in
+++ b/src/client/lldpcli.8.in
@@ -555,8 +555,8 @@ Force port description to the provided string.
.Cd lldp tx-interval Ar interval
.Bd -ragged -offset XXXXXX
Change transmit delay to the specified value in seconds. The transmit
-delay is the delay between two transmissions of LLDP PDU. The default
-value is 30 seconds. Note:
+delay is the delay between two transmissions of LLDP PDU. The valid range
+is 1 through 3600 in seconds. The default value is 30 seconds. Note:
.Nm lldpd
also starts another system based refresh timer on each port to detect
changes such as a hostname. This is the value of the tx-interval
@@ -576,8 +576,8 @@ system capabilities and CPU speed.
.Bd -ragged -offset XXXXXX
Change transmit hold value to the specified value. This value is used
to compute the TTL of transmitted packets which is the product of this
-value and of the transmit delay. The default value is 4 and therefore
-the default TTL is 120 seconds.
+value and of the transmit delay. The valid range is 1 through 100. The
+default value is 4 and therefore the default TTL is 120 seconds.
.Ed
.Cd configure
@@ -676,9 +676,10 @@ to shorten the interval between two LLDPDU.
.Cd enable
should enable LLDP-MED fast start while
.Cd tx-interval
-specifies the interval between two LLDPDU in seconds. The default
-interval is 1 second. Once 4 LLDPDU have been sent, the fast start
-mechanism is disabled until a new neighbor is detected.
+specifies the interval between two LLDPDU in seconds. The valid interval
+range is 1 through 3600 in seconds. The default interval is 1 second. Once
+4 LLDPDU have been sent, the fast start mechanism is disabled until a new
+neighbor is detected.
.Ed
.Cd unconfigure med fast-start
diff --git a/src/lib/atoms/config.c b/src/lib/atoms/config.c
index 8a4af2e8d1cd..305b5861de6e 100644
--- a/src/lib/atoms/config.c
+++ b/src/lib/atoms/config.c
@@ -262,11 +262,13 @@ _lldpctl_atom_set_int_config(lldpctl_atom_t *atom, lldpctl_key_t key, long int v
break;
case lldpctl_k_config_tx_interval:
config.c_tx_interval = value * 1000;
- if (value > 0) c->config->c_tx_interval = value * 1000;
+ if (value > 0 && value <= 3600 * 1000)
+ c->config->c_tx_interval = value * 1000;
break;
case lldpctl_k_config_tx_interval_ms:
config.c_tx_interval = value;
- if (value > 0) c->config->c_tx_interval = value;
+ if (value > 0 && value <= 3600 * 1000)
+ c->config->c_tx_interval = value;
break;
case lldpctl_k_config_ifdescr_update:
config.c_set_ifdescr = c->config->c_set_ifdescr = value;
@@ -288,12 +290,15 @@ _lldpctl_atom_set_int_config(lldpctl_atom_t *atom, lldpctl_key_t key, long int v
config.c_enable_fast_start = c->config->c_enable_fast_start = value;
break;
case lldpctl_k_config_fast_start_interval:
- config.c_tx_fast_interval = c->config->c_tx_fast_interval = value;
+ config.c_tx_fast_interval = value;
+ if (value > 0 && value <= 3600)
+ c->config->c_tx_fast_interval = value;
break;
#endif
case lldpctl_k_config_tx_hold:
config.c_tx_hold = value;
- if (value > 0) c->config->c_tx_hold = value;
+ if (value > 0 && value <= 100)
+ c->config->c_tx_hold = value;
break;
case lldpctl_k_config_max_neighbors:
config.c_max_neighbors = value;
--
2.46.0

View File

@ -0,0 +1,72 @@
From a73e04f46ebe3d5e9d0805c52b9e5d0472e65069 Mon Sep 17 00:00:00 2001
From: Hangbin Liu <liuhangbin@gmail.com>
Date: Wed, 10 Jul 2024 15:49:32 +0800
Subject: [PATCH 2/2] lldpd: limit tx ttl to 65535
Based on IEEE 802.1AB(2016) 9.2.5.22 txTTL:
During normal operation, txTTL is set to whichever is the smaller of the
values represented by Equation (1) and Equation (2):
(msgTxInterval x msgTxHold) + 1 (1)
65535 (2)
Reported-by: Matt Lucius <malucius@redhat.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
src/daemon/client.c | 5 +++--
src/daemon/lldpd.c | 3 ++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/daemon/client.c b/src/daemon/client.c
index d9d907fd74dc..c4894ac112ea 100644
--- a/src/daemon/client.c
+++ b/src/daemon/client.c
@@ -18,6 +18,7 @@
#include "lldpd.h"
#include "trace.h"
+#include <sys/param.h>
#include <sys/utsname.h>
static ssize_t
@@ -80,7 +81,7 @@ client_handle_set_configuration(struct lldpd *cfg, enum hmsg_type *type, void *i
cfg->g_config.c_tx_interval = config->c_tx_interval;
cfg->g_config.c_ttl =
cfg->g_config.c_tx_interval * cfg->g_config.c_tx_hold;
- cfg->g_config.c_ttl = (cfg->g_config.c_ttl + 999) / 1000;
+ cfg->g_config.c_ttl = MIN((cfg->g_config.c_ttl + 999) / 1000, 65535);
}
levent_send_now(cfg);
}
@@ -90,7 +91,7 @@ client_handle_set_configuration(struct lldpd *cfg, enum hmsg_type *type, void *i
cfg->g_config.c_tx_hold = config->c_tx_hold;
cfg->g_config.c_ttl =
cfg->g_config.c_tx_interval * cfg->g_config.c_tx_hold;
- cfg->g_config.c_ttl = (cfg->g_config.c_ttl + 999) / 1000;
+ cfg->g_config.c_ttl = MIN((cfg->g_config.c_ttl + 999) / 1000, 65535);
}
if (CHANGED(c_max_neighbors) && config->c_max_neighbors > 0) {
log_debug("rpc", "client change maximum neighbors to %d",
diff --git a/src/daemon/lldpd.c b/src/daemon/lldpd.c
index 6b5721e2e336..c3b67c6dfeb2 100644
--- a/src/daemon/lldpd.c
+++ b/src/daemon/lldpd.c
@@ -28,6 +28,7 @@
#include <time.h>
#include <libgen.h>
#include <assert.h>
+#include <sys/param.h>
#include <sys/utsname.h>
#include <sys/types.h>
#include <sys/wait.h>
@@ -1932,7 +1933,7 @@ lldpd_main(int argc, char *argv[], char *envp[])
cfg->g_config.c_tx_interval = LLDPD_TX_INTERVAL * 1000;
cfg->g_config.c_tx_hold = LLDPD_TX_HOLD;
cfg->g_config.c_ttl = cfg->g_config.c_tx_interval * cfg->g_config.c_tx_hold;
- cfg->g_config.c_ttl = (cfg->g_config.c_ttl + 999) / 1000;
+ cfg->g_config.c_ttl = MIN((cfg->g_config.c_ttl + 999) / 1000, 65535);
cfg->g_config.c_max_neighbors = LLDPD_MAX_NEIGHBORS;
#ifdef ENABLE_LLDPMED
cfg->g_config.c_enable_fast_start = enable_fast_start;
--
2.46.0

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-9
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

31
lldpd-cleanup.sh Executable file
View File

@ -0,0 +1,31 @@
#!/bin/sh
# Process a lldpd tarball to remove proprietary source code.
#
# Yaakov Selkowitz <yselkowi@redhat.com> - 2021
#
SOURCE="$1"
NEW_SOURCE=`echo $SOURCE | sed 's/\.tar\.gz/-free&/'`
DIRECTORY=`echo $SOURCE | sed 's/\.tar\.gz//'`
error()
{
MESSAGE=$1
echo $MESSAGE
exit 1
}
rm -rf $DIRECTORY
tar xzf $SOURCE || error "Cannot unpack $SOURCE"
pushd $DIRECTORY > /dev/null || error "Cannot open directory \"$DIRECTORY\""
echo "Remove proprietary source files"
find include/osx -type f -delete
echo
popd > /dev/null
tar czf $NEW_SOURCE $DIRECTORY
echo "$NEW_SOURCE is ready to use"

View File

@ -0,0 +1,2 @@
#Type Name ID GECOS Home directory Shell
u lldpd - "Used by the lldpd daemon" /var/lib/lldpd /sbin/nologin

View File

@ -1,48 +1,31 @@
%if 0%{?el6}
%bcond_with systemd
%global rundir /var/run/
%else
%bcond_without systemd
%global rundir /run/
%endif
%global gh_owner vincentbernat
Name: lldpd
Version: 1.0.17
Release: 2%{?dist}
Version: 1.0.18
Release: 5%{?dist}
Summary: ISC-licensed implementation of LLDP
License: ISC
URL: https://%{gh_owner}.github.io/%{name}/
Source0: https://media.luffy.cx/files/lldpd/lldpd-%{version}.tar.gz
Source1: %{name}-fedora.service
URL: https://github.com/lldpd/
Source0: lldpd-%{version}-free.tar.gz
Source1: %{name}.service
Source2: %{name}-tmpfiles
Source3: %{name}-fedora.sysconfig
Source4: %{name}-el6.init
Source5: %{name}-el7.service
Source3: %{name}.sysconfig
Source4: %{name}-systemd-sysusers.conf
Source100: lldpd-cleanup.sh
Patch1: 0001-client-add-range-restriction-for-tx-hold-and-interva.patch
Patch2: 0002-lldpd-limit-tx-ttl-to-65535.patch
BuildRequires: readline-devel
BuildRequires: check-devel
BuildRequires: net-snmp-devel
BuildRequires: gcc
BuildRequires: libxml2-devel
# EL6 needs libevent2 as the package
%if 0%{?el6}
BuildRequires: libevent2-devel
%else
BuildRequires: libevent-devel
%endif
%if 0%{?with_systemd}
# For systemd stuff
BuildRequires: systemd
BuildRequires: make
BuildRequires: net-snmp-devel
BuildRequires: readline-devel
BuildRequires: systemd-rpm-macros
%{?systemd_requires}
%else
Requires(post): chkconfig
Requires(preun): chkconfig
# This is for /sbin/service
Requires(preun): initscripts
%endif
%{?sysusers_requires_compat}
Requires(pre): shadow-utils
@ -60,106 +43,69 @@ Summary: %{summary}
%{name} development libraries and headers
%prep
%autosetup
%autosetup -p1
%build
%configure --disable-static --with-snmp --disable-silent-rules \
--with-privsep-user=%{name} --with-privsep-group=%{name} \
--with-privsep-chroot=%{rundir}%{name}/chroot \
--with-lldpd-ctl-socket=%{rundir}%{name}/%{name}.socket \
%if 0%{?with_systemd}
--with-privsep-chroot=%{_rundir}/%{name}/chroot \
--with-lldpd-ctl-socket=%{_rundir}/%{name}/%{name}.socket \
--with-systemdsystemunitdir=%{_unitdir} --with-sysusersdir=no
%endif
make %{?_smp_mflags}
%make_build
%install
%make_install
%if 0%{?with_systemd}
%if 0%{?fedora} >= 26
install -p -D -m644 %{SOURCE1} %{buildroot}%{_unitdir}/%{name}.service
%else
install -p -D -m644 %{SOURCE5} %{buildroot}%{_unitdir}/%{name}.service
%endif
install -p -D -m644 %{SOURCE2} %{buildroot}%{_tmpfilesdir}/%{name}.conf
%else
install -p -D -m755 %{SOURCE4} %{buildroot}%{_initddir}/%{name}
%endif
install -p -D -m644 %{SOURCE3} %{buildroot}/etc/sysconfig/%{name}
install -p -D -m644 %{SOURCE4} %{buildroot}%{_sysusersdir}/%{name}.conf
install -d -D -m 0755 %{buildroot}%{rundir}%{name}/chroot
install -d -D -m 0755 %{buildroot}%{_rundir}/%{name}/chroot
install -d -m 0755 %{buildroot}%{_sharedstatedir}/%{name}
# remove the docs from buildroot
rm -rf %{buildroot}/usr/share/doc/%{name}
# don't include completion conf yet
rm -f %{buildroot}/usr/share/bash-completion/completions/lldpcli
rm -f %{buildroot}/usr/share/zsh/vendor-completions/_lldpcli
rm -f %{buildroot}/usr/share/zsh/site-functions/_lldpcli
# remove static libtool archive
rm -f %{buildroot}%{_libdir}/liblldpctl.la
find %{buildroot} -type f -name "*.la" -delete
%ldconfig_scriptlets
%pre
getent group %{name} >/dev/null || groupadd -r %{name}
getent passwd %{name} >/dev/null || \
useradd -r -g %{name} -d %{_sharedstatedir}/%{name} -s /sbin/nologin \
-c "Used by the %{name} daemon" %{name}
exit 0
%sysusers_create_compat %{SOURCE4}
%post
/sbin/ldconfig
%if 0%{?with_systemd}
%systemd_post %{name}.service
%else
# This adds the proper /etc/rc*.d links for the script
/sbin/chkconfig --add %{name}
%endif
%preun
%if 0%{?with_systemd}
%systemd_preun %{name}.service
%else
if [ $1 -eq 0 ] ; then
/sbin/service %{name} stop >/dev/null 2>&1
/sbin/chkconfig --del %{name}
fi
%endif
%postun
/sbin/ldconfig
%if 0%{?with_systemd}
%systemd_postun_with_restart %{name}.service
%else
if [ "$1" -ge "1" ] ; then
/sbin/service %{name} condrestart >/dev/null 2>&1 || :
fi
%endif
%files
%doc NEWS README.md
%license LICENSE
%doc NEWS README.md
%config %{_sysconfdir}/%{name}.d
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%{_sbindir}/lldpcli
%{_sbindir}/lldpctl
%{_sbindir}/%{name}
%config %{_sysconfdir}/%{name}.d
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
%{_mandir}/man8/lldpcli.8*
%{_mandir}/man8/lldpctl.8*
%{_mandir}/man8/%{name}.8*
%{_libdir}/liblldpctl.so.4*
%dir %{rundir}%{name}
%dir %{rundir}%{name}/chroot
%if 0%{?with_systemd}
%dir %{_rundir}/%{name}
%dir %{_rundir}/%{name}/chroot
%{_unitdir}/%{name}.service
%{_tmpfilesdir}/%{name}.conf
%else
%{_initddir}/%{name}
%endif
%{_sysusersdir}/%{name}.conf
%dir %attr(-,lldpd,lldpd) %{_sharedstatedir}/%{name}
%files devel
@ -168,16 +114,68 @@ fi
%{_libdir}/liblldpctl.so
%{_libdir}/pkgconfig/lldpctl.pc
%changelog
* Mon Nov 06 2023 Hangbin Liu <haliu@redhat.com> - 1.0.17-2
- Fix liblldpctl version [RHEL-2211]
* Wed Oct 16 2024 Hangbin Liu <haliu@redhat.com> - 1.0.18-4
- Add range checking for tx-interval and tx-hold [RHEL-40245]
* Mon May 20 2024 Hangbin Liu <haliu@redhat.com> - 1.0.18-3
- Add lldpd-devel package [RHEL-22127]
* Sun Feb 18 2024 Hangbin Liu <haliu@redhat.com> - 1.0.18-2
- Remove networkd gating test [RHEL-25990]
* Wed Jan 31 2024 Hangbin Liu <haliu@redhat.com> - 1.0.18-1
- Rebased to 1.0.18 [RHEL-2211]
* Mon Nov 06 2023 Hangbin Liu <haliu@redhat.com> - 1.0.17-1
- Rebased to 1.0.17 [RHEL-2211]
- Rebased to 1.0.17 [RHEL-2211, RHEL-5791, RHEL-5796]
* Thu Aug 09 2018 Josef Ridky <jridky@redhat.com> - 1.0.1-2
- Rebuild for Net-SNMP
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 1.0.4-10
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Mon Jul 12 2021 Aaron Conole <aconole@redhat.com> - 1.0.4-9
- Strip ASL components (#1982259)
* Tue Jun 22 2021 Mohan Boddu <mboddu@redhat.com> - 1.0.4-8
- Rebuilt for RHEL 9 BETA for openssl 3.0
Related: rhbz#1971065
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 1.0.4-7
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.4-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Tue Sep 29 20:35:23 CEST 2020 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 1.0.4-5
- Rebuilt for libevent 2.1.12
* Wed Sep 02 2020 Josef Ridky <jridky@redhat.com> - 1.0.4-4
- Rebuilt for new net-snmp release
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.4-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Tue Aug 13 2019 James Hogarth <james.hogarth@gmail.com> - 1.0.4-1
- Updated to new upstream release 1.0.4
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Sun Feb 17 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 1.0.1-5
- Rebuild for readline 8.0
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Tue Jul 24 2018 Adam Williamson <awilliam@redhat.com> - 1.0.1-3
- Rebuild for new net-snmp
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Tue Apr 17 2018 James Hogarth <james.hogarth@gmail.com> - 1.0.1-1
- Update to 1.0.1

View File

@ -1 +1 @@
SHA512 (lldpd-1.0.17.tar.gz) = 8f6d6ea6a32cc0f238158a2d1f08224224bca250cf61f80e4d8b633c0471e4ff9a17a7a7d7f313f10d557a256c7419f54cbb3b78903b7bba3619f9c5b6c114c8
SHA512 (lldpd-1.0.18-free.tar.gz) = be9327a3b37abf01e239be97bbcbcbefdf6554cddc45ae3c18e1c5c2d1dd6607b3dd6bda1ccc2c5e65a83b9839660ba26322baa582b27a613e829c38a94e3686

View File

@ -0,0 +1,149 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# lldpd-test.py integration test
# Description: Test for lldpd: implementation of IEEE 802.1ab (LLDP)
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
import errno
import os
import sys
import time
import unittest
import subprocess
import signal
import shutil
import re
import socket
LLDPD_TCP_DUMP_FILE='/tmp/lldpd-tcp-dump.pcap'
LLDPD_PID_FILE='/var/run/lldpd.pid'
SERVICE_UNITDIR = '/run/systemd/system'
NETWORK_UNITDIR = '/run/systemd/network'
def setUpModule():
"""Initialize the environment, and perform sanity checks on it."""
if shutil.which('lldpd') is None:
raise OSError(errno.ENOENT, 'lldpd not found')
# Ensure the unit directory exists so tests can dump files into it.
os.makedirs(NETWORK_UNITDIR, exist_ok=True)
class lldpdUtilities():
"""Provide a set of utility functions start stop lldpd ."""
def Startlldpd(self):
"""Start lldpd interface lldpd-peer """
subprocess.check_output(['/usr/sbin/lldpd', '-cfse', '-D', '-C', 'lldpd-peer', '-I', 'lldpd-peer', '-S', 'lldpd-system-name','-m', '192.168.50.6'])
def Stoplldpd(self):
try:
with open(LLDPD_PID_FILE, 'r') as f:
pid = f.read().rstrip(' \t\r\n\0')
os.kill(int(pid), signal.SIGTERM)
os.remove(LLDPD_PID_FILE)
except IOError:
pass
def StartCaptureLLDPPackets(self):
"""Start tcpdump to capture packets"""
self.WriteServiceFile('tcpdump.service', '''\
[Unit]
Description=TCPDumpd
After=multi-user.target network.target
[Service]
Type=simple
ExecStart=/usr/sbin/tcpdump -pnnli lldpd ether proto 0x88cc -vvv -w "/tmp/lldpd-tcp-dump.pcap"
[Install]
WantedBy=multi-user.target
''')
subprocess.check_output(['systemctl','daemon-reload'])
subprocess.check_output(['systemctl','restart', 'tcpdump.service'])
def StopCapturingPackets(self):
subprocess.check_output(['systemctl', 'stop', 'tcpdump.service'])
time.sleep(3);
def SetupVethInterface(self):
"""Setup veth interface"""
subprocess.check_output(['ip', 'link', 'add', 'lldpd', 'type', 'veth', 'peer', 'name', 'lldpd-peer'])
subprocess.check_output(['ip', 'link', 'set', 'lldpd', 'address', '02:01:02:03:04:08'])
subprocess.check_output(['ip', 'link', 'set', 'lldpd-peer', 'address', '02:01:02:03:04:09'])
subprocess.check_output(['ip', 'link', 'set', 'lldpd', 'up'])
subprocess.check_output(['ip', 'link', 'set', 'lldpd-peer', 'up'])
time.sleep(3);
self.addCleanup(subprocess.call, ['ip', 'link', 'del', 'dev', 'lldpd'])
def WriteServiceFile(self, unit_name, contents):
"""Write a tcpdump unit file, and queue it to be removed."""
unit_path = os.path.join(SERVICE_UNITDIR, unit_name)
with open(unit_path, 'w') as unit:
unit.write(contents)
self.addCleanup(os.remove, unit_path)
def FindProtocolFieldsinTCPDump(self, **kwargs):
"""Look attributes in lldpd logs."""
contents = subprocess.check_output(['tcpdump', '-v', '-r', LLDPD_TCP_DUMP_FILE]).rstrip().decode('utf-8')
if kwargs is not None:
for key in kwargs:
self.assertRegex(contents, kwargs[key])
class lldpdTests(unittest.TestCase, lldpdUtilities):
def setUp(self):
""" Setup """
self.SetupVethInterface()
def tearDown(self):
self.Stoplldpd()
os.remove(LLDPD_TCP_DUMP_FILE)
def test_lldpd_trasmitted_lldp_attributes(self):
""" verify at the other end of veth received LLDP packets that contains attibutes (link address, hostname, TTL, system desc). tcpdump """
self.StartCaptureLLDPPackets()
time.sleep(5)
self.Startlldpd()
""" capture for 10 seconds """
time.sleep(10)
self.StopCapturingPackets()
self.FindProtocolFieldsinTCPDump(Chassis='Subtype MAC address \(4\): 02:01:02:03:04:09',
Port='Subtype MAC address \(3\): 02:01:02:03:04:09',
PortDesc='lldpd-peer',
TTL='TTL.*120s',
HostName=socket.gethostname() ,
System_Description='lldpd-system-name',
ManagementAddress='192.168.50.6')
def test_lldpd_trasmitted_lldp_packets(self):
""" verify at the other end of veth ifname lldpd has received LLDP packets. tcpdump """
self.StartCaptureLLDPPackets()
time.sleep(5)
self.Startlldpd()
""" capture for 10 seconds """
time.sleep(10)
self.StopCapturingPackets()
self.FindProtocolFieldsinTCPDump(MAC='02:01:02:03:04:09',
TTL='TTL 120s')
if __name__ == '__main__':
unittest.main(testRunner=unittest.TextTestRunner(stream=sys.stdout,
verbosity=2))

View File

@ -0,0 +1,35 @@
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1+
# ~~~
# LLDPD integration test
# Description: Test for lldpd:implementation of IEEE 802.1ab (LLDP)
#
# Author: Susant Sahani <susant@redhat.com>
# Copyright (c) 2018 Red Hat, Inc.
#~~~
# Include Beaker environment
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="lldpd"
LldpdPidFile="/var/run/lldpd.pid"
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "cp lldpd-tests.py /usr/bin/"
rlPhaseEnd
rlPhaseStartTest
rlLog "lldpd tests"
rlRun "/usr/bin/python3 /usr/bin/lldpd-tests.py"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "rm /usr/bin/lldpd-tests.py"
rlLog "lldpd tests done"
rlPhaseEnd
rlJournalPrintText
rlJournalEnd
rlGetTestState

13
tests/tests.yml Normal file
View File

@ -0,0 +1,13 @@
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- classic
tests:
- miscellaneous-tests
required_packages:
- lldpd
- python3
- tcpdump
- systemd
- iproute