Hello community, here is the log from the commit of package open-lldp for openSUSE:Factory checked in at 2019-11-21 12:57:34 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/open-lldp (Old) and /work/SRC/openSUSE:Factory/.open-lldp.new.26869 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "open-lldp" Thu Nov 21 12:57:34 2019 rev:13 rq:749534 version:1.0.1+102.4c7fcc3 Changes: -------- --- /work/SRC/openSUSE:Factory/open-lldp/open-lldp.changes 2019-05-25 13:15:14.480447966 +0200 +++ /work/SRC/openSUSE:Factory/.open-lldp.new.26869/open-lldp.changes 2019-11-21 12:57:34.898547949 +0100 @@ -1,0 +2,42 @@ +Tue Nov 19 13:14:16 UTC 2019 - h...@suse.com + +- Update to version v1.0.1+102.4c7fcc3: + * l2_packet: Guard ETH_P_LLDP define + * lldp_mand: retrieve permanent mac address in get_mac() + * lldp_util: use netlink to fetch mac address + * lldp_util: drop get_macstr() + * linux/if_link.h: Update and add bonding netlink definitions + +------------------------------------------------------------------- +Tue Nov 19 13:13:17 UTC 2019 - h...@suse.com + +- Update to version v1.0.1+95.3168e11: + * Test with newer GCC 8 and 9 versions + * RPM build is broken, so skip + * Place the tarball in the right place + * A tarball needs to be built after bootstrap.sh for use with RPM + * Added missing steps for building an RPM + * Finish off with testing building the RPM + * Test package installation as well + * Test under multiple GCC releases + * Drop requirement for Travis CI testing with Clang + * Support checking build with Travis CI + * vdp-netlink: account for sizes properly + * qbg: avoid warning for extra parens + * qbg: port name is always a valid pointer + * dcbx-nl: drop run_cmd + * ecp: allow for failure to create + * lldp_util: allow for null ifa_addr element + * lldpad: Do not enable port if already enabled + * Silent -Werror=address-of-packed-member warnings. + * Come up with STRNCPY_TERMINATED (#25). + * vdptool: fixed compile error for getline() + * Fix #23 by off by one strncpy value. + * 8021qaz: Block lldptool set operations if read only mode is on + * 8021qaz: Add read only option for 8021qaz module + * lldp: Allow lldptool to modify optional TLV's content + * 8021qaz: Print dscp2prio map + * autoconf: Add systemd support in configure.ac + * rpm-spec: Add vdp22 man files to lldpad.spec.in + +------------------------------------------------------------------- Old: ---- open-lldp-v1.0.1+56.cb81e95.tar.xz New: ---- open-lldp-v1.0.1+102.4c7fcc3.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ open-lldp.spec ++++++ --- /var/tmp/diff_new_pack.XUKKuc/_old 2019-11-21 12:57:35.554547747 +0100 +++ /var/tmp/diff_new_pack.XUKKuc/_new 2019-11-21 12:57:35.554547747 +0100 @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# Please submit bugfixes or comments via http://bugs.opensuse.org/ # @@ -21,7 +21,7 @@ Summary: Link Layer Discovery Protocol (LLDP) Agent License: GPL-2.0-only Group: System/Daemons -Version: 1.0.1+56.cb81e95 +Version: 1.0.1+102.4c7fcc3 Release: 0 BuildRequires: bison BuildRequires: flex ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.XUKKuc/_old 2019-11-21 12:57:35.586547737 +0100 +++ /var/tmp/diff_new_pack.XUKKuc/_new 2019-11-21 12:57:35.586547737 +0100 @@ -1,4 +1,4 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/openSUSE/lldpad.git</param> - <param name="changesrevision">cb81e9541b51b3f104106979e7727c72d090fd8d</param></service></servicedata> \ No newline at end of file + <param name="changesrevision">4c7fcc339cca5ed6a0dabd3c017ca3dc6d6d765e</param></service></servicedata> \ No newline at end of file ++++++ open-lldp-v1.0.1+56.cb81e95.tar.xz -> open-lldp-v1.0.1+102.4c7fcc3.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/.travis.yml new/open-lldp-v1.0.1+102.4c7fcc3/.travis.yml --- old/open-lldp-v1.0.1+56.cb81e95/.travis.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/.travis.yml 2019-11-04 18:38:38.000000000 +0100 @@ -0,0 +1,49 @@ +language: c +dist: xenial +#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 + +matrix: + include: + - addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-4.8 + env: + - CC="gcc-4.8" + - addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-5 + env: + - CC="gcc-5" + - addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-7 + env: + - CC="gcc-7" + - addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-8 + env: + - CC="gcc-8" + - addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-9 + env: + - CC="gcc-9" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/configure.ac new/open-lldp-v1.0.1+102.4c7fcc3/configure.ac --- old/open-lldp-v1.0.1+56.cb81e95/configure.ac 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/configure.ac 2019-11-04 18:38:38.000000000 +0100 @@ -25,6 +25,39 @@ AC_MSG_ERROR([no suitable flex found. Please install the 'flex' package.]) fi +dnl Begin determine the systemd use and location +PKG_CHECK_MODULES([SYSTEMD], [systemd], use_systemd=yes, use_systemd=no) + +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") +AC_SUBST(SPEC_BUILD_REQUIRES_POSTUN, "initscripts") +specfile_install="%{_sysconfdir}/init.d/lldpad" +specfile_install_socket="" + +if test "x$use_systemd" == xyes; then + dir="" + AC_ARG_WITH([systemdsystemunitdir], + AS_HELP_STRING([--with-systemdsystem unitdir=DIR], + [Directory for systemd service files default from pkg-config variable systemdsystemunitdir]), + [dir=${withval}], + [dir="$($PKG_CONFIG --variable=systemdsystemunitdir systemd)"]) + + systemdsystemunitdir=${dir} + AC_SUBST(SYSTEMD_SYSTEM_UNIT_DIR, [$systemdsystemunitdir]) + specfile_install="$systemdsystemunitdir/lldpad.service" + specfile_install_socket="$systemdsystemunitdir/lldpad.socket" + + AC_SUBST(SPEC_BUILD_REQUIRES_POST, "systemd") + AC_SUBST(SPEC_BUILD_REQUIRES_PREUN, "systemd") + AC_SUBST(SPEC_BUILD_REQUIRES_POSTUN, "systemd") +fi + +AM_CONDITIONAL(SYSTEMD_SYSTEM, test "x$use_systemd" == xyes) +AC_SUBST(SPEC_FILE_LLDPAD_SERVICE, $specfile_install) +AC_SUBST(SPEC_FILE_LLDPAD_SOCKET, $specfile_install_socket) +dnl End systemd stuff + PKG_CHECK_MODULES([LIBCONFIG], [libconfig >= 1.3.2]) PKG_CHECK_MODULES([LIBNL], [libnl-3.0 >= 3.2]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/contrib/build-rpm.sh new/open-lldp-v1.0.1+102.4c7fcc3/contrib/build-rpm.sh --- old/open-lldp-v1.0.1+56.cb81e95/contrib/build-rpm.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/contrib/build-rpm.sh 2019-11-04 18:38:38.000000000 +0100 @@ -0,0 +1,11 @@ +#!/bin/sh + +set -ev + +sources=~/rpmbuild/SOURCES +version="1.0.1" + +mkdir -p "$sources" +#git archive --prefix=lldpad-"$version"/ --format=tar.gz --output="$sources"/lldpad-"$version".tar.gz HEAD +tar --transform='s:^\.:lldpad-'"$version"':' --exclude='.git*' --exclude='.travis.yml' -cvzf "$sources"/lldpad-"$version".tar.gz . +#rpmbuild -ba lldpad.spec diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/dcb_protocol.c new/open-lldp-v1.0.1+102.4c7fcc3/dcb_protocol.c --- old/open-lldp-v1.0.1+56.cb81e95/dcb_protocol.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/dcb_protocol.c 2019-11-04 18:38:38.000000000 +0100 @@ -75,7 +75,7 @@ entry = (struct pg_store1 *)malloc(sizeof(struct pg_store1)); if (!entry) return; - strncpy(entry->ifname, ifname, sizeof(entry->ifname)); + STRNCPY_TERMINATED(entry->ifname, ifname, sizeof(entry->ifname)); entry->second = store; LIST_INSERT_HEAD(head, entry, entries); } @@ -1100,7 +1100,7 @@ assert(device_name); not_default = memcmp(DEF_CFG_STORE, device_name, strlen(DEF_CFG_STORE)); - strncpy (devName, device_name, MAX_DEVICE_NAME_LEN); + STRNCPY_TERMINATED (devName, device_name, MAX_DEVICE_NAME_LEN); if (not_default) handle_opermode_true(device_name); @@ -2274,9 +2274,7 @@ sizeof(char); *name = (char*)malloc(size); if (*name != NULL) { - strncpy(*name, - attribs.descript.pgid_desc[bwgid], - size); /* Localization OK */ + memcpy(*name, attribs.descript.pgid_desc[bwgid], size); /* Localization OK */ } else { goto Error; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/event_iface.c new/open-lldp-v1.0.1+102.4c7fcc3/event_iface.c --- old/open-lldp-v1.0.1+56.cb81e95/event_iface.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/event_iface.c 2019-11-04 18:38:38.000000000 +0100 @@ -77,7 +77,7 @@ LLDPAD_DBG(" IFLA_BROADCAST\n"); break; case IFLA_IFNAME: - strncpy(d, (char *)RTA_DATA(rta), IFNAMSIZ); + STRNCPY_TERMINATED(d, (char *)RTA_DATA(rta), IFNAMSIZ); LLDPAD_DBG(" IFLA_IFNAME\n"); LLDPAD_DBG(" device name is %s\n", d); break; @@ -205,6 +205,9 @@ port = newport; } else if (is_bond(device_name) || !port->portEnabled) reinit_port(device_name); + else if (port->portEnabled) { + return 0; + } lldp_add_agent(device_name, NEAREST_BRIDGE); lldp_add_agent(device_name, NEAREST_NONTPMR_BRIDGE); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/include/linux/if_link.h new/open-lldp-v1.0.1+102.4c7fcc3/include/linux/if_link.h --- old/open-lldp-v1.0.1+56.cb81e95/include/linux/if_link.h 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/include/linux/if_link.h 2019-11-04 18:38:38.000000000 +0100 @@ -116,15 +116,34 @@ IFLA_STATS64, IFLA_VF_PORTS, IFLA_PORT_SELF, - IFLA_AF_SPEC, - IFLA_GROUP, /* Group the device belongs to */ - IFLA_NET_NS_FD, - IFLA_EXT_MASK, /* Extended info mask, VFs, etc */ - IFLA_PROMISCUITY, /* Promiscuity count: > 0 means acts PROMISC */ + IFLA_AF_SPEC, + IFLA_GROUP, /* Group the device belongs to */ + IFLA_NET_NS_FD, + IFLA_EXT_MASK, /* Extended info mask, VFs, etc */ + IFLA_PROMISCUITY, /* Promiscuity count: > 0 means acts PROMISC */ #define IFLA_PROMISCUITY IFLA_PROMISCUITY - IFLA_NUM_TX_QUEUES, - IFLA_NUM_RX_QUEUES, - IFLA_CARRIER, + IFLA_NUM_TX_QUEUES, + IFLA_NUM_RX_QUEUES, + IFLA_CARRIER, + IFLA_PHYS_PORT_ID, + IFLA_CARRIER_CHANGES, + IFLA_PHYS_SWITCH_ID, + IFLA_LINK_NETNSID, + IFLA_PHYS_PORT_NAME, + IFLA_PROTO_DOWN, + IFLA_GSO_MAX_SEGS, + IFLA_GSO_MAX_SIZE, + IFLA_PAD, + IFLA_XDP, + IFLA_EVENT, + IFLA_NEW_NETNSID, + IFLA_IF_NETNSID, + IFLA_TARGET_NETNSID = IFLA_IF_NETNSID, /* new alias */ + IFLA_CARRIER_UP_COUNT, + IFLA_CARRIER_DOWN_COUNT, + IFLA_NEW_IFINDEX, + IFLA_MIN_MTU, + IFLA_MAX_MTU, __IFLA_MAX }; @@ -192,6 +211,8 @@ IFLA_INFO_KIND, IFLA_INFO_DATA, IFLA_INFO_XSTATS, + IFLA_INFO_SLAVE_KIND, + IFLA_INFO_SLAVE_DATA, __IFLA_INFO_MAX, }; @@ -243,6 +264,69 @@ MACVLAN_MODE_BRIDGE = 4, /* talk to bridge ports directly */ }; +/* Bonding section */ + +enum { + IFLA_BOND_UNSPEC, + IFLA_BOND_MODE, + IFLA_BOND_ACTIVE_SLAVE, + IFLA_BOND_MIIMON, + IFLA_BOND_UPDELAY, + IFLA_BOND_DOWNDELAY, + IFLA_BOND_USE_CARRIER, + IFLA_BOND_ARP_INTERVAL, + IFLA_BOND_ARP_IP_TARGET, + IFLA_BOND_ARP_VALIDATE, + IFLA_BOND_ARP_ALL_TARGETS, + IFLA_BOND_PRIMARY, + IFLA_BOND_PRIMARY_RESELECT, + IFLA_BOND_FAIL_OVER_MAC, + IFLA_BOND_XMIT_HASH_POLICY, + IFLA_BOND_RESEND_IGMP, + IFLA_BOND_NUM_PEER_NOTIF, + IFLA_BOND_ALL_SLAVES_ACTIVE, + IFLA_BOND_MIN_LINKS, + IFLA_BOND_LP_INTERVAL, + IFLA_BOND_PACKETS_PER_SLAVE, + IFLA_BOND_AD_LACP_RATE, + IFLA_BOND_AD_SELECT, + IFLA_BOND_AD_INFO, + IFLA_BOND_AD_ACTOR_SYS_PRIO, + IFLA_BOND_AD_USER_PORT_KEY, + IFLA_BOND_AD_ACTOR_SYSTEM, + IFLA_BOND_TLB_DYNAMIC_LB, + __IFLA_BOND_MAX, +}; + +#define IFLA_BOND_MAX (__IFLA_BOND_MAX - 1) + +enum { + IFLA_BOND_AD_INFO_UNSPEC, + IFLA_BOND_AD_INFO_AGGREGATOR, + IFLA_BOND_AD_INFO_NUM_PORTS, + IFLA_BOND_AD_INFO_ACTOR_KEY, + IFLA_BOND_AD_INFO_PARTNER_KEY, + IFLA_BOND_AD_INFO_PARTNER_MAC, + __IFLA_BOND_AD_INFO_MAX, +}; + +#define IFLA_BOND_AD_INFO_MAX (__IFLA_BOND_AD_INFO_MAX - 1) + +enum { + IFLA_BOND_SLAVE_UNSPEC, + IFLA_BOND_SLAVE_STATE, + IFLA_BOND_SLAVE_MII_STATUS, + IFLA_BOND_SLAVE_LINK_FAILURE_COUNT, + IFLA_BOND_SLAVE_PERM_HWADDR, + IFLA_BOND_SLAVE_QUEUE_ID, + IFLA_BOND_SLAVE_AD_AGGREGATOR_ID, + IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE, + IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE, + __IFLA_BOND_SLAVE_MAX, +}; + +#define IFLA_BOND_SLAVE_MAX (__IFLA_BOND_SLAVE_MAX - 1) + /* SR-IOV virtual function management section */ enum { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/include/lldp.h new/open-lldp-v1.0.1+102.4c7fcc3/include/lldp.h --- old/open-lldp-v1.0.1+56.cb81e95/include/lldp.h 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/include/lldp.h 2019-11-04 18:38:38.000000000 +0100 @@ -51,6 +51,13 @@ __x > __y ? __x : __y; \ }) +/* Use strncpy with N-1 and ensure the string is terminated. */ +#define STRNCPY_TERMINATED(DEST, SRC, N) \ + do { \ + strncpy (DEST, SRC, N - 1); \ + DEST[N - 1] = '\0'; \ + } while (false) + /* * Organizationally Unique Identifier (OUI) * http://standards.ieee.org/regauth/oui/oui.txt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/include/lldp_basman_clif.h new/open-lldp-v1.0.1+102.4c7fcc3/include/lldp_basman_clif.h --- old/open-lldp-v1.0.1+56.cb81e95/include/lldp_basman_clif.h 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/include/lldp_basman_clif.h 2019-11-04 18:38:38.000000000 +0100 @@ -31,7 +31,7 @@ void basman_cli_unregister(struct lldp_module *); int basman_print_tlv(u32, u16, char *); -#define ARG_IPV4_ADDR "ipv4" -#define ARG_IPV6_ADDR "ipv6" - +#define ARG_IPV4_ADDR "ipv4" +#define ARG_IPV6_ADDR "ipv6" +#define ARG_TLVINFO "info" #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/include/lldp_util.h new/open-lldp-v1.0.1+102.4c7fcc3/include/lldp_util.h --- old/open-lldp-v1.0.1+56.cb81e95/include/lldp_util.h 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/include/lldp_util.h 2019-11-04 18:38:38.000000000 +0100 @@ -150,8 +150,7 @@ int get_ifpflags(const char *); int get_iftype(const char *); int get_src_mac_from_bond(struct port *bond_port, char *ifname, u8 *addr); -int get_mac(const char *ifname, u8 mac[]); -int get_macstr(const char *ifname, char *addr, size_t size); +int get_mac(const char *ifname, u8 mac[], bool perm_mac); int get_saddr(const char *ifname, struct sockaddr_in *saddr); int get_ipaddr(const char *ifname, struct in_addr *); int get_ipaddrstr(const char *ifname, char *ipaddr, size_t size); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/lldp/l2_packet.h new/open-lldp-v1.0.1+102.4c7fcc3/lldp/l2_packet.h --- old/open-lldp-v1.0.1+56.cb81e95/lldp/l2_packet.h 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/lldp/l2_packet.h 2019-11-04 18:38:38.000000000 +0100 @@ -37,7 +37,9 @@ #define IP2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] #define IPSTR "%02x:%02x:%02x:%02x:%02x:%02x" +#ifndef ETH_P_LLDP #define ETH_P_LLDP 0x88cc +#endif #define ETH_P_ECP 0x88b7 /* Draft 0.2 */ #define ETH_P_ECP22 0x8940 /* Ratified standard */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/lldp/l2_packet_linux.c new/open-lldp-v1.0.1+102.4c7fcc3/lldp/l2_packet_linux.c --- old/open-lldp-v1.0.1+56.cb81e95/lldp/l2_packet_linux.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/lldp/l2_packet_linux.c 2019-11-04 18:38:38.000000000 +0100 @@ -169,7 +169,7 @@ if (l2 == NULL) return NULL; memset(l2, 0, sizeof(*l2)); - strncpy(l2->ifname, ifname, sizeof(l2->ifname)); + STRNCPY_TERMINATED(l2->ifname, ifname, sizeof(l2->ifname)); l2->rx_callback = rx_callback; l2->rx_callback_ctx = rx_callback_ctx; l2->l2_hdr = l2_hdr; @@ -183,7 +183,7 @@ return NULL; } - strncpy(ifr.ifr_name, l2->ifname, sizeof(ifr.ifr_name)); + STRNCPY_TERMINATED(ifr.ifr_name, l2->ifname, sizeof(ifr.ifr_name)); if (ioctl(l2->fd, SIOCGIFINDEX, &ifr) < 0) { perror("ioctl[SIOCGIFINDEX]"); close(l2->fd); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/lldp_8021qaz.c new/open-lldp-v1.0.1+102.4c7fcc3/lldp_8021qaz.c --- old/open-lldp-v1.0.1+56.cb81e95/lldp_8021qaz.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/lldp_8021qaz.c 2019-11-04 18:38:38.000000000 +0100 @@ -50,6 +50,7 @@ struct lldp_head lldp_head; struct config_t lldpad_cfg; +extern bool read_only_8021qaz; static int ieee8021qaz_check_pending(struct port *port, struct lldp_agent *); static void run_all_sm(struct port *port, struct lldp_agent *agent); @@ -591,7 +592,7 @@ memset(tlvs->rx, 0, sizeof(*tlvs->rx)); /* Initializing the ieee8021qaz_tlvs struct */ - strncpy(tlvs->ifname, ifname, IFNAMSIZ); + STRNCPY_TERMINATED(tlvs->ifname, ifname, IFNAMSIZ); tlvs->port = port; tlvs->ieee8021qazdu = 0; l2_packet_get_own_src_addr(port->l2, tlvs->local_mac); @@ -960,6 +961,9 @@ .dcb_pad = 0 }; + if (read_only_8021qaz) + return 0; + nlsocket = nl_socket_alloc(); if (!nlsocket) { LLDPAD_WARN("%s: %s: nl_handle_alloc failed\n", @@ -1043,6 +1047,9 @@ .dcb_pad = 0 }; + if (read_only_8021qaz) + return 0; + nlsocket = nl_socket_alloc(); if (!nlsocket) { LLDPAD_WARN("%s: %s: nl_handle_alloc failed\n", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/lldp_8021qaz_clif.c new/open-lldp-v1.0.1+102.4c7fcc3/lldp_8021qaz_clif.c --- old/open-lldp-v1.0.1+56.cb81e95/lldp_8021qaz_clif.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/lldp_8021qaz_clif.c 2019-11-04 18:38:38.000000000 +0100 @@ -251,40 +251,70 @@ static void ieee8021qaz_print_app_tlv(u16 len, char *info) { - u16 offset = 2; - u8 app; - u16 proto; + u8 app, app_idx, app_prio, app_sel; + u16 proto, offset = 2; + u8 dscp[MAX_USER_PRIORITIES][MAX_APP_ENTRIES]; + u8 dscp_count[MAX_USER_PRIORITIES] = {0}; + u8 i, j; + bool first_app = true; while (offset < len*2) { hexstr2bin(info + offset, &app, 1); hexstr2bin(info + offset + 2, (u8 *)&proto, 2); - if (offset > 6) - printf("\t"); - printf("App#%i:\n", offset/6); - printf("\t Priority: %i\n", (app & 0xE0) >> 5); - printf("\t Sel: %i\n", app & 0x07); - switch (app & 0x07) { - case 1: - printf("\t Ethertype: 0x%04x\n", ntohs(proto)); - break; - case 2: - printf("\t {S}TCP Port: %i\n", ntohs(proto)); - break; - case 3: - printf("\t UDP or DCCP Port: %i\n", ntohs(proto)); - break; - case 4: - printf("\t TCP/STCP/UDP/DCCP Port: %i\n", ntohs(proto)); - break; - default: - printf("\t Reserved Port: %i\n", ntohs(proto)); - break; + app_idx = offset/6; + app_prio = (app & 0xE0) >> 5; + app_sel = app & 0x07; + + // Selector five is DSCP. Save value to print table at the end + if (app_sel == 5) { + dscp[app_prio][dscp_count[app_prio]] = ntohs(proto) & 0x3F; + dscp_count[app_prio]++; + } else { + if (first_app) + first_app = false; + else + printf("\t"); + printf("App# %3i \t Prio %1i \t Sel %1i \t P-ID", + app_idx, app_prio, app_sel); + + switch (app_sel) { + case 1: + printf("\t Ethertype: 0x%04x\n", ntohs(proto)); + break; + case 2: + printf("\t {S}TCP Port: %i\n", ntohs(proto)); + break; + case 3: + printf("\t UDP or DCCP Port: %i\n", ntohs(proto)); + break; + case 4: + printf("\t TCP/STCP/UDP/DCCP Port: %i\n", ntohs(proto)); + break; + default: + printf("\t Reserved Port: %i\n", ntohs(proto)); + break; + } } - printf("\n"); offset += 6; } + + for(i=0; i<MAX_USER_PRIORITIES; i++) { + if (dscp_count[i] == 0) + continue; + + if (first_app) + first_app = false; + else + printf("\t"); + printf("Prio:%i \t dscp: ", i); + + for(j=0; j<dscp_count[i]; j++) { + printf(" %02i,", dscp[i][j]); + } + printf("\b \n"); + } } int ieee8021qaz_print_tlv(u32 tlvid, u16 len, char *info) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/lldp_8023.c new/open-lldp-v1.0.1+102.4c7fcc3/lldp_8023.c --- old/open-lldp-v1.0.1+56.cb81e95/lldp_8023.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/lldp_8023.c 2019-11-04 18:38:38.000000000 +0100 @@ -447,7 +447,7 @@ goto out_err; } memset(bd, 0, sizeof(struct ieee8023_data)); - strncpy(bd->ifname, ifname, IFNAMSIZ); + STRNCPY_TERMINATED(bd->ifname, ifname, IFNAMSIZ); bd->agenttype = agent->type; if (ieee8023_bld_tlv(bd, agent)) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/lldp_basman.c new/open-lldp-v1.0.1+102.4c7fcc3/lldp_basman.c --- old/open-lldp-v1.0.1+56.cb81e95/lldp_basman.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/lldp_basman.c 2019-11-04 18:38:38.000000000 +0100 @@ -679,7 +679,7 @@ goto out_err; } memset(bd, 0, sizeof(struct basman_data)); - strncpy(bd->ifname, ifname, IFNAMSIZ); + STRNCPY_TERMINATED(bd->ifname, ifname, IFNAMSIZ); bd->agenttype = agent->type; if (basman_bld_tlv(bd, agent)) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/lldp_basman_cmds.c new/open-lldp-v1.0.1+102.4c7fcc3/lldp_basman_cmds.c --- old/open-lldp-v1.0.1+56.cb81e95/lldp_basman_cmds.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/lldp_basman_cmds.c 2019-11-04 18:38:38.000000000 +0100 @@ -51,6 +51,9 @@ static int get_arg_tlvtxenable(struct cmd *, char *, char *, char *, int); static int set_arg_tlvtxenable(struct cmd *, char *, char *, char *, int); static int test_arg_tlvtxenable(struct cmd *, char *, char *, char *, int); +static int get_arg_info(struct cmd *, char *, char *, char *, int); +static int set_arg_info(struct cmd *, char *, char *, char *, int); +static int test_arg_info(struct cmd *, char *, char *, char *, int); static struct arg_handlers arg_handlers[] = { { .arg = ARG_IPV4_ADDR, .arg_class = TLV_ARG, @@ -65,6 +68,10 @@ .handle_get = get_arg_tlvtxenable, .handle_set = set_arg_tlvtxenable, .handle_test = test_arg_tlvtxenable }, + { .arg = ARG_TLVINFO, .arg_class = TLV_ARG, + .handle_get = get_arg_info, + .handle_set = set_arg_info, + .handle_test = test_arg_info }, { .arg = 0 } }; @@ -166,6 +173,89 @@ return _set_arg_tlvtxenable(cmd, arg, argvalue, obuf, obuf_len, true); } +static int get_arg_info(struct cmd *cmd, char *arg, UNUSED char *argvalue, + char *obuf, int obuf_len) +{ + const char *info_str = NULL; + char arg_path[256]; + + if (cmd->cmd != cmd_gettlv) + return cmd_invalid; + + switch (cmd->tlvid) { + case PORT_DESCRIPTION_TLV: + case SYSTEM_NAME_TLV: + case SYSTEM_DESCRIPTION_TLV: + case SYSTEM_CAPABILITIES_TLV: + case MANAGEMENT_ADDRESS_TLV: + snprintf(arg_path, sizeof(arg_path), "%s%08x.%s", + TLVID_PREFIX, cmd->tlvid, arg); + + get_config_setting(cmd->ifname, cmd->type, arg_path, + &info_str, CONFIG_TYPE_STRING); + break; + case INVALID_TLVID: + return cmd_invalid; + default: + return cmd_not_applicable; + } + + if (info_str) + snprintf(obuf, obuf_len, "%02x%s%04x%s", + (unsigned int)strlen(arg), arg, + (unsigned int)strlen(info_str), info_str); + + return cmd_success; +} + +static int _set_arg_info(struct cmd *cmd, UNUSED char *arg, char *argvalue, + char *obuf, int obuf_len, bool test) +{ + if (cmd->cmd != cmd_settlv) + return cmd_invalid; + + switch (cmd->tlvid) { + case PORT_DESCRIPTION_TLV: + case SYSTEM_NAME_TLV: + case SYSTEM_DESCRIPTION_TLV: + case SYSTEM_CAPABILITIES_TLV: + case MANAGEMENT_ADDRESS_TLV: + break; + case INVALID_TLVID: + return cmd_invalid; + default: + return cmd_not_applicable; + } + + if (strlen(argvalue) < 1) + return cmd_invalid; + + if (test) + return cmd_success; + + if (set_config_tlvinfo_str(cmd->ifname, cmd->type, + cmd->tlvid, argvalue)) + return cmd_failed; + + snprintf(obuf, obuf_len, "enableTx = %s\n", argvalue); + + somethingChangedLocal(cmd->ifname, cmd->type); + + return cmd_success; +} + +static int set_arg_info(struct cmd *cmd, char *arg, char *argvalue, + char *obuf, int obuf_len) +{ + return _set_arg_info(cmd, arg, argvalue, obuf, obuf_len, false); +} + +static int test_arg_info(struct cmd *cmd, char *arg, char *argvalue, + char *obuf, int obuf_len) +{ + return _set_arg_info(cmd, arg, argvalue, obuf, obuf_len, true); +} + struct arg_handlers *basman_get_arg_handlers() { return &arg_handlers[0]; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/lldp_dcbx.c new/open-lldp-v1.0.1+102.4c7fcc3/lldp_dcbx.c --- old/open-lldp-v1.0.1+56.cb81e95/lldp_dcbx.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/lldp_dcbx.c 2019-11-04 18:38:38.000000000 +0100 @@ -582,7 +582,7 @@ memset(manifest, 0, sizeof(*manifest)); tlvs->manifest = manifest; - strncpy(tlvs->ifname, ifname, IFNAMSIZ); + STRNCPY_TERMINATED(tlvs->ifname, ifname, IFNAMSIZ); tlvs->port = port; tlvs->dcbdu = 0; tlvs->dcbx_st = gdcbx_subtype & MASK_DCBX_FORCE; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/lldp_dcbx_nl.c new/open-lldp-v1.0.1+102.4c7fcc3/lldp_dcbx_nl.c --- old/open-lldp-v1.0.1+56.cb81e95/lldp_dcbx_nl.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/lldp_dcbx_nl.c 2019-11-04 18:38:38.000000000 +0100 @@ -561,7 +561,7 @@ seq = nlh->nlmsg_seq; - strncpy(name, ifname, sizeof(name)); + STRNCPY_TERMINATED (name, ifname, sizeof(name)); add_rta(nlh, DCB_ATTR_IFNAME, (void *)name, strlen(name) + 1); rta_parent = add_rta(nlh, DCB_ATTR_NUMTCS, NULL, 0); @@ -801,17 +801,6 @@ return(recv_msg(DCB_CMD_SAPP, DCB_ATTR_APP, seq)); } -int run_cmd(char *cmd, ...) -{ - char cbuf[128]; - va_list args; - - va_start(args, cmd); - vsprintf(cbuf, cmd, args); - va_end(args); - return system(cbuf); -} - int set_hw_all(char *ifname) { struct nlmsghdr *nlh; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/lldp_evb.c new/open-lldp-v1.0.1+102.4c7fcc3/lldp_evb.c --- old/open-lldp-v1.0.1+56.cb81e95/lldp_evb.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/lldp_evb.c 2019-11-04 18:38:38.000000000 +0100 @@ -342,7 +342,7 @@ __func__, ifname, agent->type, sizeof(*ed)); return; } - strncpy(ed->ifname, ifname, IFNAMSIZ); + STRNCPY_TERMINATED(ed->ifname, ifname, IFNAMSIZ); ed->agenttype = agent->type; evb_init_tlv(ed, agent); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/lldp_evb22.c new/open-lldp-v1.0.1+102.4c7fcc3/lldp_evb22.c --- old/open-lldp-v1.0.1+56.cb81e95/lldp_evb22.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/lldp_evb22.c 2019-11-04 18:38:38.000000000 +0100 @@ -450,7 +450,7 @@ __func__, ifname, agent->type, sizeof *ed); return; } - strncpy(ed->ifname, ifname, IFNAMSIZ); + 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); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/lldp_mand.c new/open-lldp-v1.0.1+102.4c7fcc3/lldp_mand.c --- old/open-lldp-v1.0.1+56.cb81e95/lldp_mand.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/lldp_mand.c 2019-11-04 18:38:38.000000000 +0100 @@ -100,7 +100,7 @@ static int mand_bld_mac_chassis(struct mand_data *md, struct tlv_info_chassis *chassis) { - get_mac(md->ifname, chassis->id.mac); + get_mac(md->ifname, chassis->id.mac, false); if (is_valid_mac(chassis->id.mac)) chassis->sub = CHASSIS_ID_MAC_ADDRESS; return sizeof(chassis->id.mac) + sizeof(chassis->sub); @@ -112,11 +112,13 @@ { unsigned int len; - if (!get_ipaddr(md->ifname, &chassis->id.na.ip.v4)) { + void *v4_ptr = &chassis->id.na.ip.v4; + void *v6_ptr = &chassis->id.na.ip.v6; + if (!get_ipaddr(md->ifname, v4_ptr)) { chassis->sub = CHASSIS_ID_NETWORK_ADDRESS; chassis->id.na.type = MANADDR_IPV4; len = sizeof(chassis->id.na.ip.v4); - } else if (!get_ipaddr6(md->ifname, &chassis->id.na.ip.v6)) { + } else if (!get_ipaddr6(md->ifname, v6_ptr)) { chassis->sub = CHASSIS_ID_NETWORK_ADDRESS; chassis->id.na.type = MANADDR_IPV6; len = sizeof(chassis->id.na.ip.v6); @@ -363,7 +365,7 @@ switch (subtype) { default: case PORT_ID_MAC_ADDRESS: - get_mac(md->ifname, portid.id.mac); + get_mac(md->ifname, portid.id.mac, true); if (is_valid_mac(portid.id.mac)) { portid.sub = PORT_ID_MAC_ADDRESS; length = sizeof(portid.id.mac) + @@ -371,9 +373,10 @@ break; } /* FALLTHROUGH */ - case PORT_ID_NETWORK_ADDRESS: + case PORT_ID_NETWORK_ADDRESS: { /* uses ipv4 first */ - if (!get_ipaddr(md->ifname, &portid.id.na.ip.v4)) { + void *v4_ptr = &portid.id.na.ip.v4; + if (!get_ipaddr(md->ifname, v4_ptr)) { portid.sub = PORT_ID_NETWORK_ADDRESS; portid.id.na.type = MANADDR_IPV4; length = sizeof(portid.id.na.type) + @@ -382,7 +385,8 @@ break; } /* ipv4 fails, get ipv6 */ - if (!get_ipaddr6(md->ifname, &portid.id.na.ip.v6)) { + void *v6_ptr = &portid.id.na.ip.v6; + if (!get_ipaddr6(md->ifname, v6_ptr)) { portid.sub = PORT_ID_NETWORK_ADDRESS; portid.id.na.type = MANADDR_IPV6; length = sizeof(portid.id.na.type) + @@ -390,6 +394,7 @@ sizeof(portid.sub); break; } + } /* FALLTHROUGH */ case PORT_ID_INTERFACE_NAME: portid.sub = PORT_ID_INTERFACE_NAME; @@ -600,7 +605,7 @@ return; } memset(md, 0, sizeof(struct mand_data)); - strncpy(md->ifname, ifname, IFNAMSIZ); + STRNCPY_TERMINATED(md->ifname, ifname, IFNAMSIZ); md->agenttype = agent->type; mud = find_module_user_data_by_id(&lldp_head, LLDP_MOD_MAND); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/lldp_mand_cmds.c new/open-lldp-v1.0.1+102.4c7fcc3/lldp_mand_cmds.c --- old/open-lldp-v1.0.1+56.cb81e95/lldp_mand_cmds.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/lldp_mand_cmds.c 2019-11-04 18:38:38.000000000 +0100 @@ -44,6 +44,9 @@ #include "lldp/states.h" #include "lldp_util.h" #include "messages.h" +#include "lldp_8021qaz.h" + +extern bool read_only_8021qaz; static int get_arg_adminstatus(struct cmd *, char *, char *, char *, int); static int set_arg_adminstatus(struct cmd *, char *, char *, char *, int); @@ -595,6 +598,9 @@ continue; if (!(ah = np->ops->get_arg_handler())) continue; + /* 8021QAZ set operations not allowed in read-only mode */ + if (np->id == LLDP_MOD_8021QAZ && read_only_8021qaz) + return cmd_no_access; while (ah->arg) { if (!strcasecmp(ah->arg, arg) && ah->handle_test) { rval = ah->handle_test(cmd, ah->arg, argvalue, @@ -625,6 +631,9 @@ continue; if (!(ah = np->ops->get_arg_handler())) continue; + /* 8021QAZ set operations not allowed in read-only mode */ + if (np->id == LLDP_MOD_8021QAZ && read_only_8021qaz) + return cmd_no_access; while (ah->arg) { if (!strcasecmp(ah->arg, arg) && ah->handle_set) { rval = ah->handle_set(cmd, ah->arg, argvalue, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/lldp_med.c new/open-lldp-v1.0.1+102.4c7fcc3/lldp_med.c --- old/open-lldp-v1.0.1+56.cb81e95/lldp_med.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/lldp_med.c 2019-11-04 18:38:38.000000000 +0100 @@ -905,7 +905,7 @@ goto out_err; } memset(md, 0, sizeof(struct med_data)); - strncpy(md->ifname, ifname, IFNAMSIZ); + STRNCPY_TERMINATED(md->ifname, ifname, IFNAMSIZ); md->agenttype = agent->type; if (med_bld_tlv(md, agent)) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/lldp_util.c new/open-lldp-v1.0.1+102.4c7fcc3/lldp_util.c --- old/open-lldp-v1.0.1+56.cb81e95/lldp_util.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/lldp_util.c 2019-11-04 18:38:38.000000000 +0100 @@ -366,7 +366,7 @@ fd = get_ioctl_socket(); if (fd >= 0) { memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + STRNCPY_TERMINATED(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFFLAGS, &ifr) == 0) flags = ifr.ifr_flags; } @@ -402,7 +402,7 @@ fd = get_ioctl_socket(); if (fd >= 0) { memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + STRNCPY_TERMINATED(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFPFLAGS, &ifr) == 0) flags = ifr.ifr_flags; } @@ -486,7 +486,7 @@ memset(&ifr, 0, sizeof(ifr)); memset(&ifb, 0, sizeof(ifb)); - strncpy(ifr.ifr_name, ifmaster, IFNAMSIZ); + STRNCPY_TERMINATED(ifr.ifr_name, ifmaster, IFNAMSIZ); ifr.ifr_data = (caddr_t)&ifb; if (ioctl(fd, SIOCBONDINFOQUERY, &ifr)) goto out_done; @@ -516,7 +516,7 @@ fd = get_ioctl_socket(); if (fd >= 0) { memset(&ifreq, 0, sizeof(ifreq)); - strncpy(ifreq.ifr_name, ifname, IFNAMSIZ); + STRNCPY_TERMINATED(ifreq.ifr_name, ifname, IFNAMSIZ); if (ioctl(fd, SIOCGIFINDEX, &ifreq) == 0) idx = ifreq.ifr_ifindex; } @@ -588,7 +588,7 @@ (unsigned long) &bi, 0, 0 }; ifr.ifr_data = (char *)args; - strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + STRNCPY_TERMINATED(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCDEVPRIVATE, &ifr) == 0) rc = 1; } @@ -626,7 +626,7 @@ if (fd >= 0) { memset(&ifv, 0, sizeof(ifv)); ifv.cmd = GET_VLAN_REALDEV_NAME_CMD; - strncpy(ifv.device1, ifname, sizeof(ifv.device1)); + STRNCPY_TERMINATED(ifv.device1, ifname, sizeof(ifv.device1)); if (ioctl(fd, SIOCGIFVLAN, &ifv) == 0) rc = 1; } @@ -653,7 +653,7 @@ fd = get_ioctl_socket(); if (fd >= 0) { memset(&iwreq, 0, sizeof(iwreq)); - strncpy(iwreq.ifr_name, ifname, sizeof(iwreq.ifr_name)); + STRNCPY_TERMINATED(iwreq.ifr_name, ifname, sizeof(iwreq.ifr_name)); if (ioctl(fd, SIOCGIWNAME, &iwreq) == 0) rc = 1; } @@ -666,6 +666,8 @@ { [IFLA_INFO_KIND] = { .type = NLA_STRING}, [IFLA_INFO_DATA] = { .type = NLA_NESTED }, + [IFLA_INFO_SLAVE_KIND] = { .type = NLA_STRING}, + [IFLA_INFO_SLAVE_DATA] = { .type = NLA_NESTED }, }; int is_macvtap(const char *ifname) @@ -770,7 +772,7 @@ fd = get_ioctl_socket(); if (fd >= 0) { memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + STRNCPY_TERMINATED(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFFLAGS, &ifr) == 0) if (ifr.ifr_flags & IFF_UP) rc = 1; @@ -791,7 +793,7 @@ memset(&cmd, 0, sizeof(cmd)); cmd.cmd = ETHTOOL_GSET; ifr.ifr_data = &cmd; - strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + STRNCPY_TERMINATED(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCETHTOOL, &ifr) == 0) if (cmd.supported & SUPPORTED_Autoneg) rc = 1; @@ -812,7 +814,7 @@ memset(&cmd, 0, sizeof(cmd)); cmd.cmd = ETHTOOL_GSET; ifr.ifr_data = &cmd; - strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + STRNCPY_TERMINATED(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCETHTOOL, &ifr) == 0) rc = cmd.autoneg; } @@ -849,7 +851,7 @@ memset(&cmd, 0, sizeof(cmd)); cmd.cmd = ETHTOOL_GSET; ifr.ifr_data = &cmd; - strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + STRNCPY_TERMINATED(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCETHTOOL, &ifr) == 0) { if (cmd.advertising & ADVERTISED_10baseT_Half) caps |= MAUCAPADV_b10baseT; @@ -888,7 +890,7 @@ memset(&cmd, 0, sizeof(cmd)); cmd.cmd = ETHTOOL_GSET; ifr.ifr_data = &cmd; - strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + STRNCPY_TERMINATED(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCETHTOOL, &ifr) == 0) { /* TODO: too many dot3MauTypes, * should check duplex, speed, and port */ @@ -915,7 +917,7 @@ fd = get_ioctl_socket(); if (fd >= 0) { memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + STRNCPY_TERMINATED(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFMTU, &ifr) == 0) rc = ifr.ifr_mtu; } @@ -937,38 +939,86 @@ return mfs; } -int get_mac(const char *ifname, u8 mac[]) +int get_mac(const char *ifname, u8 mac[], bool perm_mac) { - int fd; - int rc = EINVAL; - struct ifreq ifr; + int ret, s; + struct nlmsghdr *nlh; + struct ifinfomsg *ifinfo; + struct nlattr *tb[IFLA_MAX+1], + *tb2[IFLA_INFO_MAX+1]; - memset(mac, 0, 6); - fd = get_ioctl_socket(); - if (fd >= 0) { - ifr.ifr_addr.sa_family = AF_INET; - strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); - if (!ioctl(fd, SIOCGIFHWADDR, &ifr)) { - memcpy(mac, ifr.ifr_hwaddr.sa_data, 6); - rc = 0; - } + s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE); + + if (s < 0) { + goto out; } - return rc; -} -int get_macstr(const char *ifname, char *addr, size_t size) -{ - u8 mac[6]; - int rc; + nlh = malloc(NLMSG_SIZE); - rc = get_mac(ifname, mac); - if (rc == 0) { - snprintf(addr, size, "%02x:%02x:%02x:%02x:%02x:%02x", - mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + if (!nlh) { + goto out; } - return rc; -} + memset(nlh, 0, NLMSG_SIZE); + + nlh->nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)); + nlh->nlmsg_type = RTM_GETLINK; + nlh->nlmsg_flags = NLM_F_REQUEST; + + ifinfo = NLMSG_DATA(nlh); + ifinfo->ifi_family = AF_UNSPEC; + ifinfo->ifi_index = get_ifidx(ifname); + + ret = send(s, nlh, nlh->nlmsg_len, 0); + + if (ret < 0) { + goto out_free; + } + + memset(nlh, 0, NLMSG_SIZE); + + do { + ret = recv(s, (void *) nlh, NLMSG_SIZE, MSG_DONTWAIT); + } while ((ret < 0) && errno == EINTR); + + if (nlmsg_parse(nlh, sizeof(struct ifinfomsg), + (struct nlattr **)&tb, IFLA_MAX, NULL)) { + goto out_free; + } + + if (tb[IFLA_ADDRESS]) + memcpy(mac, (char*)(RTA_DATA(tb[IFLA_ADDRESS])), 6); + + /* Check for the permanent mac address on bonding slaves */ + if (perm_mac && tb[IFLA_LINKINFO]) { + char *kind; + struct nlattr *tb3; + int off = 0; + + if (nla_parse_nested(tb2, IFLA_INFO_MAX, tb[IFLA_LINKINFO], + ifla_info_policy)) { + goto out_free; + } + if (!tb2[IFLA_INFO_SLAVE_KIND]) + goto out_free; + + kind = (char*)(RTA_DATA(tb2[IFLA_INFO_SLAVE_KIND])); + if (strcmp(kind, "bond") && !tb2[IFLA_INFO_SLAVE_DATA]) + goto out_free; + + nla_for_each_nested(tb3, tb2[IFLA_INFO_SLAVE_DATA], off) { + if (nla_type(tb3) == IFLA_BOND_SLAVE_PERM_HWADDR) { + memcpy(mac, nla_data(tb3), nla_len(tb3)); + } + } + } + +out_free: + free(nlh); +out: + close(s); + return 0; +} u16 get_caps(const char *ifname) { @@ -1014,7 +1064,7 @@ fd = get_ioctl_socket(); if (fd >= 0) { ifr.ifr_addr.sa_family = AF_INET; - strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + STRNCPY_TERMINATED(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) { memcpy(saddr, &ifr.ifr_addr, sizeof(*saddr)); rc = 0; @@ -1055,9 +1105,11 @@ rc = getifaddrs(&ifaddr); if (rc == 0) { + rc = -1; for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { - if ((ifa->ifa_addr->sa_family == AF_INET6) && - (strncmp(ifa->ifa_name, ifname, IFNAMSIZ) == 0)) { + if (strncmp(ifa->ifa_name, ifname, IFNAMSIZ)) + continue; + if (ifa->ifa_addr && (ifa->ifa_addr->sa_family == AF_INET6)) { memcpy(saddr, ifa->ifa_addr, sizeof(*saddr)); rc = 0; break; @@ -1108,7 +1160,7 @@ else if (domain == AF_INET6) return get_ipaddr6(ifname, (struct in6_addr *)buf); else if (domain == AF_UNSPEC) - return get_mac(ifname, (u8 *)buf); + return get_mac(ifname, (u8 *)buf, false); else return -1; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/lldpad.c new/open-lldp-v1.0.1+102.4c7fcc3/lldpad.c --- old/open-lldp-v1.0.1+56.cb81e95/lldpad.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/lldpad.c 2019-11-04 18:38:38.000000000 +0100 @@ -84,6 +84,7 @@ bool daemonize = 0; int loglvl = LOG_WARNING; int omit_tstamp; +bool read_only_8021qaz = false; static const char *lldpad_version = "lldpad v" VERSION_STR "\n" @@ -136,7 +137,8 @@ " -t omit timestamps in log messages\n" " -v show version\n" " -f use configfile instead of default\n" - " -V set syslog level\n"); + " -V set syslog level\n" + " -R run 8021qaz module in read_only mode\n"); exit(1); } @@ -236,7 +238,7 @@ int rc = 1; for (;;) { - c = getopt(argc, argv, "hdksptvf:V:"); + c = getopt(argc, argv, "hdksptvf:RV:"); if (c < 0) break; switch (c) { @@ -259,6 +261,9 @@ case 'p': pid_file = 0; break; + case 'R': + read_only_8021qaz = true; + break; case 't': omit_tstamp = 1; break; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/lldpad.spec.in new/open-lldp-v1.0.1+102.4c7fcc3/lldpad.spec.in --- old/open-lldp-v1.0.1+56.cb81e95/lldpad.spec.in 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/lldpad.spec.in 2019-11-04 18:38:38.000000000 +0100 @@ -10,9 +10,9 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) # BuildRequires: -Requires(post): chkconfig -Requires(preun): chkconfig initscripts -Requires(postun): initscripts +Requires(post): @SPEC_BUILD_REQUIRES_POST@ +Requires(preun): @SPEC_BUILD_REQUIRES_PREUN@ +Requires(postun): @SPEC_BUILD_REQUIRES_POSTUN@ %description This package contains the Linux user space daemon and configuration tool for @@ -46,20 +46,36 @@ %post -/sbin/chkconfig --add lldpad +if [ -e /etc/init.d/%{name} ] && [ -e /sbin/chkconfig ]; then + /sbin/chkconfig --add %{name} +fi +if type systemctl >/dev/null 2>&1; then + # Scriplet only runs preset. Run enable/start manually + %systemd_post %{name}.socket %{name}.service +fi %preun if [ $1 = 0 ]; then - /sbin/service lldpad stop - /sbin/chkconfig --del lldpad + if [ -e /etc/init.d/%{name} ] && [ -e /sbin/chkconfig ]; then + /sbin/service %{name} stop + /sbin/chkconfig --del %{name} + fi + if type systemctl >/dev/null 2>&1; then + %systemd_preun %{name}.service %{name}.socket + fi fi %postun if [ $1 = 1 ]; then - /sbin/service lldpad condrestart + # Package upgrade, not uninstall + if [ -e /etc/init.d/%{name} ] && [ -e /sbin/chkconfig ]; then + /sbin/service %{name} condrestart + fi + if type systemctl >/dev/null 2>&1; then + %systemd_postun_with_restart %{name}.socket %{name}.service + fi fi - %files %defattr(-,root,root,-) %doc COPYING @@ -67,11 +83,13 @@ %doc ChangeLog %{_sbindir}/* %dir /var/lib/lldpad -%{_sysconfdir}/init.d/lldpad +@SPEC_FILE_LLDPAD_SERVICE@ +@SPEC_FILE_LLDPAD_SOCKET@ %{_sysconfdir}/bash_completion.d/lldpad %{_sysconfdir}/bash_completion.d/lldptool %{_mandir}/man8/* %{_libdir}/liblldp_clif.* +%{_mandir}/man3/liblldp_clif-vdp22.* %files devel %defattr(-,root,root,-) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/qbg/ecp.c new/open-lldp-v1.0.1+102.4c7fcc3/qbg/ecp.c --- old/open-lldp-v1.0.1+56.cb81e95/qbg/ecp.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/qbg/ecp.c 2019-11-04 18:38:38.000000000 +0100 @@ -795,7 +795,7 @@ __func__, ifname); return -1; } - strncpy(vd->ecp.ifname, ifname, sizeof vd->ecp.ifname); + STRNCPY_TERMINATED(vd->ecp.ifname, ifname, sizeof vd->ecp.ifname); ecp_rx_change_state(vd, ECP_RX_IDLE); ecp_rx_run_sm(vd); ecp_somethingChangedLocal(vd, true); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/qbg/ecp22.c new/open-lldp-v1.0.1+102.4c7fcc3/qbg/ecp22.c --- old/open-lldp-v1.0.1+56.cb81e95/qbg/ecp22.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/qbg/ecp22.c 2019-11-04 18:38:38.000000000 +0100 @@ -749,7 +749,7 @@ ifname); return NULL; } - strncpy(ecp->ifname, ifname, sizeof ecp->ifname); + STRNCPY_TERMINATED(ecp->ifname, ifname, sizeof ecp->ifname); ecp->l2 = l2_packet_init(ecp->ifname, 0, ETH_P_ECP22, ecp22_rx_receiveframe, ecp, 1); @@ -782,6 +782,10 @@ ecp = find_ecpdata(ifname, eud); if (!ecp) ecp = ecp22_create(ifname, eud); + if (!ecp) { + LLDPAD_DBG("%s:%s failed creating ECP22 instance\n", __func__, ifname); + return; + } ecp->max_retries = ECP22_MAX_RETRIES_DEFAULT; ecp->max_rte = ECP22_ACK_TIMER_DEFAULT; LIST_INIT(&ecp->inuse.head); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/qbg/vdp.c new/open-lldp-v1.0.1+102.4c7fcc3/qbg/vdp.c --- old/open-lldp-v1.0.1+56.cb81e95/qbg/vdp.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/qbg/vdp.c 2019-11-04 18:38:38.000000000 +0100 @@ -879,7 +879,7 @@ { switch(profile->state) { case VSI_UNASSOCIATED: - if ((profile->mode == VDP_MODE_DEASSOCIATE)) /* || (INACTIVE)) */ { + if (profile->mode == VDP_MODE_DEASSOCIATE) { vdp_vsi_change_bridge_state(profile, VSI_DEASSOC_PROCESSING); return true; } else if (profile->mode == VDP_MODE_ASSOCIATE) { @@ -1607,7 +1607,7 @@ __func__, ifname, sizeof(*vd)); goto out_err; } - strncpy(vd->ifname, ifname, IFNAMSIZ); + STRNCPY_TERMINATED(vd->ifname, ifname, IFNAMSIZ); vd->role = VDP_ROLE_STATION; vd->enabletx = enabletx; @@ -1882,7 +1882,7 @@ if (!macp->req_pid) return 0; sleep(1); /* Delay message notification */ - if (!profile->port || !profile->port->ifname) { + if (!profile->port || !profile->port->ifname[0]) { LLDPAD_ERR("%s: no ifname found for profile %p:\n", __func__, profile); goto error_exit; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/qbg/vdp22.c new/open-lldp-v1.0.1+102.4c7fcc3/qbg/vdp22.c --- old/open-lldp-v1.0.1+56.cb81e95/qbg/vdp22.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/qbg/vdp22.c 2019-11-04 18:38:38.000000000 +0100 @@ -834,7 +834,7 @@ ifname); return NULL; } - strncpy(vdp->ifname, ifname, sizeof vdp->ifname); + STRNCPY_TERMINATED(vdp->ifname, ifname, sizeof vdp->ifname); vdp->myrole = role; LIST_INIT(&vdp->vsi22_que); LIST_INSERT_HEAD(&eud->head, vdp, node); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/qbg/vdp22_cmds.c new/open-lldp-v1.0.1+102.4c7fcc3/qbg/vdp22_cmds.c --- old/open-lldp-v1.0.1+56.cb81e95/qbg/vdp22_cmds.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/qbg/vdp22_cmds.c 2019-11-04 18:38:38.000000000 +0100 @@ -577,7 +577,7 @@ memset(&vsi, 0, sizeof(vsi)); memset(vsi_str, 0, sizeof(vsi_str)); vsi.request = cmd->tlvid; - strncpy(vsi.ifname, cmd->ifname, sizeof(vsi.ifname) - 1); + strncpy(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)); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/qbg/vdpnl.c new/open-lldp-v1.0.1+102.4c7fcc3/qbg/vdpnl.c --- old/open-lldp-v1.0.1+56.cb81e95/qbg/vdpnl.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/qbg/vdpnl.c 2019-11-04 18:38:38.000000000 +0100 @@ -233,7 +233,7 @@ vsi->ifindex = ifinfo->ifi_index; if (tb[IFLA_IFNAME]) - strncpy(vsi->ifname, (char *)RTA_DATA(tb[IFLA_IFNAME]), + STRNCPY_TERMINATED(vsi->ifname, (char *)RTA_DATA(tb[IFLA_IFNAME]), sizeof vsi->ifname); else { if (!if_indextoname(ifinfo->ifi_index, vsi->ifname)) { @@ -304,9 +304,9 @@ size_t needed; needed = nla_total_size(sizeof(struct nlattr)) /* IFLA_VF_PORT */ - + nla_total_size(4); /* IFLA_PORT_VF */ - + nla_total_size(PORT_UUID_MAX); /* IFLA_PORT_INSTANCE_UUID */ - + nla_total_size(2); /* IFLA_PORT_RESPONSE */ + + nla_total_size(4) /* IFLA_PORT_VF */ + + nla_total_size(PORT_UUID_MAX) /* IFLA_PORT_INSTANCE_UUID */ + + nla_total_size(2); /* IFLA_PORT_RESPONSE */ return needed; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/test-driver new/open-lldp-v1.0.1+102.4c7fcc3/test-driver --- old/open-lldp-v1.0.1+56.cb81e95/test-driver 1970-01-01 01:00:00.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/test-driver 2019-11-21 12:57:35.690547705 +0100 @@ -0,0 +1 @@ +symbolic link to /usr/share/automake-1.13/test-driver diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/open-lldp-v1.0.1+56.cb81e95/vdptool.c new/open-lldp-v1.0.1+102.4c7fcc3/vdptool.c --- old/open-lldp-v1.0.1+56.cb81e95/vdptool.c 2018-12-10 17:24:17.000000000 +0100 +++ new/open-lldp-v1.0.1+102.4c7fcc3/vdptool.c 2019-11-04 18:38:38.000000000 +0100 @@ -36,6 +36,7 @@ * set and query VSI profile settings. */ +#define _GNU_SOURCE #include <stdlib.h> #include <stdio.h> #include <unistd.h> @@ -178,7 +179,7 @@ static void fill_oui_hdr(vdptool_oui_data_t *oui_data, char *oui_name) { - strncpy(oui_data->oui_name, oui_name, sizeof(oui_data->oui_name)); + STRNCPY_TERMINATED(oui_data->oui_name, oui_name, sizeof(oui_data->oui_name)); snprintf(oui_data->data, sizeof(oui_data->data), "%02x%s", (unsigned int)strlen(oui_data->oui_name), oui_data->oui_name); }