Skip to content

Commit

Permalink
bgpd: Do not start BGP session if BFD profile is in shutdown state
Browse files Browse the repository at this point in the history
If we do:

```
bfd
 profile foo
  shutdown
```

The session is dropped, but immediately established again because we don't
have a proper check on BFD.

If BFD is administratively shutdown, ignore starting the session.

Fixes: #16186

Signed-off-by: Donatas Abraitis <[email protected]>
  • Loading branch information
ton31337 committed Jun 12, 2024
1 parent ae1f3a4 commit 1fb48f5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4507,6 +4507,12 @@ bool peer_active(struct peer *peer)
{
if (BGP_CONNECTION_SU_UNSPEC(peer->connection))
return false;

if (peer->bfd_config) {
if (bfd_session_is_down(peer->bfd_config->session))
return false;
}

if (peer->afc[AFI_IP][SAFI_UNICAST] || peer->afc[AFI_IP][SAFI_MULTICAST]
|| peer->afc[AFI_IP][SAFI_LABELED_UNICAST]
|| peer->afc[AFI_IP][SAFI_MPLS_VPN] || peer->afc[AFI_IP][SAFI_ENCAP]
Expand Down
6 changes: 6 additions & 0 deletions lib/bfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1334,3 +1334,9 @@ int bfd_nht_update(const struct prefix *match, const struct zapi_route *route)

return 0;
}

bool bfd_session_is_down(const struct bfd_session_params *session)
{
return session->bss.state == BSS_DOWN ||
session->bss.state == BSS_ADMIN_DOWN;
}
2 changes: 2 additions & 0 deletions lib/bfd.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ extern bool bfd_protocol_integration_shutting_down(void);
extern int bfd_nht_update(const struct prefix *match,
const struct zapi_route *route);

extern bool bfd_session_is_down(const struct bfd_session_params *session);

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit 1fb48f5

Please sign in to comment.