]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_fsm.h
bgpd: move packet writes into dedicated pthread
[mirror_frr.git] / bgpd / bgp_fsm.h
1 /* BGP-4 Finite State Machine
2 * From RFC1771 [A Border Gateway Protocol 4 (BGP-4)]
3 * Copyright (C) 1998 Kunihiro Ishiguro
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #ifndef _QUAGGA_BGP_FSM_H
23 #define _QUAGGA_BGP_FSM_H
24
25 /* Macro for BGP read, write and timer thread. */
26 #define BGP_READ_ON(T, F, V) \
27 do { \
28 if ((peer->status != Deleted)) \
29 thread_add_read(bm->master, (F), peer, (V), &(T)); \
30 } while (0)
31
32 #define BGP_READ_OFF(T) \
33 do { \
34 if (T) \
35 THREAD_READ_OFF(T); \
36 } while (0)
37
38 #define BGP_WRITE_OFF(T) \
39 do { \
40 if (T) \
41 THREAD_WRITE_OFF(T); \
42 } while (0)
43
44 #define BGP_TIMER_ON(T, F, V) \
45 do { \
46 if ((peer->status != Deleted)) \
47 thread_add_timer(bm->master, (F), peer, (V), &(T)); \
48 } while (0)
49
50 #define BGP_TIMER_OFF(T) \
51 do { \
52 if (T) \
53 THREAD_TIMER_OFF(T); \
54 } while (0)
55
56 #define BGP_EVENT_ADD(P, E) \
57 do { \
58 if ((P)->status != Deleted) \
59 thread_add_event(bm->master, bgp_event, (P), (E), \
60 NULL); \
61 } while (0)
62
63 #define BGP_EVENT_FLUSH(P) \
64 do { \
65 assert(peer); \
66 thread_cancel_event(bm->master, (P)); \
67 } while (0)
68
69 #define BGP_MSEC_JITTER 10
70
71 /* Prototypes. */
72 extern void bgp_fsm_nht_update(struct peer *, int valid);
73 extern int bgp_event(struct thread *);
74 extern int bgp_event_update(struct peer *, int event);
75 extern int bgp_stop(struct peer *peer);
76 extern void bgp_timer_set(struct peer *);
77 extern int bgp_routeadv_timer(struct thread *);
78 extern void bgp_fsm_change_status(struct peer *peer, int status);
79 extern const char *peer_down_str[];
80 extern void bgp_update_delay_end(struct bgp *);
81 extern void bgp_maxmed_update(struct bgp *);
82 extern int bgp_maxmed_onstartup_configured(struct bgp *);
83 extern int bgp_maxmed_onstartup_active(struct bgp *);
84
85 /**
86 * Start the route advertisement timer (that honors MRAI) for all the
87 * peers. Typically called at the end of initial convergence, coming
88 * out of read-only mode.
89 */
90 extern void bgp_start_routeadv(struct bgp *);
91
92 /**
93 * See if the route advertisement timer needs to be adjusted for a
94 * peer. For example, if the last update was written to the peer a
95 * long while back, we don't need to wait for the periodic advertisement
96 * timer to expire to send the new set of prefixes. It should fire
97 * instantly and updates should go out sooner.
98 */
99 extern void bgp_adjust_routeadv(struct peer *);
100
101 #include "hook.h"
102 DECLARE_HOOK(peer_backward_transition, (struct peer * peer), (peer))
103 DECLARE_HOOK(peer_established, (struct peer * peer), (peer))
104
105 #endif /* _QUAGGA_BGP_FSM_H */