From: Eugene Bogomazov Date: Wed, 22 Jun 2022 13:12:28 +0000 (+0300) Subject: bgpd: simplify code fragment for RFC 9234 X-Git-Tag: base_8.4~303^2~2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=13896bde30bf340ca15d2cc9092569e1bbbfd5f2;p=mirror%2Ffrr.git bgpd: simplify code fragment for RFC 9234 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 --- diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 91843160ed..4e90b02f56 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -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);