0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-09-19 20:05:21 +00:00

Merge commit '8478de88' into thread-next

This commit is contained in:
Maria Matejka 2022-11-07 10:09:40 +01:00
commit 96d3804057
7 changed files with 39 additions and 3 deletions

View File

@ -327,7 +327,7 @@ clist_set_type(const struct f_tree *set, struct f_val *v)
} }
} }
static int int
clist_match_set(const struct adata *clist, const struct f_tree *set) clist_match_set(const struct adata *clist, const struct f_tree *set)
{ {
if (!clist) if (!clist)
@ -348,7 +348,7 @@ clist_match_set(const struct adata *clist, const struct f_tree *set)
return 0; return 0;
} }
static int int
eclist_match_set(const struct adata *list, const struct f_tree *set) eclist_match_set(const struct adata *list, const struct f_tree *set)
{ {
if (!list) if (!list)
@ -372,7 +372,7 @@ eclist_match_set(const struct adata *list, const struct f_tree *set)
return 0; return 0;
} }
static int int
lclist_match_set(const struct adata *list, const struct f_tree *set) lclist_match_set(const struct adata *list, const struct f_tree *set)
{ {
if (!list) if (!list)

View File

@ -119,6 +119,7 @@ struct f_tree *f_new_tree(void);
struct f_tree *build_tree(struct f_tree *); struct f_tree *build_tree(struct f_tree *);
const struct f_tree *find_tree(const struct f_tree *t, const struct f_val *val); const struct f_tree *find_tree(const struct f_tree *t, const struct f_val *val);
int same_tree(const struct f_tree *t0, const struct f_tree *t2); int same_tree(const struct f_tree *t0, const struct f_tree *t2);
int tree_node_count(const struct f_tree *t);
void tree_format(const struct f_tree *t, buffer *buf); void tree_format(const struct f_tree *t, buffer *buf);
void tree_walk(const struct f_tree *t, void (*hook)(const struct f_tree *, void *), void *data); void tree_walk(const struct f_tree *t, void (*hook)(const struct f_tree *, void *), void *data);
@ -215,6 +216,10 @@ static inline int lclist_set_type(const struct f_tree *set)
static inline int path_set_type(const struct f_tree *set) static inline int path_set_type(const struct f_tree *set)
{ return !set || set->from.type == T_INT; } { return !set || set->from.type == T_INT; }
int clist_match_set(const struct adata *clist, const struct f_tree *set);
int eclist_match_set(const struct adata *list, const struct f_tree *set);
int lclist_match_set(const struct adata *list, const struct f_tree *set);
const struct adata *clist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos); const struct adata *clist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos);
const struct adata *eclist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos); const struct adata *eclist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos);
const struct adata *lclist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos); const struct adata *lclist_filter(struct linpool *pool, const struct adata *list, const struct f_val *set, int pos);

View File

@ -134,6 +134,14 @@ same_tree(const struct f_tree *t1, const struct f_tree *t2)
return 1; return 1;
} }
int
tree_node_count(const struct f_tree *t)
{
if (t == NULL)
return 0;
return 1 + tree_node_count(t->left) + tree_node_count(t->right);
}
static void static void
tree_node_format(const struct f_tree *t, buffer *buf) tree_node_format(const struct f_tree *t, buffer *buf)

View File

@ -170,6 +170,11 @@ static inline const char *ec_subtype_str(const enum ec_subtype ecs) {
} }
} }
/* Check for EC_RT subtype within different types (0-2) */
static inline int ec_type_is_rt(uint type)
{ return (type == EC_RT) || (type == (0x0100 | EC_RT)) || (type == (0x0200 | EC_RT)); }
/* Transitive bit (for first u32 half of EC) */ /* Transitive bit (for first u32 half of EC) */
#define EC_TBIT 0x40000000 #define EC_TBIT 0x40000000
@ -189,9 +194,13 @@ static inline u32 *int_set_get_data(const struct adata *list)
static inline u32 ec_hi(u64 ec) { return ec >> 32; } static inline u32 ec_hi(u64 ec) { return ec >> 32; }
static inline u32 ec_lo(u64 ec) { return ec; } static inline u32 ec_lo(u64 ec) { return ec; }
static inline u64 ec_get(const u32 *l, int i) static inline u64 ec_get(const u32 *l, int i)
{ return (((u64) l[i]) << 32) | l[i+1]; } { return (((u64) l[i]) << 32) | l[i+1]; }
static inline void ec_put(u32 *l, int i, u64 val)
{ l[i] = ec_hi(val); l[i+1] = ec_lo(val); }
/* RFC 4360 3.1. Two-Octet AS Specific Extended Community */ /* RFC 4360 3.1. Two-Octet AS Specific Extended Community */
static inline u64 ec_as2(enum ec_subtype kind, u64 key, u64 val) static inline u64 ec_as2(enum ec_subtype kind, u64 key, u64 val)
{ return (((u64) kind | 0x0000) << 48) | (key << 32) | val; } { return (((u64) kind | 0x0000) << 48) | (key << 32) | val; }

