Skip to content

Commit

Permalink
ofproto-dpif: Avoid creating OpenFlow ports for duplicate tunnels.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
blp and azhou-nicira committed Jun 6, 2015
1 parent 332eafc commit ea0797c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Expand Up @@ -277,6 +277,7 @@ Joan Cirer joan@ev0.net
John Darrington john@darrington.wattle.id.au
John Galgay john@galgay.net
John Hurley john.hurley@netronome.com
Keith Holleman hollemanietf@gmail.com
K 華 k940545@hotmail.com
Kevin Mancuso kevin.mancuso@rackspace.com
Kiran Shanbhog kiran@vmware.com
Expand Down
10 changes: 8 additions & 2 deletions ofproto/ofproto-dpif.c
Expand Up @@ -1671,8 +1671,14 @@ port_construct(struct ofport *port_)

if (netdev_get_tunnel_config(netdev)) {
atomic_count_inc(&ofproto->backer->tnl_count);
tnl_port_add(port, port->up.netdev, port->odp_port,
ovs_native_tunneling_is_on(ofproto), namebuf);
error = tnl_port_add(port, port->up.netdev, port->odp_port,
ovs_native_tunneling_is_on(ofproto), namebuf);
if (error) {
atomic_count_dec(&ofproto->backer->tnl_count);
dpif_port_destroy(&dpif_port);
return error;
}

port->is_tunnel = true;
if (ofproto->ipfix) {
dpif_ipfix_add_tunnel_port(ofproto->ipfix, port_, port->odp_port);
Expand Down
14 changes: 10 additions & 4 deletions 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.
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions ofproto/tunnel.h
@@ -1,4 +1,4 @@
/* Copyright (c) 2013 Nicira, Inc.
/* Copyright (c) 2013, 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.
Expand Down Expand Up @@ -33,8 +33,8 @@ void ofproto_tunnel_init(void);
bool tnl_port_reconfigure(const struct ofport_dpif *, const struct netdev *,
odp_port_t, bool native_tnl, const char name[]);

void tnl_port_add(const struct ofport_dpif *, const struct netdev *,
odp_port_t odp_port, bool native_tnl, const char name[]);
int tnl_port_add(const struct ofport_dpif *, const struct netdev *,
odp_port_t odp_port, bool native_tnl, const char name[]);
void tnl_port_del(const struct ofport_dpif *);

const struct ofport_dpif *tnl_port_receive(const struct flow *);
Expand Down

0 comments on commit ea0797c

Please sign in to comment.