]>
git.proxmox.com Git - mirror_frr.git/blob - pbrd/pbr_nht.h
9b67492fbc2708e642e172b72da022efdc5c63eb
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (C) 2018 Cumulus Networks, Inc.
10 #include <lib/zclient.h>
11 #include <lib/nexthop_group.h>
16 #define PBR_NHC_NAMELEN PBR_MAP_NAMELEN + 10
18 extern struct hash
*pbr_nhg_hash
;
20 struct pbr_nexthop_group_cache
{
21 char name
[PBR_NHC_NAMELEN
];
28 * If all nexthops are considered valid
35 struct pbr_nexthop_cache
{
36 struct pbr_nexthop_group_cache
*parent
;
38 char vrf_name
[VRF_NAMSIZ
+ 1];
39 char intf_name
[INTERFACE_NAMSIZ
+ 1];
41 struct nexthop nexthop
;
48 extern void pbr_nht_write_table_range(struct vty
*vty
);
49 #define PBR_NHT_DEFAULT_LOW_TABLEID 10000
50 #define PBR_NHT_DEFAULT_HIGH_TABLEID 11000
51 extern void pbr_nht_set_tableid_range(uint32_t low
, uint32_t high
);
54 * Find and reserve the next available table for installation;
55 * Sequential calls to this function will reserve sequential table numbers
56 * until the configured range is exhausted; calls made after exhaustion always
60 pbr_nht_reserve_next_table_id(struct pbr_nexthop_group_cache
*nhgc
);
62 * Get the next tableid to use for installation to kernel
64 extern uint32_t pbr_nht_find_next_unallocated_table_id(void);
66 * Calculate where the next table representing a nhg will go in kernel
68 extern void pbr_nht_update_next_unallocated_table_id(void);
70 * Indicate if there are free spots to install a table to kernel within the
71 * configured PBR table range
73 extern bool pbr_nht_has_unallocated_table(void);
75 * Get the next rule number to use for installation
77 extern void pbr_nht_write_rule_range(struct vty
*vty
);
79 #define PBR_NHT_DEFAULT_LOW_RULE 300
80 #define PBR_NHT_DEFAULT_HIGH_RULE 1300
81 extern void pbr_nht_set_rule_range(uint32_t low
, uint32_t high
);
83 extern uint32_t pbr_nht_get_next_rule(uint32_t seqno
);
85 extern void pbr_nhgroup_add_cb(const char *name
);
86 extern void pbr_nhgroup_modify_cb(const struct nexthop_group_cmd
*nhgc
);
87 extern void pbr_nhgroup_add_nexthop_cb(const struct nexthop_group_cmd
*nhg
,
88 const struct nexthop
*nhop
);
89 extern void pbr_nhgroup_del_nexthop_cb(const struct nexthop_group_cmd
*nhg
,
90 const struct nexthop
*nhop
);
91 extern void pbr_nhgroup_delete_cb(const char *name
);
93 extern bool pbr_nht_nexthop_valid(struct nexthop_group
*nhg
);
94 extern bool pbr_nht_nexthop_group_valid(const char *name
);
96 extern struct pbr_nexthop_group_cache
*pbr_nht_add_group(const char *name
);
97 extern void pbr_nht_change_group(const char *name
);
98 extern void pbr_nht_delete_group(const char *name
);
100 extern void pbr_nht_set_seq_nhg_data(struct pbr_map_sequence
*pbrms
,
101 const struct nexthop_group_cmd
*nhgc
);
102 extern void pbr_nht_set_seq_nhg(struct pbr_map_sequence
*pbrms
,
105 extern void pbr_nht_add_individual_nexthop(struct pbr_map_sequence
*pbrms
,
106 const struct nexthop
*nhop
);
107 extern void pbr_nht_delete_individual_nexthop(struct pbr_map_sequence
*pbrms
);
109 * Given the tableid of the installed default
110 * route, find the nexthop-group associated with
111 * it, then find all pbr-maps that use it and
112 * install/delete them as well.
114 extern void pbr_nht_route_installed_for_table(uint32_t table_id
);
115 extern void pbr_nht_route_removed_for_table(uint32_t table_id
);
118 * Given the nexthop group name, lookup the associated
121 extern uint32_t pbr_nht_get_table(const char *name
);
123 extern bool pbr_nht_get_installed(const char *name
);
125 extern char *pbr_nht_nexthop_make_name(char *name
, size_t l
, uint32_t seqno
,
128 extern void pbr_nht_show_nexthop_group(struct vty
*vty
, const char *name
);
129 extern void pbr_nht_json_nexthop_group(json_object
*j
, const char *name
);
132 * When we get a callback from zebra about a nexthop changing
134 extern void pbr_nht_nexthop_update(struct zapi_route
*nhr
);
137 * When we get a callback from zebra about an interface status update.
139 extern void pbr_nht_nexthop_interface_update(struct interface
*ifp
);
141 extern void pbr_nht_init(void);
143 extern void pbr_nht_vrf_update(struct pbr_vrf
*pbr_vrf
);
144 extern void pbr_nht_interface_update(struct interface
*ifp
);