Found by inspection.

Signed-off-by: Ben Pfaff <b...@ovn.org>
---
v1->v2: Found another one to fix.

 ovn/controller/encaps.c | 11 ++++++++---
 ovn/controller/patch.c  |  2 +-
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/ovn/controller/encaps.c b/ovn/controller/encaps.c
index 03ec732..977cc3a 100644
--- a/ovn/controller/encaps.c
+++ b/ovn/controller/encaps.c
@@ -103,6 +103,10 @@ port_hash_rec(const struct ovsrec_port *port)
 
     iface = port->interfaces[0];
     ip = smap_get(&iface->options, "remote_ip");
+    if (!ip) {
+        /* This should not happen for an OVN-created port. */
+        return 0;
+    }
 
     return port_hash(chassis_id, iface->type, ip);
 }
@@ -314,7 +318,8 @@ check_and_update_tunnel(const struct sbrec_chassis 
*chassis_rec)
         if (strcmp(encap->type, iface->type)) {
             ovsrec_interface_set_type(iface, encap->type);
         }
-        if (strcmp(encap->ip, smap_get(&iface->options, "remote_ip"))) {
+        const char *ip = smap_get(&iface->options, "remote_ip");
+        if (!ip || strcmp(encap->ip, ip)) {
             struct smap options = SMAP_INITIALIZER(&options);
             smap_add(&options, "remote_ip", encap->ip);
             smap_add(&options, "key", "flow");
@@ -322,8 +327,8 @@ check_and_update_tunnel(const struct sbrec_chassis 
*chassis_rec)
             smap_destroy(&options);
         }
 
-        if (strcmp(chassis_rec->name, smap_get(&port->external_ids,
-                                               "ovn-chassis-id"))) {
+        const char *chassis = smap_get(&port->external_ids, "ovn-chassis-id");
+        if (!chassis || strcmp(chassis_rec->name, chassis)) {
             const struct smap id = SMAP_CONST1(&id, "ovn-chassis-id",
                                                chassis_rec->name);
             ovsrec_port_set_external_ids(port, &id);
diff --git a/ovn/controller/patch.c b/ovn/controller/patch.c
index 823389d..fa38f78 100644
--- a/ovn/controller/patch.c
+++ b/ovn/controller/patch.c
@@ -349,7 +349,7 @@ add_logical_patch_ports(struct controller_ctx *ctx,
         if (!strcmp(binding->type, "gateway")) {
             const char *chassis = smap_get(&binding->options,
                                            "gateway-chassis");
-            if (!strcmp(local_chassis_id, chassis)) {
+            if (chassis && !strcmp(local_chassis_id, chassis)) {
                 local_port = true;
             }
         }
-- 
2.1.3

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

Reply via email to