]> git.proxmox.com Git - mirror_frr.git/blame - pbrd/pbr_nht.h
Merge pull request #5409 from qlyoung/bgpd-lcom-ecom-parse-fixes
[mirror_frr.git] / pbrd / pbr_nht.h
CommitLineData
e5c83d9b
DS
1/*
2 * PBR-nht Header
3 * Copyright (C) 2018 Cumulus Networks, Inc.
4 * Donald Sharp
5 *
6 * FRR is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * FRR is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20#ifndef __PBR_NHT_H__
21#define __PBR_NHT_H__
22
23#include <lib/zclient.h>
24#include <lib/nexthop_group.h>
25
b13e5ad6
DS
26#include "pbr_map.h"
27
06210d1f
DS
28#define PBR_NHC_NAMELEN PBR_MAP_NAMELEN + 10
29
e5c83d9b 30struct pbr_nexthop_group_cache {
06210d1f 31 char name[PBR_NHC_NAMELEN];
e5c83d9b
DS
32
33 uint32_t table_id;
34
35 struct hash *nhh;
36
37 /*
38 * If all nexthops are considered valid
39 */
40 bool valid;
41
42 bool installed;
43};
44
45struct pbr_nexthop_cache {
46 struct pbr_nexthop_group_cache *parent;
47
b13e5ad6 48 struct nexthop *nexthop;
e5c83d9b
DS
49
50 bool valid;
51};
52
53extern void pbr_nht_write_table_range(struct vty *vty);
54#define PBR_NHT_DEFAULT_LOW_TABLEID 10000
55#define PBR_NHT_DEFAULT_HIGH_TABLEID 11000
56extern void pbr_nht_set_tableid_range(uint32_t low, uint32_t high);
57
58/*
a4044dc1
QY
59 * Get the next tableid to use for installation.
60 *
61 * peek
62 * If set to true, retrieves the next ID without marking it used. The next
63 * call will return the same ID.
e5c83d9b 64 */
a4044dc1 65extern uint32_t pbr_nht_get_next_tableid(bool peek);
e5c83d9b
DS
66/*
67 * Get the next rule number to use for installation
68 */
69extern void pbr_nht_write_rule_range(struct vty *vty);
70
71#define PBR_NHT_DEFAULT_LOW_RULE 300
72#define PBR_NHT_DEFAULT_HIGH_RULE 1300
73extern void pbr_nht_set_rule_range(uint32_t low, uint32_t high);
74
75extern uint32_t pbr_nht_get_next_rule(uint32_t seqno);
76
77extern void pbr_nhgroup_add_cb(const char *name);
78extern void pbr_nhgroup_add_nexthop_cb(const struct nexthop_group_cmd *nhg,
79 const struct nexthop *nhop);
80extern void pbr_nhgroup_del_nexthop_cb(const struct nexthop_group_cmd *nhg,
81 const struct nexthop *nhop);
82extern void pbr_nhgroup_delete_cb(const char *name);
83
84extern bool pbr_nht_nexthop_valid(struct nexthop_group *nhg);
85extern bool pbr_nht_nexthop_group_valid(const char *name);
86
b13e5ad6 87extern struct pbr_nexthop_group_cache *pbr_nht_add_group(const char *name);
e5c83d9b
DS
88extern void pbr_nht_change_group(const char *name);
89extern void pbr_nht_delete_group(const char *name);
90
b13e5ad6
DS
91extern void pbr_nht_add_individual_nexthop(struct pbr_map_sequence *pbrms);
92extern void pbr_nht_delete_individual_nexthop(struct pbr_map_sequence *pbrms);
e5c83d9b
DS
93/*
94 * Given the tableid of the installed default
95 * route, find the nexthop-group associated with
96 * it, then find all pbr-maps that use it and
97 * install/delete them as well.
98 */
99extern void pbr_nht_route_installed_for_table(uint32_t table_id);
100extern void pbr_nht_route_removed_for_table(uint32_t table_id);
101
102/*
103 * Given the nexthop group name, lookup the associated
104 * tableid with it
105 */
106extern uint32_t pbr_nht_get_table(const char *name);
107
108extern bool pbr_nht_get_installed(const char *name);
109
110extern char *pbr_nht_nexthop_make_name(char *name, size_t l, uint32_t seqno,
111 char *buffer);
112
113extern void pbr_nht_show_nexthop_group(struct vty *vty, const char *name);
114
115/*
116 * When we get a callback from zebra about a nexthop changing
117 */
118extern void pbr_nht_nexthop_update(struct zapi_route *nhr);
119
a106a408
RW
120/*
121 * When we get a callback from zebra about an interface status update.
122 */
123extern void pbr_nht_nexthop_interface_update(struct interface *ifp);
124
e5c83d9b
DS
125extern void pbr_nht_init(void);
126#endif