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