diff options
| author | Donatas Abraitis <donatas@opensourcerouting.org> | 2023-08-29 10:10:04 +0300 |
|---|---|---|
| committer | Donatas Abraitis <donatas@opensourcerouting.org> | 2023-08-29 10:10:04 +0300 |
| commit | 5ad080d37a26d72b56ecd0b796593bb7fc3aa6ad (patch) | |
| tree | 8fd15b11b56bfb9ebe2bfcc3c78bf1a5f93baac4 | |
| parent | c4e030ac87687b15418df652f69e3959c58de0e2 (diff) | |
bgpd: Handle Role capability via dynamic capabilities for SET/UNSET properly
It was missed to handle UNSET Role capability using dynamic capabilities.
Also move length check before actually handling Role capability.
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
| -rw-r--r-- | bgpd/bgp_packet.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index a9e772e243..01d73e9b07 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -2899,7 +2899,6 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt, case CAPABILITY_CODE_EXT_MESSAGE: break; case CAPABILITY_CODE_ROLE: - SET_FLAG(peer->cap, PEER_CAP_ROLE_RCV); if (hdr->length != CAPABILITY_CODE_ROLE_LEN) { flog_warn(EC_BGP_CAPABILITY_INVALID_LENGTH, "Role: Received invalid length %d", @@ -2908,11 +2907,17 @@ static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt, BGP_NOTIFY_SUBCODE_UNSPECIFIC); return BGP_Stop; } + uint8_t role; - memcpy(&role, pnt + 3, sizeof(role)); + if (action == CAPABILITY_ACTION_SET) { + SET_FLAG(peer->cap, PEER_CAP_ROLE_RCV); + memcpy(&role, pnt + 3, sizeof(role)); - peer->remote_role = role; + peer->remote_role = role; + } else { + UNSET_FLAG(peer->cap, PEER_CAP_ROLE_RCV); + } break; default: flog_warn( |
