Assign default protocol preference via proto_config_new().

The patch from Alexander V. Chernikov.
This commit is contained in:
Ondrej Zajicek 2012-01-24 11:31:00 +01:00
parent 09686693d3
commit 39c028e9e9
14 changed files with 10 additions and 8 deletions

View file

@ -219,7 +219,6 @@ CF_ADDTO(proto, dev_proto '}')
dev_proto_start: proto_start DIRECT { dev_proto_start: proto_start DIRECT {
this_proto = proto_config_new(&proto_device, sizeof(struct rt_dev_config), $1); this_proto = proto_config_new(&proto_device, sizeof(struct rt_dev_config), $1);
this_proto->preference = DEF_PREF_DIRECT;
init_list(&DIRECT_CFG->iface_list); init_list(&DIRECT_CFG->iface_list);
} }
; ;

View file

@ -200,6 +200,7 @@ proto_config_new(struct protocol *pr, unsigned size, int class)
c->global = new_config; c->global = new_config;
c->protocol = pr; c->protocol = pr;
c->name = pr->name; c->name = pr->name;
c->preference = pr->preference;
c->class = class; c->class = class;
c->out_filter = FILTER_REJECT; c->out_filter = FILTER_REJECT;
c->table = c->global->master_rtc; c->table = c->global->master_rtc;

View file

