From 2457b24fc5c935ec8c2930f9df923fc37b8bb38e Mon Sep 17 00:00:00 2001
From: Jesse Gross <jesse@nicira.com>
Date: Mon, 10 May 2010 13:34:41 -0700
Subject: [PATCH] bridge: Add iface to hash table before calling
 iface_is_internal().

When creating an interface we need to check whether it is internal.
However, the function iface_is_internal() does a lookup on the
interface name but we haven't added it to the hash table yet.  This
adds the interface to the table early on in iface_create.

NIC-78
---
 vswitchd/bridge.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 74c7d578..354d4d89 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -3613,6 +3613,8 @@ iface_create(struct port *port, const struct ovsrec_interface *if_cfg)
     iface->netdev = NULL;
     iface->cfg = if_cfg;
 
+    shash_add_assert(&br->iface_by_name, iface->name, iface);
+
     /* Attempt to create the network interface in case it doesn't exist yet. */
     if (!iface_is_internal(br, iface->name)) {
         error = set_up_iface(if_cfg, iface, true);
@@ -3620,14 +3622,13 @@ iface_create(struct port *port, const struct ovsrec_interface *if_cfg)
             VLOG_WARN("could not create iface %s: %s", iface->name,
                       strerror(error));
 
+            shash_find_and_delete_assert(&br->iface_by_name, iface->name);
             free(iface->name);
             free(iface);
             return NULL;
         }
     }
 
-    shash_add_assert(&br->iface_by_name, iface->name, iface);
-
     if (port->n_ifaces >= port->allocated_ifaces) {
         port->ifaces = x2nrealloc(port->ifaces, &port->allocated_ifaces,
                                   sizeof *port->ifaces);
-- 
2.30.2