| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Spanning tree protocol; generic parts |
|---|
| 3 | 4 | * Linux ethernet bridge |
|---|
| 4 | 5 | * |
|---|
| 5 | 6 | * Authors: |
|---|
| 6 | 7 | * Lennert Buytenhek <buytenh@gnu.org> |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or |
|---|
| 9 | | - * modify it under the terms of the GNU General Public License |
|---|
| 10 | | - * as published by the Free Software Foundation; either version |
|---|
| 11 | | - * 2 of the License, or (at your option) any later version. |
|---|
| 12 | 8 | */ |
|---|
| 13 | 9 | #include <linux/kernel.h> |
|---|
| 14 | 10 | #include <linux/rculist.h> |
|---|
| .. | .. |
|---|
| 40 | 36 | }; |
|---|
| 41 | 37 | int err; |
|---|
| 42 | 38 | |
|---|
| 39 | + /* Don't change the state of the ports if they are driven by a different |
|---|
| 40 | + * protocol. |
|---|
| 41 | + */ |
|---|
| 42 | + if (p->flags & BR_MRP_AWARE) |
|---|
| 43 | + return; |
|---|
| 44 | + |
|---|
| 43 | 45 | p->state = state; |
|---|
| 44 | 46 | err = switchdev_port_attr_set(p->dev, &attr); |
|---|
| 45 | 47 | if (err && err != -EOPNOTSUPP) |
|---|
| .. | .. |
|---|
| 49 | 51 | br_info(p->br, "port %u(%s) entered %s state\n", |
|---|
| 50 | 52 | (unsigned int) p->port_no, p->dev->name, |
|---|
| 51 | 53 | br_port_state_names[p->state]); |
|---|
| 54 | + |
|---|
| 55 | + if (p->br->stp_enabled == BR_KERNEL_STP) { |
|---|
| 56 | + switch (p->state) { |
|---|
| 57 | + case BR_STATE_BLOCKING: |
|---|
| 58 | + p->stp_xstats.transition_blk++; |
|---|
| 59 | + break; |
|---|
| 60 | + case BR_STATE_FORWARDING: |
|---|
| 61 | + p->stp_xstats.transition_fwd++; |
|---|
| 62 | + break; |
|---|
| 63 | + } |
|---|
| 64 | + } |
|---|
| 52 | 65 | } |
|---|
| 53 | 66 | |
|---|
| 54 | 67 | /* called under bridge lock */ |
|---|
| .. | .. |
|---|
| 56 | 69 | { |
|---|
| 57 | 70 | struct net_bridge_port *p; |
|---|
| 58 | 71 | |
|---|
| 59 | | - list_for_each_entry_rcu(p, &br->port_list, list) { |
|---|
| 72 | + list_for_each_entry_rcu(p, &br->port_list, list, |
|---|
| 73 | + lockdep_is_held(&br->lock)) { |
|---|
| 60 | 74 | if (p->port_no == port_no) |
|---|
| 61 | 75 | return p; |
|---|
| 62 | 76 | } |
|---|
| .. | .. |
|---|
| 488 | 502 | struct net_bridge *br; |
|---|
| 489 | 503 | int was_root; |
|---|
| 490 | 504 | |
|---|
| 505 | + p->stp_xstats.rx_bpdu++; |
|---|
| 506 | + |
|---|
| 491 | 507 | br = p->br; |
|---|
| 492 | 508 | was_root = br_is_root_bridge(br); |
|---|
| 493 | 509 | |
|---|
| .. | .. |
|---|
| 521 | 537 | /* called under bridge lock */ |
|---|
| 522 | 538 | void br_received_tcn_bpdu(struct net_bridge_port *p) |
|---|
| 523 | 539 | { |
|---|
| 540 | + p->stp_xstats.rx_tcn++; |
|---|
| 541 | + |
|---|
| 524 | 542 | if (br_is_designated_port(p)) { |
|---|
| 525 | 543 | br_info(p->br, "port %u(%s) received tcn bpdu\n", |
|---|
| 526 | 544 | (unsigned int) p->port_no, p->dev->name); |
|---|