diff options
| author | Donatas Abraitis <donatas@opensourcerouting.org> | 2022-04-30 23:04:58 +0300 |
|---|---|---|
| committer | Donatas Abraitis <donatas@opensourcerouting.org> | 2022-05-02 09:43:40 +0300 |
| commit | eea685b6d30b03b0924c0773b1f3563d95ee621f (patch) | |
| tree | 367eb007077f597d7fa6ac3e792444d64b44545a /bgpd/bgp_open.c | |
| parent | 54394daa2d5a2674dbbd4e6d8c424fc55305117c (diff) | |
bgpd: Implement CEASE/Hard Reset notification
Also, add N-Bit (Notification) flag for Graceful Restart.
This is a preparation for RFC8538.
More information: https://datatracker.ietf.org/doc/html/rfc8538
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
Diffstat (limited to 'bgpd/bgp_open.c')
| -rw-r--r-- | bgpd/bgp_open.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index dc9f97f369..324c966b35 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -517,22 +517,39 @@ static int bgp_capability_restart(struct peer *peer, SET_FLAG(peer->cap, PEER_CAP_RESTART_RCV); restart_flag_time = stream_getw(s); + + /* The most significant bit is defined in [RFC4724] as + * the Restart State ("R") bit. + */ if (CHECK_FLAG(restart_flag_time, GRACEFUL_RESTART_R_BIT)) SET_FLAG(peer->cap, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV); else UNSET_FLAG(peer->cap, PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV); + /* The second most significant bit is defined in this + * document as the Graceful Notification ("N") bit. + */ + if (CHECK_FLAG(restart_flag_time, GRACEFUL_RESTART_N_BIT)) + SET_FLAG(peer->cap, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV); + else + UNSET_FLAG(peer->cap, PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV); + UNSET_FLAG(restart_flag_time, 0xF000); peer->v_gr_restart = restart_flag_time; if (bgp_debug_neighbor_events(peer)) { - zlog_debug("%s Peer has%srestarted. Restart Time : %d", - peer->host, - CHECK_FLAG(peer->cap, - PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV) - ? " " - : " not ", - peer->v_gr_restart); + zlog_debug( + "%s Peer has%srestarted. Restart Time: %d, N-bit set: %s", + peer->host, + CHECK_FLAG(peer->cap, + PEER_CAP_GRACEFUL_RESTART_R_BIT_RCV) + ? " " + : " not ", + peer->v_gr_restart, + CHECK_FLAG(peer->cap, + PEER_CAP_GRACEFUL_RESTART_N_BIT_RCV) + ? "yes" + : "no"); } while (stream_get_getp(s) + 4 <= end) { @@ -1418,10 +1435,12 @@ static void bgp_peer_send_gr_capability(struct stream *s, struct peer *peer, restart_time = peer->bgp->restart_time; if (peer->bgp->t_startup) { SET_FLAG(restart_time, GRACEFUL_RESTART_R_BIT); + SET_FLAG(restart_time, GRACEFUL_RESTART_N_BIT); SET_FLAG(peer->cap, PEER_CAP_GRACEFUL_RESTART_R_BIT_ADV); + SET_FLAG(peer->cap, PEER_CAP_GRACEFUL_RESTART_N_BIT_ADV); if (BGP_DEBUG(graceful_restart, GRACEFUL_RESTART)) - zlog_debug("[BGP_GR] Sending R-Bit for Peer :%s :", + zlog_debug("[BGP_GR] Sending R-Bit/N-Bit for peer: %s", peer->host); } |
