1998-12-06 17:40:42 +00:00
|
|
|
/*
|
|
|
|
* BIRD -- UNIX Kernel Syncer Configuration
|
|
|
|
*
|
2000-01-17 11:52:50 +00:00
|
|
|
* (c) 1998--2000 Martin Mares <mj@ucw.cz>
|
1998-12-06 17:40:42 +00:00
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
CF_HDR
|
|
|
|
|
2016-04-12 09:14:54 +00:00
|
|
|
#include "sysdep/unix/krt.h"
|
1998-12-06 17:40:42 +00:00
|
|
|
|
2000-04-28 15:11:10 +00:00
|
|
|
CF_DEFINES
|
|
|
|
|
1999-03-03 19:49:56 +00:00
|
|
|
#define THIS_KRT ((struct krt_config *) this_proto)
|
1999-03-26 21:44:38 +00:00
|
|
|
#define THIS_KIF ((struct kif_config *) this_proto)
|
2024-09-02 09:52:00 +00:00
|
|
|
#define KIF_IFACE ((struct iface_config *) this_ipatt)
|
1999-03-03 19:49:56 +00:00
|
|
|
|
2017-12-07 12:06:01 +00:00
|
|
|
static void
|
|
|
|
kif_set_preferred(ip_addr ip)
|
|
|
|
{
|
|
|
|
if (ipa_is_ip4(ip))
|
|
|
|
KIF_IFACE->pref_v4 = ip;
|
|
|
|
else if (!ipa_is_link_local(ip))
|
|
|
|
KIF_IFACE->pref_v6 = ip;
|
|
|
|
else
|
|
|
|
KIF_IFACE->pref_ll = ip;
|
|
|
|
}
|
|
|
|
|
1998-12-06 17:40:42 +00:00
|
|
|
CF_DECLS
|
|
|
|
|
2022-05-04 10:24:30 +00:00
|
|
|
CF_KEYWORDS(KERNEL, PERSIST, SCAN, TIME, LEARN, DEVICE, ROUTES, GRACEFUL, RESTART, MERGE, PATHS)
|
2017-12-18 22:15:07 +00:00
|
|
|
CF_KEYWORDS(INTERFACE, PREFERRED)
|
1998-12-06 17:40:42 +00:00
|
|
|
|
2023-10-06 02:31:19 +00:00
|
|
|
%type <i> kern_learn
|
2016-08-30 10:43:46 +00:00
|
|
|
%type <i> kern_mp_limit
|
2022-09-14 23:38:18 +00:00
|
|
|
%type <cc> kern_channel
|
2016-08-30 10:43:46 +00:00
|
|
|
|
1998-12-06 17:40:42 +00:00
|
|
|
CF_GRAMMAR
|
|
|
|
|
1999-03-26 21:44:38 +00:00
|
|
|
/* Kernel syncer protocol */
|
1998-12-06 17:40:42 +00:00
|
|
|
|
2018-06-26 12:29:03 +00:00
|
|
|
proto: kern_proto '}' ;
|
1998-12-06 17:40:42 +00:00
|
|
|
|
2016-01-26 10:48:58 +00:00
|
|
|
kern_proto_start: proto_start KERNEL {
|
|
|
|
this_proto = krt_init_config($1);
|
|
|
|
}
|
1998-12-06 17:40:42 +00:00
|
|
|
;
|
|
|
|
|
2018-06-26 12:29:03 +00:00
|
|
|
kern_proto: kern_proto_start proto_name '{' ;
|
|
|
|
kern_proto: kern_proto kern_item ';' ;
|
1999-03-03 19:49:56 +00:00
|
|
|
|
2023-10-06 02:31:19 +00:00
|
|
|
kern_learn:
|
|
|
|
bool { $$ = $1 ? KRT_LEARN_ALIEN : KRT_LEARN_NONE; }
|
|
|
|
| ALL { $$ = KRT_LEARN_ALL; }
|
|
|
|
;
|
|
|
|
|
2016-08-30 10:43:46 +00:00
|
|
|
kern_mp_limit:
|
|
|
|
/* empty */ { $$ = KRT_DEFAULT_ECMP_LIMIT; }
|
|
|
|
| LIMIT expr { $$ = $2; if (($2 <= 0) || ($2 > 255)) cf_error("Merge paths limit must be in range 1-255"); }
|
|
|
|
;
|
|
|
|
|
2022-09-14 23:38:18 +00:00
|
|
|
|
|
|
|
kern_channel:
|
|
|
|
proto_channel
|
|
|
|
| mpls_channel
|
|
|
|
;
|
|
|
|
|
1999-03-03 19:49:56 +00:00
|
|
|
kern_item:
|
2016-01-26 10:48:58 +00:00
|
|
|
proto_item
|
2022-09-14 23:38:18 +00:00
|
|
|
| kern_channel { this_proto->net_type = $1->net_type; }
|
2016-01-26 10:48:58 +00:00
|
|
|
| PERSIST bool { THIS_KRT->persist = $2; }
|
1999-03-03 19:49:56 +00:00
|
|
|
| SCAN TIME expr {
|
|
|
|
/* Scan time of 0 means scan on startup only */
|
2017-06-14 11:15:35 +00:00
|
|
|
THIS_KRT->scan_time = $3 S_;
|
1999-03-03 19:49:56 +00:00
|
|
|
}
|
2023-10-06 02:31:19 +00:00
|
|
|
| LEARN kern_learn {
|
1999-04-03 13:05:18 +00:00
|
|
|
THIS_KRT->learn = $2;
|
|
|
|
#ifndef KRT_ALLOW_LEARN
|
|
|
|
if ($2)
|
2016-08-30 10:43:46 +00:00
|
|
|
cf_error("Learning of kernel routes not supported on this platform");
|
1999-04-03 13:05:18 +00:00
|
|
|
#endif
|
|
|
|
}
|
2014-03-20 13:07:12 +00:00
|
|
|
| GRACEFUL RESTART bool { THIS_KRT->graceful_restart = $3; }
|
2016-08-30 10:43:46 +00:00
|
|
|
| MERGE PATHS bool kern_mp_limit {
|
2018-01-23 14:12:43 +00:00
|
|
|
THIS_KRT->merge_paths = $3 ? $4 : 0;
|
2016-08-31 12:02:41 +00:00
|
|
|
#ifndef KRT_ALLOW_MERGE_PATHS
|
2016-08-30 10:43:46 +00:00
|
|
|
if ($3)
|
|
|
|
cf_error("Path merging not supported on this platform");
|
|
|
|
#endif
|
|
|
|
}
|
1999-03-03 19:49:56 +00:00
|
|
|
;
|
1998-12-06 17:40:42 +00:00
|
|
|
|
1999-03-26 21:44:38 +00:00
|
|
|
/* Kernel interface protocol */
|
|
|
|
|
2018-06-26 12:29:03 +00:00
|
|
|
proto: kif_proto '}' ;
|
1999-03-26 21:44:38 +00:00
|
|
|
|
2012-04-30 13:31:32 +00:00
|
|
|
kif_proto_start: proto_start DEVICE { this_proto = kif_init_config($1); }
|
1999-03-26 21:44:38 +00:00
|
|
|
;
|
|
|
|
|
2018-06-26 12:29:03 +00:00
|
|
|
kif_proto: kif_proto_start proto_name '{' ;
|
|
|
|
kif_proto: kif_proto kif_item ';' ;
|
1999-03-26 21:44:38 +00:00
|
|
|
|
|
|
|
kif_item:
|
2016-01-26 10:48:58 +00:00
|
|
|
proto_item
|
2017-12-07 12:06:01 +00:00
|
|
|
| INTERFACE kif_iface
|
2016-01-26 10:48:58 +00:00
|
|
|
| SCAN TIME expr {
|
1999-03-26 21:44:38 +00:00
|
|
|
/* Scan time of 0 means scan on startup only */
|
2017-06-14 11:15:35 +00:00
|
|
|
THIS_KIF->scan_time = $3 S_;
|
1999-03-26 21:44:38 +00:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2017-12-07 12:06:01 +00:00
|
|
|
kif_iface_start:
|
|
|
|
{
|
2024-09-02 09:52:00 +00:00
|
|
|
this_ipatt = cfg_allocz(sizeof(struct iface_config));
|
2017-12-07 12:06:01 +00:00
|
|
|
add_tail(&THIS_KIF->iface_list, NODE this_ipatt);
|
|
|
|
init_list(&this_ipatt->ipn_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
kif_iface_item:
|
|
|
|
PREFERRED ipa { kif_set_preferred($2); }
|
|
|
|
;
|
|
|
|
|
|
|
|
kif_iface_opts:
|
|
|
|
/* empty */
|
|
|
|
| kif_iface_opts kif_iface_item ';'
|
|
|
|
;
|
|
|
|
|
|
|
|
kif_iface_opt_list:
|
|
|
|
/* empty */
|
|
|
|
| '{' kif_iface_opts '}'
|
|
|
|
;
|
|
|
|
|
|
|
|
kif_iface:
|
|
|
|
kif_iface_start iface_patt_list_nopx kif_iface_opt_list;
|
|
|
|
|
|
|
|
|
1998-12-06 17:40:42 +00:00
|
|
|
CF_CODE
|
|
|
|
|
|
|
|
CF_END
|