1998-12-07 01:40:42 +08:00
|
|
|
/*
|
|
|
|
* BIRD -- UNIX Kernel Syncer Configuration
|
|
|
|
*
|
2000-01-17 19:52:50 +08:00
|
|
|
* (c) 1998--2000 Martin Mares <mj@ucw.cz>
|
1998-12-07 01:40:42 +08:00
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
CF_HDR
|
|
|
|
|
2016-04-12 17:14:54 +08:00
|
|
|
#include "sysdep/unix/krt.h"
|
1998-12-07 01:40:42 +08:00
|
|
|
|
2000-04-28 23:11:10 +08:00
|
|
|
CF_DEFINES
|
|
|
|
|
1999-03-04 03:49:56 +08:00
|
|
|
#define THIS_KRT ((struct krt_config *) this_proto)
|
1999-03-27 05:44:38 +08:00
|
|
|
#define THIS_KIF ((struct kif_config *) this_proto)
|
2017-12-07 20:06:01 +08:00
|
|
|
#define KIF_IFACE ((struct kif_iface_config *) this_ipatt)
|
1999-03-04 03:49:56 +08:00
|
|
|
|
2017-12-07 20:06:01 +08: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-07 01:40:42 +08:00
|
|
|
CF_DECLS
|
|
|
|
|
2015-06-08 08:20:43 +08:00
|
|
|
CF_KEYWORDS(KERNEL, PERSIST, SCAN, TIME, LEARN, DEVICE, ROUTES, GRACEFUL, RESTART, KRT_SOURCE, KRT_METRIC, MERGE, PATHS)
|
2017-12-19 06:15:07 +08:00
|
|
|
CF_KEYWORDS(INTERFACE, PREFERRED)
|
1998-12-07 01:40:42 +08:00
|
|
|
|
2016-08-30 18:43:46 +08:00
|
|
|
%type <i> kern_mp_limit
|
|
|
|
|
1998-12-07 01:40:42 +08:00
|
|
|
CF_GRAMMAR
|
|
|
|
|
1999-03-27 05:44:38 +08:00
|
|
|
/* Kernel syncer protocol */
|
1998-12-07 01:40:42 +08:00
|
|
|
|
2018-06-26 20:29:03 +08:00
|
|
|
proto: kern_proto '}' ;
|
1998-12-07 01:40:42 +08:00
|
|
|
|
2016-01-26 18:48:58 +08:00
|
|
|
kern_proto_start: proto_start KERNEL {
|
|
|
|
this_proto = krt_init_config($1);
|
|
|
|
}
|
1998-12-07 01:40:42 +08:00
|
|
|
;
|
|
|
|
|
2018-06-26 20:29:03 +08:00
|
|
|
kern_proto: kern_proto_start proto_name '{' ;
|
|
|
|
kern_proto: kern_proto kern_item ';' ;
|
1999-03-04 03:49:56 +08:00
|
|
|
|
2016-08-30 18:43:46 +08: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"); }
|
|
|
|
;
|
|
|
|
|
1999-03-04 03:49:56 +08:00
|
|
|
kern_item:
|
2016-01-26 18:48:58 +08:00
|
|
|
proto_item
|
|
|
|
| proto_channel { this_proto->net_type = $1->net_type; }
|
|
|
|
| PERSIST bool { THIS_KRT->persist = $2; }
|
1999-03-04 03:49:56 +08:00
|
|
|
| SCAN TIME expr {
|
|
|
|
/* Scan time of 0 means scan on startup only */
|
2017-06-14 19:15:35 +08:00
|
|
|
THIS_KRT->scan_time = $3 S_;
|
1999-03-04 03:49:56 +08:00
|
|
|
}
|
1999-04-03 21:05:18 +08:00
|
|
|
| LEARN bool {
|
|
|
|
THIS_KRT->learn = $2;
|
|
|
|
#ifndef KRT_ALLOW_LEARN
|
|
|
|
if ($2)
|
2016-08-30 18:43:46 +08:00
|
|
|
cf_error("Learning of kernel routes not supported on this platform");
|
1999-04-03 21:05:18 +08:00
|
|
|
#endif
|
|
|
|
}
|
2014-03-20 21:07:12 +08:00
|
|
|
| GRACEFUL RESTART bool { THIS_KRT->graceful_restart = $3; }
|
2016-08-30 18:43:46 +08:00
|
|
|
| MERGE PATHS bool kern_mp_limit {
|
2018-01-23 22:12:43 +08:00
|
|
|
THIS_KRT->merge_paths = $3 ? $4 : 0;
|
2016-08-31 20:02:41 +08:00
|
|
|
#ifndef KRT_ALLOW_MERGE_PATHS
|
2016-08-30 18:43:46 +08:00
|
|
|
if ($3)
|
|
|
|
cf_error("Path merging not supported on this platform");
|
|
|
|
#endif
|
|
|
|
}
|
1999-03-04 03:49:56 +08:00
|
|
|
;
|
1998-12-07 01:40:42 +08:00
|
|
|
|
1999-03-27 05:44:38 +08:00
|
|
|
/* Kernel interface protocol */
|
|
|
|
|
2018-06-26 20:29:03 +08:00
|
|
|
proto: kif_proto '}' ;
|
1999-03-27 05:44:38 +08:00
|
|
|
|
2012-04-30 21:31:32 +08:00
|
|
|
kif_proto_start: proto_start DEVICE { this_proto = kif_init_config($1); }
|
1999-03-27 05:44:38 +08:00
|
|
|
;
|
|
|
|
|
2018-06-26 20:29:03 +08:00
|
|
|
kif_proto: kif_proto_start proto_name '{' ;
|
|
|
|
kif_proto: kif_proto kif_item ';' ;
|
1999-03-27 05:44:38 +08:00
|
|
|
|
|
|
|
kif_item:
|
2016-01-26 18:48:58 +08:00
|
|
|
proto_item
|
2017-12-07 20:06:01 +08:00
|
|
|
| INTERFACE kif_iface
|
2016-01-26 18:48:58 +08:00
|
|
|
| SCAN TIME expr {
|
1999-03-27 05:44:38 +08:00
|
|
|
/* Scan time of 0 means scan on startup only */
|
2017-06-14 19:15:35 +08:00
|
|
|
THIS_KIF->scan_time = $3 S_;
|
1999-03-27 05:44:38 +08:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2017-12-07 20:06:01 +08:00
|
|
|
kif_iface_start:
|
|
|
|
{
|
|
|
|
this_ipatt = cfg_allocz(sizeof(struct kif_iface_config));
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
2019-07-03 06:00:11 +08:00
|
|
|
dynamic_attr: KRT_SOURCE { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_SOURCE); } ;
|
|
|
|
dynamic_attr: KRT_METRIC { $$ = f_new_dynamic_attr(EAF_TYPE_INT, T_INT, EA_KRT_METRIC); } ;
|
2012-03-23 07:26:26 +08:00
|
|
|
|
1998-12-07 01:40:42 +08:00
|
|
|
CF_CODE
|
|
|
|
|
|
|
|
CF_END
|