2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

ovs-controller: Avoid dereferencing NULL pointer when the switch acts as a hub

Starting ovs-controller with '-H' option will lead to a segment fault problem.
Add a check, and adjust the indentation of the following code.

Signed-off-by: ZhengLingyun <konghuarukhr@163.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
ZhengLingyun
2013-10-08 23:52:40 +08:00
committed by Ben Pfaff
parent a34779bcbe
commit cbd577d661

View File

@@ -477,19 +477,23 @@ lswitch_choose_destination(struct lswitch *sw, const struct flow *flow)
ofp_port_t out_port;
/* Learn the source MAC. */
ovs_rwlock_wrlock(&sw->ml->rwlock);
if (mac_learning_may_learn(sw->ml, flow->dl_src, 0)) {
struct mac_entry *mac = mac_learning_insert(sw->ml, flow->dl_src, 0);
if (mac->port.ofp_port != flow->in_port.ofp_port) {
VLOG_DBG_RL(&rl, "%016llx: learned that "ETH_ADDR_FMT" is on "
"port %"PRIu16, sw->datapath_id,
ETH_ADDR_ARGS(flow->dl_src), flow->in_port.ofp_port);
if (sw->ml) {
ovs_rwlock_wrlock(&sw->ml->rwlock);
if (mac_learning_may_learn(sw->ml, flow->dl_src, 0)) {
struct mac_entry *mac = mac_learning_insert(sw->ml, flow->dl_src,
0);
if (mac->port.ofp_port != flow->in_port.ofp_port) {
VLOG_DBG_RL(&rl, "%016llx: learned that "ETH_ADDR_FMT" is on "
"port %"PRIu16, sw->datapath_id,
ETH_ADDR_ARGS(flow->dl_src),
flow->in_port.ofp_port);
mac->port.ofp_port = flow->in_port.ofp_port;
mac_learning_changed(sw->ml);
mac->port.ofp_port = flow->in_port.ofp_port;
mac_learning_changed(sw->ml);
}
}
ovs_rwlock_unlock(&sw->ml->rwlock);
}
ovs_rwlock_unlock(&sw->ml->rwlock);
/* Drop frames for reserved multicast addresses. */
if (eth_addr_is_reserved(flow->dl_dst)) {