Skip to content

Commit

Permalink
bgpd: Drop unused route-map types
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ton31337 committed Sep 2, 2024
1 parent 745cd3e commit 4788206
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
17 changes: 6 additions & 11 deletions bgpd/bgp_routemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)) {
Expand All @@ -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.
Expand Down
7 changes: 2 additions & 5 deletions bgpd/bgpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4788206

Please sign in to comment.