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
|
|
|
|
2018-08-13 09:41:27 +00:00
|
|
|
CF_CTX
|
|
|
|
|
|
|
|
struct kif_config *kif_cf;
|
|
|
|
struct krt_config *krt_cf;
|
|
|
|
|
2000-04-28 15:11:10 +00:00
|
|
|
CF_DEFINES
|
|
|
|
|
2018-08-13 09:41:27 +00:00
|
|
|
#define THIS_KRT ((struct krt_config *) ctx->this_proto)
|
|
|
|
#define THIS_KIF ((struct kif_config *) ctx->this_proto)
|
|
|
|
#define KIF_IFACE ((struct kif_iface_config *) ctx->this_ipatt)
|
1999-03-03 19:49:56 +00:00
|
|
|
|
2017-12-07 12:06:01 +00:00
|
|
|
static void
|
2018-08-13 09:41:27 +00:00
|
|
|
kif_set_preferred(struct cf_context *ctx, ip_addr ip)
|
2017-12-07 12:06:01 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-08-13 09:41:27 +00:00
|
|
|
static struct proto_config *
|
|
|
|
kif_init_config(struct cf_context *ctx, int class)
|
|
|
|
{
|
|
|
|
if (ctx->kif_cf)
|
|
|
|
cf_error(ctx, "Kernel device protocol already defined");
|
|
|
|
|
|
|
|
ctx->kif_cf = (struct kif_config *) proto_config_new(ctx, &proto_unix_iface, class);
|
|
|
|
ctx->kif_cf->scan_time = 60 S_;
|
|
|
|
init_list(&ctx->kif_cf->iface_list);
|
|
|
|
|
|
|
|
kif_sys_init_config(ctx->kif_cf);
|
|
|
|
return (struct proto_config *) ctx->kif_cf;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct proto_config *
|
|
|
|
krt_init_config(struct cf_context *ctx, int class)
|
|
|
|
{
|
|
|
|
#ifndef CONFIG_MULTIPLE_TABLES
|
|
|
|
if (ctx->krt_cf)
|
|
|
|
cf_error(ctx, "Kernel protocol already defined");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ctx->krt_cf = (struct krt_config *) proto_config_new(ctx, &proto_unix_kernel, class);
|
|
|
|
ctx->krt_cf->scan_time = 60 S_;
|
|
|
|
|
|
|
|
krt_sys_init_config(ctx->krt_cf);
|
|
|
|
return (struct proto_config *) ctx->krt_cf;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_ALL_TABLES_AT_ONCE
|
|
|
|
void
|
|
|
|
krt_check_scan_time(struct cf_context *ctx, struct krt_config *cf)
|
|
|
|
{
|
|
|
|
if (ctx->krt_cf->scan_time != cf->scan_time)
|
|
|
|
cf_error(ctx, "All kernel syncers must use the same table scan interval");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1998-12-06 17:40:42 +00:00
|
|
|
CF_DECLS
|
|
|
|
|
2015-06-08 00:20:43 +00:00
|
|
|
CF_KEYWORDS(KERNEL, PERSIST, SCAN, TIME, LEARN, DEVICE, ROUTES, GRACEFUL, RESTART, KRT_SOURCE, KRT_METRIC, MERGE, PATHS)
|
2017-12-18 22:15:07 +00:00
|
|
|
CF_KEYWORDS(INTERFACE, PREFERRED)
|
1998-12-06 17:40:42 +00:00
|
|
|
|
2016-08-30 10:43:46 +00:00
|
|
|
%type <i> kern_mp_limit
|
|
|
|
|
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 {
|
2018-08-13 09:41:27 +00:00
|
|
|
ctx->this_proto = krt_init_config(ctx, $1);
|
2016-01-26 10:48:58 +00:00
|
|
|
}
|
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
|
|
|
|
2016-08-30 10:43:46 +00:00
|
|
|
kern_mp_limit:
|
|
|
|
/* empty */ { $$ = KRT_DEFAULT_ECMP_LIMIT; }
|
2018-08-13 09:41:27 +00:00
|
|
|
| LIMIT expr { $$ = $2; if (($2 <= 0) || ($2 > 255)) cf_error(ctx, "Merge paths limit must be in range 1-255"); }
|
2016-08-30 10:43:46 +00:00
|
|
|
;
|
|
|
|
|
1999-03-03 19:49:56 +00:00
|
|
|
kern_item:
|
2016-01-26 10:48:58 +00:00
|
|
|
proto_item
|
2018-08-13 09:41:27 +00:00
|
|
|
| proto_channel { ctx->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
|
|
|
}
|
1999-04-03 13:05:18 +00:00
|
|
|
| LEARN bool {
|
|
|
|
THIS_KRT->learn = $2;
|
|
|
|
#ifndef KRT_ALLOW_LEARN
|
|
|
|
if ($2)
|
2018-08-13 09:41:27 +00:00
|
|
|
cf_error(ctx, "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)
|
2018-08-13 09:41:27 +00:00
|
|
|
cf_error(ctx, "Path merging not supported on this platform");
|
2016-08-30 10:43:46 +00:00
|
|
|
#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
|
|
|
|
2018-08-13 09:41:27 +00:00
|
|
|
kif_proto_start: proto_start DEVICE { ctx->this_proto = kif_init_config(ctx, $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:
|
|
|
|
{
|
2018-08-13 09:41:27 +00:00
|
|
|
ctx->this_ipatt = cfg_allocz(sizeof(struct kif_iface_config));
|
|
|
|
add_tail(&THIS_KIF->iface_list, NODE ctx->this_ipatt);
|
|
|
|
init_list(&ctx->this_ipatt->ipn_list);
|
2017-12-07 12:06:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
kif_iface_item:
|
2018-08-13 09:41:27 +00:00
|
|
|
PREFERRED ipa { kif_set_preferred(ctx, $2); }
|
2017-12-07 12:06:01 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
2018-06-26 12:29:03 +00: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-22 23:26:26 +00:00
|
|
|
|
1998-12-06 17:40:42 +00:00
|
|
|
CF_CODE
|
|
|
|
|
|
|
|
CF_END
|