]>
Commit | Line | Data |
---|---|---|
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 | ||
e5c83d9b DS |
25 | struct pbr_map { |
26 | /* | |
27 | * RB Tree of the pbr_maps | |
28 | */ | |
29 | RB_ENTRY(pbr_map) pbr_map_entry; | |
30 | ||
31 | /* | |
32 | * The name of the PBR_MAP | |
33 | */ | |
34 | #define PBR_MAP_NAMELEN 100 | |
35 | char name[PBR_MAP_NAMELEN]; | |
36 | ||
37 | struct list *seqnumbers; | |
38 | ||
39 | /* | |
40 | * The list of incoming interfaces that | |
41 | * we will apply this policy map onto | |
42 | */ | |
43 | struct list *incoming; | |
44 | ||
37c606ff | 45 | bitfield_t ifi_bitfield; |
e5c83d9b DS |
46 | /* |
47 | * If valid is true we think the pbr_map is valid, | |
48 | * If false, look in individual pbrms to see | |
49 | * what we think is the invalid reason | |
50 | */ | |
51 | bool valid; | |
e5c83d9b DS |
52 | }; |
53 | ||
54 | RB_HEAD(pbr_map_entry_head, pbr_map); | |
55 | RB_PROTOTYPE(pbr_map_entry_head, pbr_map, pbr_map_entry, pbr_map_compare) | |
56 | ||
57 | struct pbr_map_interface { | |
37c606ff DS |
58 | uint32_t install_bit; |
59 | ||
e5c83d9b DS |
60 | struct interface *ifp; |
61 | ||
62 | struct pbr_map *pbrm; | |
63 | ||
64 | bool delete; | |
65 | }; | |
66 | ||
67 | struct pbr_map_sequence { | |
68 | struct pbr_map *parent; | |
69 | ||
70 | /* | |
71 | * The Unique identifier of this specific pbrms | |
72 | */ | |
73 | uint32_t unique; | |
74 | ||
75 | /* | |
76 | * The sequence of where we are for display | |
77 | */ | |
78 | uint32_t seqno; | |
79 | ||
80 | /* | |
81 | * The rule number to install into | |
82 | */ | |
83 | uint32_t ruleno; | |
84 | ||
85 | /* | |
86 | * Our policy Catchers | |
87 | */ | |
88 | struct prefix *src; | |
89 | struct prefix *dst; | |
90 | ||
49027ce8 DS |
91 | /* |
92 | * Family of the src/dst. Needed when deleting since we clear them | |
93 | */ | |
94 | unsigned char family; | |
95 | ||
e5c83d9b DS |
96 | /* |
97 | * The nexthop group we auto create | |
98 | * for when the user specifies a individual | |
99 | * nexthop | |
100 | */ | |
101 | struct nexthop_group *nhg; | |
102 | char *internal_nhg_name; | |
103 | ||
104 | /* | |
105 | * The name of the nexthop group | |
106 | * configured in the pbr-map | |
107 | */ | |
108 | char *nhgrp_name; | |
109 | ||
110 | /* | |
111 | * Do we think are nexthops are installed | |
112 | */ | |
113 | bool nhs_installed; | |
114 | ||
b13e5ad6 DS |
115 | /* |
116 | * Are we installed | |
117 | */ | |
37c606ff | 118 | uint64_t installed; |
b13e5ad6 | 119 | |
e5c83d9b DS |
120 | /* |
121 | * A reason of 0 means we think the pbr_map_sequence is good to go | |
122 | * We can accumuluate multiple failure states | |
123 | */ | |
124 | #define PBR_MAP_VALID_SEQUENCE_NUMBER 0 | |
125 | #define PBR_MAP_INVALID_NEXTHOP_GROUP (1 << 0) | |
126 | #define PBR_MAP_INVALID_NEXTHOP (1 << 1) | |
127 | #define PBR_MAP_INVALID_NO_NEXTHOPS (1 << 2) | |
128 | #define PBR_MAP_INVALID_BOTH_NHANDGRP (1 << 3) | |
129 | #define PBR_MAP_INVALID_SRCDST (1 << 4) | |
e5c83d9b DS |
130 | uint64_t reason; |
131 | ||
132 | QOBJ_FIELDS | |
133 | }; | |
134 | ||
135 | DECLARE_QOBJ_TYPE(pbr_map_sequence) | |
136 | ||
137 | extern struct pbr_map_entry_head pbr_maps; | |
138 | ||
139 | extern struct pbr_map_sequence *pbrms_get(const char *name, uint32_t seqno); | |
37c606ff DS |
140 | extern struct pbr_map_sequence * |
141 | pbrms_lookup_unique(uint32_t unique, ifindex_t ifindex, | |
142 | struct pbr_map_interface **ppmi); | |
e5c83d9b DS |
143 | |
144 | extern struct pbr_map *pbrm_find(const char *name); | |
b13e5ad6 DS |
145 | extern void pbr_map_delete(struct pbr_map_sequence *pbrms); |
146 | extern void pbr_map_delete_nexthop_group(struct pbr_map_sequence *pbrms); | |
e5c83d9b DS |
147 | extern void pbr_map_add_interface(struct pbr_map *pbrm, struct interface *ifp); |
148 | extern void pbr_map_interface_delete(struct pbr_map *pbrm, | |
149 | struct interface *ifp); | |
150 | extern void pbr_map_write_interfaces(struct vty *vty, struct interface *ifp); | |
151 | extern void pbr_map_init(void); | |
152 | ||
153 | extern bool pbr_map_check_valid(const char *name); | |
154 | ||
b13e5ad6 | 155 | extern void pbr_map_check(struct pbr_map_sequence *pbrms); |
e5c83d9b | 156 | extern void pbr_map_check_nh_group_change(const char *nh_group); |
e5c83d9b | 157 | extern void pbr_map_reason_string(unsigned int reason, char *buf, int size); |
e5c83d9b DS |
158 | |
159 | extern void pbr_map_schedule_policy_from_nhg(const char *nh_group); | |
160 | ||
b13e5ad6 | 161 | extern void pbr_map_install(struct pbr_map *pbrm); |
e5c83d9b DS |
162 | |
163 | extern void pbr_map_policy_install(const char *name); | |
b13e5ad6 DS |
164 | extern void pbr_map_policy_delete(struct pbr_map *pbrm, |
165 | struct pbr_map_interface *pmi); | |
e5c83d9b | 166 | #endif |