Message ID | 20161218081834.18541-8-blp@ovn.org |
---|---|
State | Accepted |
Headers | show |
On Sun, Dec 18, 2016 at 12:18 AM, Ben Pfaff <blp@ovn.org> wrote: > It seems like a good idea to check for and warn about all kinds of > duplicates, and to avoid segfaulting if a datapath column is empty. > (However, the database schema should prevent both issues.) > > Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Mickey Spiegel <mickeys.dev@gmail.com> --- > ovn/controller/lport.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/ovn/controller/lport.c b/ovn/controller/lport.c > index e1ecf21..3484c2c 100644 > --- a/ovn/controller/lport.c > +++ b/ovn/controller/lport.c > @@ -37,12 +37,24 @@ lport_index_init(struct lport_index *lports, struct > ovsdb_idl *ovnsb_idl) > > const struct sbrec_port_binding *pb; > SBREC_PORT_BINDING_FOR_EACH (pb, ovnsb_idl) { > + if (!pb->datapath) { > + continue; > + } > + > if (lport_lookup_by_name(lports, pb->logical_port)) { > static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); > VLOG_WARN_RL(&rl, "duplicate logical port name '%s'", > pb->logical_port); > continue; > } > + if (lport_lookup_by_key(lports, pb->datapath->tunnel_key, > + pb->tunnel_key)) { > + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); > + VLOG_WARN_RL(&rl, "duplicate logical port %"PRId64" in > logical " > + "datapath %"PRId64, > + pb->tunnel_key, pb->datapath->tunnel_key); > + continue; > + } > > struct lport *p = xmalloc(sizeof *p); > hmap_insert(&lports->by_name, &p->name_node, > -- > 2.10.2 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev >
diff --git a/ovn/controller/lport.c b/ovn/controller/lport.c index e1ecf21..3484c2c 100644 --- a/ovn/controller/lport.c +++ b/ovn/controller/lport.c @@ -37,12 +37,24 @@ lport_index_init(struct lport_index *lports, struct ovsdb_idl *ovnsb_idl) const struct sbrec_port_binding *pb; SBREC_PORT_BINDING_FOR_EACH (pb, ovnsb_idl) { + if (!pb->datapath) { + continue; + } + if (lport_lookup_by_name(lports, pb->logical_port)) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); VLOG_WARN_RL(&rl, "duplicate logical port name '%s'", pb->logical_port); continue; } + if (lport_lookup_by_key(lports, pb->datapath->tunnel_key, + pb->tunnel_key)) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); + VLOG_WARN_RL(&rl, "duplicate logical port %"PRId64" in logical " + "datapath %"PRId64, + pb->tunnel_key, pb->datapath->tunnel_key); + continue; + } struct lport *p = xmalloc(sizeof *p); hmap_insert(&lports->by_name, &p->name_node,
It seems like a good idea to check for and warn about all kinds of duplicates, and to avoid segfaulting if a datapath column is empty. (However, the database schema should prevent both issues.) Signed-off-by: Ben Pfaff <blp@ovn.org> --- ovn/controller/lport.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)