]> git.proxmox.com Git - mirror_frr.git/blame - pbrd/pbr_nht.h
pbrd: When multiple items share the pnhc do the right thing
[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 26#include "pbr_map.h"
010dd8ed 27#include "json.h"
b13e5ad6 28
06210d1f
DS
29#define PBR_NHC_NAMELEN PBR_MAP_NAMELEN + 10
30
fcf29c69
DS
31extern struct hash *pbr_nhg_hash;
32
e5c83d9b 33struct pbr_nexthop_group_cache {
06210d1f 34 char name[PBR_NHC_NAMELEN];
e5c83d9b
DS
35
36 uint32_t table_id;
37
38 struct hash *nhh;
39
40 /*
41 * If all nexthops are considered valid
42 */
43 bool valid;
44
45 bool installed;
46};
47
48struct pbr_nexthop_cache {
49 struct pbr_nexthop_group_cache *parent;
50
fcf29c69 51 char vrf_name[VRF_NAMSIZ + 1];
7cbdabff 52 char intf_name[INTERFACE_NAMSIZ + 1];
fcf29c69 53
b13e5ad6 54 struct nexthop *nexthop;
e5c83d9b 55
9d961247 56 bool looked_at;
e5c83d9b
DS
57 bool valid;
58};
59
60extern void pbr_nht_write_table_range(struct vty *vty);
61#define PBR_NHT_DEFAULT_LOW_TABLEID 10000
62#define PBR_NHT_DEFAULT_HIGH_TABLEID 11000
63extern void pbr_nht_set_tableid_range(uint32_t low, uint32_t high);
64
65/*
a4044dc1
QY
66 * Get the next tableid to use for installation.
67 *
68 * peek
69 * If set to true, retrieves the next ID without marking it used. The next
70 * call will return the same ID.
e5c83d9b 71 */
a4044dc1 72extern uint32_t pbr_nht_get_next_tableid(bool peek);
e5c83d9b
DS
73/*
74 * Get the next rule number to use for installation
75 */
76extern void pbr_nht_write_rule_range(struct vty *vty);
77
78#define PBR_NHT_DEFAULT_LOW_RULE 300
79#define PBR_NHT_DEFAULT_HIGH_RULE 1300
80extern void pbr_nht_set_rule_range(uint32_t low, uint32_t high);
81
82extern uint32_t pbr_nht_get_next_rule(uint32_t seqno);
83
84extern void pbr_nhgroup_add_cb(const char *name);
85extern void pbr_nhgroup_add_nexthop_cb(const struct nexthop_group_cmd *nhg,
86 const struct nexthop *nhop);
87extern void pbr_nhgroup_del_nexthop_cb(const struct nexthop_group_cmd *nhg,
88 const struct nexthop *nhop);
89extern void pbr_nhgroup_delete_cb(const char *name);
90
91extern bool pbr_nht_nexthop_valid(struct nexthop_group *nhg);
92extern bool pbr_nht_nexthop_group_valid(const char *name);
93
b13e5ad6 94extern struct pbr_nexthop_group_cache *pbr_nht_add_group(const char *name);
e5c83d9b
DS
95extern void pbr_nht_change_group(const char *name);
96extern void pbr_nht_delete_group(const char *name);
97
f143cffa
SW
98extern void pbr_nht_add_individual_nexthop(struct pbr_map_sequence *pbrms,
99 const struct nexthop *nhop);
b13e5ad6 100extern void pbr_nht_delete_individual_nexthop(struct pbr_map_sequence *pbrms);
e5c83d9b
DS
101/*
102 * Given the tableid of the installed default
103 * route, find the nexthop-group associated with
104 * it, then find all pbr-maps that use it and
105 * install/delete them as well.
106 */
107extern void pbr_nht_route_installed_for_table(uint32_t table_id);
108extern void pbr_nht_route_removed_for_table(uint32_t table_id);
109
110/*
111 * Given the nexthop group name, lookup the associated
112 * tableid with it
113 */
114extern uint32_t pbr_nht_get_table(const char *name);
115
116extern bool pbr_nht_get_installed(const char *name);
117
118extern char *pbr_nht_nexthop_make_name(char *name, size_t l, uint32_t seqno,
119 char *buffer);
120
121extern void pbr_nht_show_nexthop_group(struct vty *vty, const char *name);
010dd8ed 122extern void pbr_nht_json_nexthop_group(json_object *j, const char *name);
e5c83d9b
DS
123
124/*
125 * When we get a callback from zebra about a nexthop changing
126 */
127extern void pbr_nht_nexthop_update(struct zapi_route *nhr);
128
a106a408
RW
129/*
130 * When we get a callback from zebra about an interface status update.
131 */
132extern void pbr_nht_nexthop_interface_update(struct interface *ifp);
133
e5c83d9b 134extern void pbr_nht_init(void);
fcf29c69
DS
135
136extern void pbr_nht_vrf_update(struct pbr_vrf *pbr_vrf);
7cbdabff 137extern void pbr_nht_interface_update(struct interface *ifp);
e5c83d9b 138#endif