]> git.proxmox.com Git - mirror_frr.git/blame - pbrd/pbr_map.h
Merge pull request #5409 from qlyoung/bgpd-lcom-ecom-parse-fixes
[mirror_frr.git] / pbrd / pbr_map.h
CommitLineData
e5c83d9b
DS
1/*
2 * PBR-map 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_MAP_H__
21#define __PBR_MAP_H__
22
37c606ff
DS
23#include <bitfield.h>
24
be3b67b5
SW
25#include "pbr_vrf.h"
26
e5c83d9b
DS
27struct pbr_map {
28 /*
29 * RB Tree of the pbr_maps
30 */
31 RB_ENTRY(pbr_map) pbr_map_entry;
32
33 /*
34 * The name of the PBR_MAP
35 */
36#define PBR_MAP_NAMELEN 100
37 char name[PBR_MAP_NAMELEN];
38
39 struct list *seqnumbers;
40
41 /*
42 * The list of incoming interfaces that
43 * we will apply this policy map onto
44 */
45 struct list *incoming;
46
37c606ff 47 bitfield_t ifi_bitfield;
e5c83d9b
DS
48 /*
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
52 */
53 bool valid;
e5c83d9b
DS
54};
55
56RB_HEAD(pbr_map_entry_head, pbr_map);
57RB_PROTOTYPE(pbr_map_entry_head, pbr_map, pbr_map_entry, pbr_map_compare)
58
59struct pbr_map_interface {
37c606ff
DS
60 uint32_t install_bit;
61
e5c83d9b
DS
62 struct interface *ifp;
63
64 struct pbr_map *pbrm;
65
66 bool delete;
67};
68
69struct pbr_map_sequence {
70 struct pbr_map *parent;
71
72 /*
73 * The Unique identifier of this specific pbrms
74 */
75 uint32_t unique;
76
77 /*
78 * The sequence of where we are for display
79 */
80 uint32_t seqno;
81
82 /*
83 * The rule number to install into
84 */
85 uint32_t ruleno;
86
87 /*
88 * Our policy Catchers
89 */
90 struct prefix *src;
91 struct prefix *dst;
95a9fe02 92 uint32_t mark;
e5c83d9b 93
49027ce8
DS
94 /*
95 * Family of the src/dst. Needed when deleting since we clear them
96 */
97 unsigned char family;
98
be3b67b5
SW
99 /*
100 * Use interface's vrf.
101 */
102 bool vrf_unchanged;
103
104 /*
105 * The vrf to lookup in was directly configured.
106 */
107 bool vrf_lookup;
108
109 /*
110 * VRF to lookup.
111 */
112 char vrf_name[VRF_NAMSIZ + 1];
113
e5c83d9b
DS
114 /*
115 * The nexthop group we auto create
116 * for when the user specifies a individual
117 * nexthop
118 */
119 struct nexthop_group *nhg;
120 char *internal_nhg_name;
121
122 /*
123 * The name of the nexthop group
124 * configured in the pbr-map
125 */
126 char *nhgrp_name;
127
128 /*
129 * Do we think are nexthops are installed
130 */
131 bool nhs_installed;
132
b13e5ad6
DS
133 /*
134 * Are we installed
135 */
37c606ff 136 uint64_t installed;
b13e5ad6 137
e5c83d9b
DS
138 /*
139 * A reason of 0 means we think the pbr_map_sequence is good to go
140 * We can accumuluate multiple failure states
141 */
be3b67b5
SW
142#define PBR_MAP_VALID_SEQUENCE_NUMBER 0
143#define PBR_MAP_INVALID_NEXTHOP_GROUP (1 << 0)
144#define PBR_MAP_INVALID_NEXTHOP (1 << 1)
145#define PBR_MAP_INVALID_NO_NEXTHOPS (1 << 2)
146#define PBR_MAP_INVALID_BOTH_NHANDGRP (1 << 3)
147#define PBR_MAP_INVALID_EMPTY (1 << 4)
148#define PBR_MAP_INVALID_VRF (1 << 5)
e5c83d9b
DS
149 uint64_t reason;
150
151 QOBJ_FIELDS
152};
153
154DECLARE_QOBJ_TYPE(pbr_map_sequence)
155
156extern struct pbr_map_entry_head pbr_maps;
157
158extern struct pbr_map_sequence *pbrms_get(const char *name, uint32_t seqno);
37c606ff
DS
159extern struct pbr_map_sequence *
160pbrms_lookup_unique(uint32_t unique, ifindex_t ifindex,
161 struct pbr_map_interface **ppmi);
e5c83d9b
DS
162
163extern struct pbr_map *pbrm_find(const char *name);
b13e5ad6 164extern void pbr_map_delete(struct pbr_map_sequence *pbrms);
be3b67b5
SW
165extern void pbr_map_delete_nexthops(struct pbr_map_sequence *pbrms);
166extern void pbr_map_delete_vrf(struct pbr_map_sequence *pbrms);
e5c83d9b
DS
167extern void pbr_map_add_interface(struct pbr_map *pbrm, struct interface *ifp);
168extern void pbr_map_interface_delete(struct pbr_map *pbrm,
169 struct interface *ifp);
be3b67b5
SW
170
171/* Update maps installed on interface */
172extern void pbr_map_policy_interface_update(const struct interface *ifp,
173 bool state_up);
174
38e9ccde
DS
175extern void pbr_map_final_interface_deletion(struct pbr_map *pbrm,
176 struct pbr_map_interface *pmi);
be3b67b5
SW
177
178extern void pbr_map_vrf_update(const struct pbr_vrf *pbr_vrf);
179
e5c83d9b
DS
180extern void pbr_map_write_interfaces(struct vty *vty, struct interface *ifp);
181extern void pbr_map_init(void);
182
183extern bool pbr_map_check_valid(const char *name);
184
b13e5ad6 185extern void pbr_map_check(struct pbr_map_sequence *pbrms);
e5c83d9b 186extern void pbr_map_check_nh_group_change(const char *nh_group);
e5c83d9b 187extern void pbr_map_reason_string(unsigned int reason, char *buf, int size);
e5c83d9b
DS
188
189extern void pbr_map_schedule_policy_from_nhg(const char *nh_group);
190
b13e5ad6 191extern void pbr_map_install(struct pbr_map *pbrm);
e5c83d9b
DS
192
193extern void pbr_map_policy_install(const char *name);
b13e5ad6
DS
194extern void pbr_map_policy_delete(struct pbr_map *pbrm,
195 struct pbr_map_interface *pmi);
e5c83d9b 196#endif