]>
Commit | Line | Data |
---|---|---|
2638249d MM |
1 | /* |
2 | * BIRD -- Border Gateway Protocol Configuration | |
3 | * | |
4 | * (c) 2000 Martin Mares <mj@ucw.cz> | |
5 | * | |
6 | * Can be freely distributed and used under the terms of the GNU GPL. | |
7 | */ | |
8 | ||
9 | CF_HDR | |
10 | ||
11 | #include "proto/bgp/bgp.h" | |
12 | ||
cea63664 MM |
13 | CF_DEFINES |
14 | ||
2638249d | 15 | #define BGP_CFG ((struct bgp_config *) this_proto) |
d15b0b0a | 16 | #define BGP_CC ((struct bgp_channel_config *) this_channel) |
2638249d MM |
17 | |
18 | CF_DECLS | |
19 | ||
d15b0b0a OZ |
20 | CF_KEYWORDS(BGP, LOCAL, NEIGHBOR, AS, HOLD, TIME, CONNECT, RETRY, KEEPALIVE, |
21 | MULTIHOP, STARTUP, VIA, NEXT, HOP, SELF, DEFAULT, PATH, METRIC, ERROR, | |
22 | START, DELAY, FORGET, WAIT, ENABLE, DISABLE, AFTER, BGP_PATH, | |
23 | BGP_LOCAL_PREF, BGP_MED, BGP_ORIGIN, BGP_NEXT_HOP, BGP_ATOMIC_AGGR, | |
24 | BGP_AGGREGATOR, BGP_COMMUNITY, BGP_EXT_COMMUNITY, BGP_LARGE_COMMUNITY, | |
25 | SOURCE, ADDRESS, PASSWORD, RR, RS, CLIENT, CLUSTER, ID, AS4, ADVERTISE, | |
26 | IPV4, CAPABILITIES, LIMIT, PASSIVE, PREFER, OLDER, MISSING, LLADDR, | |
8ad9c4bb | 27 | DROP, IGNORE, ENHANCED, ROUTE, REFRESH, INTERPRET, COMMUNITIES, BGP_ORIGINATOR_ID, |
d15b0b0a OZ |
28 | BGP_CLUSTER_LIST, IGP, TABLE, GATEWAY, DIRECT, RECURSIVE, MED, TTL, |
29 | SECURITY, DETERMINISTIC, SECONDARY, ALLOW, BFD, ADD, PATHS, RX, TX, | |
30 | GRACEFUL, RESTART, AWARE, CHECK, LINK, PORT, EXTENDED, MESSAGES, SETKEY, | |
5bd73431 | 31 | STRICT, BIND, CONFEDERATION, MEMBER, MULTICAST, FLOW4, FLOW6, LONG, |
a52476c9 | 32 | LIVED, STALE, IMPORT, IBGP, EBGP, MANDATORY, INTERNAL, EXTERNAL, SETS, |
0b228fca | 33 | DYNAMIC, RANGE, NAME, DIGITS, BGP_AIGP, AIGP, ORIGINATE, COST, ENFORCE, |
c73b5d2d | 34 | FIRST, FREE, VALIDATE, BASE, ROLE, ROLES, PEER, PROVIDER, CUSTOMER, |
bcf23274 | 35 | RS_SERVER, RS_CLIENT, REQUIRE, BGP_OTC, GLOBAL, SEND) |
d15b0b0a | 36 | |
1cab2b4a | 37 | %type <i> bgp_nh |
d15b0b0a | 38 | %type <i32> bgp_afi |
2638249d | 39 | |
63472779 OZ |
40 | CF_KEYWORDS(CEASE, PREFIX, LIMIT, HIT, ADMINISTRATIVE, SHUTDOWN, RESET, PEER, |
41 | CONFIGURATION, CHANGE, DECONFIGURED, CONNECTION, REJECTED, COLLISION, | |
42 | OUT, OF, RESOURCES) | |
43 | ||
c73b5d2d | 44 | %type<i> bgp_cease_mask bgp_cease_list bgp_cease_flag bgp_role_name |
63472779 | 45 | |
2638249d MM |
46 | CF_GRAMMAR |
47 | ||
f851f0d7 | 48 | proto: bgp_proto '}' ; |
2638249d MM |
49 | |
50 | bgp_proto_start: proto_start BGP { | |
2bbc3083 | 51 | this_proto = proto_config_new(&proto_bgp, $1); |
d15b0b0a | 52 | BGP_CFG->local_port = BGP_PORT; |
a1beb8f3 | 53 | BGP_CFG->remote_port = BGP_PORT; |
f3e59178 | 54 | BGP_CFG->multihop = -1; /* undefined */ |
c01e3741 | 55 | BGP_CFG->hold_time = 240; |
b552ecc4 | 56 | BGP_CFG->initial_hold_time = 240; |
56a2bed4 | 57 | BGP_CFG->compare_path_lengths = 1; |
d1e146f2 | 58 | BGP_CFG->igp_metric = 1; |
6cf72d7a OZ |
59 | BGP_CFG->connect_delay_time = 5; |
60 | BGP_CFG->connect_retry_time = 120; | |
6fd766c1 MM |
61 | BGP_CFG->error_amnesia_time = 300; |
62 | BGP_CFG->error_delay_time_min = 60; | |
63 | BGP_CFG->error_delay_time_max = 300; | |
bf47fe4b | 64 | BGP_CFG->enable_refresh = 1; |
8ad9c4bb | 65 | BGP_CFG->enable_enhanced_refresh = 1; |
43c1cecc | 66 | BGP_CFG->enable_as4 = 1; |
71423871 | 67 | BGP_CFG->enable_hostname = 0; |
e8ba557c | 68 | BGP_CFG->capabilities = 2; |
41677025 | 69 | BGP_CFG->interpret_communities = 1; |
a52476c9 | 70 | BGP_CFG->allow_as_sets = 1; |
fbcb7d5f | 71 | BGP_CFG->default_local_pref = 100; |
0c791f87 OZ |
72 | BGP_CFG->gr_mode = BGP_GR_AWARE; |
73 | BGP_CFG->gr_time = 120; | |
5bd73431 OZ |
74 | BGP_CFG->llgr_mode = -1; |
75 | BGP_CFG->llgr_time = 3600; | |
a7baa098 | 76 | BGP_CFG->setkey = 1; |
c73b5d2d | 77 | BGP_CFG->local_role = BGP_ROLE_UNDEFINED; |
e0835db4 | 78 | BGP_CFG->dynamic_name = "dynbgp"; |
dea98864 | 79 | BGP_CFG->check_link = -1; |
bcf23274 | 80 | BGP_CFG->send_hold_time = -1; |
d15b0b0a OZ |
81 | } |
82 | ; | |
83 | ||
84 | bgp_loc_opts: | |
85 | /* empty */ | |
86 | | bgp_loc_opts PORT expr { BGP_CFG->local_port = $3; if (($3<1) || ($3>65535)) cf_error("Invalid port number"); } | |
87 | | bgp_loc_opts AS expr { BGP_CFG->local_as = $3; } | |
2638249d MM |
88 | ; |
89 | ||
a1beb8f3 OZ |
90 | bgp_nbr_opts: |
91 | /* empty */ | |
d15b0b0a | 92 | | bgp_nbr_opts PORT expr { BGP_CFG->remote_port = $3; if (($3<1) || ($3>65535)) cf_error("Invalid port number"); } |
a1beb8f3 | 93 | | bgp_nbr_opts AS expr { BGP_CFG->remote_as = $3; } |
23ee6b1c OZ |
94 | | bgp_nbr_opts INTERNAL { BGP_CFG->peer_type = BGP_PT_INTERNAL; } |
95 | | bgp_nbr_opts EXTERNAL { BGP_CFG->peer_type = BGP_PT_EXTERNAL; } | |
a1beb8f3 OZ |
96 | ; |
97 | ||
63472779 OZ |
98 | bgp_cease_mask: |
99 | /* true -> all except connection collision */ | |
100 | bool { $$ = $1 ? ~(1 << 7) : 0; } | |
101 | | '{' bgp_cease_list '}' { $$ = $2; } | |
102 | ; | |
103 | ||
104 | bgp_cease_list: | |
105 | bgp_cease_flag | |
106 | | bgp_cease_list ',' bgp_cease_flag { $$ = $1 | $3; } | |
107 | ; | |
108 | ||
109 | bgp_cease_flag: | |
110 | CEASE { $$ = 1 << 0; } | |
111 | | PREFIX LIMIT HIT { $$ = 1 << 1; } | |
112 | | ADMINISTRATIVE SHUTDOWN { $$ = 1 << 2; } | |
113 | | PEER DECONFIGURED { $$ = 1 << 3; } | |
114 | | ADMINISTRATIVE RESET { $$ = 1 << 4; } | |
115 | | CONNECTION REJECTED { $$ = 1 << 5; } | |
116 | | CONFIGURATION CHANGE { $$ = 1 << 6; } | |
117 | | CONNECTION COLLISION { $$ = 1 << 7; } | |
118 | | OUT OF RESOURCES { $$ = 1 << 8; } | |
119 | ; | |
120 | ||
c73b5d2d EB |
121 | bgp_role_name: |
122 | PEER { $$ = BGP_ROLE_PEER; } | |
123 | | PROVIDER { $$ = BGP_ROLE_PROVIDER; } | |
124 | | CUSTOMER { $$ = BGP_ROLE_CUSTOMER; } | |
125 | | RS_SERVER { $$ = BGP_ROLE_RS_SERVER; } | |
126 | | RS_CLIENT { $$ = BGP_ROLE_RS_CLIENT; } | |
127 | ; | |
128 | ||
2638249d MM |
129 | bgp_proto: |
130 | bgp_proto_start proto_name '{' | |
131 | | bgp_proto proto_item ';' | |
d15b0b0a | 132 | | bgp_proto bgp_proto_channel ';' |
9d456d53 | 133 | | bgp_proto mpls_channel ';' |
d15b0b0a OZ |
134 | | bgp_proto LOCAL bgp_loc_opts ';' |
135 | | bgp_proto LOCAL ipa ipa_scope bgp_loc_opts ';' { | |
136 | BGP_CFG->local_ip = $3; | |
137 | if ($4) BGP_CFG->iface = $4; | |
138 | } | |
a1beb8f3 OZ |
139 | | bgp_proto NEIGHBOR bgp_nbr_opts ';' |
140 | | bgp_proto NEIGHBOR ipa ipa_scope bgp_nbr_opts ';' { | |
e0835db4 | 141 | if (ipa_nonzero(BGP_CFG->remote_ip) || BGP_CFG->remote_range) |
53ffbff3 | 142 | cf_error("Only one neighbor per BGP instance is allowed"); |
2638249d | 143 | BGP_CFG->remote_ip = $3; |
a1beb8f3 | 144 | if ($4) BGP_CFG->iface = $4; |
2638249d | 145 | } |
e0835db4 OZ |
146 | | bgp_proto NEIGHBOR RANGE net_ip bgp_nbr_opts ';' { |
147 | if (ipa_nonzero(BGP_CFG->remote_ip) || BGP_CFG->remote_range) | |
148 | cf_error("Only one neighbor per BGP instance is allowed"); | |
149 | net_addr *n = cfg_alloc($4.length); | |
150 | net_copy(n, &($4)); | |
151 | BGP_CFG->remote_range = n; | |
152 | } | |
a1beb8f3 | 153 | | bgp_proto INTERFACE TEXT ';' { BGP_CFG->iface = if_get_by_name($3); } |
89534cda | 154 | | bgp_proto RR CLUSTER ID idval ';' { BGP_CFG->rr_cluster_id = $5; } |
d15b0b0a OZ |
155 | | bgp_proto RR CLIENT bool ';' { BGP_CFG->rr_client = $4; } |
156 | | bgp_proto RS CLIENT bool ';' { BGP_CFG->rs_client = $4; } | |
157 | | bgp_proto CONFEDERATION expr ';' { BGP_CFG->confederation = $3; } | |
158 | | bgp_proto CONFEDERATION MEMBER bool ';' { BGP_CFG->confederation_member = $4; } | |
3859e4ef OZ |
159 | | bgp_proto HOLD TIME expr ';' { BGP_CFG->hold_time = $4; if (($4 && $4<3) || ($4>65535)) cf_error("Hold time must be in range 3-65535 or zero"); } |
160 | | bgp_proto MIN HOLD TIME expr ';' { BGP_CFG->min_hold_time = $5; } | |
e3f2d5fc | 161 | | bgp_proto STARTUP HOLD TIME expr ';' { BGP_CFG->initial_hold_time = $5; } |
f3e59178 | 162 | | bgp_proto DIRECT ';' { BGP_CFG->multihop = 0; } |
9be9a264 | 163 | | bgp_proto MULTIHOP ';' { BGP_CFG->multihop = 64; } |
b1b19433 | 164 | | bgp_proto MULTIHOP expr ';' { BGP_CFG->multihop = $3; if (($3<1) || ($3>255)) cf_error("Multihop must be in range 1-255"); } |
e0835db4 OZ |
165 | | bgp_proto DYNAMIC NAME text ';' { |
166 | if (strchr($4, '%')) cf_error("Forbidden character '%%' in dynamic name"); | |
167 | if (strlen($4) > (SYM_MAX_LEN - 16)) cf_error("Dynamic name too long"); | |
168 | BGP_CFG->dynamic_name = $4; | |
169 | } | |
170 | | bgp_proto DYNAMIC NAME DIGITS expr ';' { BGP_CFG->dynamic_name_digits = $5; if ($5>10) cf_error("Dynamic name digits must be at most 10"); } | |
d15b0b0a | 171 | | bgp_proto STRICT BIND bool ';' { BGP_CFG->strict_bind = $4; } |
60e9def9 | 172 | | bgp_proto FREE BIND bool ';' { BGP_CFG->free_bind = $4; } |
7294f68b | 173 | | bgp_proto PATH METRIC bool ';' { BGP_CFG->compare_path_lengths = $4; } |
73272f04 | 174 | | bgp_proto MED METRIC bool ';' { BGP_CFG->med_metric = $4; } |
d1e146f2 | 175 | | bgp_proto IGP METRIC bool ';' { BGP_CFG->igp_metric = $4; } |
3228c72c | 176 | | bgp_proto PREFER OLDER bool ';' { BGP_CFG->prefer_older = $4; } |
be4cd99a | 177 | | bgp_proto DETERMINISTIC MED bool ';' { BGP_CFG->deterministic_med = $4; } |
e3f2d5fc MM |
178 | | bgp_proto DEFAULT BGP_MED expr ';' { BGP_CFG->default_med = $4; } |
179 | | bgp_proto DEFAULT BGP_LOCAL_PREF expr ';' { BGP_CFG->default_local_pref = $4; } | |
d15b0b0a | 180 | | bgp_proto SOURCE ADDRESS ipa ';' { BGP_CFG->local_ip = $4; } |
6f798683 | 181 | | bgp_proto START DELAY TIME expr ';' { BGP_CFG->connect_delay_time = $5; cf_warn("%s: Start delay time option is deprecated, use connect delay time", this_proto->name); } |
6cf72d7a OZ |
182 | | bgp_proto CONNECT DELAY TIME expr ';' { BGP_CFG->connect_delay_time = $5; } |
183 | | bgp_proto CONNECT RETRY TIME expr ';' { BGP_CFG->connect_retry_time = $5; } | |
3859e4ef OZ |
184 | | bgp_proto KEEPALIVE TIME expr ';' { BGP_CFG->keepalive_time = $4; if (($4<1) || ($4>65535)) cf_error("Keepalive time must be in range 1-65535"); } |
185 | | bgp_proto MIN KEEPALIVE TIME expr ';' { BGP_CFG->min_keepalive_time = $5; } | |
bcf23274 | 186 | | bgp_proto SEND HOLD TIME expr';' { BGP_CFG->send_hold_time = $5; } |
523f020b | 187 | | bgp_proto ERROR FORGET TIME expr ';' { BGP_CFG->error_amnesia_time = $5; } |
e3f2d5fc | 188 | | bgp_proto ERROR WAIT TIME expr ',' expr ';' { BGP_CFG->error_delay_time_min = $5; BGP_CFG->error_delay_time_max = $7; } |
7294f68b | 189 | | bgp_proto DISABLE AFTER ERROR bool ';' { BGP_CFG->disable_after_error = $5; } |
63472779 | 190 | | bgp_proto DISABLE AFTER CEASE bgp_cease_mask ';' { BGP_CFG->disable_after_cease = $5; } |
bf47fe4b | 191 | | bgp_proto ENABLE ROUTE REFRESH bool ';' { BGP_CFG->enable_refresh = $5; } |
8ad9c4bb | 192 | | bgp_proto ENABLE ENHANCED ROUTE REFRESH bool ';' { BGP_CFG->enable_enhanced_refresh = $6; } |
ba5ed6f3 | 193 | | bgp_proto ENABLE AS4 bool ';' { BGP_CFG->enable_as4 = $4; } |
06e0d1b6 | 194 | | bgp_proto ENABLE EXTENDED MESSAGES bool ';' { BGP_CFG->enable_extended_messages = $5; } |
71423871 | 195 | | bgp_proto ADVERTISE HOSTNAME bool ';' { BGP_CFG->enable_hostname = $4; } |
3fb06fea OZ |
196 | | bgp_proto REQUIRE ROUTE REFRESH bool ';' { BGP_CFG->require_refresh = $5; } |
197 | | bgp_proto REQUIRE ENHANCED ROUTE REFRESH bool ';' { BGP_CFG->require_enhanced_refresh = $6; } | |
198 | | bgp_proto REQUIRE AS4 bool ';' { BGP_CFG->require_as4 = $4; } | |
199 | | bgp_proto REQUIRE EXTENDED MESSAGES bool ';' { BGP_CFG->require_extended_messages = $5; } | |
200 | | bgp_proto REQUIRE HOSTNAME bool ';' { BGP_CFG->require_hostname = $4; } | |
201 | | bgp_proto REQUIRE GRACEFUL RESTART bool ';' { BGP_CFG->require_gr = $5; } | |
202 | | bgp_proto REQUIRE LONG LIVED GRACEFUL RESTART bool ';' { BGP_CFG->require_llgr = $7; } | |
e8ba557c | 203 | | bgp_proto CAPABILITIES bool ';' { BGP_CFG->capabilities = $3; } |
9eceab33 | 204 | | bgp_proto PASSWORD text ';' { BGP_CFG->password = $3; } |
a7baa098 | 205 | | bgp_proto SETKEY bool ';' { BGP_CFG->setkey = $3; } |
be6e39eb | 206 | | bgp_proto PASSIVE bool ';' { BGP_CFG->passive = $3; } |
41677025 | 207 | | bgp_proto INTERPRET COMMUNITIES bool ';' { BGP_CFG->interpret_communities = $4; } |
a15dab76 OZ |
208 | | bgp_proto ALLOW LOCAL AS ';' { BGP_CFG->allow_local_as = -1; } |
209 | | bgp_proto ALLOW LOCAL AS expr ';' { BGP_CFG->allow_local_as = $5; } | |
e919601a | 210 | | bgp_proto ALLOW BGP_LOCAL_PREF bool ';' { BGP_CFG->allow_local_pref = $4; } |
9e44ace3 | 211 | | bgp_proto ALLOW BGP_MED bool ';' { BGP_CFG->allow_med = $4; } |
a52476c9 | 212 | | bgp_proto ALLOW AS SETS bool ';' { BGP_CFG->allow_as_sets = $5; } |
0c791f87 OZ |
213 | | bgp_proto GRACEFUL RESTART bool ';' { BGP_CFG->gr_mode = $4; } |
214 | | bgp_proto GRACEFUL RESTART AWARE ';' { BGP_CFG->gr_mode = BGP_GR_AWARE; } | |
215 | | bgp_proto GRACEFUL RESTART TIME expr ';' { BGP_CFG->gr_time = $5; } | |
5bd73431 OZ |
216 | | bgp_proto LONG LIVED GRACEFUL RESTART bool ';' { BGP_CFG->llgr_mode = $6; } |
217 | | bgp_proto LONG LIVED GRACEFUL RESTART AWARE ';' { BGP_CFG->llgr_mode = BGP_LLGR_AWARE; } | |
218 | | bgp_proto LONG LIVED STALE TIME expr ';' { BGP_CFG->llgr_time = $6; } | |
b1b19433 | 219 | | bgp_proto TTL SECURITY bool ';' { BGP_CFG->ttl_security = $4; } |
523f020b | 220 | | bgp_proto CHECK LINK bool ';' { BGP_CFG->check_link = $4; } |
3b56bf88 OZ |
221 | | bgp_proto BFD bool ';' { if ($3) init_bfd_opts(&BGP_CFG->bfd); else BGP_CFG->bfd = NULL; } |
222 | | bgp_proto BFD GRACEFUL ';' { init_bfd_opts(&BGP_CFG->bfd); BGP_CFG->bfd->mode = BGP_BFD_GRACEFUL; } | |
223 | | bgp_proto BFD { open_bfd_opts(&BGP_CFG->bfd); } bfd_opts { close_bfd_opts(); } ';' | |
0b228fca | 224 | | bgp_proto ENFORCE FIRST AS bool ';' { BGP_CFG->enforce_first_as = $5; } |
c73b5d2d EB |
225 | | bgp_proto LOCAL ROLE bgp_role_name ';' { BGP_CFG->local_role = $4; } |
226 | | bgp_proto REQUIRE ROLES bool ';' { BGP_CFG->require_roles = $4; } | |
bcf23274 | 227 | | bgp_proto DISABLE RX bool ';' { BGP_CFG->disable_rx = $4; } |
2638249d MM |
228 | ; |
229 | ||
d15b0b0a | 230 | bgp_afi: |
711d617d OZ |
231 | IPV4 { $$ = BGP_AF_IPV4; } |
232 | | IPV6 { $$ = BGP_AF_IPV6; } | |
233 | | IPV4 MULTICAST { $$ = BGP_AF_IPV4_MC; } | |
234 | | IPV6 MULTICAST { $$ = BGP_AF_IPV6_MC; } | |
235 | | IPV4 MPLS { $$ = BGP_AF_IPV4_MPLS; } | |
236 | | IPV6 MPLS { $$ = BGP_AF_IPV6_MPLS; } | |
237 | | VPN4 MPLS { $$ = BGP_AF_VPN4_MPLS; } | |
238 | | VPN6 MPLS { $$ = BGP_AF_VPN6_MPLS; } | |
239 | | VPN4 MULTICAST { $$ = BGP_AF_VPN4_MC; } | |
240 | | VPN6 MULTICAST { $$ = BGP_AF_VPN6_MC; } | |
241 | | FLOW4 { $$ = BGP_AF_FLOW4; } | |
242 | | FLOW6 { $$ = BGP_AF_FLOW6; } | |
d15b0b0a OZ |
243 | ; |
244 | ||
245 | bgp_channel_start: bgp_afi | |
246 | { | |
247 | const struct bgp_af_desc *desc = bgp_get_af_desc($1); | |
248 | ||
249 | if (!desc) | |
250 | cf_error("Unknown AFI/SAFI"); | |
251 | ||
72163bd5 OZ |
252 | this_channel = channel_config_get(&channel_bgp, desc->name, desc->net, this_proto); |
253 | ||
254 | /* New channel */ | |
255 | if (!BGP_CC->desc) | |
256 | { | |
3831b619 OZ |
257 | BGP_CC->c.in_filter = FILTER_UNDEF; |
258 | BGP_CC->c.out_filter = FILTER_UNDEF; | |
72163bd5 OZ |
259 | BGP_CC->c.ra_mode = RA_UNDEF; |
260 | BGP_CC->afi = $1; | |
261 | BGP_CC->desc = desc; | |
1cab2b4a | 262 | BGP_CC->next_hop_keep = 0xff; /* undefined */ |
72163bd5 | 263 | BGP_CC->gr_able = 0xff; /* undefined */ |
5bd73431 OZ |
264 | BGP_CC->llgr_able = 0xff; /* undefined */ |
265 | BGP_CC->llgr_time = ~0U; /* undefined */ | |
09ee846d | 266 | BGP_CC->aigp = 0xff; /* undefined */ |
72163bd5 | 267 | } |
d15b0b0a OZ |
268 | }; |
269 | ||
1cab2b4a OZ |
270 | bgp_nh: |
271 | bool { $$ = $1; } | |
272 | | IBGP { $$ = NH_IBGP; } | |
273 | | EBGP { $$ = NH_EBGP; } | |
274 | ||
4155104c OZ |
275 | bgp_lladdr: SELF | DROP | IGNORE; |
276 | ||
d15b0b0a OZ |
277 | bgp_channel_item: |
278 | channel_item | |
279 | | NEXT HOP ADDRESS ipa { BGP_CC->next_hop_addr = $4; } | |
1cab2b4a OZ |
280 | | NEXT HOP SELF bgp_nh { BGP_CC->next_hop_self = $4; } |
281 | | NEXT HOP KEEP bgp_nh { BGP_CC->next_hop_keep = $4; } | |
8f79e6b9 | 282 | | NEXT HOP PREFER GLOBAL { BGP_CC->next_hop_prefer = NHP_GLOBAL; } |
3c360581 | 283 | | MANDATORY bool { BGP_CC->mandatory = $2; } |
6f798683 | 284 | | MISSING LLADDR bgp_lladdr { cf_warn("%s.%s: Missing lladdr option is deprecated and ignored, remove it", this_proto->name, this_channel->name); } |
d15b0b0a OZ |
285 | | GATEWAY DIRECT { BGP_CC->gw_mode = GW_DIRECT; } |
286 | | GATEWAY RECURSIVE { BGP_CC->gw_mode = GW_RECURSIVE; } | |
287 | | SECONDARY bool { BGP_CC->secondary = $2; } | |
1f2eb2ac OZ |
288 | | VALIDATE bool { |
289 | BGP_CC->validate = $2; | |
290 | if (BGP_SAFI(BGP_CC->afi) != BGP_SAFI_FLOW) | |
291 | cf_error("Validate option limited to flowspec channels"); | |
292 | } | |
d15b0b0a | 293 | | GRACEFUL RESTART bool { BGP_CC->gr_able = $3; } |
5bd73431 OZ |
294 | | LONG LIVED GRACEFUL RESTART bool { BGP_CC->llgr_able = $5; } |
295 | | LONG LIVED STALE TIME expr { BGP_CC->llgr_time = $5; } | |
d8022d26 | 296 | | EXTENDED NEXT HOP bool { BGP_CC->ext_next_hop = $4; } |
3fb06fea | 297 | | REQUIRE EXTENDED NEXT HOP bool { BGP_CC->require_ext_next_hop = $5; if (BGP_AFI(BGP_CC->afi) != BGP_AFI_IPV4) cf_warn("Require extended next hop option ignored for non-IPv4 channels"); } |
d15b0b0a OZ |
298 | | ADD PATHS RX { BGP_CC->add_path = BGP_ADD_PATH_RX; } |
299 | | ADD PATHS TX { BGP_CC->add_path = BGP_ADD_PATH_TX; } | |
300 | | ADD PATHS bool { BGP_CC->add_path = $3 ? BGP_ADD_PATH_FULL : 0; } | |
3fb06fea | 301 | | REQUIRE ADD PATHS bool { BGP_CC->require_add_path = $4; } |
682d3f7d | 302 | | IMPORT TABLE bool { BGP_CC->import_table = $3; } |
b7d7599c | 303 | | EXPORT TABLE bool { BGP_CC->export_table = $3; } |
09ee846d OZ |
304 | | AIGP bool { BGP_CC->aigp = $2; BGP_CC->aigp_originate = 0; } |
305 | | AIGP ORIGINATE { BGP_CC->aigp = 1; BGP_CC->aigp_originate = 1; } | |
306 | | COST expr { BGP_CC->cost = $2; if ($2 < 1) cf_error("Cost must be positive"); } | |
ef57b70f | 307 | | IGP TABLE rtable { |
6fe11c99 OZ |
308 | if (BGP_CC->desc->no_igp) |
309 | cf_error("IGP table not allowed here"); | |
310 | ||
311 | if ($3->addr_type == NET_IP4) | |
312 | BGP_CC->igp_table_ip4 = $3; | |
313 | else if ($3->addr_type == NET_IP6) | |
314 | BGP_CC->igp_table_ip6 = $3; | |
315 | else | |
316 | cf_error("Mismatched IGP table type"); | |
ef57b70f | 317 | } |
1f2eb2ac OZ |
318 | | BASE TABLE rtable { |
319 | if (BGP_SAFI(BGP_CC->afi) != BGP_SAFI_FLOW) | |
320 | cf_error("Base table option limited to flowspec channels"); | |
321 | ||
322 | if (((BGP_CC->afi == BGP_AF_FLOW4) && ($3->addr_type == NET_IP4)) || | |
323 | ((BGP_CC->afi == BGP_AF_FLOW6) && ($3->addr_type == NET_IP6))) | |
324 | BGP_CC->base_table = $3; | |
325 | else | |
326 | cf_error("Mismatched base table type"); | |
327 | } | |
d15b0b0a OZ |
328 | ; |
329 | ||
330 | bgp_channel_opts: | |
331 | /* empty */ | |
332 | | bgp_channel_opts bgp_channel_item ';' | |
333 | ; | |
334 | ||
335 | bgp_channel_opt_list: | |
336 | /* empty */ | |
337 | | '{' bgp_channel_opts '}' | |
338 | ; | |
339 | ||
340 | bgp_channel_end: | |
341 | { | |
342 | if (!this_channel->table) | |
343 | cf_error("Routing table not specified"); | |
344 | ||
345 | this_channel = NULL; | |
346 | }; | |
347 | ||
348 | bgp_proto_channel: bgp_channel_start bgp_channel_opt_list bgp_channel_end; | |
349 | ||
350 | ||
f851f0d7 | 351 | dynamic_attr: BGP_ORIGIN |
2d0652dd | 352 | { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_ENUM_BGP_ORIGIN, EA_CODE(PROTOCOL_BGP, BA_ORIGIN)); $$.flags = BAF_TRANSITIVE; } ; |
f851f0d7 | 353 | dynamic_attr: BGP_PATH |
2d0652dd | 354 | { $$ = f_new_dynamic_attr(EAF_TYPE_AS_PATH, T_PATH, EA_CODE(PROTOCOL_BGP, BA_AS_PATH)); $$.flags = BAF_TRANSITIVE; } ; |
f851f0d7 | 355 | dynamic_attr: BGP_NEXT_HOP |
2d0652dd | 356 | { $$ = f_new_dynamic_attr(EAF_TYPE_IP_ADDRESS, T_IP, EA_CODE(PROTOCOL_BGP, BA_NEXT_HOP)); $$.flags = BAF_TRANSITIVE; } ; |
f851f0d7 | 357 | dynamic_attr: BGP_MED |
2d0652dd | 358 | { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_CODE(PROTOCOL_BGP, BA_MULTI_EXIT_DISC)); $$.flags = BAF_OPTIONAL; } ; |
f851f0d7 | 359 | dynamic_attr: BGP_LOCAL_PREF |
2d0652dd | 360 | { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_CODE(PROTOCOL_BGP, BA_LOCAL_PREF)); $$.flags = BAF_TRANSITIVE; } ; |
f851f0d7 | 361 | dynamic_attr: BGP_ATOMIC_AGGR |
2d0652dd | 362 | { $$ = f_new_dynamic_attr(EAF_TYPE_OPAQUE, T_ENUM_EMPTY, EA_CODE(PROTOCOL_BGP, BA_ATOMIC_AGGR)); $$.flags = BAF_TRANSITIVE; } ; |
f851f0d7 | 363 | dynamic_attr: BGP_AGGREGATOR |
2d0652dd | 364 | { $$ = f_new_dynamic_attr(EAF_TYPE_OPAQUE, T_ENUM_EMPTY, EA_CODE(PROTOCOL_BGP, BA_AGGREGATOR)); $$.flags = BAF_OPTIONAL | BAF_TRANSITIVE; } ; |
f851f0d7 | 365 | dynamic_attr: BGP_COMMUNITY |
2d0652dd | 366 | { $$ = f_new_dynamic_attr(EAF_TYPE_INT_SET, T_CLIST, EA_CODE(PROTOCOL_BGP, BA_COMMUNITY)); $$.flags = BAF_OPTIONAL | BAF_TRANSITIVE; } ; |
f851f0d7 | 367 | dynamic_attr: BGP_ORIGINATOR_ID |
2d0652dd | 368 | { $$ = f_new_dynamic_attr(EAF_TYPE_ROUTER_ID, T_QUAD, EA_CODE(PROTOCOL_BGP, BA_ORIGINATOR_ID)); $$.flags = BAF_OPTIONAL; } ; |
f851f0d7 | 369 | dynamic_attr: BGP_CLUSTER_LIST |
2d0652dd | 370 | { $$ = f_new_dynamic_attr(EAF_TYPE_INT_SET, T_CLIST, EA_CODE(PROTOCOL_BGP, BA_CLUSTER_LIST)); $$.flags = BAF_OPTIONAL; } ; |
f851f0d7 | 371 | dynamic_attr: BGP_EXT_COMMUNITY |
2d0652dd | 372 | { $$ = f_new_dynamic_attr(EAF_TYPE_EC_SET, T_ECLIST, EA_CODE(PROTOCOL_BGP, BA_EXT_COMMUNITY)); $$.flags = BAF_OPTIONAL | BAF_TRANSITIVE; } ; |
09ee846d | 373 | dynamic_attr: BGP_AIGP |
2d0652dd | 374 | { $$ = f_new_dynamic_attr(EAF_TYPE_OPAQUE, T_ENUM_EMPTY, EA_CODE(PROTOCOL_BGP, BA_AIGP)); $$.flags = BAF_OPTIONAL; } ; |
f851f0d7 | 375 | dynamic_attr: BGP_LARGE_COMMUNITY |
2d0652dd | 376 | { $$ = f_new_dynamic_attr(EAF_TYPE_LC_SET, T_LCLIST, EA_CODE(PROTOCOL_BGP, BA_LARGE_COMMUNITY)); $$.flags = BAF_OPTIONAL | BAF_TRANSITIVE; } ; |
971721c9 | 377 | dynamic_attr: BGP_OTC |
2d0652dd | 378 | { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_CODE(PROTOCOL_BGP, BA_ONLY_TO_CUSTOMER)); $$.flags = BAF_OPTIONAL | BAF_TRANSITIVE; } ; |
42a0c054 | 379 | |
57aa0772 OZ |
380 | custom_attr: ATTRIBUTE BGP expr type symbol ';' { |
381 | if ($3 > 255 || $3 < 1) | |
382 | cf_error("Invalid attribute number (Given %i, must be 1-255)", $3); | |
383 | if ($4 != T_BYTESTRING) | |
ab47c2ae | 384 | cf_error("Attribute type must be bytestring, not %s", f_type_name($4)); |
57aa0772 OZ |
385 | if (bgp_attr_name($3)) |
386 | cf_error("Attribute BGP.%d already known as %s", $3, bgp_attr_name($3)); | |
387 | ||
ab47c2ae | 388 | struct f_dynamic_attr *a = cfg_alloc(sizeof(struct f_dynamic_attr)); |
a0fb0eaa | 389 | *a = f_new_dynamic_attr(f_type_attr($4), T_BYTESTRING, EA_CODE(PROTOCOL_BGP, $3)); |
390 | a->flags = BAF_TRANSITIVE | BAF_OPTIONAL; | |
391 | cf_define_symbol(new_config, $5, SYM_ATTRIBUTE, attribute, a); | |
392 | }; | |
12d5677a | 393 | |
cea63664 MM |
394 | CF_ENUM(T_ENUM_BGP_ORIGIN, ORIGIN_, IGP, EGP, INCOMPLETE) |
395 | ||
2638249d MM |
396 | CF_CODE |
397 | ||
398 | CF_END |