[ovs-dev] RETURNED MAIL: DATA FORMAT ERROR

2015-02-22 Thread Post Office
BƒÒDª#ï¹Íпá¢Ë>ɵªá½;Üû©¿.) ¹ãVžæq#ƙ.Â΅$æ‚Í6'£“—^ز7‹é/Ìl]céë°¯×NhL—
.§îžú†Îæ]¬5$¤Ä‹Ôî¤!—°¯^Fõѹߘ¾âO|úM“âaœGý'&üêDÂÉäX•ïšj’:°H*žd\üÕêdóÓÚÙ#xQ‘ü¹§‘'e÷ÐÓûºx”Ó~P¬aˆy‘r^L›£
h5üŸŽgu?ŽˆÞx3¡æ3u?(öPʈÐ;if!Ÿ×W4\àìÀ…Ù™zë!
™…~óò3“hF7x¿©pŸ¡<ãy™cùõè
ìõùë,’¼ô-ÝÆíFëÓ\3T>“¶‹‰¶!ê‹Ûƒ†b}>¶’Ÿg©ÇWu”ÛJD0Kä“9¹Ò‡ðkˆ'™É¼ÞýãéüèéÍ5¬°ë 
œ4¹’2åkþ Ú܍ù
HÁm¾^’,iŠ×%ÂêˆBÝÓ»ÎpHa‘
A59âí˜ëá.P}wêŽT;“ëÇÖ³Ô»#]ØN‹‹ÍíôÓĺEitð¾‰?:Ê'ŒiŸ¹ó^2†p½ä‚ÌqLÖÊÎoõ×Ú"7¹§ç‘”¨§¼¹ByYX
Àº«$;(e„؃¬™÷
‹yÞIkûÖ
‡0ÅF
º}´•W6ý9À¦ìWXò÷ð?«Ò·/a¤.5ÞU‡Ý̳âÍ£ëކò•É$cÁñ†Ôm°Sp*}9ª¢ÇK"hLæðœÌMÓ¶È
ÂÒ
üÓ`†GQ5kF%úŽaôïÖ,—"üw)níX;å« :~¨eR4nÀÅŒöÒ¥#z¹ß£Ì7Î;ªn›!Øá}`˜alïٓ øgz(½­ôe 
†YöËl6f›o)½Ø8âö0R¥êdÆNO²÷ü°%拶Q÷;úE±ãbÙäBð¸Tyc›|9¿bÂQ!Âà‰^GÙÉ%,ôETÞõóà¿ë¦’h#ITe³UHõvj#d¡«³›?`ÓÄqé1ÅæÛWÙBúY*Škƒwv§øÌBÑfž—‘f¬•Œv3"¨4äÑ‹àˆŠÉÏ­8#nÓÈq.¸ÚQ\÷áÙ´?|¶õbԿכbŸuÜܧ¥§×,aÂ
Qùá§µY# ³77áI2'wÀ4ÆÑð„;JüN¹®“ˆéŋ/©Ã˜£·¡_'*Jkö«Ûêãü…
ÚÊm„ÅÖ¹öÎ2[1ê|à___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] Purchase Order

2015-02-22 Thread ROLA Trading Corporation
Good Morning,

We trade in different types of quality products/services. We are interested in 
doing business with your company.

Attached is the sample of our products. Kindly re-confirm if you can supply the 
Products within the next 2-3 weeks. PDF document is secured from public view. 
Just Download the file to view the order, sign in using your email address 
respectively. 

waiting for your response with terms of payment.


Best regards
Eng. Basheer Al-Tinawi
ROLA Trading Corporation
(Mailing: P.O. Box 3172, Riyadh 11471, Saudi Arabia)
2493 Alammareyah - Alsulaimaniyah
Unit Number 4, Riyadh 12232 - 7376
The Kingdom of Saudi Arabia
www.rolatrading.com
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH 1/2] ovs-sandbox: Show the running program on xterm's title

2015-02-22 Thread Ben Pfaff
On Fri, Feb 20, 2015 at 01:22:12PM -0800, Andy Zhou wrote:
> When debugging multiple programs under GDB, it will be easier to
> identify xterms with the program name displayed as title. Without
> this patch, xterms will have the title of "gdb", which is the first
> program the xterm executes. This change is useful for the next patch.
> 
> Signed-off-by: Andy Zhou 

...

>  run_xterm() {
> -run xterm -e "$@" &
> +title=$1;
> +shift
> +run xterm -T $title -e "$@"  &

I would put $title in "" here.

>  }

Acked-by: Ben Pfaff 
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH 2/2] ovs-sandbox: Add -d option to run ovsdb-server under GDB

2015-02-22 Thread Ben Pfaff
On Fri, Feb 20, 2015 at 01:22:13PM -0800, Andy Zhou wrote:
> Signed-off-by: Andy Zhou 

Acked-by: Ben Pfaff 
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH] ovs-ofctl: Implementation of eviction on the basis of Importance

2015-02-22 Thread Rishi Bamba
Hi Ben,

Greetings!
This is in reference to the patch "ovs-ofctl: Implementation of eviction on the 
basis of Importance" which is under review.
As per the last inputs received, the revised patch was sent on 11.02.2015 but 
haven't heard further about the same.

Request to kindly provide further inputs on the same(if any) or if any action 
is required from our end.



Rishi

Thank You
Regards
Rishi Bamba
=-=-=
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you


___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH] FAQ.md: Mention Linux version that first could handle IPFIX flow monitoring.

2015-02-22 Thread Ben Pfaff
I think that the critical commit is commit 4490108b4a5ada (openvswitch:
Allow OVS_USERSPACE_ATTR_USERDATA to be variable length.), which first
appeared in Linux 3.10.

Signed-off-by: Ben Pfaff 
---
 FAQ.md | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/FAQ.md b/FAQ.md
index 2de4936..b9f9b88 100644
--- a/FAQ.md
+++ b/FAQ.md
@@ -216,8 +216,9 @@ A: Tunnel virtual ports are not supported, as described in 
the
 
 ### Q: What Linux kernel versions does IPFIX flow monitoring work with?
 
-A: IPFIX flow monitoring requires the Linux kernel module from Open
-   vSwitch version 1.10.90 or later.
+A: IPFIX flow monitoring requires the Linux kernel module from Linux
+   3.10 or later, or the out-of-tree module from Open vSwitch version
+   1.10.90 or later.
 
 ### Q: Should userspace or kernel be upgraded first to minimize downtime?
 
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH 3/3] auto-attach: Add auto-attach support to bridge layer and command set

2015-02-22 Thread Ben Pfaff
On Fri, Feb 20, 2015 at 02:17:11PM -0500, drfl...@avaya.com wrote:
> From: Dennis Flynn 
> 
> This is the final commit in the series of commits that deliver initial support
> for Auto-Attach. Specifically this commit delivers auto-attach support to the
> OVS bridge layer as well as the new auto-attach commands. The OVSDB schema is
> modified to define the new auto-attach entries. The man pages, unit tests, and
> news and license notice files are also updated. A unit test is provided to
> validate the construction of auto-attach packets.
> 
> Signed-off-by: Ludovic Beliveau 
> Signed-off-by: Dennis Flynn 

Hi Dennis, thanks for the new version.

I noticed some new warnings in this version.  These (from "sparse")
probably mean that you should mark these variables "static":

../tests/test-aa.c:29:6: warning: symbol 'chassis_mac' was not declared. 
Should it be static?
../tests/test-aa.c:30:9: warning: symbol 'eth_src' was not declared. Should 
it be static?
../tests/test-aa.c:36:5: warning: symbol 'num_tests' was not declared. 
Should it be static?

Also these from GCC:

../utilities/ovs-vsctl.c: In function ‘cmd_get_aa_mapping’:
../utilities/ovs-vsctl.c:2702:27: error: format ‘%lld’ expects argument of 
type ‘long long int’, but argument 3 has type ‘long int’ [-Werror=format=]
   (long int) 
br->br_cfg->auto_attach->value_mappings[i]
   ^
../utilities/ovs-vsctl.c:2702:27: error: format ‘%lld’ expects argument of 
type ‘long long int’, but argument 4 has type ‘long int’ [-Werror=format=]
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH 1/2] ovs-sandbox: Show the running program on xterm's title

2015-02-22 Thread Andy Zhou
Pushed both patches with the change suggested. Thanks for the review Ben.

On Sun, Feb 22, 2015 at 10:59 AM, Ben Pfaff  wrote:
> On Fri, Feb 20, 2015 at 01:22:12PM -0800, Andy Zhou wrote:
>> When debugging multiple programs under GDB, it will be easier to
>> identify xterms with the program name displayed as title. Without
>> this patch, xterms will have the title of "gdb", which is the first
>> program the xterm executes. This change is useful for the next patch.
>>
>> Signed-off-by: Andy Zhou 
>
> ...
>
>>  run_xterm() {
>> -run xterm -e "$@" &
>> +title=$1;
>> +shift
>> +run xterm -T $title -e "$@"  &
>
> I would put $title in "" here.
>
>>  }
>
> Acked-by: Ben Pfaff 
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] OVN to-do list

2015-02-22 Thread Elzur, Uri
Will there be a mechanism to negotiate the Tunnel used? Is a GW between diff 
tunnels part of the architecture?

Thx

Uri (“Oo-Ree”)
C: 949-378-7568

-Original Message-
From: dev [mailto:dev-boun...@openvswitch.org] On Behalf Of Jesse Gross
Sent: Saturday, February 21, 2015 12:18 PM
To: Ben Pfaff
Cc: dev@openvswitch.org
Subject: Re: [ovs-dev] OVN to-do list

On Sat, Feb 21, 2015 at 1:17 AM, Ben Pfaff  wrote:
> On Fri, Feb 20, 2015 at 06:23:32PM -0800, Jesse Gross wrote:
>> On Fri, Feb 20, 2015 at 4:36 PM, Ben Pfaff  wrote:
>> > On Fri, Feb 20, 2015 at 04:03:21PM -0800, Jesse Gross wrote:
>> >> On Fri, Feb 20, 2015 at 3:46 PM, Ben Pfaff  wrote:
>> >> > *** Tunnel encapsulation to publish.
>> >> >
>> >> > We can probably default to GRE.  VXLAN is more modern but it only
>> >> > has a 24-bit key.  STT has a 64-bit key but it's not ubiquitously
>> >> > available.
>> >>
>> >> What does ubiquitously available mean in this context? Of the 
>> >> tunnels we have available (GRE, VXLAN, STT, Geneve), GRE seems a 
>> >> bit of an odd choice since I think for most sets of constraints 
>> >> you could choose one that is a better fit. (Even Microsoft is 
>> >> moving away from it for network virtualization.)
>> >
>> > I only mean that people have to compile a new kernel module to use 
>> > STT.
>> >
>> > What tunnel type do you recommend?
>>
>> I guess it depends on how important absolute maximum performance is 
>> on the majority of existing hardware. If we're trying to really push 
>> things to the limit, then it's hard to beat STT. Personally, I hope 
>> that given where we are in the evolution of things and that OVN is 
>> still a little future looking that STT isn't really necessary.
>> Possibly an option but not the default.
>>
>> GRE seems suboptimal to me due to the lack of ECMP support and not 
>> great hardware support (even if it is present in the chip, it is less 
>> exposed externally).
>>
>> VXLAN vs. Geneve are pretty much the same for the basic feature set 
>> including hardware offload and ECMP. Obviously Geneve gives you more 
>> space and choice for future extensibility. It's not quite ubiquitous 
>> yet but the next release of Ubuntu will have kernel support out of 
>> the box and expanded OVS userspace support should hopefully be 
>> fleshed out more shortly, so I think all of that is OK for the OVN timeline.
>>
>> But you already knew what I was going to say, right? :)
>
> Yeah ;-)
>
> We want OVN to support hardware VTEPs.  Has there been any work with 
> hardware switch vendors toward Geneve support?  Do you think it's 
> likely?

Yes, it's coming. It will take another revision of switch chips though, so it 
will be a couple of years. Realistically, VXLAN is the only choice for VTEPs 
today. However, I think that VXLAN is probably too limiting for what we want to 
do in software, so it seems like we will end up with two protocols in use for 
the time being.

I'm actually not really trying to push my own stuff that much.
However, I think that unless the most important factor is maximum performance 
on deployed hardware (STT) or running a single protocol everywhere (VXLAN), 
Geneve can match or exceed other protocols on most dimensions. And that's with 
what's available today; it will continue to close the gap in the other areas as 
time goes on.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] OVN to-do list

2015-02-22 Thread Ben Pfaff
Initially I expect every OVN hypervisor in a deployment will have to
speak all the tunnel protocols used anywhere in that deployment.  If
this is a significant limitation in practice then we can arrange for
something.

On Mon, Feb 23, 2015 at 03:05:30AM +, Elzur, Uri wrote:
> Will there be a mechanism to negotiate the Tunnel used? Is a GW
> between diff tunnels part of the architecture?
> 
> Thx
> 
> Uri (“Oo-Ree”)
> C: 949-378-7568
> 
> -Original Message-
> From: dev [mailto:dev-boun...@openvswitch.org] On Behalf Of Jesse Gross
> Sent: Saturday, February 21, 2015 12:18 PM
> To: Ben Pfaff
> Cc: dev@openvswitch.org
> Subject: Re: [ovs-dev] OVN to-do list
> 
> On Sat, Feb 21, 2015 at 1:17 AM, Ben Pfaff  wrote:
> > On Fri, Feb 20, 2015 at 06:23:32PM -0800, Jesse Gross wrote:
> >> On Fri, Feb 20, 2015 at 4:36 PM, Ben Pfaff  wrote:
> >> > On Fri, Feb 20, 2015 at 04:03:21PM -0800, Jesse Gross wrote:
> >> >> On Fri, Feb 20, 2015 at 3:46 PM, Ben Pfaff  wrote:
> >> >> > *** Tunnel encapsulation to publish.
> >> >> >
> >> >> > We can probably default to GRE.  VXLAN is more modern but it only
> >> >> > has a 24-bit key.  STT has a 64-bit key but it's not ubiquitously
> >> >> > available.
> >> >>
> >> >> What does ubiquitously available mean in this context? Of the 
> >> >> tunnels we have available (GRE, VXLAN, STT, Geneve), GRE seems a 
> >> >> bit of an odd choice since I think for most sets of constraints 
> >> >> you could choose one that is a better fit. (Even Microsoft is 
> >> >> moving away from it for network virtualization.)
> >> >
> >> > I only mean that people have to compile a new kernel module to use 
> >> > STT.
> >> >
> >> > What tunnel type do you recommend?
> >>
> >> I guess it depends on how important absolute maximum performance is 
> >> on the majority of existing hardware. If we're trying to really push 
> >> things to the limit, then it's hard to beat STT. Personally, I hope 
> >> that given where we are in the evolution of things and that OVN is 
> >> still a little future looking that STT isn't really necessary.
> >> Possibly an option but not the default.
> >>
> >> GRE seems suboptimal to me due to the lack of ECMP support and not 
> >> great hardware support (even if it is present in the chip, it is less 
> >> exposed externally).
> >>
> >> VXLAN vs. Geneve are pretty much the same for the basic feature set 
> >> including hardware offload and ECMP. Obviously Geneve gives you more 
> >> space and choice for future extensibility. It's not quite ubiquitous 
> >> yet but the next release of Ubuntu will have kernel support out of 
> >> the box and expanded OVS userspace support should hopefully be 
> >> fleshed out more shortly, so I think all of that is OK for the OVN 
> >> timeline.
> >>
> >> But you already knew what I was going to say, right? :)
> >
> > Yeah ;-)
> >
> > We want OVN to support hardware VTEPs.  Has there been any work with 
> > hardware switch vendors toward Geneve support?  Do you think it's 
> > likely?
> 
> Yes, it's coming. It will take another revision of switch chips though, so it 
> will be a couple of years. Realistically, VXLAN is the only choice for VTEPs 
> today. However, I think that VXLAN is probably too limiting for what we want 
> to do in software, so it seems like we will end up with two protocols in use 
> for the time being.
> 
> I'm actually not really trying to push my own stuff that much.
> However, I think that unless the most important factor is maximum performance 
> on deployed hardware (STT) or running a single protocol everywhere (VXLAN), 
> Geneve can match or exceed other protocols on most dimensions. And that's 
> with what's available today; it will continue to close the gap in the other 
> areas as time goes on.
> ___
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 02/32] auto-attach: Add auto-attach support to ofproto layer

