Changing State on a Bridge Port
A bridge port is
either active or inactive: the associated states are BR_STATE_FORWARDING or BR_STATE_BLOCKING.
However, while the BR_STATE_BLOCKING state can be
assigned right away to a port, the BR_STATE_FORWARDING
state is reached only after first going through the intermediate states introduced in the
section "Port states" in Chapter 15.
The BR_STATE_FORWARDING and BR_STATE_BLOCKING states are assigned with the br_make_forwarding and br_make_blocking routines, respectively. The same two routines are used
regardless of whether the bridge device hosting the port is running the STP.
static void br_make_blocking(struct net_bridge_port *p)
{
if (p->state != BR_STATE_DISABLED &&
p->state != BR_STATE_BLOCKING) {
if (p->state == BR_STATE_FORWARDING ||
p->state == BR_STATE_LEARNING)
br_topology_change_detection(p->br);
p->state = BR_STATE_BLOCKING;
br_log_state(p);
del_timer(&p->forward_delay_timer);
}
}
static void br_make_forwarding(struct net_bridge_port *p)
{
if (p->state == BR_STATE_BLOCKING) {
if (p->br->stp_enabled) {
p->state = BR_STATE_LISTENING;
} else {
p->state = BR_STATE_LEARNING;
}
br_log_state(p);
mod_timer(&p->forward_delay_timer, jiffies + p->br->forward_delay);
}
}Note that you cannot assign a port any of the intermediate states between BR_STATE_BLOCKING and BR_STATE_FORWARDING, which is why br_make_forwarding returns if asked to change a port that is not in the
BR_STATE_BLOCKING state to BR_STATE_FORWARDING. However, an intermediate state ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access