Bug 198571

Summary: net-mgmt/lldpd: runtime issues when using lldpd_flags
Product: Ports & Packages Reporter: Jason Unovitch <junovitch>
Component: Individual Port(s)Assignee: Rodrigo Osorio <rodrigo>
Status: Closed FIXED    
Severity: Affects Some People CC: freebsd, rodrigo
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Patch to remove optional command_args and bump port revision none

Description Jason Unovitch freebsd_committer freebsd_triage 2015-03-13 22:37:06 UTC
Created attachment 154284 [details]
Patch to remove optional command_args and bump port revision

Issue:
net-mgmt/lldpd works if lldpd_flags are not set but fails to start when using lldpd_flags.  The error seen was this:

-I can only be used once

This made no sense as "-I" was only used once.  After some investigation, the following lines were seen when setting "-x" on the lldpd rc.d script.

+ eval '/usr/local/sbin/lldpd -I \*,!em3 -I \*,!em3'
+ /usr/local/sbin/lldpd -I '*,!em3' -I '*,!em3'

Discussion:
The lldpd rc.d script mistakenly sets "command_args=${lldpd_flags}"; command_args are optional arguments per rc.subr(8).  This causes duplicate arguments to be called when starting the program causing failure in my case or potentially unpredictable results for other flags that weren't tested or relevant.

Fix:
Attached patch removes optional "command_args" and lets the rc system do its job.
Comment 1 Bugzilla Automation freebsd_committer freebsd_triage 2015-03-13 22:37:06 UTC
Maintainer informed via mail
Comment 2 Mathieu Simon 2015-03-14 10:44:55 UTC
Hi Jason

First, thanks for your feedback, good to see somebody eventually makes use of this port - and finds bugs...

I remember that I added command_args=${lldpd_flags} expectring I "somehow" explicitely needed passing the arguments given in lldpd_flags to make use of it. - After reading rc.subr(8) I agree with you that this is bogus, I'll ask a commiter to apply your patch.

In the meantime: I don't have LLDP or CDP-capable network equipment within reach while writing this message so I tried to see what happens with a FreeBSD VM with 2 nics using the -I switch. I tried also on the CLI simply: "lldpd -d -I em0" and expected lldpd to only send over em0 not em1. Then tcpdump told me that lldp packages was sending over both em0 and em1. Neither did I see something that remotely looked like a CDP packet when launching lldpd with -c switch.

It would be nice if you could you confirm this behaviour, if this is a (FreeBSD) issue and not myself looking at it the wrong way I'll point upstream a this.

Thanks again,
Mathieu
Comment 3 Jason Unovitch freebsd_committer freebsd_triage 2015-03-14 23:34:48 UTC
(In reply to mathieu.sim from comment #2)

To answer your part of you question, after removing the rc.d script's duplication of the -I flag, here's what I see.  The results are from setting the flags shown, doing a 'service lldpd restart', and showing only the interface/transmitted lines of 'lldpcli show stat' for brevity.  I am trusting the lldpcli output and haven't checked with tcpdump as you mentioned just yet.  I'll check that later on and get back with you.

** Explicitly setting an interface ensures only that is used **
lldpd_flags="-I em0"

LLDP statistics:
Interface:    em0
  Transmitted:  1

** Explicitly blacklisting an interface but not using a wildcard results in no interfaces being used **
lldpd_flags="-I !em3"

LLDP statistics:
(no interfaces are shown)

** Using a wildcard and blacklisting an interface results in everything but that interface being used **

lldpd_flags="-I *,!em3"
LLDP statistics:
Interface:    em0
  Transmitted:  1
Interface:    em1
  Transmitted:  1
Interface:    em2
  Transmitted:  1
Interface:    wlan0
  Transmitted:  1

** Not using -I results in all interfaces being used **
lldpd_flags=""

LLDP statistics:
Interface:    em0
  Transmitted:  1
Interface:    em1
  Transmitted:  1
Interface:    em2
  Transmitted:  1
Interface:    em3
  Transmitted:  1
Interface:    wlan0
  Transmitted:  1
Comment 4 Rodrigo Osorio freebsd_committer freebsd_triage 2015-03-15 18:44:58 UTC
committed thanks
Comment 5 commit-hook freebsd_committer freebsd_triage 2015-03-15 18:45:25 UTC
A commit references this bug:

Author: rodrigo
Date: Sun Mar 15 18:44:29 UTC 2015
New revision: 381355
URL: https://svnweb.freebsd.org/changeset/ports/381355

Log:
  Fix rc script
  Bump port revision

  PR:		198571
  Submitted by:	<jason.unovitch@gmail.com>

Changes:
  head/net-mgmt/lldpd/Makefile
  head/net-mgmt/lldpd/files/lldpd.in
Comment 6 Jason Unovitch freebsd_committer freebsd_triage 2015-03-15 21:20:33 UTC
(In reply to Mathieu Simon from comment #2)

Mathieu,
I looked up some tcpdump filters for CDP and LLDPD and confirmed the behavior.  The -I flags works as intended and matches what 'lldpcli show stat' says its doing.  I did have to specify -cc per llddp(8) to force sending CDP since I don't have any other devices sending CDP.  So the only issue I saw was the rc script flags which has now been resolved.  Thanks to rodrigo@ for the quick fix.