summaryrefslogtreecommitdiff
path: root/ovn
diff options
context:
space:
mode:
authorMark Michelson <mmichels@redhat.com>2017-09-06 08:38:40 -0500
committerBen Pfaff <blp@ovn.org>2017-11-01 14:31:41 -0700
commit173acc1c55110212d7daf527352758c20e49deab (patch)
tree3c4be909694decb517858638fdce880f6d73c65c /ovn
parent5fef88eaefee82255f02dec34faa239b589944ba (diff)
downloadopenvswitch-173acc1c55110212d7daf527352758c20e49deab.tar.gz
ovn: Check for known logical switch port types.
OVN is lenient with the types of logical switch ports. Maybe too lenient. This patch attempts to solve this problem on two fronts: 1) In ovn-nbctl, if you attempt to set the port type to an unknown type, the command will not end up setting the type. 2) In northd, when copying the port type from the northbound database to the corresponding port-binding in the southbound database, a warning will be issued if the port is of an unknown type. Signed-off-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Lance Richardson <lrichard@redhat.com>
Diffstat (limited to 'ovn')
-rw-r--r--ovn/lib/ovn-util.c30
-rw-r--r--ovn/lib/ovn-util.h2
-rw-r--r--ovn/northd/ovn-northd.c9
-rw-r--r--ovn/utilities/ovn-nbctl.c7
4 files changed, 46 insertions, 2 deletions
diff --git a/ovn/lib/ovn-util.c b/ovn/lib/ovn-util.c
index 037d0798a..a554c23f5 100644
--- a/ovn/lib/ovn-util.c
+++ b/ovn/lib/ovn-util.c
@@ -299,3 +299,33 @@ default_sb_db(void)
}
return def;
}
+
+/* l3gateway, chassisredirect, and patch
+ * are not in this list since they are
+ * only set in the SB DB by northd
+ */
+static const char *OVN_NB_LSP_TYPES[] = {
+ "l2gateway",
+ "localnet",
+ "localport",
+ "router",
+ "vtep",
+};
+
+bool
+ovn_is_known_nb_lsp_type(const char *type)
+{
+ int i;
+
+ if (!type || !type[0]) {
+ return true;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(OVN_NB_LSP_TYPES); ++i) {
+ if (!strcmp(OVN_NB_LSP_TYPES[i], type)) {
+ return true;
+ }
+ }
+
+ return false;
+}
diff --git a/ovn/lib/ovn-util.h b/ovn/lib/ovn-util.h
index b3d2125a3..9b456426d 100644
--- a/ovn/lib/ovn-util.h
+++ b/ovn/lib/ovn-util.h
@@ -67,4 +67,6 @@ char *alloc_nat_zone_key(const struct uuid *key, const char *type);
const char *default_nb_db(void);
const char *default_sb_db(void);
+bool ovn_is_known_nb_lsp_type(const char *type);
+
#endif
diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index b250eb4fa..f034ba2c4 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -1963,7 +1963,14 @@ ovn_port_update_sbrec(struct northd_context *ctx,
}
sbrec_port_binding_set_options(op->sb, &options);
smap_destroy(&options);
- sbrec_port_binding_set_type(op->sb, op->nbsp->type);
+ if (ovn_is_known_nb_lsp_type(op->nbsp->type)) {
+ sbrec_port_binding_set_type(op->sb, op->nbsp->type);
+ } else {
+ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
+ VLOG_WARN_RL(
+ &rl, "Unknown port type '%s' set on logical switch '%s'.",
+ op->nbsp->type, op->nbsp->name);
+ }
} else {
const char *chassis = NULL;
if (op->peer && op->peer->od && op->peer->od->nbr) {
diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index 8e5c1a440..77889961f 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -1173,7 +1173,12 @@ nbctl_lsp_set_type(struct ctl_context *ctx)
const struct nbrec_logical_switch_port *lsp;
lsp = lsp_by_name_or_uuid(ctx, id, true);
- nbrec_logical_switch_port_set_type(lsp, type);
+ if (ovn_is_known_nb_lsp_type(type)) {
+ nbrec_logical_switch_port_set_type(lsp, type);
+ } else {
+ ctl_fatal("Logical switch port type '%s' is unrecognized. "
+ "Not setting type.", type);
+ }
}
static void