]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
BGP: Add option "next hop prefer local" and use it in direct mode of next hop computation
authorIgor Putovny <igor.putovny@nic.cz>
Thu, 29 May 2025 15:55:49 +0000 (17:55 +0200)
committerOndřej Zajíček <santiago@crfreenet.org>
Tue, 17 Jun 2025 14:31:55 +0000 (16:31 +0200)
proto/bgp/config.Y
proto/bgp/packets.c

index d73c0317c10b3a113c66576a38118d7ff04e6d5b..4a98df69e52886fd28372e7bcf30a66634d37ff8 100644 (file)
@@ -423,6 +423,7 @@ bgp_channel_item:
  | NEXT HOP SELF bgp_nh { BGP_CC->next_hop_self = $4; }
  | NEXT HOP KEEP bgp_nh { BGP_CC->next_hop_keep = $4; }
  | NEXT HOP PREFER GLOBAL { BGP_CC->next_hop_prefer = NHP_GLOBAL; }
+ | NEXT HOP PREFER LOCAL  { BGP_CC->next_hop_prefer = NHP_LOCAL;  }
  | LINK LOCAL NEXT HOP FORMAT bgp_llnh { BGP_CC->llnh_format = $6; }
  | MANDATORY bool { BGP_CC->mandatory = $2; }
  | MISSING LLADDR bgp_lladdr { cf_warn("%s.%s: Missing lladdr option is deprecated and ignored, remove it", this_proto->name, this_channel->name); }
index 2eabe6ec13c36f58098b8834d25caa46867f249f..f6744ec700d528155a65e57ce08f53a9ea96db21 100644 (file)
@@ -1086,10 +1086,12 @@ bgp_apply_next_hop(struct bgp_parse_state *s, rta *a, ip_addr gw, ip_addr ll)
     neighbor *nbr = NULL;
 
     /* GW_DIRECT -> single_hop -> p->neigh != NULL */
-    if (ipa_nonzero2(gw))
+    if ((c->cf->next_hop_prefer == NHP_GLOBAL) && ipa_nonzero2(gw))
       nbr = neigh_find(&p->p, gw, NULL, 0);
     else if (ipa_nonzero(ll))
       nbr = neigh_find(&p->p, ll, p->neigh->iface, 0);
+    else if (ipa_nonzero2(gw))
+      nbr = neigh_find(&p->p, gw, NULL, 0);
     else
       WITHDRAW(BAD_NEXT_HOP " - zero address");