Compare commits

...

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

14 changed files with 303 additions and 8 deletions

8
.gitignore vendored
View File

@ -1 +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

@ -1 +0,0 @@
ffae3bd667f7edae300b0c63a5f0103eb8c1118f SOURCES/lldpd-1.0.1.tar.gz

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

@ -9,19 +9,23 @@
%global gh_owner vincentbernat
Name: lldpd
Version: 1.0.1
Version: 1.0.18
Release: 2%{?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
# Upstream https://media.luffy.cx/files/lldpd/lldpd-%{version}.tar.gz
Source0: lldpd-%{version}-free.tar.gz
Source1: %{name}-fedora.service
Source2: %{name}-tmpfiles
Source3: %{name}-fedora.sysconfig
Source4: %{name}-el6.init
Source5: %{name}-el7.service
Source100: lldpd-cleanup.sh
BuildRequires: gcc
BuildRequires: readline-devel
BuildRequires: check-devel
BuildRequires: net-snmp-devel
@ -36,6 +40,7 @@ BuildRequires: libevent-devel
%if 0%{?with_systemd}
# For systemd stuff
BuildRequires: systemd
BuildRequires: make
%{?systemd_requires}
%else
Requires(post): chkconfig
@ -151,8 +156,7 @@ fi
%{_mandir}/man8/lldpcli.8*
%{_mandir}/man8/lldpctl.8*
%{_mandir}/man8/%{name}.8*
%{_libdir}/liblldpctl.so.4
%{_libdir}/liblldpctl.so.4.8.0
%{_libdir}/liblldpctl.so.4*
%dir %{rundir}%{name}
%dir %{rundir}%{name}/chroot
%if 0%{?with_systemd}
@ -171,8 +175,61 @@ fi
%changelog
* Thu Aug 09 2018 Josef Ridky <jridky@redhat.com> - 1.0.1-2
- Rebuild for Net-SNMP
* 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, RHEL-5791, RHEL-5796]
* 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

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (lldpd-1.0.18-free.tar.gz) = be9327a3b37abf01e239be97bbcbcbefdf6554cddc45ae3c18e1c5c2d1dd6607b3dd6bda1ccc2c5e65a83b9839660ba26322baa582b27a613e829c38a94e3686

View File

@ -0,0 +1,147 @@
#!/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()
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()
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