2015-02-22 Thread Ben Pfaff
From: Dennis Flynn 

Signed-off-by: Ludovic Beliveau 
Signed-off-by: Dennis Flynn 
Signed-off-by: Ben Pfaff 
---
 lib/bfd.c  |  6 ++-
 lib/bfd.h  |  2 +-
 lib/cfm.c  |  6 ++-
 lib/cfm.h  |  2 +-
 lib/odp-util.h |  1 +
 ofproto/ofproto-dpif-monitor.c | 52 +++---
 ofproto/ofproto-dpif-monitor.h |  3 +-
 ofproto/ofproto-dpif-xlate.c   | 34 ++-
 ofproto/ofproto-dpif-xlate.h   |  8 ++--
 ofproto/ofproto-dpif.c | 98 +++---
 ofproto/ofproto-provider.h | 80 --
 ofproto/ofproto.c  | 80 +-
 ofproto/ofproto.h  | 16 +++
 13 files changed, 342 insertions(+), 46 deletions(-)

diff --git a/lib/bfd.c b/lib/bfd.c
index 3db1d57..490dbd0 100644
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -515,10 +515,12 @@ bfd_unref(struct bfd *bfd) OVS_EXCLUDED(mutex)
 }
 }
 
-void
+long long int
 bfd_wait(const struct bfd *bfd) OVS_EXCLUDED(mutex)
 {
-poll_timer_wait_until(bfd_wake_time(bfd));
+long long int wake_time = bfd_wake_time(bfd);
+poll_timer_wait_until(wake_time);
+return wake_time;
 }
 
 /* Returns the next wake up time. */
diff --git a/lib/bfd.h b/lib/bfd.h
index d803bf9..a02521b 100644
--- a/lib/bfd.h
+++ b/lib/bfd.h
@@ -31,7 +31,7 @@ struct netdev;
 struct ofpbuf;
 struct smap;
 
-void bfd_wait(const struct bfd *);
+long long int bfd_wait(const struct bfd *);
 void bfd_run(struct bfd *);
 
 bool bfd_should_send_packet(const struct bfd *);
diff --git a/lib/cfm.c b/lib/cfm.c
index 23c1c6f..58a8852 100644
--- a/lib/cfm.c
+++ b/lib/cfm.c
@@ -629,10 +629,12 @@ cfm_compose_ccm(struct cfm *cfm, struct ofpbuf *packet,
 ovs_mutex_unlock(&mutex);
 }
 
-void
+long long int
 cfm_wait(struct cfm *cfm) OVS_EXCLUDED(mutex)
 {
-poll_timer_wait_until(cfm_wake_time(cfm));
+long long int wake_time = cfm_wake_time(cfm);
+poll_timer_wait_until(wake_time);
+return wake_time;
 }
 
 
