aboutsummaryrefslogtreecommitdiff
path: root/vswitchd
diff options
context:
space:
mode:
authorEthan Jackson <ethan@nicira.com>2012-11-05 19:00:07 -0800
committerEthan Jackson <ethan@nicira.com>2012-11-06 12:40:05 -0800
commitb099cd5f555a22646fe0be565ccef3c0cf9dcd87 (patch)
treec8cce9e3c0f8a4846322344110d2f0cdc718690a /vswitchd
parent3c82d0682ab7661d218545e9ba06e52f1cf44e43 (diff)
bridge: Fix a segmentation fault in bridge_init_ofproto().
When the database is initially created there may no be rows in the Open_vSwitch table. In this case, the ovsrec_open_vswitch passed to bridge_init_ofproto() is NULL and causes a segmentation fault. Signed-off-by: Ethan Jackson <ethan@nicira.com>
Diffstat (limited to 'vswitchd')
-rw-r--r--vswitchd/bridge.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 9fcc9709..8f544a99 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -276,25 +276,27 @@ bridge_init_ofproto(const struct ovsrec_open_vswitch *cfg)
shash_init(&iface_hints);
- for (i = 0; i < cfg->n_bridges; i++) {
- const struct ovsrec_bridge *br_cfg = cfg->bridges[i];
- int j;
-
- for (j = 0; j < br_cfg->n_ports; j++) {
- struct ovsrec_port *port_cfg = br_cfg->ports[j];
- int k;
-
- for (k = 0; k < port_cfg->n_interfaces; k++) {
- struct ovsrec_interface *if_cfg = port_cfg->interfaces[k];
- struct iface_hint *iface_hint;
-
- iface_hint = xmalloc(sizeof *iface_hint);
- iface_hint->br_name = br_cfg->name;
- iface_hint->br_type = br_cfg->datapath_type;
- iface_hint->ofp_port = if_cfg->n_ofport_request ?
- *if_cfg->ofport_request : OFPP_NONE;
-
- shash_add(&iface_hints, if_cfg->name, iface_hint);
+ if (cfg) {
+ for (i = 0; i < cfg->n_bridges; i++) {
+ const struct ovsrec_bridge *br_cfg = cfg->bridges[i];
+ int j;
+
+ for (j = 0; j < br_cfg->n_ports; j++) {
+ struct ovsrec_port *port_cfg = br_cfg->ports[j];
+ int k;
+
+ for (k = 0; k < port_cfg->n_interfaces; k++) {
+ struct ovsrec_interface *if_cfg = port_cfg->interfaces[k];
+ struct iface_hint *iface_hint;
+
+ iface_hint = xmalloc(sizeof *iface_hint);
+ iface_hint->br_name = br_cfg->name;
+ iface_hint->br_type = br_cfg->datapath_type;
+ iface_hint->ofp_port = if_cfg->n_ofport_request ?
+ *if_cfg->ofport_request : OFPP_NONE;
+
+ shash_add(&iface_hints, if_cfg->name, iface_hint);
+ }
}
}
}