diff options
author | Maria Matejka <mq@ucw.cz> | 2022-11-07 10:24:56 +0100 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2022-11-07 10:24:56 +0100 |
commit | 54179a1ab38542e7087db37bfe3de9d32886c78e (patch) | |
tree | ca4238a2046bd5b6be90dab52b5b0cd3ab8663c0 /proto | |
parent | 96d380405701bb01d792ff1c867a607d7fefa001 (diff) | |
parent | 8f79e6b93e32a4eb7e4dda9bd4a9d04400b79d45 (diff) |
Merge commit '8f79e6b9' into thread-next
Diffstat (limited to 'proto')
-rw-r--r-- | proto/bgp/bgp.c | 5 | ||||
-rw-r--r-- | proto/bgp/bgp.h | 4 | ||||
-rw-r--r-- | proto/bgp/config.Y | 3 | ||||
-rw-r--r-- | proto/bgp/packets.c | 6 |
4 files changed, 15 insertions, 3 deletions
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index f8655d47..2f8da1af 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -2105,6 +2105,10 @@ bgp_postconfig(struct proto_config *CF) if (!cc->gw_mode) cc->gw_mode = cf->multihop ? GW_RECURSIVE : GW_DIRECT; + /* Different default for next_hop_prefer */ + if (!cc->next_hop_prefer) + cc->next_hop_prefer = (cc->gw_mode == GW_DIRECT) ? NHP_GLOBAL : NHP_LOCAL; + /* Defaults based on proto config */ if (cc->gr_able == 0xff) cc->gr_able = (cf->gr_mode == BGP_GR_ABLE); @@ -2235,6 +2239,7 @@ bgp_channel_reconfigure(struct channel *C, struct channel_config *CC, int *impor return 0; if ((new->gw_mode != old->gw_mode) || + (new->next_hop_prefer != old->next_hop_prefer) || (new->aigp != old->aigp) || (new->cost != old->cost)) { diff --git a/proto/bgp/bgp.h b/proto/bgp/bgp.h index c7b8e40b..b87e0fc4 100644 --- a/proto/bgp/bgp.h +++ b/proto/bgp/bgp.h @@ -145,6 +145,7 @@ struct bgp_channel_config { ip_addr next_hop_addr; /* Local address for NEXT_HOP attribute */ u8 next_hop_self; /* Always set next hop to local IP address (NH_*) */ u8 next_hop_keep; /* Do not modify next hop attribute (NH_*) */ + u8 next_hop_prefer; /* Prefer global or link-local next hop (NHP_*) */ u8 mandatory; /* Channel is mandatory in capability negotiation */ u8 gw_mode; /* How we compute route gateway from next_hop attr, see GW_* */ u8 secondary; /* Accept also non-best routes (i.e. RA_ACCEPTED) */ @@ -187,6 +188,9 @@ struct bgp_channel_config { #define GW_DIRECT 1 #define GW_RECURSIVE 2 +#define NHP_GLOBAL 1 +#define NHP_LOCAL 2 + #define BGP_ADD_PATH_RX 1 #define BGP_ADD_PATH_TX 2 #define BGP_ADD_PATH_FULL 3 diff --git a/proto/bgp/config.Y b/proto/bgp/config.Y index 9f0d2306..b4edf2c5 100644 --- a/proto/bgp/config.Y +++ b/proto/bgp/config.Y @@ -31,7 +31,7 @@ CF_KEYWORDS(BGP, LOCAL, NEIGHBOR, AS, HOLD, TIME, CONNECT, RETRY, KEEPALIVE, LIVED, STALE, IMPORT, IBGP, EBGP, MANDATORY, INTERNAL, EXTERNAL, SETS, DYNAMIC, RANGE, NAME, DIGITS, AIGP, ORIGINATE, COST, ENFORCE, FIRST, FREE, VALIDATE, BASE, ROLE, ROLES, PEER, PROVIDER, CUSTOMER, - RS_SERVER, RS_CLIENT, REQUIRE, BGP_OTC) + RS_SERVER, RS_CLIENT, REQUIRE, BGP_OTC, PREFER, GLOBAL) %type <i> bgp_nh %type <i32> bgp_afi @@ -264,6 +264,7 @@ bgp_channel_item: | NEXT HOP ADDRESS ipa { BGP_CC->next_hop_addr = $4; } | 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; } | MANDATORY bool { BGP_CC->mandatory = $2; } | MISSING LLADDR bgp_lladdr { log(L_WARN "%s.%s: Missing lladdr option is deprecated and ignored, remove it", this_proto->name, this_channel->name); } | GATEWAY DIRECT { BGP_CC->gw_mode = GW_DIRECT; } diff --git a/proto/bgp/packets.c b/proto/bgp/packets.c index f9c1da41..506268c9 100644 --- a/proto/bgp/packets.c +++ b/proto/bgp/packets.c @@ -1028,13 +1028,15 @@ bgp_apply_next_hop(struct bgp_parse_state *s, ea_list **to, ip_addr gw, ip_addr WITHDRAW(BAD_NEXT_HOP " - zero address"); rtable *tab = ipa_is_ip4(gw) ? c->igp_table_ip4 : c->igp_table_ip6; + ip_addr lla = (c->cf->next_hop_prefer == NHP_LOCAL) ? ll : IPA_NONE; + if (s->mpls) { u32 labels[BGP_MPLS_MAX]; - ea_set_hostentry(to, c->c.table, tab, gw, ll, BGP_MPLS_MAX, labels); + ea_set_hostentry(to, c->c.table, tab, gw, lla, BGP_MPLS_MAX, labels); } else - ea_set_hostentry(to, c->c.table, tab, gw, ll, 0, NULL); + ea_set_hostentry(to, c->c.table, tab, gw, lla, 0, NULL); } } |