0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-18 17:18:42 +00:00

Merge commit 'adf37d8e' into thread-next

This commit is contained in:
Maria Matejka 2022-09-20 09:14:39 +02:00
commit 28427a68c3
7 changed files with 22 additions and 19 deletions

View File

@ -294,8 +294,8 @@ proto_item:
| MRTDUMP mrtdump_mask { this_proto->mrtdump = $2; } | MRTDUMP mrtdump_mask { this_proto->mrtdump = $2; }
| ROUTER ID idval { this_proto->router_id = $3; } | ROUTER ID idval { this_proto->router_id = $3; }
| DESCRIPTION text { this_proto->dsc = $2; } | DESCRIPTION text { this_proto->dsc = $2; }
| VRF text { this_proto->vrf = if_get_by_name($2); this_proto->vrf_set = 1; } | VRF text { this_proto->vrf = if_get_by_name($2); }
| VRF DEFAULT { this_proto->vrf = NULL; this_proto->vrf_set = 1; } | VRF DEFAULT { this_proto->vrf = &default_vrf; }
; ;

View File

@ -37,6 +37,7 @@
static pool *if_pool; static pool *if_pool;
list iface_list; list iface_list;
struct iface default_vrf;
static void if_recalc_preferred(struct iface *i); static void if_recalc_preferred(struct iface *i);
@ -147,7 +148,7 @@ ifa_send_notify(struct proto *p, unsigned c, struct ifa *a)
{ {
if (p->ifa_notify && if (p->ifa_notify &&
(p->proto_state != PS_DOWN) && (p->proto_state != PS_DOWN) &&
(!p->vrf_set || p->vrf == a->iface->master)) (!p->vrf || p->vrf == a->iface->master))
{ {
if (p->debug & D_IFACES) if (p->debug & D_IFACES)
log(L_TRACE "%s < address %N on interface %s %s", log(L_TRACE "%s < address %N on interface %s %s",
@ -185,7 +186,7 @@ if_send_notify(struct proto *p, unsigned c, struct iface *i)
{ {
if (p->if_notify && if (p->if_notify &&
(p->proto_state != PS_DOWN) && (p->proto_state != PS_DOWN) &&
(!p->vrf_set || p->vrf == i->master)) (!p->vrf || p->vrf == i->master))
{ {
if (p->debug & D_IFACES) if (p->debug & D_IFACES)
log(L_TRACE "%s < interface %s %s", p->name, i->name, log(L_TRACE "%s < interface %s %s", p->name, i->name,
@ -243,7 +244,7 @@ if_recalc_flags(struct iface *i UNUSED, uint flags)
{ {
if ((flags & IF_ADMIN_UP) && if ((flags & IF_ADMIN_UP) &&
!(flags & (IF_SHUTDOWN | IF_TMP_DOWN)) && !(flags & (IF_SHUTDOWN | IF_TMP_DOWN)) &&
!(i->master_index && !i->master)) !(i->master_index && i->master == &default_vrf))
flags |= IF_UP; flags |= IF_UP;
else else
flags &= ~IF_UP; flags &= ~IF_UP;
@ -301,6 +302,9 @@ if_update(struct iface *new)
struct iface *i; struct iface *i;
unsigned c; unsigned c;
if (!new->master)
new->master = &default_vrf;
WALK_LIST(i, iface_list) WALK_LIST(i, iface_list)
if (!strcmp(new->name, i->name)) if (!strcmp(new->name, i->name))
{ {
@ -711,6 +715,7 @@ if_init(void)
{ {
if_pool = rp_new(&root_pool, "Interfaces"); if_pool = rp_new(&root_pool, "Interfaces");
init_list(&iface_list); init_list(&iface_list);
strcpy(default_vrf.name, "default");
neigh_init(if_pool); neigh_init(if_pool);
} }
@ -843,7 +848,7 @@ if_show(void)
continue; continue;
char mbuf[16 + sizeof(i->name)] = {}; char mbuf[16 + sizeof(i->name)] = {};
if (i->master) if (i->master != &default_vrf)
bsprintf(mbuf, " master=%s", i->master->name); bsprintf(mbuf, " master=%s", i->master->name);
else if (i->master_index) else if (i->master_index)
bsprintf(mbuf, " master=#%u", i->master_index); bsprintf(mbuf, " master=#%u", i->master_index);

View File

@ -28,6 +28,8 @@ struct ifa { /* Interface address */
unsigned flags; /* Analogous to iface->flags */ unsigned flags; /* Analogous to iface->flags */
}; };
extern struct iface default_vrf;
struct iface { struct iface {
node n; node n;
char name[16]; char name[16];

View File

@ -142,7 +142,7 @@ if_connected(ip_addr a, struct iface *i, struct ifa **ap, uint flags)
} }
static inline int static inline int
if_connected_any(ip_addr a, struct iface *vrf, uint vrf_set, struct iface **iface, struct ifa **addr, uint flags) if_connected_any(ip_addr a, struct iface *vrf, struct iface **iface, struct ifa **addr, uint flags)
{ {
struct iface *i; struct iface *i;
struct ifa *b; struct ifa *b;
@ -153,7 +153,7 @@ if_connected_any(ip_addr a, struct iface *vrf, uint vrf_set, struct iface **ifac
/* Prefer SCOPE_HOST or longer prefix */ /* Prefer SCOPE_HOST or longer prefix */
WALK_LIST(i, iface_list) WALK_LIST(i, iface_list)
if ((!vrf_set || vrf == i->master) && ((s = if_connected(a, i, &b, flags)) >= 0)) if ((!vrf || vrf == i->master) && ((s = if_connected(a, i, &b, flags)) >= 0))
if (scope_better(s, scope) || (scope_remote(s, scope) && ifa_better(b, *addr))) if (scope_better(s, scope) || (scope_remote(s, scope) && ifa_better(b, *addr)))
{ {
*iface = i; *iface = i;
@ -245,7 +245,7 @@ neigh_find(struct proto *p, ip_addr a, struct iface *iface, uint flags)
iface = (scope < 0) ? NULL : iface; iface = (scope < 0) ? NULL : iface;
} }
else else
scope = if_connected_any(a, p->vrf, p->vrf_set, &iface, &addr, flags); scope = if_connected_any(a, p->vrf, &iface, &addr, flags);
/* scope < 0 means i don't know neighbor */ /* scope < 0 means i don't know neighbor */
/* scope >= 0 <=> iface != NULL */ /* scope >= 0 <=> iface != NULL */
@ -369,7 +369,7 @@ neigh_update(neighbor *n, struct iface *iface)
return; return;
/* VRF-bound neighbors ignore changes in other VRFs */ /* VRF-bound neighbors ignore changes in other VRFs */
if (p->vrf_set && (p->vrf != iface->master)) if (p->vrf && (p->vrf != iface->master))
return; return;
scope = if_connected(n->addr, iface, &ifa, n->flags); scope = if_connected(n->addr, iface, &ifa, n->flags);
@ -379,7 +379,7 @@ neigh_update(neighbor *n, struct iface *iface)
{ {
/* When neighbor is going down, try to respawn it on other ifaces */ /* When neighbor is going down, try to respawn it on other ifaces */
if ((scope < 0) && (n->scope >= 0) && !n->ifreq && (n->flags & NEF_STICKY)) if ((scope < 0) && (n->scope >= 0) && !n->ifreq && (n->flags & NEF_STICKY))
scope = if_connected_any(n->addr, p->vrf, p->vrf_set, &iface, &ifa, n->flags); scope = if_connected_any(n->addr, p->vrf, &iface, &ifa, n->flags);
} }
else else
{ {

View File

@ -1200,7 +1200,6 @@ proto_init(struct proto_config *c, node *n)
p->proto_state = PS_DOWN; p->proto_state = PS_DOWN;
p->last_state_change = current_time(); p->last_state_change = current_time();
p->vrf = c->vrf; p->vrf = c->vrf;
p->vrf_set = c->vrf_set;
insert_node(&p->n, n); insert_node(&p->n, n);
p->event = ev_new_init(proto_pool, proto_event, p); p->event = ev_new_init(proto_pool, proto_event, p);
@ -1377,8 +1376,7 @@ proto_reconfigure(struct proto *p, struct proto_config *oc, struct proto_config
if ((nc->protocol != oc->protocol) || if ((nc->protocol != oc->protocol) ||
(nc->net_type != oc->net_type) || (nc->net_type != oc->net_type) ||
(nc->disabled != p->disabled) || (nc->disabled != p->disabled) ||
(nc->vrf != oc->vrf) || (nc->vrf != oc->vrf))
(nc->vrf_set != oc->vrf_set))
return 0; return 0;
p->name = nc->name; p->name = nc->name;
@ -2297,8 +2295,8 @@ proto_cmd_show(struct proto *p, uintptr_t verbose, int cnt)
cli_msg(-1006, " Message: %s", p->message); cli_msg(-1006, " Message: %s", p->message);
if (p->cf->router_id) if (p->cf->router_id)
cli_msg(-1006, " Router ID: %R", p->cf->router_id); cli_msg(-1006, " Router ID: %R", p->cf->router_id);
if (p->vrf_set) if (p->vrf)
cli_msg(-1006, " VRF: %s", p->vrf ? p->vrf->name : "default"); cli_msg(-1006, " VRF: %s", p->vrf->name);
if (p->proto->show_proto_info) if (p->proto->show_proto_info)
p->proto->show_proto_info(p); p->proto->show_proto_info(p);

View File

@ -100,7 +100,6 @@ struct proto_config {
int class; /* SYM_PROTO or SYM_TEMPLATE */ int class; /* SYM_PROTO or SYM_TEMPLATE */
u8 net_type; /* Protocol network type (NET_*), 0 for undefined */ u8 net_type; /* Protocol network type (NET_*), 0 for undefined */
u8 disabled; /* Protocol enabled/disabled by default */ u8 disabled; /* Protocol enabled/disabled by default */
u8 vrf_set; /* Related VRF instance (below) is defined */
u8 late_if_feed; /* Delay interface feed after channels are up */ u8 late_if_feed; /* Delay interface feed after channels are up */
u32 debug, mrtdump; /* Debugging bitfields, both use D_* constants */ u32 debug, mrtdump; /* Debugging bitfields, both use D_* constants */
u32 router_id; /* Protocol specific router ID */ u32 router_id; /* Protocol specific router ID */
@ -137,7 +136,6 @@ struct proto {
uint active_loops; /* Number of active IO loops */ uint active_loops; /* Number of active IO loops */
byte net_type; /* Protocol network type (NET_*), 0 for undefined */ byte net_type; /* Protocol network type (NET_*), 0 for undefined */
byte disabled; /* Manually disabled */ byte disabled; /* Manually disabled */
byte vrf_set; /* Related VRF instance (above) is defined */
byte proto_state; /* Protocol state machine (PS_*, see below) */ byte proto_state; /* Protocol state machine (PS_*, see below) */
byte active; /* From PS_START to cleanup after PS_STOP */ byte active; /* From PS_START to cleanup after PS_STOP */
byte do_stop; /* Stop actions are scheduled */ byte do_stop; /* Stop actions are scheduled */

View File

@ -666,7 +666,7 @@ bfd_add_request(struct bfd_proto *p, struct bfd_request *req)
{ {
struct bfd_config *cf = (struct bfd_config *) (p->p.cf); struct bfd_config *cf = (struct bfd_config *) (p->p.cf);
if (p->p.vrf_set && (p->p.vrf != req->vrf)) if (p->p.vrf && (p->p.vrf != req->vrf))
return 0; return 0;
if (ipa_is_ip4(req->addr) ? !cf->accept_ipv4 : !cf->accept_ipv6) if (ipa_is_ip4(req->addr) ? !cf->accept_ipv4 : !cf->accept_ipv6)