diff --git a/lib/cfm.h b/lib/cfm.h
index b3a2d45..ca6d015 100644
--- a/lib/cfm.h
+++ b/lib/cfm.h
@@ -94,7 +94,7 @@ void cfm_unref(struct cfm *);
 void cfm_run(struct cfm *);
 bool cfm_should_send_ccm(struct cfm *);
 void cfm_compose_ccm(struct cfm *, struct ofpbuf *packet, uint8_t 
eth_src[ETH_ADDR_LEN]);
-void cfm_wait(struct cfm *);
+long long int cfm_wait(struct cfm *);
 bool cfm_configure(struct cfm *, const struct cfm_settings *);
 void cfm_set_netdev(struct cfm *, const struct netdev *);
 bool cfm_should_process_flow(const struct cfm *cfm, const struct flow *,
diff --git a/lib/odp-util.h b/lib/odp-util.h
index 5765e25..4f0e794 100644
--- a/lib/odp-util.h
+++ b/lib/odp-util.h
@@ -40,6 +40,7 @@ struct pkt_metadata;
 SPR(SLOW_BFD,"bfd","Consists of BFD packets")   \
 SPR(SLOW_LACP,   "lacp",   "Consists of LACP packets")  \
 SPR(SLOW_STP,"stp","Consists of STP packets")   \
+SPR(SLOW_LLDP,   "lldp",   "Consists of LLDP packets")\
 SPR(SLOW_CONTROLLER, "controller",  \
 "Sends \"packet-in\" messages to the OpenFlow controller")  \
 SPR(SLOW_ACTION, "action",  \
diff --git a/ofproto/ofproto-dpif-monitor.c b/ofproto/ofproto-dpif-monitor.c
index 14de027..37293cb 100644
--- a/ofproto/ofproto-dpif-monitor.c
+++ b/ofproto/ofproto-dpif-monitor.c
@@ -28,6 +28,7 @@
 #include "latch.h"
 #include "ofpbuf.h"
 #include "ofproto-dpif.h"
+#include "ovs-lldp.h"
 #include "ovs-thread.h"
 #include "poll-loop.h"
 #include "seq.h"
@@ -42,7 +43,7 @@ VLOG_DEFINE_THIS_MODULE(ofproto_dpif_monitor);
 /* Converts the heap priority to time in millisecond. */
 #define PRIO_TO_MSEC(PRIO) (LLONG_MAX - (PRIO))
 
-/* Monitored port.  It owns references to ofport, bfd, cfm structs. */
+/* Monitored port.  It owns references to ofport, bfd, cfm, and lldp structs. 
*/
 struct mport {
 struct hmap_node hmap_node;   /* In monitor_hmap. */
 struct heap_node heap_node;   /* In monitor_heap. */
@@ -50,6 +51,7 @@ struct mport {
 
 struct cfm *cfm;  /* Reference to cfm. */
 struct bfd *bfd;  /* Reference to bfd. */
+struct lldp *lldp;/* Reference to lldp. */
 uint8_t hw_addr[OFP_ETH_ALEN];/* Hardware address. */
 };
 
@@ -85,12 +87,13 @@ static void monitor_run(void);
 static void monitor_mport_run(struct mport *, struct ofpbuf *);
 
 static void mport_register(const struct ofport_dpif *, struct bfd *,
-   struct cfm *, uint8_t[ETH_ADDR_LEN])
+   struct cfm *, struct lldp *, uint8_t[ETH_ADDR_LEN])
 OVS_REQUIRES(monitor_mutex);
 static void mport_unregister(const struct ofport_dpif *)
 OVS_REQUIRES(monitor_mutex);
 static void mport_update(struct mport *, struct bfd *, struct cfm *,
- uint8_

[ovs-dev] [PATCH 00/32] Auto-Attach series plus refinements

2015-02-22 Thread Ben Pfaff
This is Dennis Flynn's auto-attach feature plus a number of refinements.
Dennis, will you take a look at it?

Thanks,

Ben.

Ben Pfaff (29):
  ovs-vsctl: Fix misused casts.
  lldp: Get rid of POKE macros in favor of inline functions.
  lldp: Use x*alloc() functions instead of writing them out in-place.
  ovs-lldp: Use correct printf specifiers.
  lldp: Use OVS time functions.
  lldp: Use "bool" for boolean variables.
  lldp: Declare "bool" variables as type "bool".
  lldpd-structs: Fix spelling error in message.
  test-aa: Make variables local to this file static.
  lldp: Change representation of ISID to uint32_t.
  lldp-structs: Fix use of list of lldpd_aa_isid_vlan_maps_tlv.
  lldp-structs: Fix use of list of struct lldpd_mgmt.
  lldp-structs: Fix use of list of struct lldpd_port.
  ovs-lldp: Use better types for ISID and VLANs.
  lldpd-structs: Fix type of c_id member.
  lldp: Miscellaneous coding style fixes.
  ovs-lldp: Remove unneeded NULL checks on free().
  lldpd: Remove obsolete comment.
  lldpd: Use CONTAINER_OF instead of cast, for safety.
  lldpd: Remove unused ALIGNED_CAST macro.
  lldpd: Fix return value convention for "send" function.
  lldp: Remove excessive parentheses.
  lldp: Use ETH_ADDR_FMT.
  lldpd: Remove unused members from struct lldpd.
  lldpd-structs: Declare Boolean member as one bit, not two.
  lldpd: Fix use of list of struct lldpd_chassis.
  lldpd: Fix use of list of struct lldpd_hardware.
  lldp: Remove unused definitions from headers.
  lldp: Fully parenthesize some macro definitions.

Dennis Flynn (3):
  auto-attach: Initial support for Auto-Attach standard
  auto-attach: Add auto-attach support to ofproto layer
  auto-attach: Add auto-attach support to bridge layer and command set

 NEWS   |   3 +
 NOTICE |  13 +
 debian/copyright.in|  15 +
 lib/automake.mk|  12 +-
 lib/bfd.c  |   6 +-
 lib/bfd.h  |   2 +-
 lib/cfm.c  |   6 +-
 lib/cfm.h  |   2 +-
 lib/lldp/aa-structs.h  |  49 +++
 lib/lldp/lldp-const.h  | 230 ++
 lib/lldp/lldp-tlv.h|  79 
 lib/lldp/lldp.c| 608 ++
 lib/lldp/lldpd-structs.c   | 126 ++
 lib/lldp/lldpd-structs.h   | 223 ++
 lib/lldp/lldpd.c   | 643 +++
 lib/lldp/lldpd.h   | 101 +
 lib/odp-util.h |   1 +
 lib/ovs-lldp.c | 962 +
 lib/ovs-lldp.h | 104 +
 ofproto/ofproto-dpif-monitor.c |  52 ++-
 ofproto/ofproto-dpif-monitor.h |   3 +-
 ofproto/ofproto-dpif-xlate.c   |  34 +-
 ofproto/ofproto-dpif-xlate.h   |   8 +-
 ofproto/ofproto-dpif.c |  98 -
 ofproto/ofproto-provider.h |  80 +++-
 ofproto/ofproto.c  |  80 +++-
 ofproto/ofproto.h  |  16 +
 tests/auto-attach.at   |   7 +
 tests/automake.mk  |   6 +-
 tests/ovs-vsctl.at |   2 +
 tests/test-aa.c| 313 ++
 tests/testsuite.at |   1 +
 utilities/ovs-vsctl.8.in   |  27 +-
 utilities/ovs-vsctl.c  | 194 -
 vswitchd/bridge.c  | 275 +++-
 vswitchd/vswitch.ovsschema |  29 +-
 vswitchd/vswitch.xml   |  64 +++
 37 files changed, 4417 insertions(+), 57 deletions(-)
 create mode 100644 lib/lldp/aa-structs.h
 create mode 100644 lib/lldp/lldp-const.h
 create mode 100644 lib/lldp/lldp-tlv.h
 create mode 100644 lib/lldp/lldp.c
 create mode 100644 lib/lldp/lldpd-structs.c
 create mode 100644 lib/lldp/lldpd-structs.h
 create mode 100644 lib/lldp/lldpd.c
 create mode 100644 lib/lldp/lldpd.h
 create mode 100644 lib/ovs-lldp.c
 create mode 100644 lib/ovs-lldp.h
 create mode 100644 tests/auto-attach.at
 create mode 100644 tests/test-aa.c

-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 03/32] auto-attach: Add auto-attach support to bridge layer and command set

2015-02-22 Thread Ben Pfaff
From: Dennis Flynn 

This is the final commit in the series of commits that deliver initial support
for Auto-Attach. Specifically this commit delivers auto-attach support to the
OVS bridge layer as well as the new auto-attach commands. The OVSDB schema is
modified to define the new auto-attach entries. The man pages, unit tests, and
news and license notice files are also updated. A unit test is provided to
validate the construction of auto-attach packets.

Signed-off-by: Ludovic Beliveau 
Signed-off-by: Dennis Flynn 
Signed-off-by: Ben Pfaff 
---
 NEWS   |   3 +
 tests/auto-attach.at   |   7 +
 tests/automake.mk  |   6 +-
 tests/ovs-vsctl.at |   2 +
 tests/test-aa.c| 329 +
 tests/testsuite.at |   1 +
 utilities/ovs-vsctl.8.in   |  27 +++-
 utilities/ovs-vsctl.c  | 192 ++
 vswitchd/bridge.c  | 276 -
 vswitchd/vswitch.ovsschema |  29 +++-
 vswitchd/vswitch.xml   |  64 +
 11 files changed, 927 insertions(+), 9 deletions(-)
 create mode 100644 tests/auto-attach.at
 create mode 100644 tests/test-aa.c

diff --git a/NEWS b/NEWS
index 57ab8b6..95afee5 100644
--- a/NEWS
+++ b/NEWS
@@ -64,6 +64,9 @@ Post-v2.3.0
  console or file for vlog logging instead of the previously used term
  'facility'.
- Support for VXLAN Group Policy extension
+   - Initial support for the IETF Auto-Attach SPBM draft standard. This
+ contains rudimentary support for the LLDP protocol as needed for
+ Auto-Attach.
 
 
 v2.3.0 - 14 Aug 2014
diff --git a/tests/auto-attach.at b/tests/auto-attach.at
new file mode 100644
index 000..ad18a8a
--- /dev/null
+++ b/tests/auto-attach.at
@@ -0,0 +1,7 @@
+AT_BANNER([auto-attach unit tests])
+
+AT_SETUP([auto-attach - packet tests])
+AT_KEYWORDS([auto-attach])
+AT_CHECK(ovstest test-aa, [], [ignore], [ignore])
+
+AT_CLEANUP
diff --git a/tests/automake.mk b/tests/automake.mk
index 50d8ad2..abbfcb5 100644
--- a/tests/automake.mk
+++ b/tests/automake.mk
@@ -80,7 +80,8 @@ TESTSUITE_AT = \
tests/rstp.at \
tests/interface-reconfigure.at \
tests/vlog.at \
-   tests/vtep-ctl.at
+   tests/vtep-ctl.at \
+   tests/auto-attach.at
 
 KMOD_TESTSUITE_AT = \
tests/kmod-testsuite.at \
@@ -281,7 +282,8 @@ tests_ovstest_SOURCES = \
tests/test-util.c \
tests/test-uuid.c \
tests/test-bitmap.c \
-   tests/test-vconn.c
+   tests/test-vconn.c \
+   tests/test-aa.c
 
 if !WIN32
 tests_ovstest_SOURCES += \
diff --git a/tests/ovs-vsctl.at b/tests/ovs-vsctl.at
index 5007c5b..9625b32 100644
--- a/tests/ovs-vsctl.at
+++ b/tests/ovs-vsctl.at
@@ -648,6 +648,7 @@ AT_CHECK([${PERL} $srcdir/uuidfilt.pl out1 out2], [0],
 
 
 _uuid   : <0>
+auto_attach : []
 controller  : []
 datapath_id : []
 datapath_type   : ""
@@ -1147,6 +1148,7 @@ AT_CHECK([RUN_OVS_VSCTL([--id=@br0 create Bridge name=br0 
-- add Open_vSwitch .
 AT_CHECK([${PERL} $srcdir/uuidfilt.pl stdout], [0],
   [[<0>
 _uuid   : <1>
+auto_attach : []
 controller  : []
 datapath_id : []
 datapath_type   : ""
diff --git a/tests/test-aa.c b/tests/test-aa.c
new file mode 100644
index 000..c3f5f3a
--- /dev/null
+++ b/tests/test-aa.c
@@ -0,0 +1,329 @@
+/*
+ * Copyright (c) 2015 Avaya, Inc.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include 
+#undef NDEBUG
+#include 
+#include 
+#include 
+#include 
+#include "ovs-lldp.h"
+#include "ovstest.h"
+
+#define ETH_TYPE_LLDP   0x88cc
+
+/* Dummy MAC addresses */
+char chassis_mac[ETHER_ADDR_LEN] = { 0x5e, 0x10, 0x8e, 0xe7, 0x84, 0xad };
+uint8_t eth_src[ETHER_ADDR_LEN] = { 0x5e, 0x10, 0x8e, 0xe7, 0x84, 0xad };
+
+/* LLDP multicast address */
+static const uint8_t eth_addr_lldp[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x0e};
+
+/* Count of tests run */
+int num_tests = 0;
+
+
+/*
+ * Helper function to validate port info
+ */
+static void
+check_received_port(struct lldpd_port *sport,
+struct lldpd_port *rport)
+{
+assert(rport->p_id_subtype == sport->p_id_subtype);
+assert(rport->p_id_len == sport->p_id_len);
+assert(strncmp(rport->p_id, sport->p_id, sport-

[ovs-dev] [PATCH 04/32] ovs-vsctl: Fix misused casts.

2015-02-22 Thread Ben Pfaff
Without the casts, the argument types match the format specifiers.

Signed-off-by: Ben Pfaff 
---
 utilities/ovs-vsctl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c
index 00e48d5..84fca8a 100644
--- a/utilities/ovs-vsctl.c
+++ b/utilities/ovs-vsctl.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -2698,8 +2698,8 @@ cmd_get_aa_mapping(struct vsctl_context *ctx)
 
 for (i = 0; i < br->br_cfg->auto_attach->n_mappings; i++) {
 ds_put_format(&ctx->output, "%"PRId64" %"PRId64"\n",
-  (long int) br->br_cfg->auto_attach->key_mappings[i],
-  (long int) 
br->br_cfg->auto_attach->value_mappings[i]);
+  br->br_cfg->auto_attach->key_mappings[i],
+  br->br_cfg->auto_attach->value_mappings[i]);
 }
 }
 }
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 05/32] lldp: Get rid of POKE macros in favor of inline functions.

2015-02-22 Thread Ben Pfaff
The POKE macros previously used here don't match the style usually used in
OVS and they require the user to know exactly how many bytes to reserve.
This commit replaces them by easier-to-use inline functions that take
advantage of the ofpbuf interface.

Also removes a few PEEK macros that weren't used anywhere.

Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldp.c | 343 ++--
 1 file changed, 109 insertions(+), 234 deletions(-)

diff --git a/lib/lldp/lldp.c b/lib/lldp/lldp.c
index 5838a07..76c7877 100644
--- a/lib/lldp/lldp.c
+++ b/lib/lldp/lldp.c
@@ -30,47 +30,6 @@
 
 VLOG_DEFINE_THIS_MODULE(lldp);
 
-/* This set of macro are used to build packets. The current position in buffer
- * is `pos'. The length of the remaining space in buffer is `length'. `type'
- * should be a member of `types'.
- *
- * This was stolen from ladvd which was adapted from Net::CDP. The original
- * author of those macros, Michael Chapman, has relicensed those macros under
- * the ISC license.
- */
-
-#define POKE(value, type, func)   \
-((length >= sizeof type) &&  \
-( \
-type = func(value),   \
-memcpy(pos, &type, sizeof type), \
-length -= sizeof type,   \
-pos += sizeof type,  \
-1 \
-) \
-)
-#define POKE_UINT8(value) POKE(value, types.f_uint8, )
-#define POKE_UINT16(value) POKE(value, types.f_uint16, htons)
-#define POKE_UINT32(value) POKE(value, types.f_uint32, htonl)
-#define POKE_BYTES(value, bytes)   \
-((length >= (bytes)) &&\
-(  \
-memcpy(pos, value, bytes), \
-length -= (bytes), \
-pos += (bytes),\
-1  \
-)  \
-)
-#define POKE_SAVE(where) (where = pos, 1)
-#define POKE_RESTORE(where)\
-do {   \
-if ((where) > pos) \
-length -= ((where) - pos); \
-else   \
-length += (pos - (where)); \
-pos = (where); \
-} while(0)
-
 /* This set of macro are used to parse packets. The same variable as for POKE_
  * are used. There is no check on boundaries.
  */
@@ -103,23 +62,6 @@ VLOG_DEFINE_THIS_MODULE(lldp);
  (length -= (bytes),   \
  pos += (bytes),   \
  memcmp(pos-bytes, value, bytes))
-#define PEEK_SAVE POKE_SAVE
-#define PEEK_RESTORE POKE_RESTORE
-
-/* LLDP specific. We need a `tlv' pointer. */
-#define POKE_START_LLDP_TLV(type) \
-( \
-tlv = pos,\
-POKE_UINT16(type << 9)\
-)
-#define POKE_END_LLDP_TLV\
-(\
-memcpy(&types.f_uint16, tlv, sizeof(uint16_t)),  \
-types.f_uint16 |= htons((pos - (tlv + 2)) & 0x01ff), \
-memcpy(tlv, &types.f_uint16, sizeof(uint16_t)),  \
-1\
-)
-
 #define CHECK_TLV_SIZE(x, name) \
 do {\
 if (tlv_size < (x)) {   \
@@ -128,6 +70,7 @@ VLOG_DEFINE_THIS_MODULE(lldp);
 goto malformed; \
 }   \
 } while (0)
+#define PEEK_SAVE(where) (where = pos, 1)
 
 static union {
 uint8_t  f_uint8;
@@ -161,17 +104,51 @@ lldpd_af_from_lldp_proto(int proto)
 }
 }
 
+static void
+lldp_tlv_put_u8(struct ofpbuf *p, uint8_t x)
+{
+ofpbuf_put(p, &x, sizeof x);
+}
+
+static void
+lldp_tlv_put_u16(struct ofpbuf *p, uint16_t x)
+{
+ovs_be16 nx = htons(x);
+ofpbuf_put(p, &nx, sizeof nx);
+}
+
+static void
+lldp_tlv_put_u32(struct ofpbuf *p, uint32_t x)
+{
+ovs_be32 nx = htonl(x);
+ofpbuf_put(p, &nx, sizeof nx);
+}
+
+static void
+lldp_tlv_start(struct ofpbuf *p, uint8_t tlv, unsigned int *start)
+{
+*start = ofpbuf_size(p);
+lldp_tlv_put_u16(p, tlv << 9);
+}
+
+static void
+lldp_tlv_end(struct ofpbuf *p, unsigned int start)
+{
+ovs_be16 *tlv = ofpbuf_at(p, start, 2);
+*tlv |= htons((ofpbuf_size(p) - (start + 2)) & 0x1ff);
+}
+
 int
 lldp_send(struct lldpd *global OVS_UNUSED,
   struct lldpd_hardware *hardware,
   struct ofpbuf *p)
 {
+unsigned int orig_size = ofpbuf_size(p);
+unsigned int start;
+
 struct lldpd_port *port;
 struct lldpd_chassis *chassis;
-struct lldpd_frame *frame;
-uint8_t *packet, *pos, *tlv;
 struct lldpd_mgmt *mgmt;
-int length, proto;
 const uint8_t avaya[] = LLDP_TLV_ORG_AVAYA;
 struct lldpd_

[ovs-dev] [PATCH 06/32] lldp: Use x*alloc() functions instead of writing them out in-place.

2015-02-22 Thread Ben Pfaff
Also use flexible array member instead of array of length 1 in
struct lldpd_frame.

Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldp.c  | 33 +
 lib/lldp/lldpd-structs.h |  4 ++--
 lib/lldp/lldpd.c | 18 +-
 lib/ovs-lldp.c   |  7 +--
 4 files changed, 13 insertions(+), 49 deletions(-)

diff --git a/lib/lldp/lldp.c b/lib/lldp/lldp.c
index 76c7877..f620d73 100644
--- a/lib/lldp/lldp.c
+++ b/lib/lldp/lldp.c
@@ -341,17 +341,10 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, 
int s,
 
 VLOG_DBG("receive LLDP PDU on %s", hardware->h_ifname);
 
-if ((chassis = calloc(1, sizeof *chassis)) == NULL) {
-VLOG_WARN("failed to allocate remote chassis");
-return -1;
-}
+chassis = xzalloc(sizeof *chassis);
 list_init(&chassis->c_mgmt.m_entries);
 
-if ((port = calloc(1, sizeof *port)) == NULL) {
-VLOG_WARN("failed to allocate remote port");
-free(chassis);
-return -1;
-}
+port = xzalloc(sizeof *port);
 list_init(&port->p_isid_vlan_maps.m_entries);
 
 length = s;
@@ -411,12 +404,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
   hardware->h_ifname);
 goto malformed;
 }
-if ((b = (char *) calloc(1, tlv_size - 1)) == NULL) {
-VLOG_WARN("unable to allocate memory for id tlv received "
-  "on %s",
-  hardware->h_ifname);
-goto malformed;
-}
+b = xzalloc(tlv_size - 1);
 PEEK_BYTES(b, tlv_size - 1);
 if (tlv_type == LLDP_TLV_PORT_ID) {
 port->p_id_subtype = tlv_subtype;
@@ -442,12 +430,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
 VLOG_DBG("empty tlv received on %s", hardware->h_ifname);
 break;
 }
-if ((b = (char *) calloc(1, tlv_size + 1)) == NULL) {
-VLOG_WARN("unable to allocate memory for string tlv "
-  "received on %s",
-  hardware->h_ifname);
-goto malformed;
-}
+b = xzalloc(tlv_size + 1);
 PEEK_BYTES(b, tlv_size);
 if (tlv_type == LLDP_TLV_PORT_DESCR) {
 port->p_descr = b;
@@ -552,13 +535,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
 
 num_mappings /= 5; /* Each mapping is 5 Bytes */
 for(; num_mappings > 0; num_mappings--) {
-isid_vlan_map = (struct lldpd_aa_isid_vlan_maps_tlv *)
-calloc(1, sizeof *isid_vlan_map);
-if (!isid_vlan_map) {
-VLOG_WARN("unable to allocate memory "
-  "for aa_isid_vlan_maps_tlv struct");
-goto malformed;
-}
+isid_vlan_map = xzalloc(sizeof *isid_vlan_map);
 aa_status_vlan_word = PEEK_UINT16;
 
 /* Status is first 4 most-significant bits. */
diff --git a/lib/lldp/lldpd-structs.h b/lib/lldp/lldpd-structs.h
index 98ebd52..727dc72 100644
--- a/lib/lldp/lldpd-structs.h
+++ b/lib/lldp/lldpd-structs.h
@@ -1,6 +1,6 @@
 /* -*- mode: c; c-file-style: "openbsd" -*- */
 /*
- * Copyright (c) 2008 Vincent Bernat 
+ * Copyright (c) 2008, 2015 Vincent Bernat 
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -149,7 +149,7 @@ struct lldpd_config {
 
 struct lldpd_frame {
 int size;
-unsigned char frame[1];
+unsigned char frame[];
 };
 
 struct lldpd_hardware;
diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c
index 9c8173e..a5a07b9 100644
--- a/lib/lldp/lldpd.c
+++ b/lib/lldp/lldpd.c
@@ -82,10 +82,7 @@ lldpd_alloc_hardware(struct lldpd *cfg, char *name, int 
index)
 
 VLOG_DBG("allocate a new local hardware interface (%s)", name);
 
-if ((hw = (struct lldpd_hardware *) calloc(1, sizeof *hw)) == NULL) {
-return NULL;
-}
-
+hw = xzalloc(sizeof *hw);
 hw->h_cfg = cfg;
 ovs_strlcpy(hw->h_ifname, name, sizeof hw->h_ifname);
 hw->h_ifindex = index;
@@ -112,11 +109,7 @@ lldpd_alloc_mgmt(int family, void *addrptr, size_t 
addrsize, u_int32_t iface)
 errno = EOVERFLOW;
 return NULL;
 }
-mgmt = calloc(1, sizeof *mgmt);
-if (mgmt == NULL) {
-errno = ENOMEM;
-return NULL;
-}
+mgmt = xzalloc(sizeof *mgmt);
 mgmt->m_family = family;
 memcpy(&mgmt->m_addr, addrptr, addrsize);
 mgmt->m_addrsize = addrsize;
@@ -392,10 +385,9 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
 
 /* Add port */
 port->p_lastchange = port->p_lastupdate = time(NULL);
-if ((port->p_lastframe = mal

[ovs-dev] [PATCH 08/32] lldp: Use OVS time functions.

2015-02-22 Thread Ben Pfaff
Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldpd-structs.c | 4 ++--
 lib/lldp/lldpd.c | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/lldp/lldpd-structs.c b/lib/lldp/lldpd-structs.c
index 7a434ff..bd77c28 100644
--- a/lib/lldp/lldpd-structs.c
+++ b/lib/lldp/lldpd-structs.c
@@ -18,9 +18,9 @@
 #include 
 #include "lldpd-structs.h"
 #include 
-#include 
 #include 
 #include "lldpd.h"
+#include "timeval.h"
 
 VLOG_DEFINE_THIS_MODULE(lldpd_structs);
 
@@ -69,7 +69,7 @@ lldpd_remote_cleanup(struct lldpd_hardware *hw,
 {
 struct lldpd_port *port, *port_next;
 int del;
-time_t now = time(NULL);
+time_t now = time_now();
 
 VLOG_DBG("cleanup remote port on %s", hw->h_ifname);
 LIST_FOR_EACH_SAFE (port, port_next, p_entries, &hw->h_rports.p_entries) {
diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c
index a5a07b9..88cebe0 100644
--- a/lib/lldp/lldpd.c
+++ b/lib/lldp/lldpd.c
@@ -29,7 +29,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #ifndef _WIN32
 #include 
@@ -42,6 +41,7 @@
 #include "compiler.h"
 #include "list.h"
 #include "packets.h"
+#include "timeval.h"
 
 VLOG_DEFINE_THIS_MODULE(lldpd);
 
@@ -267,7 +267,7 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
 (memcmp(oport->p_lastframe->frame, frame, s) == 0)) {
 /* Already received the same frame */
 VLOG_DBG("duplicate frame, no need to decode");
-oport->p_lastupdate = time(NULL);
+oport->p_lastupdate = time_now();
 return;
 }
 }
@@ -384,7 +384,7 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
 }
 
 /* Add port */
-port->p_lastchange = port->p_lastupdate = time(NULL);
+port->p_lastchange = port->p_lastupdate = time_now();
 port->p_lastframe = xmalloc(s + sizeof(struct lldpd_frame));
 port->p_lastframe->size = s;
 memcpy(port->p_lastframe->frame, frame, s);
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 07/32] ovs-lldp: Use correct printf specifiers.

2015-02-22 Thread Ben Pfaff
Signed-off-by: Ben Pfaff 
---
 lib/ovs-lldp.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/lib/ovs-lldp.c b/lib/ovs-lldp.c
index f2d966c..9d88213 100644
--- a/lib/ovs-lldp.c
+++ b/lib/ovs-lldp.c
@@ -307,15 +307,13 @@ aa_print_isid_status_port_isid(struct lldp *lldp, struct 
lldpd_port *port)
   mapping->isid_vlan_data.vlan,
   mapping->isid_vlan_data.status);
 
-/* Update the status of our internal state for the mapping.
- */
+/* Update the status of our internal state for the mapping. */
 if (m) {
-VLOG_INFO("Setting status for ISID=%u to %u",
-  isid,
-  mapping->isid_vlan_data.status);
+VLOG_INFO("Setting status for ISID=%"PRIu32" to %"PRIu16,
+  isid, mapping->isid_vlan_data.status);
 m->status = mapping->isid_vlan_data.status;
 } else {
-VLOG_WARN("Couldn't find mapping for I-SID=%u", isid);
+VLOG_WARN("Couldn't find mapping for I-SID=%"PRIu32, isid);
 }
 }
 }
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 09/32] lldp: Use "bool" for boolean variables.

2015-02-22 Thread Ben Pfaff
Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldp.c  |  4 ++--
 lib/lldp/lldpd-structs.c | 17 -
 lib/lldp/lldpd-structs.h |  6 +++---
 lib/lldp/lldpd.c | 10 +-
 4 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/lib/lldp/lldp.c b/lib/lldp/lldp.c
index f620d73..b3c8346 100644
--- a/lib/lldp/lldp.c
+++ b/lib/lldp/lldp.c
@@ -597,8 +597,8 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
 return 1;
 
 malformed:
-lldpd_chassis_cleanup(chassis, 1);
-lldpd_port_cleanup(port, 1);
+lldpd_chassis_cleanup(chassis, true);
+lldpd_port_cleanup(port, true);
 free(port);
 return -1;
 }
diff --git a/lib/lldp/lldpd-structs.c b/lib/lldp/lldpd-structs.c
index bd77c28..abd251a 100644
--- a/lib/lldp/lldpd-structs.c
+++ b/lib/lldp/lldpd-structs.c
@@ -44,7 +44,7 @@ lldpd_chassis_mgmt_cleanup(struct lldpd_chassis *chassis)
 }
 
 void
-lldpd_chassis_cleanup(struct lldpd_chassis *chassis, int all)
+lldpd_chassis_cleanup(struct lldpd_chassis *chassis, bool all)
 {
 lldpd_chassis_mgmt_cleanup(chassis);
 VLOG_DBG("cleanup chassis %s",
@@ -58,27 +58,26 @@ lldpd_chassis_cleanup(struct lldpd_chassis *chassis, int 
all)
 }
 
 /* Cleanup a remote port. The before last argument, `expire` is a function that
- * should be called when a remote port is removed. If the last argument is 1,
- * all remote ports are removed.
+ * should be called when a remote port is removed. If the last argument is
+ * true, all remote ports are removed.
  */
 void
 lldpd_remote_cleanup(struct lldpd_hardware *hw,
  void(*expire)(struct lldpd_hardware *,
struct lldpd_port *),
- int all)
+ bool all)
 {
 struct lldpd_port *port, *port_next;
-int del;
 time_t now = time_now();
 
 VLOG_DBG("cleanup remote port on %s", hw->h_ifname);
 LIST_FOR_EACH_SAFE (port, port_next, p_entries, &hw->h_rports.p_entries) {
-del = all;
+bool del = all;
 if (!all && expire &&
 (now >= port->p_lastupdate + port->p_chassis->c_ttl)) {
 hw->h_ageout_cnt++;
 hw->h_delete_cnt++;
-del = 1;
+del = true;
 }
 if (del) {
 if (expire) {
@@ -88,7 +87,7 @@ lldpd_remote_cleanup(struct lldpd_hardware *hw,
 if (!all) {
 list_remove(&port->p_entries);
 }
-lldpd_port_cleanup(port, 1);
+lldpd_port_cleanup(port, true);
 free(port);
 }
 }
@@ -100,7 +99,7 @@ lldpd_remote_cleanup(struct lldpd_hardware *hw,
 /* If `all' is true, clear all information, including information that
are not refreshed periodically. Port should be freed manually. */
 void
-lldpd_port_cleanup(struct lldpd_port *port, int all)
+lldpd_port_cleanup(struct lldpd_port *port, bool all)
 {
 /* We set these to NULL so we don't free wrong memory */
 
diff --git a/lib/lldp/lldpd-structs.h b/lib/lldp/lldpd-structs.h
index 727dc72..c926c29 100644
--- a/lib/lldp/lldpd-structs.h
+++ b/lib/lldp/lldpd-structs.h
@@ -219,10 +219,10 @@ struct lldpd_neighbor_change {
 
 /* Cleanup functions */
 void lldpd_chassis_mgmt_cleanup(struct lldpd_chassis *);
-void lldpd_chassis_cleanup(struct lldpd_chassis *, int);
+void lldpd_chassis_cleanup(struct lldpd_chassis *, bool all);
 void lldpd_remote_cleanup(struct lldpd_hardware *,
-void (*expire)(struct lldpd_hardware *, struct lldpd_port *), int);
-void lldpd_port_cleanup(struct lldpd_port *, int);
+void (*expire)(struct lldpd_hardware *, struct lldpd_port *), bool all);
+void lldpd_port_cleanup(struct lldpd_port *, bool all);
 void lldpd_config_cleanup(struct lldpd_config *);
 
 #endif
diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c
index 88cebe0..ff77afd 100644
--- a/lib/lldp/lldpd.c
+++ b/lib/lldp/lldpd.c
@@ -123,7 +123,7 @@ lldpd_hardware_cleanup(struct lldpd *cfg, struct 
lldpd_hardware *hardware)
 {
 VLOG_DBG("cleanup hardware port %s", hardware->h_ifname);
 
-lldpd_port_cleanup(&hardware->h_lport, 1);
+lldpd_port_cleanup(&hardware->h_lport, true);
 if (hardware->h_ops && hardware->h_ops->cleanup) {
 hardware->h_ops->cleanup(cfg, hardware);
 }
@@ -141,10 +141,10 @@ lldpd_cleanup(struct lldpd *cfg)
 LIST_FOR_EACH_SAFE (hw, hw_next, h_entries, &cfg->g_hardware.h_entries) {
 if (!hw->h_flags) {
 list_remove(&hw->h_entries);
-lldpd_remote_cleanup(hw, NULL, 1);
+lldpd_remote_cleanup(hw, NULL, true);
 lldpd_hardware_cleanup(cfg, hw);
 } else {
-lldpd_remote_cleanup(hw, NULL, 0);
+lldpd_remote_cleanup(hw, NULL, false);
 }
 }
 
@@ -335,8 +335,8 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
 } else if (count > cfg->g_config.c_max_neighbors - 1) {
 VLOG_DBG("too many neighbors for port %s, drop this new one",
  hw->

[ovs-dev] [PATCH 10/32] lldp: Declare "bool" variables as type "bool".

2015-02-22 Thread Ben Pfaff
Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldp.c  | 10 ++
 lib/lldp/lldpd.c | 27 ++-
 2 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/lib/lldp/lldp.c b/lib/lldp/lldp.c
index b3c8346..7c80296 100644
--- a/lib/lldp/lldp.c
+++ b/lib/lldp/lldp.c
@@ -328,7 +328,9 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
 const char avaya_oid[] = LLDP_TLV_ORG_AVAYA;
 const char dcbx[] = LLDP_TLV_ORG_DCBX;
 char orgid[3];
-int length, gotend = 0, ttl_received = 0, af;
+int length, af;
+bool gotend = false;
+bool ttl_received = false;
 int tlv_size, tlv_type, tlv_subtype;
 u_int8_t *pos, *tlv;
 char *b;
@@ -365,7 +367,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
 goto malformed;
 }
 
-while (length && (!gotend)) {
+while (length && !gotend) {
 if (length < 2) {
 VLOG_WARN("tlv header too short received on %s",
   hardware->h_ifname);
@@ -392,7 +394,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
 VLOG_DBG("extra data after lldp end on %s",
  hardware->h_ifname);
 }
-gotend = 1;
+gotend = true;
 break;
 
 case LLDP_TLV_CHASSIS_ID:
@@ -420,7 +422,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
 case LLDP_TLV_TTL:
 CHECK_TLV_SIZE(2, "TTL");
 chassis->c_ttl = PEEK_UINT16;
-ttl_received = 1;
+ttl_received = true;
 break;
 
 case LLDP_TLV_PORT_DESCR:
diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c
index ff77afd..f35ea44 100644
--- a/lib/lldp/lldpd.c
+++ b/lib/lldp/lldpd.c
@@ -241,7 +241,7 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
 int guess = LLDPD_MODE_LLDP;
 struct eth_header eheader;
 int count = 0;
-int found = 0;
+bool found = false;
 
 VLOG_DBG("decode a received frame on %s size %d", hw->h_ifname,s);
 
@@ -315,7 +315,7 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
 chassis->c_id_len) == 0)) {
 ochassis = oport->p_chassis;
 VLOG_DBG("MSAP is already known");
-found = 1;
+found = true;
 break;
 }
 }
@@ -344,7 +344,7 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
 
 /* No, but do we already know the system? */
 if (!oport) {
-int found = 0;
+bool found = false;
 VLOG_DBG("MSAP is unknown, search for the chassis");
 
 LIST_FOR_EACH (ochassis, list, &cfg->g_chassis.list) {
@@ -353,7 +353,7 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
 (chassis->c_id_len == ochassis->c_id_len) &&
 (memcmp(chassis->c_id, ochassis->c_id,
 chassis->c_id_len) == 0)) {
-found=1;
+found = true;
 break;
 }
 }
@@ -423,7 +423,8 @@ lldpd_hide_ports(struct lldpd *cfg,
 struct lldpd_port *port;
 int protocols[LLDPD_MODE_MAX + 1];
 char buffer[256];
-int i, j, k, found = 0;
+bool found = false;
+int i, j, k;
 unsigned int min;
 
 VLOG_DBG("apply smart filter for port %s", hw->h_ifname);
@@ -452,7 +453,7 @@ lldpd_hide_ports(struct lldpd *cfg,
 /* If we need a tie breaker, we take the first protocol only */
 if (cfg->g_config.c_smart & mask &
 (SMART_OUTGOING_ONE_PROTO | SMART_INCOMING_ONE_PROTO)) {
-found = 1;
+found = true;
 }
 protocols[i] = 1;
 } else {
@@ -463,32 +464,32 @@ lldpd_hide_ports(struct lldpd *cfg,
 /* We set the p_hidden flag to 1 if the protocol is disabled */
 LIST_FOR_EACH (port, p_entries, &hw->h_rports.p_entries) {
 if (mask == SMART_OUTGOING) {
-port->p_hidden_out = protocols[port->p_protocol] ? 0 : 1;
+port->p_hidden_out = protocols[port->p_protocol] ? false : true;
 } else {
-port->p_hidden_in = protocols[port->p_protocol] ? 0 : 1;
+port->p_hidden_in = protocols[port->p_protocol] ? false : true;
 }
 }
 
 /* If we want only one neighbor, we take the first one */
 if (cfg->g_config.c_smart & mask &
 (SMART_OUTGOING_ONE_NEIGH | SMART_INCOMING_ONE_NEIGH)) {
-found = 0;
+found = false;
 
 LIST_FOR_EACH (port, p_entries, &hw->h_rports.p_entries) {
 if (mask == SMART_OUTGOING) {
 if (found) {
-port->p_hidden_out = 1;
+port->p_hidden_out = true;
 }
 if (!port->p_hidden_out) {
-found = 1;
+found = true;
 }
 }
 if (mask == SMART_INCOMING) {
 if (fo

[ovs-dev] [PATCH 12/32] test-aa: Make variables local to this file static.

2015-02-22 Thread Ben Pfaff
Found by sparse.

Signed-off-by: Ben Pfaff 
---
 tests/test-aa.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/test-aa.c b/tests/test-aa.c
index c3f5f3a..58c20c8 100644
--- a/tests/test-aa.c
+++ b/tests/test-aa.c
@@ -26,14 +26,14 @@
 #define ETH_TYPE_LLDP   0x88cc
 
 /* Dummy MAC addresses */
-char chassis_mac[ETHER_ADDR_LEN] = { 0x5e, 0x10, 0x8e, 0xe7, 0x84, 0xad };
-uint8_t eth_src[ETHER_ADDR_LEN] = { 0x5e, 0x10, 0x8e, 0xe7, 0x84, 0xad };
+static char chassis_mac[ETH_ADDR_LEN] = { 0x5e, 0x10, 0x8e, 0xe7, 0x84, 0xad };
+static uint8_t eth_src[ETH_ADDR_LEN] = { 0x5e, 0x10, 0x8e, 0xe7, 0x84, 0xad };
 
 /* LLDP multicast address */
 static const uint8_t eth_addr_lldp[6] = {0x01, 0x80, 0xC2, 0x00, 0x00, 0x0e};
 
 /* Count of tests run */
-int num_tests = 0;
+static int num_tests = 0;
 
 
 /*
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 11/32] lldpd-structs: Fix spelling error in message.

2015-02-22 Thread Ben Pfaff
Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldpd-structs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/lldp/lldpd-structs.c b/lib/lldp/lldpd-structs.c
index abd251a..33598b4 100644
--- a/lib/lldp/lldpd-structs.c
+++ b/lib/lldp/lldpd-structs.c
@@ -48,7 +48,7 @@ lldpd_chassis_cleanup(struct lldpd_chassis *chassis, bool all)
 {
 lldpd_chassis_mgmt_cleanup(chassis);
 VLOG_DBG("cleanup chassis %s",
- chassis->c_name ? chassis->c_name : "(unkwnon)");
+ chassis->c_name ? chassis->c_name : "(unknown)");
 free(chassis->c_id);
 free(chassis->c_name);
 free(chassis->c_descr);
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 15/32] lldp-structs: Fix use of list of struct lldpd_mgmt.

2015-02-22 Thread Ben Pfaff
A list of some type should have type "struct ovs_list", not some other
type that encapsulates it.

Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldp.c  | 6 +++---
 lib/lldp/lldpd-structs.c | 7 ++-
 lib/lldp/lldpd-structs.h | 2 +-
 lib/lldp/lldpd.c | 9 +++--
 lib/ovs-lldp.c   | 4 ++--
 5 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/lib/lldp/lldp.c b/lib/lldp/lldp.c
index cb3fbbc..2bd7d48 100644
--- a/lib/lldp/lldp.c
+++ b/lib/lldp/lldp.c
@@ -206,7 +206,7 @@ lldp_send(struct lldpd *global OVS_UNUSED,
 lldp_tlv_put_u16(p, chassis->c_cap_enabled);
 lldp_tlv_end(p, start);
 
-LIST_FOR_EACH (mgmt, m_entries, &chassis->c_mgmt.m_entries) {
+LIST_FOR_EACH (mgmt, m_entries, &chassis->c_mgmt) {
 lldp_tlv_start(p, LLDP_TLV_MGMT_ADDR, &start);
 lldp_tlv_put_u8(p, mgmt->m_addrsize + 1);
 lldp_tlv_put_u8(p, lldpd_af_to_lldp_proto(mgmt->m_family));
@@ -352,7 +352,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
 VLOG_DBG("receive LLDP PDU on %s", hardware->h_ifname);
 
 chassis = xzalloc(sizeof *chassis);
-list_init(&chassis->c_mgmt.m_entries);
+list_init(&chassis->c_mgmt);
 
 port = xzalloc(sizeof *port);
 list_init(&port->p_isid_vlan_maps);
@@ -480,7 +480,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
 VLOG_WARN("unable to allocate memory for management address");
 goto malformed;
 }
-list_push_back(&chassis->c_mgmt.m_entries, &mgmt->m_entries);
+list_push_back(&chassis->c_mgmt, &mgmt->m_entries);
 break;
 
 case LLDP_TLV_ORG:
diff --git a/lib/lldp/lldpd-structs.c b/lib/lldp/lldpd-structs.c
index 33598b4..d440df9 100644
--- a/lib/lldp/lldpd-structs.c
+++ b/lib/lldp/lldpd-structs.c
@@ -32,15 +32,12 @@ lldpd_chassis_mgmt_cleanup(struct lldpd_chassis *chassis)
 VLOG_DBG("cleanup management addresses for chassis %s",
  chassis->c_name ? chassis->c_name : "(unknown)");
 
-LIST_FOR_EACH_SAFE (mgmt,
-mgmt_next,
-m_entries,
-&chassis->c_mgmt.m_entries) {
+LIST_FOR_EACH_SAFE (mgmt, mgmt_next, m_entries, &chassis->c_mgmt) {
list_remove(&mgmt->m_entries);
free(mgmt);
 }
 
-list_init(&chassis->c_mgmt.m_entries);
+list_init(&chassis->c_mgmt);
 }
 
 void
diff --git a/lib/lldp/lldpd-structs.h b/lib/lldp/lldpd-structs.h
index 5d33561..1ea2225 100644
--- a/lib/lldp/lldpd-structs.h
+++ b/lib/lldp/lldpd-structs.h
@@ -76,7 +76,7 @@ struct lldpd_chassis {
 
 u_int16_t   c_ttl;
 
-struct lldpd_mgmt  c_mgmt;
+struct ovs_list c_mgmt; /* Contains "struct lldp_mgmt"s. */
 };
 /* WARNING: any change to this structure should also be reflected into
`lldpd_copy_chassis()` which is not using marshaling. */
diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c
index f35ea44..03d58fd 100644
--- a/lib/lldp/lldpd.c
+++ b/lib/lldp/lldpd.c
@@ -180,15 +180,12 @@ lldpd_move_chassis(struct lldpd_chassis *ochassis,
  * marshaling.
  */
 memcpy(ochassis, chassis, sizeof *ochassis);
-list_init(&ochassis->c_mgmt.m_entries);
+list_init(&ochassis->c_mgmt);
 
 /* Copy of management addresses */
-LIST_FOR_EACH_SAFE (mgmt,
-mgmt_next,
-m_entries,
-&chassis->c_mgmt.m_entries) {
+LIST_FOR_EACH_SAFE (mgmt, mgmt_next, m_entries, &chassis->c_mgmt) {
 list_remove(&mgmt->m_entries);
-list_insert(&ochassis->c_mgmt.m_entries, &mgmt->m_entries);
+list_insert(&ochassis->c_mgmt, &mgmt->m_entries);
 }
 
 /* Restore saved values */
diff --git a/lib/ovs-lldp.c b/lib/ovs-lldp.c
index cae2a2e..23dd46e 100644
--- a/lib/ovs-lldp.c
+++ b/lib/ovs-lldp.c
@@ -824,7 +824,7 @@ lldp_create(const struct netdev *netdev,
 lchassis->c_id = xmalloc(ETH_ADDR_LEN);
 netdev_get_etheraddr(netdev, (uint8_t *) lchassis->c_id);
 
-list_init(&lchassis->c_mgmt.m_entries);
+list_init(&lchassis->c_mgmt);
 lchassis->c_ttl = lldp->lldpd->g_config.c_tx_interval *
   lldp->lldpd->g_config.c_tx_hold;
 lchassis->c_ttl = LLDP_CHASSIS_TTL;
@@ -921,7 +921,7 @@ lldp_create_dummy(void)
 lchassis->c_id_len = ETH_ADDR_LEN;
 lchassis->c_id = xmalloc(ETH_ADDR_LEN);
 
-list_init(&lchassis->c_mgmt.m_entries);
+list_init(&lchassis->c_mgmt);
 lchassis->c_ttl = LLDP_CHASSIS_TTL;
 lldpd_assign_cfg_to_protocols(lldp->lldpd);
 list_init(&lldp->lldpd->g_chassis.list);
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 14/32] lldp-structs: Fix use of list of lldpd_aa_isid_vlan_maps_tlv.

2015-02-22 Thread Ben Pfaff
A list of some type should have type "struct ovs_list", not some other
type that encapsulates it.

Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldp.c  | 11 +--
 lib/lldp/lldpd-structs.h |  2 +-
 lib/ovs-lldp.c   | 17 +++--
 tests/test-aa.c  | 13 +
 4 files changed, 18 insertions(+), 25 deletions(-)

diff --git a/lib/lldp/lldp.c b/lib/lldp/lldp.c
index a078538..cb3fbbc 100644
--- a/lib/lldp/lldp.c
+++ b/lib/lldp/lldp.c
@@ -274,7 +274,7 @@ lldp_send(struct lldpd *global OVS_UNUSED,
 lldp_tlv_end(p, start);
 }
 
-if (!list_is_empty(&port->p_isid_vlan_maps.m_entries)) {
+if (!list_is_empty(&port->p_isid_vlan_maps)) {
 int j;
 
 for (j = 0; j < LLDP_TLV_AA_ISID_VLAN_DIGEST_LENGTH; j++) {
@@ -288,7 +288,7 @@ lldp_send(struct lldpd *global OVS_UNUSED,
 
 LIST_FOR_EACH (vlan_isid_map,
m_entries,
-   &hardware->h_lport.p_isid_vlan_maps.m_entries) {
+   &hardware->h_lport.p_isid_vlan_maps) {
 u_int16_t status_vlan_word;
 status_vlan_word =
 (vlan_isid_map->isid_vlan_data.status << 12) |
@@ -355,7 +355,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
 list_init(&chassis->c_mgmt.m_entries);
 
 port = xzalloc(sizeof *port);
-list_init(&port->p_isid_vlan_maps.m_entries);
+list_init(&port->p_isid_vlan_maps);
 
 length = s;
 pos = (u_int8_t*) frame;
@@ -560,9 +560,8 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
 PEEK_BYTES(isid, 3);
 isid_vlan_map->isid_vlan_data.isid =
 (isid[0] << 16) | (isid[1] << 8) | isid[2];
-list_push_back(
-(struct ovs_list *) &port->p_isid_vlan_maps,
-(struct ovs_list *) isid_vlan_map);
+list_push_back(&port->p_isid_vlan_maps,
+   &isid_vlan_map->m_entries);
 isid_vlan_map = NULL;
 }
 break;
diff --git a/lib/lldp/lldpd-structs.h b/lib/lldp/lldpd-structs.h
index c926c29..5d33561 100644
--- a/lib/lldp/lldpd-structs.h
+++ b/lib/lldp/lldpd-structs.h
@@ -100,7 +100,7 @@ struct lldpd_port {
 char *p_descr;
 u_int16_tp_mfs;
 struct lldpd_aa_element_tlvp_element;
-struct lldpd_aa_isid_vlan_maps_tlv p_isid_vlan_maps;
+struct ovs_list p_isid_vlan_maps; /* Contains "struct 
lldpd_aa_isid_vlan_maps_tlv"s. */
 };
 
 /* Used to modify some port related settings */
diff --git a/lib/ovs-lldp.c b/lib/ovs-lldp.c
index 4f27e5e..cae2a2e 100644
--- a/lib/ovs-lldp.c
+++ b/lib/ovs-lldp.c
@@ -261,11 +261,11 @@ aa_print_isid_status_port_isid(struct lldp *lldp, struct 
lldpd_port *port)
 {
 struct lldpd_aa_isid_vlan_maps_tlv *mapping;
 
-if (list_is_empty(&port->p_isid_vlan_maps.m_entries)) {
+if (list_is_empty(&port->p_isid_vlan_maps)) {
 return;
 }
 
-LIST_FOR_EACH (mapping, m_entries, &port->p_isid_vlan_maps.m_entries) {
+LIST_FOR_EACH (mapping, m_entries, &port->p_isid_vlan_maps) {
 uint32_t isid = mapping->isid_vlan_data.isid;
 struct aa_mapping_internal *m = mapping_find_by_isid(lldp, isid);
 
@@ -405,8 +405,7 @@ update_mapping_on_lldp(struct lldp *lldp, struct 
lldpd_hardware *hardware,
 lm->isid_vlan_data.isid = m->isid;
 lm->isid_vlan_data.vlan = m->vlan;
 
-list_push_back(&hardware->h_lport.p_isid_vlan_maps.m_entries,
-   &lm->m_entries);
+list_push_back(&hardware->h_lport.p_isid_vlan_maps, &lm->m_entries);
 
 /* TODO Should be done in the Auto Attach state machine when a mapping goes
  * from "pending" to "active".
@@ -584,10 +583,8 @@ aa_mapping_unregister_mapping(struct lldp *lldp,
 {
 struct lldpd_aa_isid_vlan_maps_tlv *lm, *lm_next;
 
-LIST_FOR_EACH_SAFE (lm,
-lm_next,
-m_entries,
-&hw->h_lport.p_isid_vlan_maps.m_entries) {
+LIST_FOR_EACH_SAFE (lm, lm_next, m_entries,
+&hw->h_lport.p_isid_vlan_maps) {
 uint32_t isid = lm->isid_vlan_data.isid;
 
 if (isid == (uint32_t) m->isid) {
@@ -866,7 +863,7 @@ lldp_create(const struct netdev *netdev,
 hw->h_lport.p_element.system_id.mlt_id[0] = 0;
 hw->h_lport.p_element.system_id.mlt_id[1] = 0;
 
-list_init(&hw->h_lport.p_isid_vlan_maps.m_entries);
+list_init(&hw->h_lport.p_isid_vlan_maps);
 list_init(&lldp->lldpd->g_hardware.h_entries);
 list_push_back(&lldp->lldpd->g_hardware.h_entries, &hw->h_entries);
 
@@ -954,7 +951,7 @@ lldp_create_dummy(void)
 hw->h_lport.p_element.system_id.mlt_id[0] = 0;
 hw->h_lport.p_element.system_id.mlt_id[1] = 0;
 
-list_init(&hw->h_lport.p_isid_vlan_maps.m_entries);
+list_init(&hw->h_lport.p_isid_vlan_

[ovs-dev] [PATCH 13/32] lldp: Change representation of ISID to uint32_t.

2015-02-22 Thread Ben Pfaff
It's a lot more straightforward to deal with integer values as integers
instead of arrays of bytes.

Signed-off-by: Ben Pfaff 
---
 lib/lldp/aa-structs.h |  2 +-
 lib/lldp/lldp.c   | 19 +++
 lib/ovs-lldp.c| 42 +++---
 tests/test-aa.c   | 24 ++--
 4 files changed, 25 insertions(+), 62 deletions(-)

diff --git a/lib/lldp/aa-structs.h b/lib/lldp/aa-structs.h
index f58be76..e9d1162 100644
--- a/lib/lldp/aa-structs.h
+++ b/lib/lldp/aa-structs.h
@@ -38,7 +38,7 @@ struct lldpd_aa_element_tlv {
 struct lldpd_aa_isid_vlan_map_data {
 uint16_t status;
 uint16_t vlan;
-uint8_t  isid[3];
+uint32_t isid;
 };
 
 struct lldpd_aa_isid_vlan_maps_tlv {
diff --git a/lib/lldp/lldp.c b/lib/lldp/lldp.c
index 7c80296..a078538 100644
--- a/lib/lldp/lldp.c
+++ b/lib/lldp/lldp.c
@@ -125,6 +125,15 @@ lldp_tlv_put_u32(struct ofpbuf *p, uint32_t x)
 }
 
 static void
+lldp_tlv_put_isid(struct ofpbuf *p, uint32_t isid)
+{
+uint8_t *data = ofpbuf_put_uninit(p, 3);
+data[0] = isid >> 16;
+data[1] = isid >> 8;
+data[2] = isid;
+}
+
+static void
 lldp_tlv_start(struct ofpbuf *p, uint8_t tlv, unsigned int *start)
 {
 *start = ofpbuf_size(p);
@@ -286,8 +295,7 @@ lldp_send(struct lldpd *global OVS_UNUSED,
 vlan_isid_map->isid_vlan_data.vlan;
 
 lldp_tlv_put_u16(p, status_vlan_word);
-ofpbuf_put(p, &vlan_isid_map->isid_vlan_data.isid,
-   sizeof vlan_isid_map->isid_vlan_data.isid);
+lldp_tlv_put_isid(p, vlan_isid_map->isid_vlan_data.isid);
 }
 
 lldp_tlv_end(p, start);
@@ -537,6 +545,8 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
 
 num_mappings /= 5; /* Each mapping is 5 Bytes */
 for(; num_mappings > 0; num_mappings--) {
+uint8_t isid[3];
+
 isid_vlan_map = xzalloc(sizeof *isid_vlan_map);
 aa_status_vlan_word = PEEK_UINT16;
 
@@ -547,8 +557,9 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
 /* Vlan is last 12 bits */
 isid_vlan_map->isid_vlan_data.vlan =
 aa_status_vlan_word & 0x0FFF;
-PEEK_BYTES(&isid_vlan_map->isid_vlan_data.isid,
-sizeof isid_vlan_map->isid_vlan_data.isid);
+PEEK_BYTES(isid, 3);
+isid_vlan_map->isid_vlan_data.isid =
+(isid[0] << 16) | (isid[1] << 8) | isid[2];
 list_push_back(
 (struct ovs_list *) &port->p_isid_vlan_maps,
 (struct ovs_list *) isid_vlan_map);
diff --git a/lib/ovs-lldp.c b/lib/ovs-lldp.c
index 9d88213..4f27e5e 100644
--- a/lib/ovs-lldp.c
+++ b/lib/ovs-lldp.c
@@ -101,38 +101,6 @@ static struct hmap *const all_mappings 
OVS_GUARDED_BY(mutex) = &all_mappings__;
 
 static struct lldp_aa_element_system_id system_id_null;
 
-/* Convert an array to an integer.  I-SID are stored in an array of bytes
- * in the LLDP hardware structrure.
- */
-static uint32_t
-array_to_int(uint8_t *array, size_t len)
-{
-uint32_t res = 0;
-unsigned int i = 0;
-
-ovs_assert(len <= sizeof(uint32_t));
-
-for (i = 0; i < len; i++) {
-res = res | (array[len - i - 1] << (i * 8));
-}
-
-return res;
-}
-
-/* Convert an integer to an array of byte.
- */
-static void
-int_to_array(uint8_t *array, size_t len, uint32_t value)
-{
-unsigned int i;
-
-ovs_assert(len <= sizeof(uint32_t));
-
-for (i = 0; i < len; i++) {
-array[len - i - 1] = value >> (8 * i);
-}
-}
-
 /* Convert an LLDP chassis ID to a string.
  */
 static void
@@ -298,8 +266,7 @@ aa_print_isid_status_port_isid(struct lldp *lldp, struct 
lldpd_port *port)
 }
 
 LIST_FOR_EACH (mapping, m_entries, &port->p_isid_vlan_maps.m_entries) {
-uint32_t isid = array_to_int(mapping->isid_vlan_data.isid,
-sizeof mapping->isid_vlan_data.isid);
+uint32_t isid = mapping->isid_vlan_data.isid;
 struct aa_mapping_internal *m = mapping_find_by_isid(lldp, isid);
 
 VLOG_INFO("h_rport: isid=%u, vlan=%u, status=%d",
@@ -435,9 +402,7 @@ update_mapping_on_lldp(struct lldp *lldp, struct 
lldpd_hardware *hardware,
 VLOG_INFO("\t\t hardware->h_ifname=%s", hardware->h_ifname);
 }
 
-int_to_array(lm->isid_vlan_data.isid,
- ARRAY_SIZE(lm->isid_vlan_data.isid),
- (uint32_t) m->isid);
+lm->isid_vlan_data.isid = m->isid;
 lm->isid_vlan_data.vlan = m->vlan;
 
 list_push_back(&hardware->h_lport.p_isid_vlan_maps.m_entries,
@@ -623,8 +588,7 @@ aa_mapping_unregister_mapping(struct lldp *lldp,
 lm_next,
 m_entries,
 &hw->h_lport.p_isid_vlan_maps.m_entries

[ovs-dev] [PATCH 23/32] lldpd: Remove unused ALIGNED_CAST macro.

2015-02-22 Thread Ben Pfaff
Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldpd.h | 2 --
 1 file changed, 2 deletions(-)

diff --git a/lib/lldp/lldpd.h b/lib/lldp/lldpd.h
index f142180..2c00966 100644
--- a/lib/lldp/lldpd.h
+++ b/lib/lldp/lldpd.h
@@ -61,8 +61,6 @@ struct event_base;
 struct lldpd_chassis **, struct lldpd_port **
 #define PROTO_GUESS_SIG char *, int
 
-#define ALIGNED_CAST(TYPE, ATTR) ((TYPE) (void *) (ATTR))
-
 struct protocol {
 int  mode;   /* > 0 mode identifier (unique per protocol) */
 int  enabled;/* Is this protocol enabled? */
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 17/32] ovs-lldp: Use better types for ISID and VLANs.

2015-02-22 Thread Ben Pfaff
An ISID is 24 bits, so it fits in a uint32_t.  A VLAN is 12 bits, so it
fits in a uint16_t.  Use these types consistently, instead of int64_t.

This removes a check in aa_mapping_unregister() that seems a little
mysterious to me: it previously checked for ISID and VLAN values >= 0.  I
don't see a way that they could be < 0 in this situation though.

Signed-off-by: Ben Pfaff 
---
 lib/ovs-lldp.c| 69 +--
 lib/ovs-lldp.h|  8 +++
 vswitchd/bridge.c |  9 
 3 files changed, 34 insertions(+), 52 deletions(-)

diff --git a/lib/ovs-lldp.c b/lib/ovs-lldp.c
index 0d0cedc..446386a 100644
--- a/lib/ovs-lldp.c
+++ b/lib/ovs-lldp.c
@@ -78,8 +78,8 @@ enum aa_status {
 struct aa_mapping_internal {
 struct hmap_node hmap_node_isid;
 struct hmap_node hmap_node_aux;
-int64_t  isid;
-int64_t  vlan;
+uint32_t isid;
+uint16_t vlan;
 void *aux;
 enum aa_status   status;
 };
@@ -119,14 +119,12 @@ chassisid_to_string(uint8_t *array, size_t len, char 
**str)
 /* Find an Auto Attach mapping keyed by I-SID.
  */
 static struct aa_mapping_internal *
-mapping_find_by_isid(struct lldp *lldp, const uint64_t isid)
+mapping_find_by_isid(struct lldp *lldp, uint32_t isid)
 OVS_REQUIRES(mutex)
 {
 struct aa_mapping_internal *m;
 
-HMAP_FOR_EACH_IN_BUCKET (m,
- hmap_node_isid,
- hash_bytes(&isid, sizeof isid, 0),
+HMAP_FOR_EACH_IN_BUCKET (m, hmap_node_isid, hash_int(isid, 0),
  &lldp->mappings_by_isid) {
 if (isid == m->isid) {
 return m;
@@ -323,11 +321,8 @@ aa_print_isid_status(struct ds *ds, struct lldp *lldp) 
OVS_REQUIRES(mutex)
 ds_put_format(ds, "  --- \n");
 
 HMAP_FOR_EACH (m, hmap_node_isid, &lldp->mappings_by_isid) {
-ds_put_format(ds, "%-8ld %-4ld %-11s %-11s\n",
-  (long int) m->isid,
-  (long int) m->vlan,
-  "Switch",
-  aa_status_to_str(m->status));
+ds_put_format(ds, "%-8"PRIu32" %-4"PRIu16" %-11s %-11s\n",
+  m->isid, m->vlan, "Switch", aa_status_to_str(m->status));
 }
 }
 
@@ -520,8 +515,8 @@ aa_mapping_register(void *aux, const struct 
aa_mapping_settings *s)
 struct aa_mapping_internal *bridge_m;
 struct lldp *lldp;
 
-VLOG_INFO("Adding mapping ISID=%ld, VLAN=%ld, aux=%p", (long int) s->isid,
-  (long int) s->vlan, aux);
+VLOG_INFO("Adding mapping ISID=%"PRIu32", VLAN=%"PRIu16", aux=%p",
+  s->isid, s->vlan, aux);
 
 ovs_mutex_lock(&mutex);
 
@@ -534,11 +529,9 @@ aa_mapping_register(void *aux, const struct 
aa_mapping_settings *s)
 bridge_m->vlan = s->vlan;
 bridge_m->aux = aux;
 bridge_m->status = AA_STATUS_PENDING;
-hmap_insert(all_mappings,
-&bridge_m->hmap_node_isid,
-hash_bytes((const void *) &bridge_m->isid,
-   sizeof bridge_m->isid,
-   0));
+hmap_insert(all_mappings, &bridge_m->hmap_node_isid,
+hash_int(bridge_m->isid, 0));
+
 
 /* Update mapping on the all the LLDP instances. */
 HMAP_FOR_EACH (lldp, hmap_node, all_lldps) {
@@ -556,11 +549,8 @@ aa_mapping_register(void *aux, const struct 
aa_mapping_settings *s)
 m->vlan = s->vlan;
 m->status = AA_STATUS_PENDING;
 m->aux = aux;
-hmap_insert(&lldp->mappings_by_isid,
-&m->hmap_node_isid,
-hash_bytes((const void *) &m->isid,
-   sizeof m->isid,
-   0));
+hmap_insert(&lldp->mappings_by_isid, &m->hmap_node_isid,
+hash_int(m->isid, 0));
 hmap_insert(&lldp->mappings_by_aux,
 &m->hmap_node_aux,
 hash_pointer(m->aux, 0));
@@ -587,7 +577,7 @@ aa_mapping_unregister_mapping(struct lldp *lldp,
 &hw->h_lport.p_isid_vlan_maps) {
 uint32_t isid = lm->isid_vlan_data.isid;
 
-if (isid == (uint32_t) m->isid) {
+if (isid == m->isid) {
 VLOG_INFO("\t\t Removing lport, isid=%u, vlan=%u",
   isid,
   lm->isid_vlan_data.vlan);
@@ -626,17 +616,15 @@ aa_mapping_unregister(void *aux)
 HMAP_FOR_EACH (lldp, hmap_node, all_lldps) {
 struct lldpd_hardware *hw;
 struct aa_mapping_internal *m = mapping_find_by_aux(lldp, aux);
-int64_t isid_tmp = -1, vlan_tmp = -1;
 
 /* Remove from internal hash tables. */
 if (m) {
-struct aa_mapping_internal *p =
-mapping_find_by_isid(lldp, m->isid);
+uint32_t isid = m->isid;
+uint16_t vlan = m->vlan;
+struct aa_mapping_internal *p = mapping_find_by_isid(lldp, 

[ovs-dev] [PATCH 19/32] lldp: Miscellaneous coding style fixes.

2015-02-22 Thread Ben Pfaff
Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldp.c  |  4 ++--
 lib/lldp/lldpd-structs.h | 14 +++---
 lib/ovs-lldp.c   | 34 +-
 3 files changed, 22 insertions(+), 30 deletions(-)

diff --git a/lib/lldp/lldp.c b/lib/lldp/lldp.c
index 2b8de0e..8fece07 100644
--- a/lib/lldp/lldp.c
+++ b/lib/lldp/lldp.c
@@ -244,8 +244,8 @@ lldp_send(struct lldpd *global OVS_UNUSED,
 /* Element type should be first 4 most significant bits, so bitwise OR
  * that with the first 4 bits of the 12-bit-wide mgmt_vlan
  */
-aa_element_first_byte = ((port->p_element.type & 0xF) << 4) |
-((port->p_element.mgmt_vlan >> 8) & 0xF);
+aa_element_first_byte = (((port->p_element.type & 0xF) << 4) |
+ ((port->p_element.mgmt_vlan >> 8) & 0xF));
 
 /* Second byte should just be the remaining 8 bits of .mgmt_vlan */
 aa_element_second_byte = port->p_element.mgmt_vlan & 0x0FF;
diff --git a/lib/lldp/lldpd-structs.h b/lib/lldp/lldpd-structs.h
index f38969b..ef7af74 100644
--- a/lib/lldp/lldpd-structs.h
+++ b/lib/lldp/lldpd-structs.h
@@ -155,13 +155,13 @@ struct lldpd_frame {
 struct lldpd_hardware;
 struct lldpd;
 struct lldpd_ops {
-int(*send)(struct lldpd *,
-   struct lldpd_hardware*,
-   char *, size_t); /* Function to send a frame */
-int(*recv)(struct lldpd *,
-   struct lldpd_hardware*,
-   int, char *, size_t); /* Function to receive a frame */
-int(*cleanup)(struct lldpd *, struct lldpd_hardware *); /* Cleanup */
+int (*send)(struct lldpd *,
+struct lldpd_hardware *,
+char *, size_t); /* Function to send a frame */
+int (*recv)(struct lldpd *,
+struct lldpd_hardware *,
+int, char *, size_t); /* Function to receive a frame */
+int (*cleanup)(struct lldpd *, struct lldpd_hardware *); /* Cleanup */
 };
 
 /* An interface is uniquely identified by h_ifindex, h_ifname and h_ops. This
diff --git a/lib/ovs-lldp.c b/lib/ovs-lldp.c
index 68e8c24..aa52cd9 100644
--- a/lib/ovs-lldp.c
+++ b/lib/ovs-lldp.c
@@ -218,14 +218,10 @@ aa_print_element_status_port(struct ds *ds, struct 
lldpd_hardware *hw)
 chassisid_to_string((uint8_t *) &port->p_element.system_id,
 sizeof port->p_element.system_id, &system);
 
-ds_put_format(ds,
-  "\tAuto Attach Primary Server Id: %s\n",
-  id);
-ds_put_format(ds,
-  "\tAuto Attach Primary Server Descr: %s\n",
+ds_put_format(ds, "\tAuto Attach Primary Server Id: %s\n", id);
+ds_put_format(ds, "\tAuto Attach Primary Server Descr: %s\n",
   descr);
-ds_put_format(ds,
-  "\tAuto Attach Primary Server System Id: %s\n",
+ds_put_format(ds, "\tAuto Attach Primary Server System Id: %s\n",
   system);
 
 free(id);
@@ -405,15 +401,13 @@ update_mapping_on_lldp(struct lldp *lldp, struct 
lldpd_hardware *hardware,
 /* TODO Should be done in the Auto Attach state machine when a mapping goes
  * from "pending" to "active".
  */
-{
-struct bridge_aa_vlan *node = xmalloc(sizeof *node);
+struct bridge_aa_vlan *node = xmalloc(sizeof *node);
 
-node->port_name = xstrdup(hardware->h_ifname);
-node->vlan = m->vlan;
-node->oper = BRIDGE_AA_VLAN_OPER_ADD;
+node->port_name = xstrdup(hardware->h_ifname);
+node->vlan = m->vlan;
+node->oper = BRIDGE_AA_VLAN_OPER_ADD;
 
-list_push_back(&lldp->active_mapping_queue, &node->list_node);
-}
+list_push_back(&lldp->active_mapping_queue, &node->list_node);
 }
 
 /* Bridge will poll the list of VLAN that needs to be auto configure based on
@@ -587,15 +581,13 @@ aa_mapping_unregister_mapping(struct lldp *lldp,
 /* TODO Should be done in the AA SM when a mapping goes
  * from "pending" to "active".
  */
-{
-struct bridge_aa_vlan *node = xmalloc(sizeof *node);
+struct bridge_aa_vlan *node = xmalloc(sizeof *node);
 
-node->port_name = xstrdup(hw->h_ifname);
-node->vlan = (uint32_t) m->vlan;
-node->oper = BRIDGE_AA_VLAN_OPER_REMOVE;
+node->port_name = xstrdup(hw->h_ifname);
+node->vlan = m->vlan;
+node->oper = BRIDGE_AA_VLAN_OPER_REMOVE;
 
-list_push_back(&lldp->active_mapping_queue, &node->list_node);
-}
+list_push_back(&lldp->active_mapping_queue, &node->list_node);
 
 break;
 }
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 21/32] lldpd: Remove obsolete comment.

2015-02-22 Thread Ben Pfaff
Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldpd.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c
index eb32269..c7b40d2 100644
--- a/lib/lldp/lldpd.c
+++ b/lib/lldp/lldpd.c
@@ -402,7 +402,6 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
  * freed with lldpd_port_cleanup() and therefore, the refcount
  * of the chassis that was attached to it is decreased.
  */
-/* coverity[use_after_free] TAILQ_REMOVE does the right thing */
 i = list_size(&hw->h_rports);
 VLOG_DBG("%"PRIuSIZE " neighbors for %s", i, hw->h_ifname);
 
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 22/32] lldpd: Use CONTAINER_OF instead of cast, for safety.

2015-02-22 Thread Ben Pfaff
Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldpd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c
index c7b40d2..06f8ea0 100644
--- a/lib/lldp/lldpd.c
+++ b/lib/lldp/lldpd.c
@@ -86,8 +86,8 @@ lldpd_alloc_hardware(struct lldpd *cfg, char *name, int index)
 hw->h_cfg = cfg;
 ovs_strlcpy(hw->h_ifname, name, sizeof hw->h_ifname);
 hw->h_ifindex = index;
-hw->h_lport.p_chassis = (struct lldpd_chassis *)
-list_front(&cfg->g_chassis.list);
+hw->h_lport.p_chassis = CONTAINER_OF(list_front(&cfg->g_chassis.list),
+ struct lldpd_chassis, list);
 hw->h_lport.p_chassis->c_refcount++;
 list_init(&hw->h_rports);
 
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 20/32] ovs-lldp: Remove unneeded NULL checks on free().

2015-02-22 Thread Ben Pfaff
Signed-off-by: Ben Pfaff 
---
 lib/ovs-lldp.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/lib/ovs-lldp.c b/lib/ovs-lldp.c
index aa52cd9..5deee58 100644
--- a/lib/ovs-lldp.c
+++ b/lib/ovs-lldp.c
@@ -482,16 +482,12 @@ aa_configure(const struct aa_settings *s)
 
 LIST_FOR_EACH (chassis, list, &lldp->lldpd->g_chassis.list) {
 /* System Description */
-if (chassis->c_descr) {
-free(chassis->c_descr);
-}
+free(chassis->c_descr);
 chassis->c_descr = s->system_description[0] ?
 xstrdup(s->system_description) : xstrdup(PACKAGE_STRING);
 
 /* System Name */
-if (chassis->c_name) {
-free(chassis->c_name);
-}
+free(chassis->c_name);
 chassis->c_name = xstrdup(s->system_name);
 }
 }
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 30/32] lldpd: Fix use of list of struct lldpd_hardware.

2015-02-22 Thread Ben Pfaff
A list of some type should have type "struct ovs_list", not some other
type that encapsulates it.

This ovs_list is a bit puzzling in itself, because it appears to always
have exactly one element.

Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldpd.c |  6 +++---
 lib/lldp/lldpd.h |  9 -
 lib/ovs-lldp.c   | 28 
 tests/test-aa.c  |  5 ++---
 4 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c
index d309f32..c1bfdaf 100644
--- a/lib/lldp/lldpd.c
+++ b/lib/lldp/lldpd.c
@@ -64,7 +64,7 @@ lldpd_get_hardware(struct lldpd *cfg, char *name, int index,
 {
 struct lldpd_hardware *hw;
 
-LIST_FOR_EACH (hw, h_entries, &cfg->g_hardware.h_entries) {
+LIST_FOR_EACH (hw, h_entries, &cfg->g_hardware) {
 if (!strcmp(hw->h_ifname, name) && hw->h_ifindex == index
 && (!ops || ops == hw->h_ops)) {
 return hw;
@@ -137,7 +137,7 @@ lldpd_cleanup(struct lldpd *cfg)
 
 VLOG_DBG("cleanup all ports");
 
-LIST_FOR_EACH_SAFE (hw, hw_next, h_entries, &cfg->g_hardware.h_entries) {
+LIST_FOR_EACH_SAFE (hw, hw_next, h_entries, &cfg->g_hardware) {
 if (!hw->h_flags) {
 list_remove(&hw->h_entries);
 lldpd_remote_cleanup(hw, NULL, true);
@@ -542,7 +542,7 @@ lldpd_hide_all(struct lldpd *cfg)
 
 VLOG_DBG("apply smart filter results on all ports");
 
-LIST_FOR_EACH (hw, h_entries, &cfg->g_hardware.h_entries) {
+LIST_FOR_EACH (hw, h_entries, &cfg->g_hardware) {
 if (cfg->g_config.c_smart & SMART_INCOMING_FILTER) {
 lldpd_hide_ports(cfg, hw, SMART_INCOMING);
 }
diff --git a/lib/lldp/lldpd.h b/lib/lldp/lldpd.h
index aa7665e..3aaf790 100644
--- a/lib/lldp/lldpd.h
+++ b/lib/lldp/lldpd.h
@@ -84,9 +84,16 @@ struct lldpd {
 int g_lastrid;
 
 struct ovs_list g_chassis; /* Contains "struct lldp_chassis". */
-struct lldpd_hardware g_hardware;
+struct ovs_list g_hardware; /* Contains "struct lldpd_hardware". */
 };
 
+static inline struct lldpd_hardware *
+lldpd_first_hardware(struct lldpd *lldpd)
+{
+return CONTAINER_OF(list_front(&lldpd->g_hardware),
+struct lldpd_hardware, h_entries);
+}
+
 /* lldpd.c */
 struct lldpd_hardware *lldpd_get_hardware(struct lldpd *,
 char *, int, struct lldpd_ops *);
diff --git a/lib/ovs-lldp.c b/lib/ovs-lldp.c
index abea477..4ac5d90 100644
--- a/lib/ovs-lldp.c
+++ b/lib/ovs-lldp.c
@@ -179,7 +179,7 @@ aa_print_lldp_and_aa_stats(struct ds *ds, struct lldp *lldp)
 return;
 }
 
-LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware.h_entries) {
+LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware) {
 ds_put_format(ds, "\ttx cnt: %"PRIu64"\n", hw->h_tx_cnt);
 ds_put_format(ds, "\trx cnt: %"PRIu64"\n", hw->h_rx_cnt);
 ds_put_format(ds, "\trx discarded cnt: %"PRIu64"\n",
@@ -244,7 +244,7 @@ aa_print_element_status(struct ds *ds, struct lldp *lldp) 
OVS_REQUIRES(mutex)
 return;
 }
 
-LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware.h_entries) {
+LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware) {
 aa_print_element_status_port(ds, hw);
 }
 }
@@ -305,7 +305,7 @@ aa_print_isid_status(struct ds *ds, struct lldp *lldp) 
OVS_REQUIRES(mutex)
 
 ds_put_format(ds, "LLDP: %s\n", lldp->name);
 
-LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware.h_entries) {
+LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware) {
 aa_print_isid_status_port(lldp, hw);
 }
 
@@ -546,7 +546,7 @@ aa_mapping_register(void *aux, const struct 
aa_mapping_settings *s)
 hash_pointer(m->aux, 0));
 
 /* Configure the mapping on each port of the LLDP stack. */
-LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware.h_entries) {
+LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware) {
 update_mapping_on_lldp(lldp, hw, m);
 }
 }
@@ -622,7 +622,7 @@ aa_mapping_unregister(void *aux)
 free(m);
 
 /* Remove from all the lldp instances */
-LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware.h_entries) {
+LIST_FOR_EACH (hw, h_entries, &lldp->lldpd->g_hardware) {
 if (hw->h_ifname) {
 VLOG_INFO("\t\t hardware->h_ifname=%s", hw->h_ifname);
 }
@@ -672,11 +672,8 @@ void
 lldp_process_packet(struct lldp *lldp, const struct ofpbuf *p)
 {
 if (lldp) {
-lldpd_recv(lldp->lldpd,
-   (struct lldpd_hardware *)
-   lldp->lldpd->g_hardware.h_entries.next,
-   (char *) p->data_,
-   p->size_);
+lldpd_recv(lldp->lldpd, lldpd_first_hardware(lldp->lldpd),
+   (char *) p->data_, p->size_);
 }
 }
 
@@ -730,8 +727,7 @@ lldp_put_packet(struct lldp *lldp, struct ofpbuf *packet,
 uint8_t eth_src[ETH_ADDR_LEN]) OVS_EXC

[ovs-dev] [PATCH 25/32] lldp: Remove excessive parentheses.

2015-02-22 Thread Ben Pfaff
The OVS style is to usually avoid parentheses in cases like these where
they just make expressions harder to read.

Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldp.c  |  9 +++--
 lib/lldp/lldpd.c | 31 +++
 2 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/lib/lldp/lldp.c b/lib/lldp/lldp.c
index 8fece07..53388af 100644
--- a/lib/lldp/lldp.c
+++ b/lib/lldp/lldp.c
@@ -409,7 +409,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
 case LLDP_TLV_PORT_ID:
 CHECK_TLV_SIZE(2, "Port Id");
 tlv_subtype = PEEK_UINT8;
-if ((tlv_subtype == 0) || (tlv_subtype > 7)) {
+if (tlv_subtype == 0 || tlv_subtype > 7) {
 VLOG_WARN("unknown subtype for tlv id received on %s",
   hardware->h_ifname);
 goto malformed;
@@ -538,7 +538,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
  */
 num_mappings = tlv_size - 4 -
 LLDP_TLV_AA_ISID_VLAN_DIGEST_LENGTH;
-if ((num_mappings % 5) != 0) {
+if (num_mappings % 5 != 0) {
 VLOG_INFO("malformed vlan-isid mappings tlv received");
 goto malformed;
 }
@@ -596,10 +596,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
 }
 
 /* Some random check */
-if ((chassis->c_id == NULL) ||
-(port->p_id == NULL) ||
-(!ttl_received) ||
-(gotend == 0)) {
+if (!chassis->c_id || !port->p_id || !ttl_received || !gotend) {
 VLOG_WARN("some mandatory tlv are missing for frame received "
   "on %s", hardware->h_ifname);
 goto malformed;
diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c
index 4467960..8259e9d 100644
--- a/lib/lldp/lldpd.c
+++ b/lib/lldp/lldpd.c
@@ -65,9 +65,8 @@ lldpd_get_hardware(struct lldpd *cfg, char *name, int index,
 struct lldpd_hardware *hw;
 
 LIST_FOR_EACH (hw, h_entries, &cfg->g_hardware.h_entries) {
-if ((strcmp(hw->h_ifname, name) == 0) &&
-(hw->h_ifindex == index) &&
-((!ops) || (ops == hw->h_ops))) {
+if (!strcmp(hw->h_ifname, name) && hw->h_ifindex == index
+&& (!ops || ops == hw->h_ops)) {
 return hw;
 }
 }
@@ -259,9 +258,9 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
 }
 
 LIST_FOR_EACH (oport, p_entries, &hw->h_rports) {
-if ((oport->p_lastframe != NULL) &&
-(oport->p_lastframe->size == s) &&
-(memcmp(oport->p_lastframe->frame, frame, s) == 0)) {
+if (oport->p_lastframe &&
+oport->p_lastframe->size == s &&
+!memcmp(oport->p_lastframe->frame, frame, s)) {
 /* Already received the same frame */
 VLOG_DBG("duplicate frame, no need to decode");
 oport->p_lastupdate = time_now();
@@ -303,13 +302,13 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
 LIST_FOR_EACH (oport, p_entries, &hw->h_rports) {
 if (port->p_protocol == oport->p_protocol) {
 count++;
-if ((port->p_id_subtype == oport->p_id_subtype) &&
-(port->p_id_len == oport->p_id_len) &&
-(memcmp(port->p_id, oport->p_id, port->p_id_len) == 0) &&
-(chassis->c_id_subtype == oport->p_chassis->c_id_subtype) &&
-(chassis->c_id_len == oport->p_chassis->c_id_len) &&
-(memcmp(chassis->c_id, oport->p_chassis->c_id,
-chassis->c_id_len) == 0)) {
+if (port->p_id_subtype == oport->p_id_subtype &&
+port->p_id_len == oport->p_id_len &&
+!memcmp(port->p_id, oport->p_id, port->p_id_len) &&
+chassis->c_id_subtype == oport->p_chassis->c_id_subtype &&
+chassis->c_id_len == oport->p_chassis->c_id_len &&
+!memcmp(chassis->c_id, oport->p_chassis->c_id,
+chassis->c_id_len)) {
 ochassis = oport->p_chassis;
 VLOG_DBG("MSAP is already known");
 found = true;
@@ -445,7 +444,7 @@ lldpd_hide_ports(struct lldpd *cfg,
 }
 }
 for (i = 0; i <= LLDPD_MODE_MAX; i++) {
-if ((protocols[i] == min) && !found) {
+if (protocols[i] == min && !found) {
 /* If we need a tie breaker, we take the first protocol only */
 if (cfg->g_config.c_smart & mask &
 (SMART_OUTGOING_ONE_PROTO | SMART_INCOMING_ONE_PROTO)) {
@@ -498,8 +497,8 @@ lldpd_hide_ports(struct lldpd *cfg,
 
 k = j = 0;
 LIST_FOR_EACH (port, p_entries, &hw->h_rports) {
-if (!(((mask == SMART_OUTGOING) && port->p_hidden_out) ||
-  ((mask == SMART_INCOMING) && port->p_hidden_in))) {
+if (!((mask == SMART_OUTGOING && port->p_hidden_out) ||
+  (mask == SMART_INCOMING

[ovs-dev] [PATCH 24/32] lldpd: Fix return value convention for "send" function.

2015-02-22 Thread Ben Pfaff
errno values are positive values, so it's not reasonable to use E2BIG as
an error return with positive values also indicating packet lengths.

Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldpd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c
index 06f8ea0..4467960 100644
--- a/lib/lldp/lldpd.c
+++ b/lib/lldp/lldpd.c
@@ -598,7 +598,7 @@ lldpd_send(struct lldpd_hardware *hw, struct ofpbuf *p)
 /* We send only if we have at least one remote system
  * speaking this protocol or if the protocol is forced */
 if (cfg->g_protocols[i].enabled > 1) {
-if ((lldp_size = cfg->g_protocols[i].send(cfg, hw, p)) != E2BIG) {
+if ((lldp_size = cfg->g_protocols[i].send(cfg, hw, p)) != -E2BIG) {
 sent++;
 continue;
 } else {
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 18/32] lldpd-structs: Fix type of c_id member.

2015-02-22 Thread Ben Pfaff
This member is typically an Ethernet address so the appropriate type is
uint8_t, not char.  This eliminates a couple of casts.

Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldp.c  | 2 +-
 lib/lldp/lldpd-structs.h | 2 +-
 lib/ovs-lldp.c   | 4 ++--
 tests/test-aa.c  | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/lldp/lldp.c b/lib/lldp/lldp.c
index 2bd7d48..2b8de0e 100644
--- a/lib/lldp/lldp.c
+++ b/lib/lldp/lldp.c
@@ -341,7 +341,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int 
s,
 bool ttl_received = false;
 int tlv_size, tlv_type, tlv_subtype;
 u_int8_t *pos, *tlv;
-char *b;
+void *b;
 struct lldpd_aa_isid_vlan_maps_tlv *isid_vlan_map = NULL;
 u_int8_t msg_auth_digest[LLDP_TLV_AA_ISID_VLAN_DIGEST_LENGTH];
 struct lldpd_mgmt *mgmt;
diff --git a/lib/lldp/lldpd-structs.h b/lib/lldp/lldpd-structs.h
index 64ca093..f38969b 100644
--- a/lib/lldp/lldpd-structs.h
+++ b/lib/lldp/lldpd-structs.h
@@ -66,7 +66,7 @@ struct lldpd_chassis {
 u_int16_t   c_index;  /* Monotonic index */
 u_int8_tc_protocol;   /* Protocol used to get this chassis */
 u_int8_tc_id_subtype;
-char*c_id;
+uint8_t *c_id;/* Typically an Ethernet address. */
 int c_id_len;
 char*c_name;
 char*c_descr;
diff --git a/lib/ovs-lldp.c b/lib/ovs-lldp.c
index 446386a..68e8c24 100644
--- a/lib/ovs-lldp.c
+++ b/lib/ovs-lldp.c
@@ -207,7 +207,7 @@ aa_print_element_status_port(struct ds *ds, struct 
lldpd_hardware *hw)
 
 if (port->p_chassis) {
 if (port->p_chassis->c_id_len > 0) {
-chassisid_to_string((uint8_t *) port->p_chassis->c_id,
+chassisid_to_string(port->p_chassis->c_id,
 port->p_chassis->c_id_len, &id);
 }
 
@@ -808,7 +808,7 @@ lldp_create(const struct netdev *netdev,
 lchassis->c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR;
 lchassis->c_id_len = ETH_ADDR_LEN;
 lchassis->c_id = xmalloc(ETH_ADDR_LEN);
-netdev_get_etheraddr(netdev, (uint8_t *) lchassis->c_id);
+netdev_get_etheraddr(netdev, lchassis->c_id);
 
 list_init(&lchassis->c_mgmt);
 lchassis->c_ttl = lldp->lldpd->g_config.c_tx_interval *
diff --git a/tests/test-aa.c b/tests/test-aa.c
index 09d137c..95a5d0d 100644
--- a/tests/test-aa.c
+++ b/tests/test-aa.c
@@ -26,7 +26,7 @@
 #define ETH_TYPE_LLDP   0x88cc
 
 /* Dummy MAC addresses */
-static char chassis_mac[ETH_ADDR_LEN] = { 0x5e, 0x10, 0x8e, 0xe7, 0x84, 0xad };
+static uint8_t chassis_mac[ETH_ADDR_LEN] = { 0x5e, 0x10, 0x8e, 0xe7, 0x84, 
0xad };
 static uint8_t eth_src[ETH_ADDR_LEN] = { 0x5e, 0x10, 0x8e, 0xe7, 0x84, 0xad };
 
 /* LLDP multicast address */
@@ -61,7 +61,7 @@ check_received_chassis(struct lldpd_chassis *schassis,
 {
 assert(rchassis->c_id_subtype == schassis->c_id_subtype);
 assert(rchassis->c_id_len == schassis->c_id_len);
-assert(strncmp(rchassis->c_id, schassis->c_id, schassis->c_id_len) == 0);
+assert(memcmp(rchassis->c_id, schassis->c_id, schassis->c_id_len) == 0);
 assert(strcmp(rchassis->c_name, schassis->c_name) == 0);
 assert(strcmp(rchassis->c_descr, schassis->c_descr) == 0);
 assert(rchassis->c_cap_available == schassis->c_cap_available);
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 27/32] lldpd: Remove unused members from struct lldpd.

2015-02-22 Thread Ben Pfaff
Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldpd.h | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/lib/lldp/lldpd.h b/lib/lldp/lldpd.h
index 2c00966..d25bb01 100644
--- a/lib/lldp/lldpd.h
+++ b/lib/lldp/lldpd.h
@@ -79,17 +79,10 @@ struct protocol {
 #define SMART_HIDDEN(port) (port->p_hidden_in)
 
 struct lldpd {
-int g_sock;
 struct lldpd_config g_config;
 struct protocol *g_protocols;
 int g_lastrid;
 
-/* Unix socket handling */
-const char  *g_ctlname;
-int g_ctl;
-
-char*g_lsb_release;
-
 struct lldpd_chassis g_chassis;
 struct lldpd_hardware g_hardware;
 };
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 31/32] lldp: Remove unused definitions from headers.

2015-02-22 Thread Ben Pfaff
Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldpd-structs.h |  5 -
 lib/lldp/lldpd.h | 17 -
 lib/ovs-lldp.h   |  8 
 3 files changed, 30 deletions(-)

diff --git a/lib/lldp/lldpd-structs.h b/lib/lldp/lldpd-structs.h
index 0763bb3..d62f37c 100644
--- a/lib/lldp/lldpd-structs.h
+++ b/lib/lldp/lldpd-structs.h
@@ -103,11 +103,6 @@ struct lldpd_port {
 struct ovs_list p_isid_vlan_maps; /* Contains "struct 
lldpd_aa_isid_vlan_maps_tlv"s. */
 };
 
-/* Used to modify some port related settings */
-struct lldpd_port_set {
-char *ifname;
-};
-
 /* Smart mode / Hide mode */
 #define SMART_INCOMING_FILTER (1<<0) /* Incoming filtering enabled */
 #define SMART_INCOMING_ONE_PROTO  (1<<1) /* On reception, keep only 1 proto */
diff --git a/lib/lldp/lldpd.h b/lib/lldp/lldpd.h
index 3aaf790..7fa0bbc 100644
--- a/lib/lldp/lldpd.h
+++ b/lib/lldp/lldpd.h
@@ -26,7 +26,6 @@
 #include 
 #include 
 #include 
-#include 
 #include "list.h"
 #include "lldpd-structs.h"
 #include "lldp-tlv.h"
@@ -34,27 +33,11 @@
 #include "openvswitch/vlog.h"
 #include "ofpbuf.h"
 
-#define SYSCONFDIR   ""
-#define LLDPD_CTL_SOCKET ""
-#define LLDPCLI_PATH ""
-#define PRIVSEP_USER ""
-#define PRIVSEP_GROUP""
-#define PRIVSEP_CHROOT   ""
-
 #define ETHERTYPE_LLDP 0x88cc
 
-struct event;
-struct event_base;
-
 #define LLDPD_TX_INTERVAL  5
 #define LLDPD_TX_HOLD  4
 #define LLDPD_TTL  LLDPD_TX_INTERVAL * LLDPD_TX_HOLD
-#define LLDPD_TX_MSGDELAY  1
-#define LLDPD_MAX_NEIGHBORS4
-#define LLDPD_FAST_TX_INTERVAL 1
-#define LLDPD_FAST_INIT4
-
-#define USING_AGENTX_SUBAGENT_MODULE 1
 
 #define PROTO_SEND_SIG struct lldpd *, struct lldpd_hardware *,struct ofpbuf *
 #define PROTO_DECODE_SIG struct lldpd *, char *, int, struct lldpd_hardware *,\
diff --git a/lib/ovs-lldp.h b/lib/ovs-lldp.h
index 7ef7cca..519b4ad 100644
--- a/lib/ovs-lldp.h
+++ b/lib/ovs-lldp.h
@@ -23,24 +23,16 @@
 #include "list.h"
 #include "lldp/lldpd.h"
 #include "ofpbuf.h"
-#include "ovsdb-data.h"
-#include "ovs-thread.h"
 #include "packets.h"
 #include "timer.h"
 
 /* Transmit every LLDPD_TX_INTERVAL seconds. */
 #define LLDP_DEFAULT_TRANSMIT_INTERVAL_MS LLDPD_TX_INTERVAL * 1000
 
-struct flow_wildcards;
 struct flow;
 struct netdev;
 struct smap;
 
-struct lldp_status {
-/* TODO should reflect lldp stack detail */
-char *stackdetail; /* Added because MSVC doesn't like empty structs */
-};
-
 /* Structure per LLDP instance (at the moment per port when enabled).
  */
 struct lldp {
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 28/32] lldpd-structs: Declare Boolean member as one bit, not two.

2015-02-22 Thread Ben Pfaff
Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldpd-structs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/lldp/lldpd-structs.h b/lib/lldp/lldpd-structs.h
index ef7af74..0763bb3 100644
--- a/lib/lldp/lldpd-structs.h
+++ b/lib/lldp/lldpd-structs.h
@@ -89,7 +89,7 @@ struct lldpd_port {
 struct lldpd_frame   *p_lastframe; /* Frame received during last update */
 u_int8_t p_protocol;   /* Protocol used to get this port */
 u_int8_t p_hidden_in:1; /* Considered hidden for reception */
-u_int8_t p_hidden_out:2; /* Considered hidden for emission */
+u_int8_t p_hidden_out:1; /* Considered hidden for emission */
 /* Important: all fields that should be ignored to check if a port has
  * been changed should be before p_id_subtype. Check
  * `lldpd_reset_timer()`.
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 29/32] lldpd: Fix use of list of struct lldpd_chassis.

2015-02-22 Thread Ben Pfaff
A list of some type should have type "struct ovs_list", not some other
type that encapsulates it.

Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldpd.c | 10 +-
 lib/lldp/lldpd.h |  2 +-
 lib/ovs-lldp.c   | 10 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c
index 8259e9d..d309f32 100644
--- a/lib/lldp/lldpd.c
+++ b/lib/lldp/lldpd.c
@@ -85,7 +85,7 @@ lldpd_alloc_hardware(struct lldpd *cfg, char *name, int index)
 hw->h_cfg = cfg;
 ovs_strlcpy(hw->h_ifname, name, sizeof hw->h_ifname);
 hw->h_ifindex = index;
-hw->h_lport.p_chassis = CONTAINER_OF(list_front(&cfg->g_chassis.list),
+hw->h_lport.p_chassis = CONTAINER_OF(list_front(&cfg->g_chassis),
  struct lldpd_chassis, list);
 hw->h_lport.p_chassis->c_refcount++;
 list_init(&hw->h_rports);
@@ -149,7 +149,7 @@ lldpd_cleanup(struct lldpd *cfg)
 
 VLOG_DBG("cleanup all chassis");
 
-LIST_FOR_EACH_SAFE (chassis, chassis_next, list, &cfg->g_chassis.list) {
+LIST_FOR_EACH_SAFE (chassis, chassis_next, list, &cfg->g_chassis) {
 if (chassis->c_refcount == 0) {
 list_remove(&chassis->list);
 lldpd_chassis_cleanup(chassis, 1);
@@ -343,7 +343,7 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
 bool found = false;
 VLOG_DBG("MSAP is unknown, search for the chassis");
 
-LIST_FOR_EACH (ochassis, list, &cfg->g_chassis.list) {
+LIST_FOR_EACH (ochassis, list, &cfg->g_chassis) {
 if ((chassis->c_protocol == ochassis->c_protocol) &&
 (chassis->c_id_subtype == ochassis->c_id_subtype) &&
 (chassis->c_id_len == ochassis->c_id_len) &&
@@ -374,8 +374,8 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
 VLOG_DBG("unknown chassis, add it to the list");
 chassis->c_index = ++cfg->g_lastrid;
 chassis->c_refcount = 0;
-list_push_back(&cfg->g_chassis.list, &chassis->list);
-listsize = list_size(&cfg->g_chassis.list);
+list_push_back(&cfg->g_chassis, &chassis->list);
+listsize = list_size(&cfg->g_chassis);
 VLOG_DBG("%"PRIuSIZE " different systems are known", listsize);
 }
 
diff --git a/lib/lldp/lldpd.h b/lib/lldp/lldpd.h
index d25bb01..aa7665e 100644
--- a/lib/lldp/lldpd.h
+++ b/lib/lldp/lldpd.h
@@ -83,7 +83,7 @@ struct lldpd {
 struct protocol *g_protocols;
 int g_lastrid;
 
-struct lldpd_chassis g_chassis;
+struct ovs_list g_chassis; /* Contains "struct lldp_chassis". */
 struct lldpd_hardware g_hardware;
 };
 
diff --git a/lib/ovs-lldp.c b/lib/ovs-lldp.c
index 5deee58..abea477 100644
--- a/lib/ovs-lldp.c
+++ b/lib/ovs-lldp.c
@@ -480,7 +480,7 @@ aa_configure(const struct aa_settings *s)
 HMAP_FOR_EACH (lldp, hmap_node, all_lldps) {
 struct lldpd_chassis *chassis;
 
-LIST_FOR_EACH (chassis, list, &lldp->lldpd->g_chassis.list) {
+LIST_FOR_EACH (chassis, list, &lldp->lldpd->g_chassis) {
 /* System Description */
 free(chassis->c_descr);
 chassis->c_descr = s->system_description[0] ?
@@ -803,8 +803,8 @@ lldp_create(const struct netdev *netdev,
   lldp->lldpd->g_config.c_tx_hold;
 lchassis->c_ttl = LLDP_CHASSIS_TTL;
 lldpd_assign_cfg_to_protocols(lldp->lldpd);
-list_init(&lldp->lldpd->g_chassis.list);
-list_push_back(&lldp->lldpd->g_chassis.list, &lchassis->list);
+list_init(&lldp->lldpd->g_chassis);
+list_push_back(&lldp->lldpd->g_chassis, &lchassis->list);
 
 if ((hw = lldpd_alloc_hardware(lldp->lldpd,
(char *) netdev_get_name(netdev),
@@ -895,8 +895,8 @@ lldp_create_dummy(void)
 list_init(&lchassis->c_mgmt);
 lchassis->c_ttl = LLDP_CHASSIS_TTL;
 lldpd_assign_cfg_to_protocols(lldp->lldpd);
-list_init(&lldp->lldpd->g_chassis.list);
-list_push_back(&lldp->lldpd->g_chassis.list, &lchassis->list);
+list_init(&lldp->lldpd->g_chassis);
+list_push_back(&lldp->lldpd->g_chassis, &lchassis->list);
 
 hw = lldpd_alloc_hardware(lldp->lldpd, "dummy-hw", 0);
 
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] [PATCH 32/32] lldp: Fully parenthesize some macro definitions.

2015-02-22 Thread Ben Pfaff
Signed-off-by: Ben Pfaff 
---
 lib/lldp/lldpd.h | 2 +-
 lib/ovs-lldp.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/lldp/lldpd.h b/lib/lldp/lldpd.h
index 7fa0bbc..33504ea 100644
--- a/lib/lldp/lldpd.h
+++ b/lib/lldp/lldpd.h
@@ -37,7 +37,7 @@
 
 #define LLDPD_TX_INTERVAL  5
 #define LLDPD_TX_HOLD  4
-#define LLDPD_TTL  LLDPD_TX_INTERVAL * LLDPD_TX_HOLD
+#define LLDPD_TTL  (LLDPD_TX_INTERVAL * LLDPD_TX_HOLD)
 
 #define PROTO_SEND_SIG struct lldpd *, struct lldpd_hardware *,struct ofpbuf *
 #define PROTO_DECODE_SIG struct lldpd *, char *, int, struct lldpd_hardware *,\
diff --git a/lib/ovs-lldp.h b/lib/ovs-lldp.h
index 519b4ad..a24bbce 100644
--- a/lib/ovs-lldp.h
+++ b/lib/ovs-lldp.h
@@ -27,7 +27,7 @@
 #include "timer.h"
 
 /* Transmit every LLDPD_TX_INTERVAL seconds. */
-#define LLDP_DEFAULT_TRANSMIT_INTERVAL_MS LLDPD_TX_INTERVAL * 1000
+#define LLDP_DEFAULT_TRANSMIT_INTERVAL_MS (LLDPD_TX_INTERVAL * 1000)
 
 struct flow;
 struct netdev;
-- 
2.1.3

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


Re: [ovs-dev] [PATCH 3/3] auto-attach: Add auto-attach support to bridge layer and command set

2015-02-22 Thread Ben Pfaff
On Sun, Feb 22, 2015 at 11:45:29AM -0800, Ben Pfaff wrote:
> On Fri, Feb 20, 2015 at 02:17:11PM -0500, drfl...@avaya.com wrote:
> > From: Dennis Flynn 
> > 
> > This is the final commit in the series of commits that deliver initial 
> > support
> > for Auto-Attach. Specifically this commit delivers auto-attach support to 
> > the
> > OVS bridge layer as well as the new auto-attach commands. The OVSDB schema 
> > is
> > modified to define the new auto-attach entries. The man pages, unit tests, 
> > and
> > news and license notice files are also updated. A unit test is provided to
> > validate the construction of auto-attach packets.
> > 
> > Signed-off-by: Ludovic Beliveau 
> > Signed-off-by: Dennis Flynn 
> 
> Hi Dennis, thanks for the new version.
> 
> I noticed some new warnings in this version.  These (from "sparse")
> probably mean that you should mark these variables "static":
> 
> ../tests/test-aa.c:29:6: warning: symbol 'chassis_mac' was not declared. 
> Should it be static?
> ../tests/test-aa.c:30:9: warning: symbol 'eth_src' was not declared. 
> Should it be static?
> ../tests/test-aa.c:36:5: warning: symbol 'num_tests' was not declared. 
> Should it be static?
> 
> Also these from GCC:
> 
> ../utilities/ovs-vsctl.c: In function ‘cmd_get_aa_mapping’:
> ../utilities/ovs-vsctl.c:2702:27: error: format ‘%lld’ expects argument 
> of type ‘long long int’, but argument 3 has type ‘long int’ [-Werror=format=]
>(long int) 
> br->br_cfg->auto_attach->value_mappings[i]
>^
> ../utilities/ovs-vsctl.c:2702:27: error: format ‘%lld’ expects argument 
> of type ‘long long int’, but argument 4 has type ‘long int’ [-Werror=format=]

Never mind, I took care of this myself and posted a series that includes
these and some other refinements.  Dennis, will you look it over?

The series starts here:
http://openvswitch.org/pipermail/dev/2015-February/051568.html

Thanks,

Ben.
___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


[ovs-dev] Returned mail: Data format error

2015-02-22 Thread Returned mail
Dear user dev@openvswitch.org,

We have found that your account has been used to send a huge amount of junk 
email messages during the recent week.
Most likely your computer had been compromised and now runs a trojan proxy 
server.

We recommend you to follow our instructions in order to keep your computer safe.

Have a nice day,
openvswitch.org support team.

___
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev