]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: simplify code fragment for RFC 9234
authorEugene Bogomazov <eb@qrator.net>
Wed, 22 Jun 2022 13:12:28 +0000 (16:12 +0300)
committerEugene Bogomazov <eb@qrator.net>
Wed, 22 Jun 2022 13:12:28 +0000 (16:12 +0300)
Roles cannot be applied to iBGP sessions, so we can move this check to
the top of the role configuration method. Thus, we simplify the internal
logic of branching.

Signed-off-by: Eugene Bogomazov <eb@qrator.net>
bgpd/bgpd.c

index 91843160edf62cd06c733d3e9c4ed8df8fe7c57e..4e90b02f56a5dad7b5c09e518d5f080be2b0f916 100644 (file)
@@ -4920,6 +4920,9 @@ int peer_ebgp_multihop_unset(struct peer *peer)
 /* Set Open Policy Role and check its correctness */
 int peer_role_set(struct peer *peer, uint8_t role, bool strict_mode)
 {
+       if (peer->sort != BGP_PEER_EBGP)
+               return BGP_ERR_INVALID_INTERNAL_ROLE;
+
        if (peer->local_role == role) {
                if (CHECK_FLAG(peer->flags, PEER_FLAG_STRICT_MODE) &&
                    !strict_mode)
@@ -4934,8 +4937,6 @@ int peer_role_set(struct peer *peer, uint8_t role, bool strict_mode)
                                bgp_session_reset(peer);
                }
        } else {
-               if (peer->sort != BGP_PEER_EBGP)
-                       return BGP_ERR_INVALID_INTERNAL_ROLE;
                peer->local_role = role;
                if (strict_mode)
                        SET_FLAG(peer->flags, PEER_FLAG_STRICT_MODE);