^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Linux ethernet bridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Authors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Lennert Buytenhek <buytenh@gnu.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #ifndef _BR_PRIVATE_STP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #define _BR_PRIVATE_STP_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #define BPDU_TYPE_CONFIG 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #define BPDU_TYPE_TCN 0x80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) /* IEEE 802.1D-1998 timer values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define BR_MIN_HELLO_TIME (1*HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define BR_MAX_HELLO_TIME (10*HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define BR_MIN_FORWARD_DELAY (2*HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define BR_MAX_FORWARD_DELAY (30*HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define BR_MIN_MAX_AGE (6*HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define BR_MAX_MAX_AGE (40*HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define BR_MIN_PATH_COST 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define BR_MAX_PATH_COST 65535
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct br_config_bpdu {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) unsigned int topology_change:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) unsigned int topology_change_ack:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) bridge_id root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) int root_path_cost;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) bridge_id bridge_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) port_id port_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) int message_age;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int max_age;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) int hello_time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) int forward_delay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /* called under bridge lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) static inline int br_is_designated_port(const struct net_bridge_port *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) return !memcmp(&p->designated_bridge, &p->br->bridge_id, 8) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) (p->designated_port == p->port_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* br_stp.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) void br_become_root_bridge(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) void br_config_bpdu_generation(struct net_bridge *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) void br_configuration_update(struct net_bridge *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) void br_port_state_selection(struct net_bridge *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) void br_received_config_bpdu(struct net_bridge_port *p,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) const struct br_config_bpdu *bpdu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) void br_received_tcn_bpdu(struct net_bridge_port *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) void br_transmit_config(struct net_bridge_port *p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) void br_transmit_tcn(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) void br_topology_change_detection(struct net_bridge *br);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) void __br_set_topology_change(struct net_bridge *br, unsigned char val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) /* br_stp_bpdu.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) void br_send_config_bpdu(struct net_bridge_port *, struct br_config_bpdu *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) void br_send_tcn_bpdu(struct net_bridge_port *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #endif