Skip to content

Commit

Permalink
bgpd: Enable enforce-first-as by default
Browse files Browse the repository at this point in the history
It's been for a while disabled by default, but this seems reasonable to flip it.

We had `bgp enforce-first-as` as a global BGP knob to enable/disable this
behavior globally, later we introduced `enforce-first-as` per neighbor, with disabled
by default. Now let's enable this by default.

Signed-off-by: Donatas Abraitis <[email protected]>
  • Loading branch information
ton31337 committed Oct 26, 2023
1 parent a709218 commit 74682f9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -17973,8 +17973,8 @@ static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp,
addr);

/* enforce-first-as */
if (peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS))
vty_out(vty, " neighbor %s enforce-first-as\n", addr);
if (!peergroup_flag_check(peer, PEER_FLAG_ENFORCE_FIRST_AS))
vty_out(vty, " no neighbor %s enforce-first-as\n", addr);

/* update-source */
if (peergroup_flag_check(peer, PEER_FLAG_UPDATE_SOURCE)) {
Expand Down
9 changes: 9 additions & 0 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,8 @@ struct peer *peer_new(struct bgp *bgp)

SET_FLAG(peer->sflags, PEER_STATUS_CAPABILITY_OPEN);

SET_FLAG(peer->flags, PEER_FLAG_ENFORCE_FIRST_AS);

/* Initialize per peer bgp GR FSM */
bgp_peer_gr_init(peer);

Expand Down Expand Up @@ -2860,6 +2862,13 @@ static void peer_group2peer_config_copy(struct peer_group *group,
SET_FLAG(peer->flags,
PEER_FLAG_CAPABILITY_SOFT_VERSION);

/* enforce-first-as */
if (!CHECK_FLAG(peer->flags_override,
PEER_FLAG_ENFORCE_FIRST_AS))
if (CHECK_FLAG(conf->flags, PEER_FLAG_ENFORCE_FIRST_AS))
SET_FLAG(peer->flags,
PEER_FLAG_ENFORCE_FIRST_AS);

/* password apply */
if (!CHECK_FLAG(peer->flags_override, PEER_FLAG_PASSWORD))
PEER_STR_ATTR_INHERIT(peer, group, password,
Expand Down
2 changes: 1 addition & 1 deletion doc/user/bgp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,7 @@ Configuring Peers
Discard updates received from the specified (eBGP) peer if the AS_PATH
attribute does not contain the PEER's ASN as the first AS_PATH segment.

Default: disabled.
Default: enabled.

.. clicmd:: neighbor PEER extended-optional-parameters

Expand Down
5 changes: 0 additions & 5 deletions tests/bgpd/test_peer_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,6 @@ static struct test_peer_attr test_peer_attrs[] = {
.u.flag = PEER_FLAG_DONT_CAPABILITY,
.type = PEER_AT_GLOBAL_FLAG,
},
{
.cmd = "enforce-first-as",
.u.flag = PEER_FLAG_ENFORCE_FIRST_AS,
.type = PEER_AT_GLOBAL_FLAG,
},
{
.cmd = "local-as",
.peer_cmd = "local-as 1",
Expand Down
1 change: 0 additions & 1 deletion tests/bgpd/test_peer_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class TestFlag(frrtest.TestMultiOut):
TestFlag.okfail("peer\\description")
TestFlag.okfail("peer\\disable-connected-check")
TestFlag.okfail("peer\\dont-capability-negotiate")
TestFlag.okfail("peer\\enforce-first-as")
TestFlag.okfail("peer\\local-as")
TestFlag.okfail("peer\\local-as 1 no-prepend")
TestFlag.okfail("peer\\local-as 1 no-prepend replace-as")
Expand Down
2 changes: 1 addition & 1 deletion yang/frr-bgp-neighbor.yang
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ submodule frr-bgp-neighbor {

leaf enforce-first-as {
type boolean;
default "false";
default "true";
description
"When set to 'true' it will enforce the first AS for EBGP routes.";
}
Expand Down

0 comments on commit 74682f9

Please sign in to comment.