From 8bfb9b125743635fa22aa256cf6191734b8b6c6b Mon Sep 17 00:00:00 2001 From: Yue Tao Date: Fri, 17 Sep 2021 15:03:10 +0800 Subject: [PATCH] Add debian package for lldpd Porting lldpd-create-run-dir.patch and lldpd-i40e-disable.patch. Skip the patch lldpd-clear-station.patch, which has been integrated by upstream commit 3cb4e08c266fde2f7eddf93d2033ec2252e6fbbf Story: 2009221 Task: 43357 Signed-off-by: Yue Tao Change-Id: Ifbbe4bab5879a2b6aad5f6263b1df2373cf8e8d6 --- .../debian-configure-lldp-initscript.patch | 23 ++ networking/lldpd/debian/deb_patches/series | 1 + networking/lldpd/debian/meta_data.yaml | 8 + .../debian/patches/lldpd-create-run-dir.patch | 12 + .../debian/patches/lldpd-i40e-disable.patch | 230 ++++++++++++++++++ networking/lldpd/debian/patches/series | 2 + 6 files changed, 276 insertions(+) create mode 100644 networking/lldpd/debian/deb_patches/debian-configure-lldp-initscript.patch create mode 100644 networking/lldpd/debian/deb_patches/series create mode 100644 networking/lldpd/debian/meta_data.yaml create mode 100644 networking/lldpd/debian/patches/lldpd-create-run-dir.patch create mode 100644 networking/lldpd/debian/patches/lldpd-i40e-disable.patch create mode 100644 networking/lldpd/debian/patches/series diff --git a/networking/lldpd/debian/deb_patches/debian-configure-lldp-initscript.patch b/networking/lldpd/debian/deb_patches/debian-configure-lldp-initscript.patch new file mode 100644 index 000000000..4436dcbd1 --- /dev/null +++ b/networking/lldpd/debian/deb_patches/debian-configure-lldp-initscript.patch @@ -0,0 +1,23 @@ +From yue.tao@windriver.com + +Subject: install the i40e-lldp-configure.sh to /etc/init.d. The script allows +a user to enable and disable the internal LLDP agent. + +--- a/debian/rules ++++ b/debian/rules +@@ -9,3 +9,8 @@ override_dh_auto_configure: + --with-snmp \ + --with-xml \ + --with-systemdsystemunitdir=/lib/systemd/system ++ ++override_dh_install: ++ install -d -m 755 debian/tmp/etc/init.d ++ install -m 755 i40e-lldp-configure.sh debian/tmp/etc/init.d ++ dh_install +--- a/debian/lldpd.install ++++ b/debian/lldpd.install +@@ -5,3 +5,4 @@ debian/tmp/usr/sbin/lldp* + debian/tmp/usr/share/bash-completion/completions/* + debian/tmp/usr/share/zsh/vendor-completions/* + debian/tmp/etc/lldpd.d/* ++debian/tmp/etc/init.d/* diff --git a/networking/lldpd/debian/deb_patches/series b/networking/lldpd/debian/deb_patches/series new file mode 100644 index 000000000..cf72e1b5d --- /dev/null +++ b/networking/lldpd/debian/deb_patches/series @@ -0,0 +1 @@ +debian-configure-lldp-initscript.patch diff --git a/networking/lldpd/debian/meta_data.yaml b/networking/lldpd/debian/meta_data.yaml new file mode 100644 index 000000000..b9778b60c --- /dev/null +++ b/networking/lldpd/debian/meta_data.yaml @@ -0,0 +1,8 @@ +debver: 1.0.11-1 +dl_path: + name: lldpd-debian-1.0.11-1.tar.gz + url: https://salsa.debian.org/debian/lldpd/-/archive/debian/1.0.11-1/lldpd-debian-1.0.11-1.tar.gz + md5sum: 2e01f096f54c5e7513489ceb2017896c +revision: + dist: $STX_DIST + PKG_GITREVCOUNT: true diff --git a/networking/lldpd/debian/patches/lldpd-create-run-dir.patch b/networking/lldpd/debian/patches/lldpd-create-run-dir.patch new file mode 100644 index 000000000..538cc7fa1 --- /dev/null +++ b/networking/lldpd/debian/patches/lldpd-create-run-dir.patch @@ -0,0 +1,12 @@ +Index: lldpd-0.9.0/src/daemon/lldpd.service.in +=================================================================== +--- lldpd-0.9.0.orig/src/daemon/lldpd.service.in ++++ lldpd-0.9.0/src/daemon/lldpd.service.in +@@ -9,6 +9,7 @@ Type=notify + NotifyAccess=main + EnvironmentFile=-/etc/default/lldpd + EnvironmentFile=-/etc/sysconfig/lldpd ++ExecStartPre=/bin/mkdir -p /var/run/lldpd + ExecStart=@sbindir@/lldpd $DAEMON_ARGS $LLDPD_OPTIONS + Restart=on-failure + PrivateTmp=yes diff --git a/networking/lldpd/debian/patches/lldpd-i40e-disable.patch b/networking/lldpd/debian/patches/lldpd-i40e-disable.patch new file mode 100644 index 000000000..9f9913ca8 --- /dev/null +++ b/networking/lldpd/debian/patches/lldpd-i40e-disable.patch @@ -0,0 +1,230 @@ +Index: lldpd-0.9.0/src/daemon/lldpd.service.in +=================================================================== +--- lldpd-0.9.0.orig/src/daemon/lldpd.service.in ++++ lldpd-0.9.0/src/daemon/lldpd.service.in +@@ -10,6 +10,7 @@ NotifyAccess=main + EnvironmentFile=-/etc/default/lldpd + EnvironmentFile=-/etc/sysconfig/lldpd + ExecStartPre=/bin/mkdir -p /var/run/lldpd ++ExecStartPre=/etc/init.d/i40e-lldp-configure.sh stop + ExecStart=@sbindir@/lldpd $DAEMON_ARGS $LLDPD_OPTIONS + Restart=on-failure + PrivateTmp=yes +--- /dev/null ++++ b/i40e-lldp-configure.sh +@@ -0,0 +1,215 @@ ++#!/bin/bash ++################################################################################ ++# Copyright (c) 2021 Wind River Systems, Inc. ++# ++# SPDX-License-Identifier: Apache-2.0 ++# ++################################################################################ ++ ++# Certain i40e network devices (XL710 Fortville) have an internal firmware LLDP ++# agent enabled by default. This can prevent LLDP PDUs from being processed by ++# the driver and any upper layer agents. ++# ++# This script allows a user to enable and disable the internal LLDP agent. ++# ++# Note: debugfs must be enabled in the kernel ++# ++# Note: Devices with firmware 5.05 and 8.10 use the ethtool command ++# Devices with firmware 7.10 use the sysfs command ++# ++# To enable: ++# ./i40e-lldp-configure.sh start ++# ++# To disable: ++# ./i40e-lldp-configure.sh stop ++ ++PROGNAME=$(basename $0) ++DEBUGFS_PATH=/sys/kernel/debug ++DEBUGFS_I40_DEVICES_PATH=$DEBUGFS_PATH/i40e ++LLDP_COMMAND=lldp ++ ++function log { ++ local MSG="${PROGNAME}: $1" ++ logger -p notice "${MSG}" ++} ++ ++function err { ++ local MSG="${PROGNAME}: $1" ++ logger -p error "${MSG}" ++} ++ ++function configure_device { ++ local DEVICE=$1 ++ local ACTION=$2 ++ local DEVICE_PATH=${DEBUGFS_I40_DEVICES}/${DEVICE} ++ ++ if [ ! -d ${DEVICE_PATH} ]; then ++ return 1 ++ fi ++ ++ echo "${LLDP_COMMAND} ${ACTION}" > ${DEVICE_PATH}/command ++ RET=$? ++ ++ if [ ${RET} -ne 0 ]; then ++ err "Failed to ${ACTION} internal LLDP agent for device ${DEVICE}" ++ return ${RET} ++ fi ++ ++ log "${ACTION} internal LLDP agent for device ${DEVICE}" ++ return ${RET} ++} ++ ++function ethtool_device { ++ local DEVICE=$1 ++ local COMMAND=$2 ++ ++ ethtool --set-priv-flags ${DEVICE} disable-fw-lldp ${COMMAND} ++ RET=$? ++ ++ if [ ${RET} -ne 0 ]; then ++ err "Failed to set disable-fw-lldp ${COMMAND} for device ${DEVICE}" ++ return ${RET} ++ fi ++ ++ log "Set disable-fw-lldp ${COMMAND} for device ${DEVICE}" ++ return ${RET} ++} ++ ++ ++function is_debugfs_mounted { ++ if grep -qs "${DEBUGFS_PATH}" /proc/mounts; then ++ return 0 ++ fi ++ return 1 ++} ++ ++function mount_debugfs { ++ mount -t debugfs none ${DEBUGFS_PATH} ++} ++ ++function unmount_debugfs { ++ umount ${DEBUGFS_PATH} ++} ++ ++function find_device_interface_from_pciaddr { ++ INTERFACE="" ++ ++ #Get device PCI address from path ++ local PCI_ADDR=${DEVICE##*/} ++ ++ #Lookup the device directory ++ local DEVICE_PATH ++ DEVICE_PATH=$(find /sys/devices -type d -name ${PCI_ADDR}) ++ ++ if [ -z "${DEVICE_PATH}" ]; then ++ log "Unable to find interface for ${PCI_ADDR}" ++ else ++ #Get the interface name for device ++ INTERFACE=$(ls ${DEVICE_PATH}/net) ++ if [ -z "${INTERFACE}" ]; then ++ log "Unable to find interface for ${PCI_ADDR}" ++ else ++ log "Found interface ${INTERFACE} for PCI address ${PCI_ADDR}" ++ fi ++ fi ++ ++} ++ ++function scan_devices { ++ local ACTION=$1 ++ local DEBUGFS_MOUNTED="false" ++ local DEVICES=${DEBUGFS_I40_DEVICES_PATH}/* ++ ++ if [ "${ACTION}" = "start" ]; then ++ local ETHTOOL_COMMAND="off" ++ else ++ local ETHTOOL_COMMAND="on" ++ fi ++ ++ if is_debugfs_mounted; then ++ DEBUGFS_MOUNTED="true" ++ fi ++ ++ if [ ${DEBUGFS_MOUNTED} = "false" ]; then ++ mount_debugfs ++ RET=$? ++ if [ ${RET} -ne 0 ]; then ++ err "Failed to mount debugfs" ++ return ${RET} ++ fi ++ log "Mounted debugfs" ++ fi ++ ++ # Set option to prevent the below for loop from running once ++ # if there are no directories in the $DEVICES path. ++ # Save the initial state in order to reset later ++ shopt -q nullglob ++ NULLGLOB=$? ++ shopt -s nullglob ++ ++ for DEVICE in $DEVICES; do ++ find_device_interface_from_pciaddr ++ if [ ! -z "${INTERFACE}" ]; then ++ ethtool_device ${INTERFACE} ${ETHTOOL_COMMAND} ++ RET=$? ++ # Ethtool method does not work for some firmware versions ++ # Fall back to sysfs method if ethtool does not work ++ if [ ${RET} -ne 0 ]; then ++ # Sysfs method is not able to return 1 if it fails ++ configure_device ${DEVICE} ${ACTION} ++ fi ++ else ++ configure_device ${DEVICE} ${ACTION} ++ fi ++ done ++ ++ # Unset option if that was the original state ++ if [ "${NULLGLOB}" -eq 1 ]; then ++ shopt -u nullglob ++ fi ++ ++ if [ ${DEBUGFS_MOUNTED} = "false" ]; then ++ unmount_debugfs ++ RET=$? ++ if [ ${RET} -ne 0 ]; then ++ err "Failed to unmount debugfs" ++ return ${RET} ++ fi ++ log "Unmounted debugfs" ++ fi ++ ++ return 0 ++} ++ ++function start { ++ scan_devices start ++ return $? ++} ++ ++function stop { ++ scan_devices stop ++ return $? ++} ++ ++function status { ++ return 0 ++} ++ ++case "$1" in ++ start) ++ start ++ ;; ++ stop) ++ stop ++ ;; ++ restart) ++ stop ++ start ++ ;; ++ status) ++ status ++ ;; ++ *) ++ echo "Usage: $0 {start|stop|restart|status}" ++ exit 1 ++esac diff --git a/networking/lldpd/debian/patches/series b/networking/lldpd/debian/patches/series new file mode 100644 index 000000000..5e24af182 --- /dev/null +++ b/networking/lldpd/debian/patches/series @@ -0,0 +1,2 @@ +lldpd-create-run-dir.patch +lldpd-i40e-disable.patch