@ -39,6 +39,7 @@ struct protocol {
char *template; /* Template for automatic generation of names */ char *template; /* Template for automatic generation of names */
int name_counter; /* Counter for automatic name generation */ int name_counter; /* Counter for automatic name generation */
int attr_class; /* Attribute class known to this protocol */ int attr_class; /* Attribute class known to this protocol */
unsigned preference; /* Default protocol preference */
void (*preconfig)(struct protocol *, struct config *); /* Just before configuring */ void (*preconfig)(struct protocol *, struct config *); /* Just before configuring */
void (*postconfig)(struct proto_config *); /* After configuring each instance */ void (*postconfig)(struct proto_config *); /* After configuring each instance */

View file

@ -109,6 +109,7 @@ dev_copy_config(struct proto_config *dest, struct proto_config *src)
struct protocol proto_device = { struct protocol proto_device = {
name: "Direct", name: "Direct",
template: "direct%d", template: "direct%d",
preference: DEF_PREF_DIRECT,
init: dev_init, init: dev_init,
reconfigure: dev_reconfigure, reconfigure: dev_reconfigure,
copy_config: dev_copy_config copy_config: dev_copy_config

View file

@ -1178,6 +1178,7 @@ struct protocol proto_bgp = {
name: "BGP", name: "BGP",
template: "bgp%d", template: "bgp%d",
attr_class: EAP_BGP, attr_class: EAP_BGP,
preference: DEF_PREF_BGP,
init: bgp_init, init: bgp_init,
start: bgp_start, start: bgp_start,
shutdown: bgp_shutdown, shutdown: bgp_shutdown,

View file

@ -33,7 +33,6 @@ CF_ADDTO(proto, bgp_proto '}' { bgp_check_config(BGP_CFG); } )
bgp_proto_start: proto_start BGP { bgp_proto_start: proto_start BGP {
this_proto = proto_config_new(&proto_bgp, sizeof(struct bgp_config), $1); this_proto = proto_config_new(&proto_bgp, sizeof(struct bgp_config), $1);
this_proto->preference = DEF_PREF_BGP;
BGP_CFG->hold_time = 240; BGP_CFG->hold_time = 240;
BGP_CFG->connect_retry_time = 120; BGP_CFG->connect_retry_time = 120;
BGP_CFG->initial_hold_time = 240; BGP_CFG->initial_hold_time = 240;

View file

@ -129,7 +129,6 @@ CF_ADDTO(proto, ospf_proto '}' { ospf_proto_finish(); } )
ospf_proto_start: proto_start OSPF { ospf_proto_start: proto_start OSPF {
this_proto = proto_config_new(&proto_ospf, sizeof(struct ospf_config), $1); this_proto = proto_config_new(&proto_ospf, sizeof(struct ospf_config), $1);
this_proto->preference = DEF_PREF_OSPF;
init_list(&OSPF_CFG->area_list); init_list(&OSPF_CFG->area_list);
init_list(&OSPF_CFG->vlink_list); init_list(&OSPF_CFG->vlink_list);
OSPF_CFG->rfc1583 = DEFAULT_RFC1583; OSPF_CFG->rfc1583 = DEFAULT_RFC1583;

View file

@ -1542,6 +1542,7 @@ struct protocol proto_ospf = {
name: "OSPF", name: "OSPF",
template: "ospf%d", template: "ospf%d",
attr_class: EAP_OSPF, attr_class: EAP_OSPF,
preference: DEF_PREF_OSPF,
init: ospf_init, init: ospf_init,
dump: ospf_dump, dump: ospf_dump,
start: ospf_start, start: ospf_start,

View file

@ -24,7 +24,6 @@ CF_ADDTO(proto, pipe_proto '}')
pipe_proto_start: proto_start PIPE { pipe_proto_start: proto_start PIPE {
this_proto = proto_config_new(&proto_pipe, sizeof(struct pipe_config), $1); this_proto = proto_config_new(&proto_pipe, sizeof(struct pipe_config), $1);
this_proto->preference = DEF_PREF_PIPE;
PIPE_CFG->mode = PIPE_TRANSPARENT; PIPE_CFG->mode = PIPE_TRANSPARENT;
} }
; ;

View file

@ -197,6 +197,7 @@ pipe_get_status(struct proto *P, byte *buf)
struct protocol proto_pipe = { struct protocol proto_pipe = {
name: "Pipe", name: "Pipe",
template: "pipe%d", template: "pipe%d",
preference: DEF_PREF_PIPE,
postconfig: pipe_postconfig, postconfig: pipe_postconfig,
init: pipe_init, init: pipe_init,
start: pipe_start, start: pipe_start,

View file

@ -975,7 +975,6 @@ void
rip_init_config(struct rip_proto_config *c) rip_init_config(struct rip_proto_config *c)
{ {
init_list(&c->iface_list); init_list(&c->iface_list);
c->c.preference = DEF_PREF_RIP;
c->infinity = 16; c->infinity = 16;
c->port = 520; c->port = 520;
c->period = 30; c->period = 30;
@ -1032,6 +1031,7 @@ struct protocol proto_rip = {
name: "RIP", name: "RIP",
template: "rip%d", template: "rip%d",
attr_class: EAP_RIP, attr_class: EAP_RIP,
preference: DEF_PREF_RIP,
get_route_info: rip_get_route_info, get_route_info: rip_get_route_info,
get_attr: rip_get_attr, get_attr: rip_get_attr,

View file

@ -353,7 +353,6 @@ static_if_notify(struct proto *p, unsigned flags, struct iface *i)
void void
static_init_config(struct static_config *c) static_init_config(struct static_config *c)
{ {
c->c.preference = DEF_PREF_STATIC;
init_list(&c->iface_routes); init_list(&c->iface_routes);
init_list(&c->other_routes); init_list(&c->other_routes);
} }
@ -523,6 +522,7 @@ static_copy_config(struct proto_config *dest, struct proto_config *src)
struct protocol proto_static = { struct protocol proto_static = {
name: "Static", name: "Static",
template: "static%d", template: "static%d",
preference: DEF_PREF_STATIC,
init: static_init, init: static_init,
dump: static_dump, dump: static_dump,
start: static_start, start: static_start,

View file

@ -31,7 +31,6 @@ kern_proto_start: proto_start KERNEL {
cf_error("Kernel protocol already defined"); cf_error("Kernel protocol already defined");
#endif #endif
cf_krt = this_proto = proto_config_new(&proto_unix_kernel, sizeof(struct krt_config), $1); cf_krt = this_proto = proto_config_new(&proto_unix_kernel, sizeof(struct krt_config), $1);
this_proto->preference = DEF_PREF_INHERITED;
THIS_KRT->scan_time = 60; THIS_KRT->scan_time = 60;
THIS_KRT->learn = THIS_KRT->persist = 0; THIS_KRT->learn = THIS_KRT->persist = 0;
krt_scan_construct(THIS_KRT); krt_scan_construct(THIS_KRT);
@ -67,7 +66,6 @@ kif_proto_start: proto_start DEVICE {
if (cf_kif) if (cf_kif)
cf_error("Kernel device protocol already defined"); cf_error("Kernel device protocol already defined");
cf_kif = this_proto = proto_config_new(&proto_unix_iface, sizeof(struct kif_config), $1); cf_kif = this_proto = proto_config_new(&proto_unix_iface, sizeof(struct kif_config), $1);
this_proto->preference = DEF_PREF_DIRECT;
THIS_KIF->scan_time = 60; THIS_KIF->scan_time = 60;
init_list(&THIS_KIF->primary); init_list(&THIS_KIF->primary);
krt_if_construct(THIS_KIF); krt_if_construct(THIS_KIF);

View file

@ -243,6 +243,7 @@ kif_copy_config(struct proto_config *dest, struct proto_config *src)
struct protocol proto_unix_iface = { struct protocol proto_unix_iface = {
name: "Device", name: "Device",
template: "device%d", template: "device%d",
preference: DEF_PREF_DIRECT,
preconfig: kif_preconfig, preconfig: kif_preconfig,
init: kif_init, init: kif_init,
start: kif_start, start: kif_start,
@ -968,6 +969,7 @@ struct protocol proto_unix_kernel = {
name: "Kernel", name: "Kernel",
template: "kernel%d", template: "kernel%d",
attr_class: EAP_KRT, attr_class: EAP_KRT,
preference: DEF_PREF_INHERITED,
preconfig: krt_preconfig, preconfig: krt_preconfig,
postconfig: krt_postconfig, postconfig: krt_postconfig,
init: krt_init, init: krt_init,