mirror of
https://github.com/openvswitch/ovs
synced 2025-09-04 00:05:15 +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:
@@ -477,19 +477,23 @@ lswitch_choose_destination(struct lswitch *sw, const struct flow *flow)
|
|||||||
ofp_port_t out_port;
|
ofp_port_t out_port;
|
||||||
|
|
||||||
/* Learn the source MAC. */
|
/* Learn the source MAC. */
|
||||||
ovs_rwlock_wrlock(&sw->ml->rwlock);
|
if (sw->ml) {
|
||||||
if (mac_learning_may_learn(sw->ml, flow->dl_src, 0)) {
|
ovs_rwlock_wrlock(&sw->ml->rwlock);
|
||||||
struct mac_entry *mac = mac_learning_insert(sw->ml, flow->dl_src, 0);
|
if (mac_learning_may_learn(sw->ml, flow->dl_src, 0)) {
|
||||||
if (mac->port.ofp_port != flow->in_port.ofp_port) {
|
struct mac_entry *mac = mac_learning_insert(sw->ml, flow->dl_src,
|
||||||
VLOG_DBG_RL(&rl, "%016llx: learned that "ETH_ADDR_FMT" is on "
|
0);
|
||||||
"port %"PRIu16, sw->datapath_id,
|
if (mac->port.ofp_port != flow->in_port.ofp_port) {
|
||||||
ETH_ADDR_ARGS(flow->dl_src), 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->port.ofp_port = flow->in_port.ofp_port;
|
||||||
mac_learning_changed(sw->ml);
|
mac_learning_changed(sw->ml);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
ovs_rwlock_unlock(&sw->ml->rwlock);
|
||||||
}
|
}
|
||||||
ovs_rwlock_unlock(&sw->ml->rwlock);
|
|
||||||
|
|
||||||
/* Drop frames for reserved multicast addresses. */
|
/* Drop frames for reserved multicast addresses. */
|
||||||
if (eth_addr_is_reserved(flow->dl_dst)) {
|
if (eth_addr_is_reserved(flow->dl_dst)) {
|
||||||
|
Reference in New Issue
Block a user