]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Merge commit '8478de88' into thread-next
authorMaria Matejka <mq@ucw.cz>
Mon, 7 Nov 2022 09:09:40 +0000 (10:09 +0100)
committerMaria Matejka <mq@ucw.cz>
Mon, 7 Nov 2022 09:18:19 +0000 (10:18 +0100)
1  2 
filter/data.c
filter/data.h
lib/attrs.h
nest/proto.c
nest/protocol.h
proto/bgp/packets.c

diff --cc filter/data.c
Simple merge
diff --cc filter/data.h
Simple merge
diff --cc lib/attrs.h
Simple merge
diff --cc nest/proto.c
Simple merge
diff --cc nest/protocol.h
index 892d189071a3d940e81831b7b1d85a1414d610f4,46744357eb2cdd989cc7c15a6979d6173e3b90eb..101e092615f3df66da24fd9eaf963b7c78374bf4
@@@ -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 */
  };
  
index 074d6cf70159e013158edca4aeabf2e596370f42,8087608a87c2055166c1a00b06d38e42b8070ddc..f9c1da41387e8c4daddefa6b2924e54f26d094e4
@@@ -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;
  
 -  if (p->p.vrf_set && s->src && s->src->p.vrf_set && (p->p.vrf != s->src->p.vrf))
+   /* 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 */
    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;
  
 -  if (p->p.vrf_set && ra->nh.iface && (p->p.vrf != ra->nh.iface->master))
+   /* 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 */
    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);
        }
 -      bgp_unset_attr(to, s->pool, BA_MPLS_LABEL_STACK);
+       else
++      bgp_unset_attr(to, BA_MPLS_LABEL_STACK);
      }
      else
      {
        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);
        }
 -      bgp_unset_attr(to, s->pool, BA_MPLS_LABEL_STACK);
+       else
++      bgp_unset_attr(to, BA_MPLS_LABEL_STACK);
      }
    }