Hello community,

here is the log from the commit of package lldpad.1044 for openSUSE:12.1:Update 
checked in at 2012-11-12 17:43:09
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:12.1:Update/lldpad.1044 (Old)
 and      /work/SRC/openSUSE:12.1:Update/.lldpad.1044.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "lldpad.1044", Maintainer is ""

Changes:
--------
New Changes file:

--- /dev/null   2012-10-22 00:44:18.403455820 +0200
+++ /work/SRC/openSUSE:12.1:Update/.lldpad.1044.new/lldpad.changes      
2012-11-12 17:43:11.000000000 +0100
@@ -0,0 +1,41 @@
+-------------------------------------------------------------------
+Sat Oct 27 18:41:35 UTC 2012 - ldun...@suse.com
+
+- Added lldpad-remove-var-lock-subsys-use.patch: remove use of
+  /var/lock/subsys in init file (bnc#714646)
+
+-------------------------------------------------------------------
+Tue Jul  6 10:53:00 CEST 2010 - h...@suse.de
+
+- Port rpm from SLES11 SP1.
+
+-------------------------------------------------------------------
+Fri May  7 16:02:31 CEST 2010 - h...@suse.de
+
+- Remove 'fix link flap' patch (bnc#603580)
+
+-------------------------------------------------------------------
+Mon Apr 26 13:53:10 CEST 2010 - h...@suse.de
+
+- Patches from bnc#599107:
+  * fix race condition by opening client socket earlier
+  * fix error in construction of the Priority Group TLV
+  * fix link flap
+  * fix segfault when handling lldptool arguments
+  * fix buffer overflow in lldp-med inventory string
+
+-------------------------------------------------------------------
+Fri Mar 26 11:50:46 CET 2010 - ku...@suse.de
+
+- Fix requires of -devel subpackage
+
+-------------------------------------------------------------------
+Wed Mar 24 16:00:04 CET 2010 - h...@suse.de
+
+- Fixup mkinitrd setup script to always create /var/lib/lldpad
+
+-------------------------------------------------------------------
+Tue Mar 23 15:11:03 CET 2010 - h...@suse.de
+
+- Obsolete dcbd by lldpad version 0.9.32 (bnc#590487)
+

New:
----
  lldpad-0.9.32-compile-fixes
  lldpad-0.9.32-fix-buffer-overflow
  lldpad-0.9.32-fix-error-in-pgid-construction
  lldpad-0.9.32-fix-lldptool-segfault
  lldpad-0.9.32-fix-race-condition
  lldpad-0.9.32.tar.bz2
  lldpad-init-script-fixup
  lldpad-makefile-fixup
  lldpad-remove-var-lock-subsys-use.patch
  lldpad.changes
  lldpad.spec
  mkinitrd-boot.sh
  mkinitrd-setup.sh
  mkinitrd-stop.sh

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ lldpad.spec ++++++
#
# spec file for package lldpad
#
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#


Name:           lldpad
Summary:        Link Layer Discovery Protocol (LLDP) Agent
License:        GPL-2.0
Group:          System/Daemons
Version:        0.9.32
Release:        0
BuildRequires:  bison
BuildRequires:  flex
BuildRequires:  pkgconfig
Url:            
http://www.intel.com/network/connectivity/products/server_adapters.htm
Source:         
http://downloads.sourceforge.net/e1000/%{name}-%{version}.tar.bz2
Source20:       mkinitrd-boot.sh
Source21:       mkinitrd-stop.sh
Source22:       mkinitrd-setup.sh
Patch1:         %{name}-makefile-fixup
Patch2:         %{name}-init-script-fixup
Patch3:         %{name}-%{version}-compile-fixes
Patch10:        %{name}-%{version}-fix-race-condition
Patch11:        %{name}-%{version}-fix-error-in-pgid-construction
Patch13:        %{name}-%{version}-fix-lldptool-segfault
Patch14:        %{name}-%{version}-fix-buffer-overflow
Patch15:        %{name}-remove-var-lock-subsys-use.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Provides:       dcbd = %{version}
Obsoletes:      dcbd < %{version}

%description
This package contains the Link Layer Discovery Protocol (LLDP) Agent
with Data Center Bridging (DCB) for Intel(R) Network Connections
'lldpad' plus the configuration tools 'dcbtool' and 'lldptool'.



Authors:
--------
    e1000-eedc Mailing List <e1000-e...@lists.sourceforge.net>
    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497

%package devel
Summary:        Link Layer Discovery Protocol (LLDP) Agent
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}

%description devel
This package contains the Link Layer Discovery Protocol (LLDP) Agent
with Data Center Bridging (DCB) for Intel(R) Network Connections
'lldpad' plus the configuration tools 'dcbtool' and 'lldptool'.



Authors:
--------
    e1000-eedc Mailing List <e1000-e...@lists.sourceforge.net>
    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497

%prep
%setup
%patch1 -p0
%patch2 -p1
%patch3 -p1
%patch10 -p1
%patch11 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1

%build
autoreconf --install
%configure --disable-cxx --bindir=/bin --sbindir=/sbin
make %{?_smp_mflags}

%install
mkdir -p ${RPM_BUILD_ROOT}/var/lib/lldpad
%makeinstall
install -d ${RPM_BUILD_ROOT}/lib/mkinitrd/scripts/
install -m 755 %{S:20} ${RPM_BUILD_ROOT}/lib/mkinitrd/scripts/boot-lldpad.sh
install -m 755 %{S:21} ${RPM_BUILD_ROOT}/lib/mkinitrd/scripts/boot-killlldpad.sh
install -m 755 %{S:22} ${RPM_BUILD_ROOT}/lib/mkinitrd/scripts/setup-lldpad.sh

%post
[ -x /sbin/mkinitrd_setup ] && mkinitrd_setup
%{fillup_and_insserv -n -i lldpad}

%preun
%{stop_on_removal lldpad}

%postun
[ -x /sbin/mkinitrd_setup ] && mkinitrd_setup
%{insserv_cleanup lldpad}

%clean
rm -rf %{buildroot}

%files
%defattr(-,root,root,-)
%doc COPYING
%doc README
%doc ChangeLog
%dir /var/lib/lldpad
/sbin/*
/etc/init.d/lldpad
%{_mandir}/man8/*
/lib/mkinitrd

%files devel
%defattr(-,root,root,-)
%{_includedir}/*
%{_libdir}/pkgconfig/*.pc

%changelog
++++++ lldpad-0.9.32-compile-fixes ++++++
diff --git a/config.c b/config.c
index 67998a0..fb778c6 100644
--- a/config.c
+++ b/config.c
@@ -48,6 +48,7 @@
 #include "drv_cfg.h"
 #include "config.h"
 #include "clif_msgs.h"
+#include "eloop.h"
 #include "lldp/l2_packet.h"
 
 config_t lldpad_cfg;
@@ -559,7 +560,7 @@ int set_cfg(const char *ifname, char *path, void *value, 
int type)
  */
 int get_config_tlvfield(const char *ifname, u32 tlvid, const char *field, void 
*val, int type)
 {
-       int rc;
+       int rc = 0;
        char path[256];
 
        memset(path, 0, sizeof(path));
@@ -570,7 +571,6 @@ int get_config_tlvfield(const char *ifname, u32 tlvid, 
const char *field, void *
                rc = EIO;
                goto out_err;
        }
-       rc = 0;
 
 out_err:
        return rc;
@@ -582,7 +582,7 @@ int get_config_tlvfield_int(const char *ifname, u32 tlvid, 
const char *field, in
        int rc;
        long int val = (long int) *value;
 
-       get_config_tlvfield(ifname, tlvid, field, &val, CONFIG_TYPE_INT);
+       rc = get_config_tlvfield(ifname, tlvid, field, &val, CONFIG_TYPE_INT);
        *value = (int) val;
        return rc;
 }
diff --git a/dcb_protocol.c b/dcb_protocol.c
index 7305456..94b58cd 100644
--- a/dcb_protocol.c
+++ b/dcb_protocol.c
@@ -888,9 +888,6 @@ Exit:
 
 void remove_dcb_support(void)
 {
-       void *it_elm = NULL;
-       void *it_second = NULL;
-
        while (feature_struct.lh_first != NULL)     /* Delete. */
                features_erase(&feature_struct.lh_first);
 
@@ -1403,10 +1400,10 @@ boolean_t add_pg_defaults()
 boolean_t remove_pg_defaults()
 {
        char   sTmp[MAX_DESCRIPTION_LEN];
-       void * itp = NULL;
+       pg_it  itpg;
 
        snprintf(sTmp, MAX_DESCRIPTION_LEN, DEF_CFG_STORE);
-       pg_it itpg = pg_find(&pg, sTmp);
+       itpg = pg_find(&pg, sTmp);
        if (itpg == NULL)
                return FALSE;
 
@@ -1452,10 +1449,10 @@ boolean_t add_pfc_defaults()
 boolean_t remove_pfc_defaults()
 {
        char   sTmp[MAX_DESCRIPTION_LEN];
-       void * itp = NULL;
+       pfc_it itpfc;
 
        snprintf(sTmp, MAX_DESCRIPTION_LEN, DEF_CFG_STORE);
-       pfc_it itpfc = pfc_find(&pfc, sTmp);
+       itpfc = pfc_find(&pfc, sTmp);
        if (itpfc == NULL) {
                return FALSE;
        }
@@ -1507,11 +1504,11 @@ boolean_t add_app_defaults(u32 subtype)
 boolean_t remove_app_defaults(u32 subtype)
 {
        char   sTmp[MAX_DESCRIPTION_LEN];
-       void * itp = NULL;
+       app_it it;
 
        snprintf(sTmp, MAX_DESCRIPTION_LEN, "%s",   /* Localization OK */
                         DEF_CFG_STORE);
-       app_it it = apptlv_find(&apptlv, sTmp, subtype);
+       it = apptlv_find(&apptlv, sTmp, subtype);
 
        if (it == NULL) {
                return FALSE;
@@ -1555,11 +1552,11 @@ boolean_t add_llink_defaults(u32 subtype)
 boolean_t remove_llink_defaults(u32 subtype)
 {
        char   sTmp[MAX_DESCRIPTION_LEN];
-       void * itp = NULL;
+       llink_it itllink;
 
        snprintf(sTmp, MAX_DESCRIPTION_LEN, "%s",   /* Localization OK */
                         DEF_CFG_STORE);
-       llink_it itllink = llink_find(&llink, sTmp, subtype);
+       itllink = llink_find(&llink, sTmp, subtype);
        if (itllink == NULL) {
                return FALSE;
        }
diff --git a/drv_cfg.c b/drv_cfg.c
index d449e42..46383ec 100644
--- a/drv_cfg.c
+++ b/drv_cfg.c
@@ -38,6 +38,7 @@
 #include <linux/dcbnl.h>
 #include <errno.h>
 #include "lldpad.h"
+#include "lldp_rtnl.h"
 #include "dcb_driver_if_types.h"
 #include "dcb_driver_interface.h"
 #include "dcb_protocol.h"
diff --git a/include/lldp_rtnl.h b/include/lldp_rtnl.h
index 7b1f5c9..fc4c53d 100644
--- a/include/lldp_rtnl.h
+++ b/include/lldp_rtnl.h
@@ -25,8 +25,14 @@
 
 
*******************************************************************************/
 
+#ifndef _LLDP_RTNL_H
 #define _LLDP_RTNL_H
+
+#include "dcb_protocol.h"
+
 typedef int rtnl_handler(struct nlmsghdr *nh, void *arg);
 
 int set_operstate(char *ifname, __u8 operstate);
 int set_linkmode(char *ifname, __u8 linkmode);
+
+#endif /* _LLDP_RTNL_H */
diff --git a/lldp/ports.h b/lldp/ports.h
index 51de561..898dec2 100644
--- a/lldp/ports.h
+++ b/lldp/ports.h
@@ -170,6 +170,7 @@ int set_port_hw_resetting(const char *ifname, int 
resetting);
 int get_port_hw_resetting(const char *ifname);
 void set_lldp_port_enable_state(const char *ifname, int enable);
 void set_lldp_port_admin(const char *ifname, int enable);
+void set_port_oper_delay(const char *ifname);
 
 int get_lldp_port_statistics(char *ifname, struct portstats *stats);
 
diff --git a/lldp_dcbx_cmds.c b/lldp_dcbx_cmds.c
index 714867b..151fab4 100644
--- a/lldp_dcbx_cmds.c
+++ b/lldp_dcbx_cmds.c
@@ -34,6 +34,7 @@
 #include "dcb_events.h"
 #include "lldp_mand_clif.h"
 #include "lldp_dcbx_cmds.h"
+#include "lldp_dcbx_cfg.h"
 #include "clif_msgs.h"
 #include "dcb_protocol.h"
 #include "lldp/ports.h"
@@ -98,7 +99,6 @@ static int get_arg_tlvtxenable(struct cmd *cmd, char *arg, 
char *argvalue,
        case (OUI_CEE_DCBX << 8) | 2:
                snprintf(arg_path, sizeof(arg_path), "%s%08x.%s",
                         TLVID_PREFIX, cmd->tlvid, arg);
-               
                if (get_config_setting(cmd->ifname, arg_path, (void *)&value,
                                        CONFIG_TYPE_BOOL))
                        value = FALSE;
@@ -113,8 +113,8 @@ static int get_arg_tlvtxenable(struct cmd *cmd, char *arg, 
char *argvalue,
                s = VAL_YES;
        else
                s = VAL_NO;
-       
-       sprintf(obuf, "%02x%s%04x%s", strlen(arg), arg, strlen(s), s);
+
+       sprintf(obuf, "%02x%s%04x%s", (int)strlen(arg), arg, (int)strlen(s), s);
 
        return cmd_success;
 }
@@ -418,7 +418,6 @@ int dcbx_clif_cmd(void *data,
        u8 subtype;
        u8 plen;
        char port_id[MAX_U8_BUF];
-       struct port *port;
        pg_attribs pg_data;
        pfc_attribs pfc_data;
        app_attribs app_data;
@@ -439,7 +438,7 @@ int dcbx_clif_cmd(void *data,
 
        if (ilen < DCB_PORT_OFF)
                return dcb_invalid_cmd;
-       
+
        if (ibuf[DCB_VER_OFF] != (CLIF_MSG_VERSION | 0x30)) {
                printf("unsupported client interface message version %x\n",
                        ibuf[DCB_VER_OFF]);
diff --git a/lldp_mand.c b/lldp_mand.c
index 53ee621..2c11884 100644
--- a/lldp_mand.c
+++ b/lldp_mand.c
@@ -181,7 +181,7 @@ static int mand_bld_chassis_tlv(struct mand_data *md)
        /* check for value in shared memory first */
        if (lldpad_shm_get_msap(md->ifname, CHASSIS_ID_TLV, (char *)&chassis, 
&length))
                goto bld_tlv;
-       
+
        /* subtype may differ when LLDP-MED is enabled */
        if (!is_tlv_txenabled(md->ifname, TLVID_MED(LLDP_MED_RESERVED)))
                goto bld_config;
@@ -227,7 +227,6 @@ bld_macaddr:
        }
 
 bld_netaddr:
-bld_ipv4:
        /* uses ipv4 first */
        if (!get_ipaddr(md->ifname, &chassis.id.na.ip.v4)) {
                chassis.sub = CHASSIS_ID_NETWORK_ADDRESS; 
@@ -238,7 +237,7 @@ bld_ipv4:
 
                goto bld_tlv;
        }
-bld_ipv6:
+
        /* ipv4 fails, get ipv6 */
        if (!get_ipaddr6(md->ifname, &chassis.id.na.ip.v6)) {
                chassis.sub = CHASSIS_ID_NETWORK_ADDRESS; 
@@ -249,7 +248,6 @@ bld_ipv6:
                goto bld_tlv;
        }
 
-bld_ifname:
        /* use ifname */
        chassis.sub = CHASSIS_ID_INTERFACE_NAME;
        strncpy(chassis.id.ifname, md->ifname, IFNAMSIZ);
diff --git a/lldp_util.c b/lldp_util.c
index 13cbd62..9dd9671 100644
--- a/lldp_util.c
+++ b/lldp_util.c
@@ -983,7 +983,6 @@ int str2mac(const char *src, u8 *mac, size_t size)
 {
        int i = 0;
        int rc = -1;
-       const char *s = NULL;
 
        if (size < 6)
                goto out_err;
@@ -1005,11 +1004,12 @@ out_err:
 
 int str2addr(int domain, const char *src, void *dst, size_t size)
 {
-       if ((domain == AF_INET) || (domain == AF_INET6))
+       if ((domain == AF_INET) || (domain == AF_INET6)) {
                if (1 == inet_pton(domain, src, dst))
                        return 0;
                else
                        return -1;
+       }
 
        if (domain == AF_UNSPEC)
                return str2mac(src, (u8 *)dst, size);
@@ -1019,11 +1019,12 @@ int str2addr(int domain, const char *src, void *dst, 
size_t size)
 
 int addr2str(int domain, const void *src, char *dst, size_t size)
 {
-       if ((domain == AF_INET) || (domain == AF_INET6))
+       if ((domain == AF_INET) || (domain == AF_INET6)) {
                if (inet_ntop(domain, src, dst, size))
                        return 0;
                else
                        return -1;
+       }
 
        if (domain == AF_UNSPEC)
                return mac2str((u8 *)src, dst, size);
diff --git a/lldpad.c b/lldpad.c
index 3098ce1..250d808 100644
--- a/lldpad.c
+++ b/lldpad.c
@@ -147,7 +147,6 @@ int main(int argc, char *argv[])
        char buf[32];
        int shm_remove = 0;
        int killme = 0;
-       int rval;
        pid_t pid;
        int cnt;
 
diff --git a/nltest.c b/nltest.c
index c7e5146..5d612b4 100644
--- a/nltest.c
+++ b/nltest.c
@@ -971,7 +971,6 @@ static int get_app_cfg(char *ifname, appgroup_attribs 
*app_data)
        struct dcbmsg *d;
        struct rtattr *rta_parent, *rta_child;
        int rval = 0;
-       int i;
        unsigned int seq;
        __u8 idtype;
        __u16 id;
@@ -1051,7 +1050,6 @@ int set_hw_app(char *ifname, appgroup_attribs *app_data)
 {
        struct nlmsghdr *nlh;
        struct rtattr *rta_parent, *rta_child;
-       int i;
        int seq;
 
        printf("set_hw_app: %s\n", ifname);
++++++ lldpad-0.9.32-fix-buffer-overflow ++++++
lldpad: fix buffer overflow in med inventory string.

From: Eric Multanen <eric.w.multa...@intel.com>

MED inventory allows 32 max chars, excluding '\0', increase the buffer to be
33 to make sure we have the output string null terminated when retrieving from
the sysfs.
---

 lldp_med.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

--
Signed-off-by: Eric Multanen <eric.w.multa...@intel.com>

diff --git a/lldp_med.c b/lldp_med.c
index fd2dc8e..5405c8f 100644
--- a/lldp_med.c
+++ b/lldp_med.c
@@ -248,7 +248,7 @@ int med_read_inventory(u8 subtype, char *buf, size_t size)
                break;
        case LLDP_MED_INV_SWREV:
                if (!uname(&uts)) {
-                       strncpy(buf, uts.release, size);
+                       strncpy(buf, uts.release, size - 1);
                        goto out_err;
                }
                fprintf(stderr, "###:%s: uname() failed for %d, try"
@@ -298,7 +298,7 @@ out_err:
 static struct unpacked_tlv *med_bld_invtlv(struct med_data *md, u8 subtype)
 {
        int length;
-       u8 desc[32];
+       u8 desc[33];
        struct unpacked_tlv *tlv = NULL;
 
        if (!is_tlv_txenabled(md->ifname, TLVID_MED(subtype))) {
++++++ lldpad-0.9.32-fix-error-in-pgid-construction ++++++
commit d5c865e5804e54a4804fca653742dfacea94fcb0

From: John Fastabend <john.r.fastab...@intel.com>

lldpad: use correct array index in bld_dcbx2_pg_tlv

    Incorrect array index's are being used in bld_dcbx2_pg_tlv,
    resulting in the incorrect pgid being set. And make the
    coding style more Linux.

    Fix provided by Sourav Chatterjee.

    Signed-off-by: John Fastabend <john.r.fastab...@intel.com>
---

 tlv_dcbx.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

--
Signed-off-by: John Fastabend <john.r.fastab...@intel.com>

diff --git a/tlv_dcbx.c b/tlv_dcbx.c
index 69b4ef6..9b539fc 100644
--- a/tlv_dcbx.c
+++ b/tlv_dcbx.c
@@ -444,10 +444,15 @@ struct unpacked_tlv *bld_dcbx2_pg_tlv(struct dcbx_tlvs 
*dcbx, boolean_t *success
                        tmpbyte = 0;
                        if (pg_cfg.tx.up[k].strict_priority == dcb_link)
                                tmpbyte = 0xf;
-                       else    tmpbyte = pg_cfg.tx.up[k+1].pgid & 0xf;
+                       else
+                               tmpbyte = pg_cfg.tx.up[k].pgid & 0xf;
+
+                       tmpbyte <<= 4;
+
                        if (pg_cfg.tx.up[k+1].strict_priority == dcb_link)
-                               tmpbyte |= (0xf) << 4;
-                       else    tmpbyte |= (pg_cfg.tx.up[k].pgid & 0xf) << 4;
+                               tmpbyte |= 0xf;
+                       else
+                               tmpbyte |= (pg_cfg.tx.up[k+1].pgid & 0xf);
                        pg_info->data.pg_ids[j] = tmpbyte;
                }
                for (i = 0; i < MAX_BANDWIDTH_GROUPS; i++) {
++++++ lldpad-0.9.32-fix-lldptool-segfault ++++++
lldpad: fix segfault handling lldptool arguments

From: Eric Multanen <eric.w.multa...@intel.com>

This patch fixes a segfault which occurred when
incomplete arguments were passed via the lldptool
set commands.  In addition, it tightens up the
argument handling.  Errors are printed in more
cases where incorrect or unnecessary arguments
are supplied.
---

 lldp_mand_cmds.c |   28 ++++++++++++++++++++--------
 lldptool_cmds.c  |   32 +++++++++++++++++++++++---------
 2 files changed, 43 insertions(+), 17 deletions(-)

--
Signed-off-by: Eric Multanen <eric.w.multa...@intel.com>

diff --git a/lldp_mand_cmds.c b/lldp_mand_cmds.c
index 780fe62..5f444f3 100644
--- a/lldp_mand_cmds.c
+++ b/lldp_mand_cmds.c
@@ -65,6 +65,9 @@ int get_arg_adminstatus(struct cmd *cmd, char *arg, char 
*argvalue, char *obuf)
        int value;
        char *s;
 
+       if (cmd->cmd != cmd_get_lldp)
+               return cmd_bad_params;
+
        if (cmd->tlvid != INVALID_TLVID)
                return cmd_bad_params;
 
@@ -101,7 +104,7 @@ int get_arg_tlvtxenable(struct cmd *cmd, char *arg, char 
*argvalue, char *obuf)
        char arg_path[256];
 
        if (cmd->cmd != cmd_gettlv)
-               return cmd_invalid;
+               return cmd_bad_params;
 
        switch (cmd->tlvid) {
        case CHASSIS_ID_TLV:
@@ -130,7 +133,7 @@ int handle_get_arg(struct cmd *cmd, char *arg, char 
*argvalue, char *obuf)
 {
        struct lldp_module *np;
        struct arg_handlers *ah;
-       int rval = cmd_failed;
+       int rval = cmd_invalid;
 
        if (!init_cfg())
                return rval;
@@ -328,7 +331,7 @@ int mand_clif_cmd(void  *data,
        u8 arglen;
        u16 argvalue_len;
        int ioff, roff;
-       int rstatus = cmd_success;
+       int rstatus = cmd_invalid;
        char *arg = NULL;
        char *argvalue = NULL;
 
@@ -386,11 +389,15 @@ int mand_clif_cmd(void  *data,
 
        switch (cmd.cmd) {
        case cmd_getstats:
+               if (arg || argvalue)
+                       break;
                rstatus = get_port_stats(&cmd, rbuf+roff);
                break;
        case cmd_gettlv:
                sprintf(rbuf+roff, "%08x", cmd.tlvid);
                roff+=8;
+               if (argvalue)
+                       break;
                if (arg)
                        rstatus = handle_get_arg(&cmd, arg, NULL,
                                                 rbuf+strlen(rbuf));
@@ -400,19 +407,24 @@ int mand_clif_cmd(void  *data,
        case cmd_settlv:
                sprintf(rbuf+roff, "%08x", cmd.tlvid);
                roff+=8;
-               rstatus = handle_set_arg(&cmd, arg, argvalue,
+               if (arg && argvalue)
+                       rstatus = handle_set_arg(&cmd, arg, argvalue,
                                         rbuf+strlen(rbuf));
                break;
        case cmd_get_lldp:
-               rstatus = handle_get_arg(&cmd, arg, NULL,
+               if (argvalue)
+                       break;
+               if (arg)
+                       rstatus = handle_get_arg(&cmd, arg, NULL,
                                         rbuf+strlen(rbuf));
                break;
        case cmd_set_lldp:
-               rstatus = handle_set_arg(&cmd, arg, argvalue,
-                       rbuf+strlen(rbuf));
+               if (arg && argvalue)
+                       rstatus = handle_set_arg(&cmd, arg, argvalue,
+                               rbuf+strlen(rbuf));
                break;
        default:
-               return cmd_invalid;
+               break;
        }
 
        return rstatus;
diff --git a/lldptool_cmds.c b/lldptool_cmds.c
index 12218cc..08845c1 100644
--- a/lldptool_cmds.c
+++ b/lldptool_cmds.c
@@ -37,6 +37,8 @@
 #include "lldp.h"
 #include "lldp_mod.h"
 
+static char *print_status(cmd_status status);
+
 int render_cmd(struct cmd *cmd, char *arg, char *argvalue)
 {
        int len;
@@ -112,6 +114,12 @@ int cli_cmd_gettlv(struct clif *clif, int argc, char 
*argv[],
                cmd->ops |= op_local;
        if (arg)
                cmd->ops |= op_arg;
+
+       if (argvalue) {
+               printf("%s\n", print_status(cmd_invalid));
+               return cmd_invalid;
+       }
+
        render_cmd(cmd, arg, argvalue);
        return clif_command(clif, cmd->obuf, raw);
 }
@@ -125,8 +133,10 @@ int cli_cmd_settlv(struct clif *clif, int argc, char 
*argv[],
        if (argc > 0)
                get_arg_value(argv[0], &arg, &argvalue);
 
-       if (!argvalue)
+       if (!argvalue) {
+               printf("%s\n", print_status(cmd_invalid));
                return cmd_invalid;
+       }
 
        render_cmd(cmd, arg, argvalue);
        return clif_command(clif, cmd->obuf, raw);
@@ -138,10 +148,14 @@ int cli_cmd_getlldp(struct clif *clif, int argc, char 
*argv[],
        char *arg = NULL;
        char *argvalue = NULL;
 
-       if (argc < 1)
-               return 1;
+       if (argc > 0)
+               get_arg_value(argv[0], &arg, &argvalue);
+
+       if (!arg || argvalue) {
+               printf("%s\n", print_status(cmd_invalid));
+               return cmd_invalid;
+       }
 
-       get_arg_value(argv[0], &arg, &argvalue);
 
        render_cmd(cmd, arg, argvalue);
        return clif_command(clif, cmd->obuf, raw);
@@ -153,13 +167,13 @@ int cli_cmd_setlldp(struct clif *clif, int argc, char 
*argv[],
        char *arg = NULL;
        char *argvalue = NULL;
 
-       if (argc < 1)
-               return 1;
-
-       get_arg_value(argv[0], &arg, &argvalue);
+       if (argc > 0)
+               get_arg_value(argv[0], &arg, &argvalue);
 
-       if (!argvalue)
+       if (!argvalue) {
+               printf("%s\n", print_status(cmd_invalid));
                return cmd_invalid;
+       }
 
        render_cmd(cmd, arg, argvalue);
        return clif_command(clif, cmd->obuf, raw);
++++++ lldpad-0.9.32-fix-race-condition ++++++
commit a8439e6af4483fa97e1a0b69a8486c2f220f935c

From: Eric Multanen <eric.w.multa...@intel.com>

lldpad: init the client interface socket early

    When lldpad is run as a daemon, a dcbtool or lldptool
    command executed immediately afterwards is in a race
    with the daemon lldpad for accessing the client interface
    socket.  The tool will typically fail because the
    client interface is not set up yet.  This patch splits
    the client interface intiailization into two steps,
    1) create the socket, and 2) register the socket.  The
    creation step is done early, before the daemon is
    started, to prevent the race.  The registration of
    the socket (with eloop) is still performed at the
    same place it was before.
---

 ctrl_iface.c         |    8 +++++--
 include/ctrl_iface.h |    1 +
 lldpad.c             |   60 +++++++++++++++++++++++++-------------------------
 3 files changed, 37 insertions(+), 32 deletions(-)

--
Signed-off-by: Eric Multanen <eric.w.multa...@intel.com>

diff --git a/ctrl_iface.c b/ctrl_iface.c
index 19cc282..308c01b 100644
--- a/ctrl_iface.c
+++ b/ctrl_iface.c
@@ -406,6 +406,12 @@ static char *ctrl_iface_path(struct clif_data *clifd)
 }
 
 
+void ctrl_iface_register(struct clif_data *clifd)
+{
+       eloop_register_read_sock(clifd->ctrl_sock, ctrl_iface_receive, clifd,
+                                NULL);
+}
+
 int ctrl_iface_init(struct clif_data *clifd)
 {
        struct sockaddr_un addr;
@@ -481,8 +487,6 @@ int ctrl_iface_init(struct clif_data *clifd)
        free(fname);
 
        clifd->ctrl_sock = s;
-       eloop_register_read_sock(s, ctrl_iface_receive, clifd,
-                                NULL);
 
        return 0;
 
diff --git a/include/ctrl_iface.h b/include/ctrl_iface.h
index 3947f09..a735933 100644
--- a/include/ctrl_iface.h
+++ b/include/ctrl_iface.h
@@ -48,6 +48,7 @@ struct clif_data {
 };
 
 int ctrl_iface_init(struct clif_data *clifd);
+void ctrl_iface_register(struct clif_data *clifd);
 void ctrl_iface_deinit(struct clif_data *clifd);
 void ctrl_iface_send(struct clif_data *clifd, int level, u32 moduleid,
                                char *buf, size_t len);
diff --git a/lldpad.c b/lldpad.c
index 3098ce1..f09d56f 100644
--- a/lldpad.c
+++ b/lldpad.c
@@ -261,6 +261,35 @@ int main(int argc, char *argv[])
                exit(1);
        }
 
+       /* initialize lldpad user data */
+       clifd = malloc(sizeof(struct clif_data));
+       if (clifd == NULL) {
+               fprintf(stderr, "failed to malloc user data\n");
+               log_message(MSG_ERR_SERVICE_START_FAILURE,
+                       "%s", "failed to malloc user data");
+               exit(1);
+       }
+
+       clifd->ctrl_interface = (char *) CLIF_IFACE_DIR;
+       strcpy(clifd->iface, CLIF_IFACE_IFNAME);
+       clifd->ctrl_interface_gid_set = 0;
+       clifd->ctrl_interface_gid = 0;
+
+       if (eloop_init(clifd)) {
+               fprintf(stderr, "failed to initialize event loop\n");
+               log_message(MSG_ERR_SERVICE_START_FAILURE,
+                       "%s", "failed to initialize event loop");
+               exit(1);
+       }
+
+       /* initialize the client interface socket before daemonize */
+       if (ctrl_iface_init(clifd) < 0) {
+               fprintf(stderr, "failed to register client interface\n");
+               log_message(MSG_ERR_SERVICE_START_FAILURE,
+                       "%s", "failed to register client interface");
+               exit(1);
+       }
+
        if (daemonize && os_daemonize(PID_FILE)) {
                log_message(MSG_ERR_SERVICE_START_FAILURE,
                        "%s", "error daemonizing lldpad");
@@ -323,28 +352,6 @@ int main(int argc, char *argv[])
 
        init_modules("");
 
-       /* initialize lldpad user data */
-       clifd = malloc(sizeof(struct clif_data));
-       if (clifd == NULL) {
-               if (!daemonize)
-                       fprintf(stderr, "failed to malloc user data\n");
-               log_message(MSG_ERR_SERVICE_START_FAILURE,
-                       "%s", "failed to malloc user data");
-               exit(1);
-       }
-
-       clifd->ctrl_interface = (char *) CLIF_IFACE_DIR;
-       strcpy(clifd->iface, CLIF_IFACE_IFNAME);
-       clifd->ctrl_interface_gid_set = 0;
-       clifd->ctrl_interface_gid = 0;
-
-       if (eloop_init(clifd)) {
-               if (!daemonize)
-                       fprintf(stderr, "failed to initialize event loop\n");
-               log_message(MSG_ERR_SERVICE_START_FAILURE,
-                       "%s", "failed to initialize event loop");
-               exit(1);
-       }
 
        eloop_register_signal_terminate(eloop_terminate, NULL);
 
@@ -357,14 +364,7 @@ int main(int argc, char *argv[])
                exit(1);
        }
 
-       if (ctrl_iface_init(clifd) < 0) {
-               if (!daemonize)
-                       fprintf(stderr,
-                               "failed to register client interface\n");
-               log_message(MSG_ERR_SERVICE_START_FAILURE,
-                       "%s", "failed to register client interface");
-               exit(1);
-       }
+       ctrl_iface_register(clifd);
 
        /* Find available interfaces, read in the lldpad.conf file and
         * add adapters */
++++++ lldpad-init-script-fixup ++++++
Index: lldpad-0.9.29/lldpad.init
===================================================================
--- lldpad-0.9.29.orig/lldpad.init
+++ lldpad-0.9.29/lldpad.init
@@ -38,15 +38,15 @@
 #
 ### BEGIN INIT INFO
 # Provides: lldpad
-# Required-Start: network
-# Required-Stop:
+# Required-Start: $network
+# Required-Stop: $network
 # Default-Start: 3 5
 # Default-Stop:
 # Description: Data Center Bridging Exchange protocol daemon
 ### END INIT INFO
 
 LLDPAD=lldpad
-LLDPAD_BIN=/usr/sbin/$LLDPAD
+LLDPAD_BIN=/sbin/$LLDPAD
 
 test -x $LLDPAD_BIN || { echo "$LLDPAD_BIN not installed";
        if [ "$1" = "stop" ]; then exit 0;
++++++ lldpad-makefile-fixup ++++++
--- Makefile.am.orig    2010-03-18 13:05:42.385312521 +0100
+++ Makefile.am 2010-03-18 13:06:04.202288295 +0100
@@ -99,15 +99,4 @@ install-data-local: lldpad.init
        $(MKDIR_P) $(DESTDIR)/etc/init.d
        $(INSTALL_SCRIPT) lldpad.init $(DESTDIR)/etc/init.d/lldpad
 
-install-data-hook:
-       /sbin/chkconfig --add lldpad || true
-       ## provide legacy support for apps that use the old dcbd interface.
-       test -e $(includedir)/dcbd || `ln -T -s $(includedir)/lldpad 
$(includedir)/dcbd`
-       test -e $(includedir)/dcbd/clif_cmds.h || `ln -T -s 
$(includedir)/lldpad/lldp_dcbx_cmds.h $(includedir)/dcbd/clif_cmds.h`
-
-uninstall-local:
-       /sbin/chkconfig --del lldpad || true
-       rm -f '$(DESTDIR)/etc/init.d/lldpad'
-       rm -f '$(includedir)/dcbd/clif_cmds.h'
-       rm -f '$(includedir)/dcbd'
 
++++++ lldpad-remove-var-lock-subsys-use.patch ++++++
diff -Naurp lldpad-0.9.32.orig/lldpad.init lldpad-0.9.32/lldpad.init
--- lldpad-0.9.32.orig/lldpad.init      2010-03-22 15:34:18.000000000 +0100
+++ lldpad-0.9.32/lldpad.init   2012-10-27 20:26:13.811918067 +0200
@@ -154,13 +154,11 @@ case "$1" in
                $LLDPAD_BIN -k
                start_daemon $LLDPAD_BIN -d $OPTIONS
                rc_status -v
-               [ $? -eq 0 ] && touch /var/lock/subsys/lldpad
                ;;
        stop)
                echo -n $"Shutting down $LLDPAD: "
                killproc $LLDPAD
                rc_status -v
-               [ $? -eq 0 ] && rm -f /var/lock/subsys/lldpad
                ;;
        status)
                echo -n "Checking for service $LLDPAD: "
++++++ mkinitrd-boot.sh ++++++
#!/bin/bash
#%stage: device
#%depends: network
#%programs: /sbin/lldpad /sbin/dcbtool
#%if: "$root_dcbd"
#
##### DCBD initialization
##
## This script initializes DCBD (Data Center Bridging Exchange protocol daemon)

/sbin/lldpad -d
++++++ mkinitrd-setup.sh ++++++
#!/bin/bash
#
#%stage: device
#%depends: fcoe
#

#
# Check if DCBX is active for FCoE traffic
#
dcbd_check_app_fcoe() {
    local if=$1
    local dcberr=1

    . /etc/fcoe/cfg-${if}
    if [ "$DCB_REQUIRED" = "yes" ] ; then
        echo "active"
    fi
}

if [ "${root_fcoe}" ] ; then
    dcb_status=$(dcbd_check_app_fcoe $fcoe_vif)
    if [ "$dcb_status" = "active" ] ; then
        root_dcbd=1
    fi
fi

save_var root_dcbd

if [ "${root_dcbd}" ] ; then
    mkdir -p ${tmp_mnt}/var/lib/lldpad
    if [ -f /var/lib/lldpad/lldpad.conf ] ; then
        # copy the dcbd configuration
        cp -p /var/lib/lldpad/lldpad.conf ${tmp_mnt}/var/lib/lldpad
    fi
fi
++++++ mkinitrd-stop.sh ++++++
#!/bin/bash
#
#%stage: setup
#%provides: killprogs
#
#%if: "$root_dcbd" -a "$root_fcoe"
#%dontshow
#
##### kill fcoe
##
## Because we will run and use the dcbd daemon from the new root
## the old one has to be killed. During that time no DCB
## exceptions should occur!
##
## Command line parameters
## -----------------------
##

# kill dcbd, will be restarted from the real root
lldpad_pid=$(pidof lldpad)
[ "$lldpad_pid" ] && kill -TERM $lldpad_pid
-- 
To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org
For additional commands, e-mail: opensuse-commit+h...@opensuse.org

Reply via email to