]> git.proxmox.com Git - mirror_frr.git/blob - zebra/table_manager.h
bgpd: Refactor subgroup_announce_table() to reuse an existing helpers
[mirror_frr.git] / zebra / table_manager.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* zebra table Manager for routing table identifier management
3 * Copyright (C) 2018 6WIND
4 */
5
6 #ifndef _TABLE_MANAGER_H
7 #define _TABLE_MANAGER_H
8
9 #include <stdint.h>
10
11 #include "lib/linklist.h"
12 #include "frrevent.h"
13 #include "lib/ns.h"
14
15 #include "zebra/zserv.h"
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 /*
22 * Table chunk struct
23 * Client daemon which the chunk belongs to can be identified by either
24 * proto (daemon protocol) + instance + VRF.
25 * If the client then passes a non-empty value to keep field when it requests
26 * for chunks, the chunks won't be garbage collected and the client will be
27 * responsible of its release.
28 * Otherwise, if the keep field is not set (value 0) for the chunk, it will be
29 * automatically released when the client disconnects or when it reconnects
30 * (in case it died unexpectedly, we can know it's the same because it will have
31 * the same proto and instance values)
32 */
33 struct table_manager_chunk {
34 vrf_id_t vrf_id;
35 uint8_t proto;
36 uint16_t instance;
37 uint32_t start; /* First table RT ID of the chunk */
38 uint32_t end; /* Last table RT ID of the chunk */
39 };
40
41 /*
42 * Main table manager struct
43 * Holds a linked list of table chunks.
44 */
45 struct table_manager {
46 struct list *lc_list;
47 uint32_t start;
48 uint32_t end;
49 };
50
51 void table_manager_enable(struct zebra_vrf *zvrf);
52 struct table_manager_chunk *assign_table_chunk(uint8_t proto, uint16_t instance,
53 uint32_t size,
54 struct zebra_vrf *zvrf);
55 int release_table_chunk(uint8_t proto, uint16_t instance, uint32_t start,
56 uint32_t end, struct zebra_vrf *zvrf);
57 int release_daemon_table_chunks(struct zserv *client);
58 void table_manager_disable(struct zebra_vrf *zvrf);
59 int table_manager_range(struct vty *vty, bool add, struct zebra_vrf *zvrf,
60 const char *min, const char *max);
61
62 #ifdef __cplusplus
63 }
64 #endif
65
66 #endif /* _TABLE_MANAGER_H */