0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-09 12:48:43 +00:00

Merge commit 'e3c0eca9' into thread-next

This commit is contained in:
Maria Matejka 2023-10-13 11:04:39 +02:00
commit 21b75c472d
9 changed files with 36 additions and 12 deletions

View File

@ -288,7 +288,7 @@ ifa_send_notify(struct iface_subscription *s, unsigned c, struct ifa *a)
if (s->ifa_notify &&
(p->proto_state != PS_DOWN) &&
(!p->vrf || p->vrf == a->iface->master))
(!p->vrf || if_in_vrf(a->iface, p->vrf)))
{
if (p->debug & D_IFACES)
log(L_TRACE "%s < address %N on interface %s %s",
@ -330,7 +330,7 @@ if_send_notify(struct iface_subscription *s, unsigned c, struct iface *i)
if (s->if_notify &&
(p->proto_state != PS_DOWN) &&
(!p->vrf || p->vrf == i->master))
(!p->vrf || if_in_vrf(i, p->vrf)))
{
if (p->debug & D_IFACES)
log(L_TRACE "%s < interface %s %s", p->name, i->name,

View File

@ -58,6 +58,7 @@ struct iface {
#define IF_IGNORE 0x40 /* Not to be used by routing protocols (loopbacks etc.) */
#define IF_ADMIN_UP 0x80 /* Administrative up (e.g. IFF_UP in Linux) */
#define IF_LINK_UP 0x100 /* Link available (e.g. IFF_LOWER_UP in Linux) */
#define IF_VRF 0x200 /* Iface is VRF master */
#define IA_PRIMARY 0x10000 /* This address is primary */
#define IA_SECONDARY 0x20000 /* This address has been reported as secondary by the kernel */
@ -124,6 +125,9 @@ struct iface *if_find_by_name(const char *);
struct iface *if_get_by_name(const char *);
void if_recalc_all_preferred_addresses(void);
static inline int if_in_vrf(struct iface *i, struct iface *vrf)
{ return (i->flags & IF_VRF) ? (i == vrf) : (i->master == vrf); }
struct iface *if_walk_first(void);
struct iface *if_walk_next(struct iface *);
void if_walk_done(void);

View File

@ -166,7 +166,7 @@ if_connected_any(ip_addr a, struct iface *vrf, struct iface **iface, struct ifa
/* Prefer SCOPE_HOST or longer prefix */
WALK_LIST(i, global_iface_list)
if ((!vrf || vrf == i->master) && ((s = if_connected(a, i, &b, flags)) >= 0))
if ((!vrf || if_in_vrf(i,vrf)) && ((s = if_connected(a, i, &b, flags)) >= 0))
if (scope_better(s, scope) || (scope_remote(s, scope) && ifa_better(b, *addr)))
{
*iface = i;
@ -432,7 +432,7 @@ neigh_update(neighbor *n, struct iface *iface)
return;
/* VRF-bound neighbors ignore changes in other VRFs */
if (p->vrf && (p->vrf != iface->master))
if (p->vrf && !if_in_vrf(iface, p->vrf))
return;
scope = if_connected(n->addr, iface, &ifa, n->flags);

View File

@ -2062,7 +2062,7 @@ babel_reconfigure_ifaces(struct babel_proto *p, struct babel_config *cf)
{
IFACE_WALK(iface)
{
if (p->p.vrf && p->p.vrf != iface->master)
if (p->p.vrf && !if_in_vrf(iface, p->p.vrf))
continue;
if (!(iface->flags & IF_UP))

View File

@ -1189,7 +1189,7 @@ bgp_use_gateway(struct bgp_export_state *s)
return NULL;
/* Do not use gateway from different VRF */
if (p->p.vrf && nhad->nh.iface && (p->p.vrf != nhad->nh.iface->master))
if (p->p.vrf && nhad->nh.iface && !if_in_vrf(nhad->nh.iface, p->p.vrf))
return 0;
/* Use it when exported to internal peers */

View File

@ -1229,7 +1229,7 @@ ospf_reconfigure_ifaces2(struct ospf_proto *p)
IFACE_WALK(iface)
{
if (p->p.vrf && p->p.vrf != iface->master)
if (p->p.vrf && !if_in_vrf(iface, p->p.vrf))
continue;
if (! (iface->flags & IF_UP))
@ -1277,7 +1277,7 @@ ospf_reconfigure_ifaces3(struct ospf_proto *p)
IFACE_WALK(iface)
{
if (p->p.vrf && p->p.vrf != iface->master)
if (p->p.vrf && !if_in_vrf(iface, p->p.vrf))
continue;
if (! (iface->flags & IF_UP))

View File

@ -668,7 +668,7 @@ radv_reconfigure(struct proto *P, struct proto_config *CF)
IFACE_WALK(iface)
{
if (p->p.vrf && p->p.vrf != iface->master)
if (p->p.vrf && !if_in_vrf(iface, p->p.vrf))
continue;
if (!(iface->flags & IF_UP))

View File

@ -854,7 +854,7 @@ rip_reconfigure_ifaces(struct rip_proto *p, struct rip_config *cf)
{
IFACE_WALK(iface)
{
if (p->p.vrf && p->p.vrf != iface->master)
if (p->p.vrf && !if_in_vrf(iface, p->p.vrf))
continue;
if (!(iface->flags & IF_UP))

View File

@ -429,13 +429,21 @@ struct nl_want_attrs {
};
#define BIRD_IFLA_MAX (IFLA_WIRELESS+1)
#define BIRD_IFLA_MAX (IFLA_LINKINFO+1)
static struct nl_want_attrs ifla_attr_want[BIRD_IFLA_MAX] = {
[IFLA_IFNAME] = { 1, 0, 0 },
[IFLA_MTU] = { 1, 1, sizeof(u32) },
[IFLA_MASTER] = { 1, 1, sizeof(u32) },
[IFLA_WIRELESS] = { 1, 0, 0 },
[IFLA_LINKINFO] = { 1, 0, 0 },
};
#define BIRD_INFO_MAX (IFLA_INFO_DATA+1)
static struct nl_want_attrs ifinfo_attr_want[BIRD_INFO_MAX] = {
[IFLA_INFO_KIND]= { 1, 0, 0 },
[IFLA_INFO_DATA]= { 1, 0, 0 },
};
@ -975,7 +983,7 @@ nl_parse_link(struct nlmsghdr *h, int scan)
int new = h->nlmsg_type == RTM_NEWLINK;
struct iface f = {};
struct iface *ifi;
char *name;
const char *name, *kind = NULL;
u32 mtu, master = 0;
uint fl;
@ -1002,6 +1010,15 @@ nl_parse_link(struct nlmsghdr *h, int scan)
if (a[IFLA_MASTER])
master = rta_get_u32(a[IFLA_MASTER]);
if (a[IFLA_LINKINFO])
{
struct rtattr *li[BIRD_INFO_MAX];
nl_attr_len = RTA_PAYLOAD(a[IFLA_LINKINFO]);
nl_parse_attrs(RTA_DATA(a[IFLA_LINKINFO]), ifinfo_attr_want, li, sizeof(li));
if (li[IFLA_INFO_KIND])
kind = RTA_DATA(li[IFLA_INFO_KIND]);
}
ifi = if_find_by_index(i->ifi_index);
if (!new)
{
@ -1041,6 +1058,9 @@ nl_parse_link(struct nlmsghdr *h, int scan)
if (fl & IFF_MULTICAST)
f.flags |= IF_MULTICAST;
if (kind && !strcmp(kind, "vrf"))
f.flags |= IF_VRF;
ifi = if_update(&f);
if (!scan)