diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2023-11-23 20:54:22 +0100 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2023-11-23 20:54:22 +0100 |
commit | 3fb06fea1d14ef147a567052391a5b359704e971 (patch) | |
tree | 692750a6792e18fc1dcf50c277d0cde275577815 /proto/bgp/bgp.c | |
parent | b6923f6386b04340d6b2b6a75fbe83c392f207ca (diff) |
BGP: Add options to require BGP capabilities
Some BGP capabilities change the BGP behavior in a significant way, so if
the configuration depends on it, it is better to not establish BGP
session when the capability is not available.
Add several BGP option to require individual BGP capabilities during
session negotiation.
Diffstat (limited to 'proto/bgp/bgp.c')
-rw-r--r-- | proto/bgp/bgp.c | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index 914935b9..b14df932 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -2000,6 +2000,21 @@ bgp_postconfig(struct proto_config *CF) if (interior && (cf->local_role != BGP_ROLE_UNDEFINED)) log(L_WARN "BGP roles are not recommended to be used within AS confederations"); + if (cf->require_enhanced_refresh && !(cf->enable_refresh && cf->enable_enhanced_refresh)) + cf_warn("Enhanced refresh required but disabled"); + + if (cf->require_as4 && !cf->enable_as4) + cf_warn("AS4 support required but disabled"); + + if (cf->require_extended_messages && !cf->enable_extended_messages) + cf_warn("Extended messages required but not enabled"); + + if (cf->require_gr && !cf->gr_mode) + cf_warn("Graceful restart required but not enabled"); + + if (cf->require_llgr && !cf->llgr_mode) + cf_warn("Long-lived graceful restart required but not enabled"); + if (cf->require_roles && (cf->local_role == BGP_ROLE_UNDEFINED)) cf_error("Local role must be set if roles are required"); @@ -2123,6 +2138,12 @@ bgp_postconfig(struct proto_config *CF) if (cc->secondary && !cc->c.table->sorted) cf_error("BGP with secondary option requires sorted table"); + + if (cc->require_ext_next_hop && !cc->ext_next_hop) + cf_warn("Extended next hop required but not enabled"); + + if (cc->require_add_path && !cc->add_path) + cf_warn("ADD-PATH required but not enabled"); } } @@ -2167,20 +2188,30 @@ bgp_reconfigure(struct proto *P, struct proto_config *CF) if (C->stale) same = proto_configure_channel(P, &C, NULL) && same; - if (same) - proto_setup_mpls_map(P, RTS_BGP, 1); + /* Reset name counter */ + p->dynamic_name_counter = 0; - if (same && (p->start_state > BSS_PREPARE)) - bgp_update_bfd(p, new->bfd); + if (!same) + return 0; /* We should update our copy of configuration ptr as old configuration will be freed */ - if (same) - p->cf = new; + p->cf = new; - /* Reset name counter */ - p->dynamic_name_counter = 0; + /* Check whether existing connections are compatible with required capabilities */ + struct bgp_conn *ci = &p->incoming_conn; + if (((ci->state == BS_OPENCONFIRM) || (ci->state == BS_ESTABLISHED)) && !bgp_check_capabilities(ci)) + return 0; - return same; + struct bgp_conn *co = &p->outgoing_conn; + if (((co->state == BS_OPENCONFIRM) || (co->state == BS_ESTABLISHED)) && !bgp_check_capabilities(co)) + return 0; + + proto_setup_mpls_map(P, RTS_BGP, 1); + + if (p->start_state > BSS_PREPARE) + bgp_update_bfd(p, new->bfd); + + return 1; } #define TABLE(cf, NAME) ((cf)->NAME ? (cf)->NAME->table : NULL ) |