diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2019-08-01 00:53:22 +0200 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2019-08-01 00:53:22 +0200 |
commit | da8644d7d99a0f693037d244f456164568abc68c (patch) | |
tree | c4ead657616263981f7fcbbb98424eb842343b5f | |
parent | d72d3891bf262b28cd4d03fd72e88bf37fef112a (diff) |
Nest: VRF of protocol can be explicitly specified as 'default'
Protocol can have specified VRF, in such case it is restricted to a set
of ifaces associated with the VRF, otherwise it can use all interfaces.
The patch allows to specify VRF as 'default', in which case it is
restricted to a set of iface not associated with any VRF.
-rw-r--r-- | nest/config.Y | 5 | ||||
-rw-r--r-- | nest/iface.c | 4 | ||||
-rw-r--r-- | nest/neighbor.c | 2 | ||||
-rw-r--r-- | nest/proto.c | 5 | ||||
-rw-r--r-- | nest/protocol.h | 2 | ||||
-rw-r--r-- | proto/bfd/bfd.c | 2 |
6 files changed, 14 insertions, 6 deletions
diff --git a/nest/config.Y b/nest/config.Y index 358c7745..168bb397 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -55,7 +55,7 @@ get_passwords(void) CF_DECLS CF_KEYWORDS(ROUTER, ID, PROTOCOL, TEMPLATE, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT) -CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, VRF, TABLE, STATES, ROUTES, FILTERS) +CF_KEYWORDS(INTERFACE, IMPORT, EXPORT, FILTER, NONE, VRF, DEFAULT, TABLE, STATES, ROUTES, FILTERS) CF_KEYWORDS(RECEIVE, LIMIT, ACTION, WARN, BLOCK, RESTART, DISABLE, KEEP, FILTERED) CF_KEYWORDS(PASSWORD, FROM, PASSIVE, TO, ID, EVENTS, PACKETS, PROTOCOLS, INTERFACES) CF_KEYWORDS(ALGORITHM, KEYED, HMAC, MD5, SHA1, SHA256, SHA384, SHA512) @@ -227,7 +227,8 @@ proto_item: | IMPORT LIMIT limit_spec { this_proto->in_limit = $3; } | EXPORT LIMIT limit_spec { this_proto->out_limit = $3; } | IMPORT KEEP FILTERED bool { this_proto->in_keep_filtered = $4; } - | VRF text { this_proto->vrf = if_get_by_name($2); } + | VRF text { this_proto->vrf = if_get_by_name($2); this_proto->vrf_set = 1; } + | VRF DEFAULT { this_proto->vrf = NULL; this_proto->vrf_set = 1; } | TABLE rtable { this_proto->table = $2; } | ROUTER ID idval { this_proto->router_id = $3; } | DESCRIPTION text { this_proto->dsc = $2; } diff --git a/nest/iface.c b/nest/iface.c index 1ef16185..55677803 100644 --- a/nest/iface.c +++ b/nest/iface.c @@ -140,7 +140,7 @@ if_copy(struct iface *to, struct iface *from) static inline void ifa_send_notify(struct proto *p, unsigned c, struct ifa *a) { - if (p->ifa_notify && (!p->vrf || p->vrf == a->iface->master)) + if (p->ifa_notify && (!p->vrf_set || p->vrf == a->iface->master)) { if (p->debug & D_IFACES) log(L_TRACE "%s <%s address %I/%d on interface %s %s", @@ -177,7 +177,7 @@ ifa_notify_change(unsigned c, struct ifa *a) static inline void if_send_notify(struct proto *p, unsigned c, struct iface *i) { - if (p->if_notify && (!p->vrf || p->vrf == i->master)) + if (p->if_notify && (!p->vrf_set || p->vrf == i->master)) { if (p->debug & D_IFACES) log(L_TRACE "%s < interface %s %s", p->name, i->name, diff --git a/nest/neighbor.c b/nest/neighbor.c index f8159d35..1362ae26 100644 --- a/nest/neighbor.c +++ b/nest/neighbor.c @@ -153,7 +153,7 @@ neigh_find2(struct proto *p, ip_addr *a, struct iface *ifa, unsigned flags) } else WALK_LIST(i, iface_list) - if ((!p->vrf || p->vrf == i->master) && + if ((!p->vrf_set || p->vrf == i->master) && ((scope = if_connected(a, i, &addr)) >= 0)) { ifa = i; diff --git a/nest/proto.c b/nest/proto.c index 162441b6..66cb937d 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -387,6 +387,7 @@ proto_init(struct proto_config *c) q->export_state = ES_DOWN; q->last_state_change = now; q->vrf = c->vrf; + q->vrf_set = c->vrf_set; add_tail(&initial_proto_list, &q->n); @@ -411,6 +412,7 @@ proto_reconfigure(struct proto *p, struct proto_config *oc, struct proto_config if ((nc->protocol != oc->protocol) || (nc->disabled != p->disabled) || (nc->vrf != oc->vrf) || + (nc->vrf_set != oc->vrf_set) || (nc->table->table != oc->table->table)) return 0; @@ -1567,6 +1569,9 @@ proto_cmd_show(struct proto *p, uintptr_t verbose, int cnt) if (p->cf->router_id) cli_msg(-1006, " Router ID: %R", p->cf->router_id); + if (p->vrf_set) + cli_msg(-1006, " VRF: %s", p->vrf ? p->vrf->name : "default"); + if (p->proto->show_proto_info) p->proto->show_proto_info(p); else diff --git a/nest/protocol.h b/nest/protocol.h index cc1dd5ca..02fd8d96 100644 --- a/nest/protocol.h +++ b/nest/protocol.h @@ -93,6 +93,7 @@ struct proto_config { int class; /* SYM_PROTO or SYM_TEMPLATE */ u32 debug, mrtdump; /* Debugging bitfields, both use D_* constants */ unsigned preference, disabled; /* Generic parameters */ + int vrf_set; /* Related VRF instance (below) is defined */ int in_keep_filtered; /* Routes rejected in import filter are kept */ u32 router_id; /* Protocol specific router ID */ struct iface *vrf; /* Related VRF instance, NULL if global */ @@ -149,6 +150,7 @@ struct proto { unsigned preference; /* Default route preference */ byte accept_ra_types; /* Which types of route announcements are accepted (RA_OPTIMAL or RA_ANY) */ byte disabled; /* Manually disabled */ + byte vrf_set; /* Related VRF instance (above) is defined */ byte proto_state; /* Protocol state machine (PS_*, see below) */ byte core_state; /* Core state machine (FS_*, see below) */ byte export_state; /* Route export state (ES_*, see below) */ diff --git a/proto/bfd/bfd.c b/proto/bfd/bfd.c index c9f1a7e5..3af8a2be 100644 --- a/proto/bfd/bfd.c +++ b/proto/bfd/bfd.c @@ -624,7 +624,7 @@ bfd_request_notify(struct bfd_request *req, u8 state, u8 diag) static int bfd_add_request(struct bfd_proto *p, struct bfd_request *req) { - if (p->p.vrf && (p->p.vrf != req->vrf)) + if (p->p.vrf_set && (p->p.vrf != req->vrf)) return 0; struct bfd_session *s = bfd_find_session_by_addr(p, req->addr); |