]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Handle Role capability via dynamic capabilities for SET/UNSET properly 14283/head
authorDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 29 Aug 2023 07:10:04 +0000 (10:10 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 29 Aug 2023 07:10:04 +0000 (10:10 +0300)
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>
bgpd/bgp_packet.c

index a9e772e2437ca57142d3a1183793c8eac416af99..01d73e9b0723b8bb7139d01c62a36eb2385af952 100644 (file)
@@ -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(