From 4788206b16e103553a7f3201ffc66103569d4e80 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Mon, 2 Sep 2024 15:32:00 +0300 Subject: [PATCH] bgpd: Drop unused route-map types When applying the route-map, we always set rmap_type to know who triggered this action. PEER_RMAP_TYPE_IMPORT/EXPORT was used as a dead-code, and PEER_RMAP_TYPE_NOSET not used at all. Signed-off-by: Donatas Abraitis --- bgpd/bgp_routemap.c | 17 ++++++----------- bgpd/bgpd.h | 7 ++----- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index d0b65a7426d5..d37b1710635a 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -1992,10 +1992,9 @@ route_set_ip_nexthop(void *rule, const struct prefix *prefix, void *object) SET_FLAG(path->attr->rmap_change_flags, BATTR_RMAP_NEXTHOP_UNCHANGED); } else if (rins->peer_address) { - if ((CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN) - || CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IMPORT)) - && peer->su_remote - && sockunion_family(peer->su_remote) == AF_INET) { + if ((CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)) && + peer->su_remote && + sockunion_family(peer->su_remote) == AF_INET) { path->attr->nexthop.s_addr = sockunion2ip(peer->su_remote); path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP); @@ -3950,8 +3949,7 @@ route_set_ipv6_nexthop_prefer_global(void *rule, const struct prefix *prefix, path = object; peer = path->peer; - if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN) - || CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IMPORT)) { + if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)) { /* Set next hop preference to global */ SET_FLAG(path->attr->nh_flags, BGP_ATTR_NH_MP_PREFER_GLOBAL); SET_FLAG(path->attr->rmap_change_flags, @@ -4077,10 +4075,8 @@ route_set_ipv6_nexthop_peer(void *rule, const struct prefix *pfx, void *object) path = object; peer = path->peer; - if ((CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN) - || CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IMPORT)) - && peer->su_remote - && sockunion_family(peer->su_remote) == AF_INET6) { + if ((CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)) && + peer->su_remote && sockunion_family(peer->su_remote) == AF_INET6) { peer_address = peer->su_remote->sin6.sin6_addr; /* Set next hop value and length in attribute. */ if (IN6_IS_ADDR_LINKLOCAL(&peer_address)) { @@ -4095,7 +4091,6 @@ route_set_ipv6_nexthop_peer(void *rule, const struct prefix *pfx, void *object) path->attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; } - } else if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_OUT)) { /* The next hop value will be set as part of packet * rewrite. diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 7f1b82d9c763..5cebc8807758 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -1827,16 +1827,13 @@ struct peer { struct stream *last_reset_cause; /* The kind of route-map Flags.*/ - uint16_t rmap_type; + uint8_t rmap_type; #define PEER_RMAP_TYPE_IN (1U << 0) /* neighbor route-map in */ #define PEER_RMAP_TYPE_OUT (1U << 1) /* neighbor route-map out */ #define PEER_RMAP_TYPE_NETWORK (1U << 2) /* network route-map */ #define PEER_RMAP_TYPE_REDISTRIBUTE (1U << 3) /* redistribute route-map */ #define PEER_RMAP_TYPE_DEFAULT (1U << 4) /* default-originate route-map */ -#define PEER_RMAP_TYPE_NOSET (1U << 5) /* not allow to set commands */ -#define PEER_RMAP_TYPE_IMPORT (1U << 6) /* neighbor route-map import */ -#define PEER_RMAP_TYPE_EXPORT (1U << 7) /* neighbor route-map export */ -#define PEER_RMAP_TYPE_AGGREGATE (1U << 8) /* aggregate-address route-map */ +#define PEER_RMAP_TYPE_AGGREGATE (1U << 5) /* aggregate-address route-map */ /** Peer overwrite configuration. */ struct bfd_session_config {