blob: 814cf1364cfb3acfe65907d77b93377bd38a3395 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * Linux ethernet bridge
4 *
5 * Authors:
6 * Lennert Buytenhek <buytenh@gnu.org>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 */
8
9#ifndef _BR_PRIVATE_STP_H
10#define _BR_PRIVATE_STP_H
11
12#define BPDU_TYPE_CONFIG 0
13#define BPDU_TYPE_TCN 0x80
14
stephen hemminger14f98f22011-04-04 14:03:33 +000015/* IEEE 802.1D-1998 timer values */
16#define BR_MIN_HELLO_TIME (1*HZ)
17#define BR_MAX_HELLO_TIME (10*HZ)
18
19#define BR_MIN_FORWARD_DELAY (2*HZ)
20#define BR_MAX_FORWARD_DELAY (30*HZ)
21
22#define BR_MIN_MAX_AGE (6*HZ)
23#define BR_MAX_MAX_AGE (40*HZ)
24
25#define BR_MIN_PATH_COST 1
26#define BR_MAX_PATH_COST 65535
27
Eric Dumazet95c96172012-04-15 05:58:06 +000028struct br_config_bpdu {
29 unsigned int topology_change:1;
30 unsigned int topology_change_ack:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 bridge_id root;
32 int root_path_cost;
33 bridge_id bridge_id;
34 port_id port_id;
35 int message_age;
36 int max_age;
37 int hello_time;
38 int forward_delay;
39};
40
41/* called under bridge lock */
42static inline int br_is_designated_port(const struct net_bridge_port *p)
43{
44 return !memcmp(&p->designated_bridge, &p->br->bridge_id, 8) &&
45 (p->designated_port == p->port_id);
46}
47
48
49/* br_stp.c */
Joe Perches348662a2013-10-18 13:48:22 -070050void br_become_root_bridge(struct net_bridge *br);
51void br_config_bpdu_generation(struct net_bridge *);
52void br_configuration_update(struct net_bridge *);
53void br_port_state_selection(struct net_bridge *);
54void br_received_config_bpdu(struct net_bridge_port *p,
55 const struct br_config_bpdu *bpdu);
56void br_received_tcn_bpdu(struct net_bridge_port *p);
57void br_transmit_config(struct net_bridge_port *p);
58void br_transmit_tcn(struct net_bridge *br);
59void br_topology_change_detection(struct net_bridge *br);
Vivien Didelot8384b5f2016-12-10 13:44:28 -050060void __br_set_topology_change(struct net_bridge *br, unsigned char val);
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62/* br_stp_bpdu.c */
Joe Perches348662a2013-10-18 13:48:22 -070063void br_send_config_bpdu(struct net_bridge_port *, struct br_config_bpdu *);
64void br_send_tcn_bpdu(struct net_bridge_port *);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
66#endif