View File

@ -960,6 +960,7 @@ channel_config_get(const struct channel_class *cc, const char *name, uint net_ty
cf_error("Multiple %s channels", name); cf_error("Multiple %s channels", name);
cf->parent = proto; cf->parent = proto;
cf->copy = 1;
return cf; return cf;
} }

View File

@ -464,6 +464,7 @@ struct channel_config {
u8 ra_mode; /* Mode of received route advertisements (RA_*) */ u8 ra_mode; /* Mode of received route advertisements (RA_*) */
u16 preference; /* Default route preference */ u16 preference; /* Default route preference */
u32 debug; /* Debugging flags (D_*) */ u32 debug; /* Debugging flags (D_*) */
u8 copy; /* Value from channel_config_get() is new (0) or from template (1) */
u8 merge_limit; /* Maximal number of nexthops for RA_MERGED */ u8 merge_limit; /* Maximal number of nexthops for RA_MERGED */
u8 in_keep; /* Which states of routes to keep (RIK_*) */ u8 in_keep; /* Which states of routes to keep (RIK_*) */
u8 rpki_reload; /* RPKI changes trigger channel reload */ u8 rpki_reload; /* RPKI changes trigger channel reload */

View File

@ -1112,6 +1112,10 @@ bgp_use_next_hop(struct bgp_export_state *s, eattr *a)
if ((ipa_is_ip4(*nh) != bgp_channel_is_ipv4(c)) && !c->ext_next_hop) if ((ipa_is_ip4(*nh) != bgp_channel_is_ipv4(c)) && !c->ext_next_hop)
return 0; return 0;
/* Do not pass NEXT_HOP between different VRFs */
if (p->p.vrf && s->src && s->src->p.vrf && (p->p.vrf != s->src->p.vrf))
return 0;
/* Keep it when exported to internal peers */ /* Keep it when exported to internal peers */
if (p->is_interior && ipa_nonzero(*nh)) if (p->is_interior && ipa_nonzero(*nh))
return 1; return 1;
@ -1148,6 +1152,10 @@ bgp_use_gateway(struct bgp_export_state *s)
if ((ipa_is_ip4(nhad->nh.gw) != bgp_channel_is_ipv4(c)) && !c->ext_next_hop) if ((ipa_is_ip4(nhad->nh.gw) != bgp_channel_is_ipv4(c)) && !c->ext_next_hop)
return NULL; return NULL;
/* Do not use gateway from different VRF */
if (p->p.vrf && nhad->nh.iface && (p->p.vrf != nhad->nh.iface->master))
return 0;
/* Use it when exported to internal peers */ /* Use it when exported to internal peers */
if (p->is_interior) if (p->is_interior)
return &nhad->nh; return &nhad->nh;
@ -1177,6 +1185,8 @@ bgp_update_next_hop_ip(struct bgp_export_state *s, eattr *a, ea_list **to)
uint lnum = nhloc->labels ? nhloc->labels : 1; uint lnum = nhloc->labels ? nhloc->labels : 1;
bgp_set_attr_data(to, BA_MPLS_LABEL_STACK, 0, labels, lnum * 4); bgp_set_attr_data(to, BA_MPLS_LABEL_STACK, 0, labels, lnum * 4);
} }
else
bgp_unset_attr(to, BA_MPLS_LABEL_STACK);
} }
else else
{ {
@ -1190,6 +1200,8 @@ bgp_update_next_hop_ip(struct bgp_export_state *s, eattr *a, ea_list **to)
u32 implicit_null = BGP_MPLS_NULL; u32 implicit_null = BGP_MPLS_NULL;
bgp_set_attr_data(to, BA_MPLS_LABEL_STACK, 0, &implicit_null, 4); bgp_set_attr_data(to, BA_MPLS_LABEL_STACK, 0, &implicit_null, 4);
} }
else
bgp_unset_attr(to, BA_MPLS_LABEL_STACK);
} }
} }