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