3 * Copyright (C) 2018 Cumulus Networks, Inc.
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
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.
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
29 * RB Tree of the pbr_maps
31 RB_ENTRY(pbr_map
) pbr_map_entry
;
34 * The name of the PBR_MAP
36 #define PBR_MAP_NAMELEN 100
37 char name
[PBR_MAP_NAMELEN
];
39 struct list
*seqnumbers
;
42 * The list of incoming interfaces that
43 * we will apply this policy map onto
45 struct list
*incoming
;
47 bitfield_t ifi_bitfield
;
49 * If valid is true we think the pbr_map is valid,
50 * If false, look in individual pbrms to see
51 * what we think is the invalid reason
56 RB_HEAD(pbr_map_entry_head
, pbr_map
);
57 RB_PROTOTYPE(pbr_map_entry_head
, pbr_map
, pbr_map_entry
, pbr_map_compare
)
59 struct pbr_map_interface
{
62 struct interface
*ifp
;
69 struct pbr_map_sequence
{
70 struct pbr_map
*parent
;
73 * The Unique identifier of this specific pbrms
78 * The sequence of where we are for display
83 * The rule number to install into
96 * Family of the src/dst. Needed when deleting since we clear them
101 * Use interface's vrf.
106 * The vrf to lookup in was directly configured.
113 char vrf_name
[VRF_NAMSIZ
+ 1];
116 * The nexthop group we auto create
117 * for when the user specifies a individual
120 struct nexthop_group
*nhg
;
121 char *internal_nhg_name
;
124 * The name of the nexthop group
125 * configured in the pbr-map
130 * Do we think are nexthops are installed
140 * A reason of 0 means we think the pbr_map_sequence is good to go
141 * We can accumuluate multiple failure states
143 #define PBR_MAP_VALID_SEQUENCE_NUMBER 0
144 #define PBR_MAP_INVALID_NEXTHOP_GROUP (1 << 0)
145 #define PBR_MAP_INVALID_NEXTHOP (1 << 1)
146 #define PBR_MAP_INVALID_NO_NEXTHOPS (1 << 2)
147 #define PBR_MAP_INVALID_BOTH_NHANDGRP (1 << 3)
148 #define PBR_MAP_INVALID_EMPTY (1 << 4)
149 #define PBR_MAP_INVALID_VRF (1 << 5)
155 DECLARE_QOBJ_TYPE(pbr_map_sequence
)
157 extern struct pbr_map_entry_head pbr_maps
;
159 extern struct pbr_map_sequence
*pbrms_get(const char *name
, uint32_t seqno
);
160 extern struct pbr_map_sequence
*
161 pbrms_lookup_unique(uint32_t unique
, ifindex_t ifindex
,
162 struct pbr_map_interface
**ppmi
);
164 extern struct pbr_map
*pbrm_find(const char *name
);
165 extern void pbr_map_delete(struct pbr_map_sequence
*pbrms
);
166 extern void pbr_map_delete_nexthops(struct pbr_map_sequence
*pbrms
);
167 extern void pbr_map_delete_vrf(struct pbr_map_sequence
*pbrms
);
168 extern void pbr_map_add_interface(struct pbr_map
*pbrm
, struct interface
*ifp
);
169 extern void pbr_map_interface_delete(struct pbr_map
*pbrm
,
170 struct interface
*ifp
);
172 extern uint8_t pbr_map_decode_dscp_enum(const char *name
);
174 /* Update maps installed on interface */
175 extern void pbr_map_policy_interface_update(const struct interface
*ifp
,
178 extern void pbr_map_final_interface_deletion(struct pbr_map
*pbrm
,
179 struct pbr_map_interface
*pmi
);
181 extern void pbr_map_vrf_update(const struct pbr_vrf
*pbr_vrf
);
183 extern void pbr_map_write_interfaces(struct vty
*vty
, struct interface
*ifp
);
184 extern void pbr_map_init(void);
186 extern bool pbr_map_check_valid(const char *name
);
189 * Re-check the pbr map for validity.
191 * Install if valid, remove if not.
193 * If changed is set, the config on the on the map has changed somewhere
194 * and the rules need to be replaced if valid.
196 extern void pbr_map_check(struct pbr_map_sequence
*pbrms
, bool changed
);
197 extern void pbr_map_check_nh_group_change(const char *nh_group
);
198 extern void pbr_map_reason_string(unsigned int reason
, char *buf
, int size
);
200 extern void pbr_map_schedule_policy_from_nhg(const char *nh_group
,
203 extern void pbr_map_install(struct pbr_map
*pbrm
);
205 extern void pbr_map_policy_install(const char *name
);
206 extern void pbr_map_policy_delete(struct pbr_map
*pbrm
,
207 struct pbr_map_interface
*pmi
);
209 extern void pbr_map_check_vrf_nh_group_change(const char *nh_group
,
210 struct pbr_vrf
*pbr_vrf
,
211 uint32_t old_vrf_id
);
212 extern void pbr_map_check_interface_nh_group_change(const char *nh_group
,
213 struct interface
*ifp
,
214 ifindex_t oldifindex
);