From: Maria Matejka Date: Mon, 7 Nov 2022 09:09:40 +0000 (+0100) Subject: Merge commit '8478de88' into thread-next X-Git-Tag: v3.0-alpha1~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96d380405701bb01d792ff1c867a607d7fefa001;p=thirdparty%2Fbird.git Merge commit '8478de88' into thread-next --- 96d380405701bb01d792ff1c867a607d7fefa001 diff --cc nest/protocol.h index 892d18907,46744357e..101e09261 --- a/nest/protocol.h +++ b/nest/protocol.h @@@ -464,8 -493,9 +464,9 @@@ struct channel_config u8 ra_mode; /* Mode of received route advertisements (RA_*) */ u16 preference; /* Default route preference */ 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 in_keep_filtered; /* Routes rejected in import filter are kept */ + u8 in_keep; /* Which states of routes to keep (RIK_*) */ u8 rpki_reload; /* RPKI changes trigger channel reload */ }; diff --cc proto/bgp/packets.c index 074d6cf70,8087608a8..f9c1da413 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@@ -1112,6 -1112,10 +1112,10 @@@ bgp_use_next_hop(struct bgp_export_stat if ((ipa_is_ip4(*nh) != bgp_channel_is_ipv4(c)) && !c->ext_next_hop) return 0; + /* Do not pass NEXT_HOP between different VRFs */ - if (p->p.vrf_set && s->src && s->src->p.vrf_set && (p->p.vrf != s->src->p.vrf)) ++ 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 */ if (p->is_interior && ipa_nonzero(*nh)) return 1; @@@ -1131,32 -1135,26 +1135,36 @@@ bgp_use_gateway(struct bgp_export_stat /* Handle next hop self option - also applies to gateway */ if (c->cf->next_hop_self && bgp_match_src(s, c->cf->next_hop_self)) - return 0; + return NULL; + + eattr *nhea = ea_find(ra, &ea_gen_nexthop); + if (!nhea) + return NULL; /* We need one valid global gateway */ - if ((ra->dest != RTD_UNICAST) || ra->nh.next || ipa_zero(ra->nh.gw) || ipa_is_link_local(ra->nh.gw)) - return 0; + struct nexthop_adata *nhad = (struct nexthop_adata *) nhea->u.ptr; + if (!NEXTHOP_IS_REACHABLE(nhad) || + !NEXTHOP_ONE(nhad) || ipa_zero(nhad->nh.gw) || + ipa_is_link_local(nhad->nh.gw)) + return NULL; /* Check for non-matching AF */ - if ((ipa_is_ip4(ra->nh.gw) != bgp_channel_is_ipv4(c)) && !c->ext_next_hop) - return 0; + if ((ipa_is_ip4(nhad->nh.gw) != bgp_channel_is_ipv4(c)) && !c->ext_next_hop) + return NULL; + /* Do not use gateway from different VRF */ - if (p->p.vrf_set && ra->nh.iface && (p->p.vrf != ra->nh.iface->master)) ++ if (p->p.vrf && nhad->nh.iface && (p->p.vrf != nhad->nh.iface->master)) + return 0; + /* Use it when exported to internal peers */ if (p->is_interior) - return 1; + return &nhad->nh; /* Use it when forwarded to single-hop BGP peer on on the same iface */ - return p->neigh && (p->neigh->iface == ra->nh.iface); + if (p->neigh && (p->neigh->iface == nhad->nh.iface)) + return &nhad->nh; + + return NULL; } static void @@@ -1173,10 -1171,12 +1181,12 @@@ bgp_update_next_hop_ip(struct bgp_expor if (s->mpls) { u32 implicit_null = BGP_MPLS_NULL; - u32 *labels = ra->nh.labels ? ra->nh.label : &implicit_null; - uint lnum = ra->nh.labels ? ra->nh.labels : 1; - bgp_set_attr_data(to, s->pool, BA_MPLS_LABEL_STACK, 0, labels, lnum * 4); + u32 *labels = nhloc->labels ? nhloc->label : &implicit_null; + uint lnum = nhloc->labels ? nhloc->labels : 1; + bgp_set_attr_data(to, BA_MPLS_LABEL_STACK, 0, labels, lnum * 4); } + else - bgp_unset_attr(to, s->pool, BA_MPLS_LABEL_STACK); ++ bgp_unset_attr(to, BA_MPLS_LABEL_STACK); } else { @@@ -1188,8 -1188,10 +1198,10 @@@ if (s->mpls) { u32 implicit_null = BGP_MPLS_NULL; - bgp_set_attr_data(to, s->pool, 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, s->pool, BA_MPLS_LABEL_STACK); ++ bgp_unset_attr(to, BA_MPLS_LABEL_STACK); } }