diff options
author | Ben Pfaff <blp@nicira.com> | 2015-06-05 08:13:28 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2015-06-05 21:18:31 -0700 |
commit | ea0797c929dc663ed443f07cd0bfc9d788d11367 (patch) | |
tree | d27a67f0bda311eb55327a10d9f42fe4d0ec8b4d /ofproto/tunnel.c | |
parent | 332eafce794d8c6d10474d3c802ef886a05a453c (diff) | |
download | openvswitch-ea0797c929dc663ed443f07cd0bfc9d788d11367.tar.gz |
ofproto-dpif: Avoid creating OpenFlow ports for duplicate tunnels.
Until now, when two tunnels had an identical configuration, both of them
were assigned OpenFlow ports, but only one of those OpenFlow ports was
functional. With this commit, only one of the two (or more) identically
configured tunnels will be assigned an OpenFlow port number.
Reported-by: Keith Holleman <hollemanietf@gmail.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Co-authored-by: Andy Zhou <azhou@nicira.com>
Signed-off-by: Andy Zhou <azhou@nicira.com>
Diffstat (limited to 'ofproto/tunnel.c')
-rw-r--r-- | ofproto/tunnel.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ofproto/tunnel.c b/ofproto/tunnel.c index 3ea0eb44f..d2ac7c6a8 100644 --- a/ofproto/tunnel.c +++ b/ofproto/tunnel.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2013, 2014 Nicira, Inc. +/* Copyright (c) 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. @@ -203,14 +203,20 @@ tnl_port_add__(const struct ofport_dpif *ofport, const struct netdev *netdev, /* Adds 'ofport' to the module with datapath port number 'odp_port'. 'ofport's * must be added before they can be used by the module. 'ofport' must be a - * tunnel. */ -void + * tunnel. + * + * Returns 0 if successful, otherwise a positive errno value. */ +int tnl_port_add(const struct ofport_dpif *ofport, const struct netdev *netdev, odp_port_t odp_port, bool native_tnl, const char name[]) OVS_EXCLUDED(rwlock) { + bool ok; + fat_rwlock_wrlock(&rwlock); - tnl_port_add__(ofport, netdev, odp_port, true, native_tnl, name); + ok = tnl_port_add__(ofport, netdev, odp_port, true, native_tnl, name); fat_rwlock_unlock(&rwlock); + + return ok ? 0 : EEXIST; } /* Checks if the tunnel represented by 'ofport' reconfiguration due to changes |