]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/bgp_keepalives.h
bgpd: put BGP keepalives in a pthread
[mirror_frr.git] / bgpd / bgp_keepalives.h
CommitLineData
03014d48
QY
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 */
34extern 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 */
51extern 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 */
59extern void peer_keepalives_off(struct peer *);
60
61/* Entry function for keepalives pthread.
62 *
63 * This function loops over an internal list of peers, generating keepalives at
64 * regular intervals as determined by each peer's keepalive timer.
65 *
66 * See peer_keepalives_on() for additional details.
67 *
68 * @param arg pthread arg, not used
69 */
70extern void *peer_keepalives_start(void *arg);
71
72/* Poking function for keepalives pthread.
73 *
74 * Under normal circumstances the pthread will automatically wake itself
75 * whenever it is necessary to do work. This function may be used to force the
76 * thread to wake up and see if there is any work to do, or if it is time to
77 * die.
78 *
79 * It is not necessary to call this after peer_keepalives_on().
80 */
81extern void peer_keepalives_wake(void);
82
83#endif /* _BGP_KEEPALIVES_H */