]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/bgp_keepalives.h
bgpd: use new threading infra
[mirror_frr.git] / bgpd / bgp_keepalives.h
1 /* BGP Keepalives.
2 *
3 * Implemented server-style in a pthread.
4 * --------------------------------------
5 * Copyright (C) 2017 Cumulus Networks, Inc.
6 *
7 * This file is part of Free Range Routing.
8 *
9 * Free Range Routing is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2, or (at your option) any later
12 * version.
13 *
14 * Free Range Routing is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GN5U General Public License along
20 * with Free Range Routing; see the file COPYING. If not, write to the Free
21 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 * 02111-1307, USA.
23 */
24 #ifndef _BGP_KEEPALIVES_H_
25 #define _BGP_KEEPALIVES_H_
26
27 #include "bgpd.h"
28
29 /* Thread control flag.
30 *
31 * Setting this flag to 'false' while the thread is running will result in
32 * thread termination.
33 */
34 extern bool bgp_keepalives_thread_run;
35
36 /* Turns on keepalives for a peer.
37 *
38 * This function adds the peer to an internal list of peers to generate
39 * keepalives for.
40 *
41 * At set intervals, a BGP KEEPALIVE packet is generated and placed on
42 * peer->obuf. This operation is thread-safe with respect to peer->obuf.
43 *
44 * peer->v_keepalive determines the interval. Changing this value before
45 * unregistering this peer with peer_keepalives_off() results in undefined
46 * behavior.
47 *
48 * If the peer is already registered for keepalives via this function, nothing
49 * happens.
50 */
51 extern void peer_keepalives_on(struct peer *);
52
53 /* Turns off keepalives for a peer.
54 *
55 * Removes the peer from the internal list of peers to generate keepalives for.
56 *
57 * If the peer is already unregistered for keepalives, nothing happens.
58 */
59 extern void peer_keepalives_off(struct peer *);
60
61 /* Pre-run initialization function for keepalives pthread.
62 *
63 * Initializes synchronization primitives. This should be called before
64 * anything else to avoid race conditions.
65 */
66 extern void peer_keepalives_init(void);
67
68 /* Entry function for keepalives pthread.
69 *
70 * This function loops over an internal list of peers, generating keepalives at
71 * regular intervals as determined by each peer's keepalive timer.
72 *
73 * See peer_keepalives_on() for additional details.
74 *
75 * @param arg pthread arg, not used
76 */
77 extern void *peer_keepalives_start(void *arg);
78
79 /* Poking function for keepalives pthread.
80 *
81 * Under normal circumstances the pthread will automatically wake itself
82 * whenever it is necessary to do work. This function may be used to force the
83 * thread to wake up and see if there is any work to do, or if it is time to
84 * die.
85 *
86 * It is not necessary to call this after peer_keepalives_on().
87 */
88 extern void peer_keepalives_wake(void);
89
90 /* stop function */
91 int peer_keepalives_stop(void **result);
92
93 #endif /* _BGP_KEEPALIVES_H */