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>
/* 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)
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);