received in bgp_path_info->peer. If it is the same, or if the peer structure
received is a peer_group containing it, returns RMAP_MATCH. */
static enum route_map_cmd_result_t
-route_match_peer(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_peer(void *rule, const struct prefix *prefix, void *object)
{
struct bgp_match_peer_compiled *pc;
union sockunion *su;
struct peer *peer;
struct listnode *node, *nnode;
- if (type == RMAP_BGP) {
- pc = rule;
- su = &pc->su;
- peer = ((struct bgp_path_info *)object)->peer;
+ pc = rule;
+ su = &pc->su;
+ peer = ((struct bgp_path_info *)object)->peer;
- if (pc->interface) {
- if (!peer->conf_if)
- return RMAP_NOMATCH;
+ if (pc->interface) {
+ if (!peer->conf_if)
+ return RMAP_NOMATCH;
- if (strcmp(peer->conf_if, pc->interface) == 0)
- return RMAP_MATCH;
+ if (strcmp(peer->conf_if, pc->interface) == 0)
+ return RMAP_MATCH;
- return RMAP_NOMATCH;
- }
+ return RMAP_NOMATCH;
+ }
- /* If su='0.0.0.0' (command 'match peer local'), and it's a
- NETWORK,
- REDISTRIBUTE, AGGREGATE-ADDRESS or DEFAULT_GENERATED route
- => return RMAP_MATCH
- */
- if (sockunion_same(su, &su_def)) {
- int ret;
- if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_NETWORK)
- || CHECK_FLAG(peer->rmap_type,
- PEER_RMAP_TYPE_REDISTRIBUTE)
- || CHECK_FLAG(peer->rmap_type,
- PEER_RMAP_TYPE_AGGREGATE)
- || CHECK_FLAG(peer->rmap_type,
- PEER_RMAP_TYPE_DEFAULT))
- ret = RMAP_MATCH;
- else
- ret = RMAP_NOMATCH;
- return ret;
- }
+ /* If su='0.0.0.0' (command 'match peer local'), and it's a
+ NETWORK,
+ REDISTRIBUTE, AGGREGATE-ADDRESS or DEFAULT_GENERATED route
+ => return RMAP_MATCH
+ */
+ if (sockunion_same(su, &su_def)) {
+ int ret;
+ if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_NETWORK)
+ || CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_REDISTRIBUTE)
+ || CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_AGGREGATE)
+ || CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_DEFAULT))
+ ret = RMAP_MATCH;
+ else
+ ret = RMAP_NOMATCH;
+ return ret;
+ }
+
+ if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
+ if (sockunion_same(su, &peer->su))
+ return RMAP_MATCH;
- if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
+ return RMAP_NOMATCH;
+ } else {
+ group = peer->group;
+ for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) {
if (sockunion_same(su, &peer->su))
return RMAP_MATCH;
-
- return RMAP_NOMATCH;
- } else {
- group = peer->group;
- for (ALL_LIST_ELEMENTS(group->peer, node, nnode,
- peer)) {
- if (sockunion_same(su, &peer->su))
- return RMAP_MATCH;
- }
- return RMAP_NOMATCH;
}
+ return RMAP_NOMATCH;
}
+
return RMAP_NOMATCH;
}
#if defined(HAVE_LUA)
static enum route_map_cmd_result_t
-route_match_command(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_command(void *rule, const struct prefix *prefix, void *object)
{
int status = RMAP_NOMATCH;
u_int32_t locpref = 0;
/* Match function should return 1 if match is success else return
zero. */
static enum route_map_cmd_result_t
-route_match_ip_address(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_ip_address(void *rule, const struct prefix *prefix, void *object)
{
struct access_list *alist;
- if (type == RMAP_BGP && prefix->family == AF_INET) {
+ if (prefix->family == AF_INET) {
alist = access_list_lookup(AFI_IP, (char *)rule);
if (alist == NULL)
return RMAP_NOMATCH;
/* Match function return 1 if match is success else return zero. */
static enum route_map_cmd_result_t
-route_match_ip_next_hop(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_ip_next_hop(void *rule, const struct prefix *prefix, void *object)
{
struct access_list *alist;
struct bgp_path_info *path;
struct prefix_ipv4 p;
- if (type == RMAP_BGP && prefix->family == AF_INET) {
+ if (prefix->family == AF_INET) {
path = object;
p.family = AF_INET;
p.prefix = path->attr->nexthop;
/* Match function return 1 if match is success else return zero. */
static enum route_map_cmd_result_t
-route_match_ip_route_source(void *rule, const struct prefix *pfx,
- route_map_object_t type, void *object)
+route_match_ip_route_source(void *rule, const struct prefix *pfx, void *object)
{
struct access_list *alist;
struct bgp_path_info *path;
struct peer *peer;
struct prefix_ipv4 p;
- if (type == RMAP_BGP && pfx->family == AF_INET) {
+ if (pfx->family == AF_INET) {
path = object;
peer = path->peer;
static enum route_map_cmd_result_t
route_match_address_prefix_list(void *rule, afi_t afi,
- const struct prefix *prefix,
- route_map_object_t type, void *object)
+ const struct prefix *prefix, void *object)
{
struct prefix_list *plist;
- if (type != RMAP_BGP)
- return RMAP_NOMATCH;
-
plist = prefix_list_lookup(afi, (char *)rule);
if (plist == NULL)
return RMAP_NOMATCH;
static enum route_map_cmd_result_t
route_match_ip_address_prefix_list(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
- return route_match_address_prefix_list(rule, AFI_IP, prefix, type,
- object);
+ return route_match_address_prefix_list(rule, AFI_IP, prefix, object);
}
static void *route_match_ip_address_prefix_list_compile(const char *arg)
static enum route_map_cmd_result_t
route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
struct prefix_list *plist;
struct bgp_path_info *path;
struct prefix_ipv4 p;
- if (type == RMAP_BGP && prefix->family == AF_INET) {
+ if (prefix->family == AF_INET) {
path = object;
p.family = AF_INET;
p.prefix = path->attr->nexthop;
static enum route_map_cmd_result_t
route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
struct bgp_path_info *path;
- if (type == RMAP_BGP && prefix->family == AF_INET) {
+ if (prefix->family == AF_INET) {
path = (struct bgp_path_info *)object;
if (!path)
return RMAP_NOMATCH;
/* `match ip route-source prefix-list PREFIX_LIST' */
static enum route_map_cmd_result_t
-route_match_ip_route_source_prefix_list(void *rule,
- const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_ip_route_source_prefix_list(void *rule, const struct prefix *prefix,
+ void *object)
{
struct prefix_list *plist;
struct bgp_path_info *path;
struct peer *peer;
struct prefix_ipv4 p;
- if (type == RMAP_BGP && prefix->family == AF_INET) {
+ if (prefix->family == AF_INET) {
path = object;
peer = path->peer;
/* Match function should return 1 if match is success else 0 */
static enum route_map_cmd_result_t
-route_match_evpn_default_route(void *rule, const struct prefix *p,
- route_map_object_t type, void *object)
+route_match_evpn_default_route(void *rule, const struct prefix *p, void *object)
{
- if (type == RMAP_BGP && is_evpn_prefix_default(p))
+ if (is_evpn_prefix_default(p))
return RMAP_MATCH;
return RMAP_NOMATCH;
/* Match function should return 1 if match is success else return
zero. */
static enum route_map_cmd_result_t
-route_match_mac_address(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_mac_address(void *rule, const struct prefix *prefix, void *object)
{
struct access_list *alist;
struct prefix p;
- if (type == RMAP_BGP) {
- alist = access_list_lookup(AFI_L2VPN, (char *)rule);
- if (alist == NULL)
- return RMAP_NOMATCH;
-
- if (prefix->u.prefix_evpn.route_type != BGP_EVPN_MAC_IP_ROUTE)
- return RMAP_NOMATCH;
+ alist = access_list_lookup(AFI_L2VPN, (char *)rule);
+ if (alist == NULL)
+ return RMAP_NOMATCH;
- p.family = AF_ETHERNET;
- p.prefixlen = ETH_ALEN * 8;
- p.u.prefix_eth = prefix->u.prefix_evpn.macip_addr.mac;
+ if (prefix->u.prefix_evpn.route_type != BGP_EVPN_MAC_IP_ROUTE)
+ return RMAP_NOMATCH;
- return (access_list_apply(alist, &p) == FILTER_DENY
- ? RMAP_NOMATCH
- : RMAP_MATCH);
- }
+ p.family = AF_ETHERNET;
+ p.prefixlen = ETH_ALEN * 8;
+ p.u.prefix_eth = prefix->u.prefix_evpn.macip_addr.mac;
- return RMAP_NOMATCH;
+ return (access_list_apply(alist, &p) == FILTER_DENY ? RMAP_NOMATCH
+ : RMAP_MATCH);
}
/* Route map `mac address' match statement. `arg' should be
* ...RMAP_NOOP to ignore this match check.
*/
static enum route_map_cmd_result_t
-route_match_vni(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_vni(void *rule, const struct prefix *prefix, void *object)
{
vni_t vni = 0;
unsigned int label_cnt = 0;
struct bgp_path_info *path = NULL;
struct prefix_evpn *evp = (struct prefix_evpn *) prefix;
- if (type == RMAP_BGP) {
- vni = *((vni_t *)rule);
- path = (struct bgp_path_info *)object;
+ vni = *((vni_t *)rule);
+ path = (struct bgp_path_info *)object;
- /*
- * This rmap filter is valid for vxlan tunnel type only.
- * For any other tunnel type, return noop to ignore
- * this check.
- */
- if (path->attr->encap_tunneltype != BGP_ENCAP_TYPE_VXLAN)
- return RMAP_NOOP;
+ /*
+ * This rmap filter is valid for vxlan tunnel type only.
+ * For any other tunnel type, return noop to ignore
+ * this check.
+ */
+ if (path->attr->encap_tunneltype != BGP_ENCAP_TYPE_VXLAN)
+ return RMAP_NOOP;
- /*
- * Apply filter to type 1, 2, 5 routes only.
- * Other route types do not have vni label.
- */
- if (evp && (evp->prefix.route_type != BGP_EVPN_AD_ROUTE &&
- evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE &&
- evp->prefix.route_type != BGP_EVPN_IP_PREFIX_ROUTE))
- return RMAP_NOOP;
+ /*
+ * Apply filter to type 1, 2, 5 routes only.
+ * Other route types do not have vni label.
+ */
+ if (evp
+ && (evp->prefix.route_type != BGP_EVPN_AD_ROUTE
+ && evp->prefix.route_type != BGP_EVPN_MAC_IP_ROUTE
+ && evp->prefix.route_type != BGP_EVPN_IP_PREFIX_ROUTE))
+ return RMAP_NOOP;
- if (path->extra == NULL)
- return RMAP_NOMATCH;
+ if (path->extra == NULL)
+ return RMAP_NOMATCH;
- for ( ; label_cnt < BGP_MAX_LABELS &&
- label_cnt < path->extra->num_labels; label_cnt++) {
- if (vni == label2vni(&path->extra->label[label_cnt]))
- return RMAP_MATCH;
- }
+ for (;
+ label_cnt < BGP_MAX_LABELS && label_cnt < path->extra->num_labels;
+ label_cnt++) {
+ if (vni == label2vni(&path->extra->label[label_cnt]))
+ return RMAP_MATCH;
}
return RMAP_NOMATCH;
/* Match function should return 1 if match is success else return
zero. */
static enum route_map_cmd_result_t
-route_match_evpn_route_type(void *rule, const struct prefix *pfx,
- route_map_object_t type, void *object)
+route_match_evpn_route_type(void *rule, const struct prefix *pfx, void *object)
{
uint8_t route_type = 0;
- if (type == RMAP_BGP) {
- route_type = *((uint8_t *)rule);
+ route_type = *((uint8_t *)rule);
- if (route_type == pfx->u.prefix_evpn.route_type)
- return RMAP_MATCH;
- }
+ if (route_type == pfx->u.prefix_evpn.route_type)
+ return RMAP_MATCH;
return RMAP_NOMATCH;
}
/* Match function should return 1 if match is success else return zero. */
static enum route_map_cmd_result_t
-route_match_rd(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_rd(void *rule, const struct prefix *prefix, void *object)
{
struct prefix_rd *prd_rule = NULL;
const struct prefix_rd *prd_route = NULL;
struct bgp_path_info *path = NULL;
- if (type == RMAP_BGP) {
- if (prefix->family != AF_EVPN)
- return RMAP_NOMATCH;
+ if (prefix->family != AF_EVPN)
+ return RMAP_NOMATCH;
- prd_rule = (struct prefix_rd *)rule;
- path = (struct bgp_path_info *)object;
+ prd_rule = (struct prefix_rd *)rule;
+ path = (struct bgp_path_info *)object;
- if (path->net == NULL || path->net->pdest == NULL)
- return RMAP_NOMATCH;
+ if (path->net == NULL || path->net->pdest == NULL)
+ return RMAP_NOMATCH;
- prd_route = (struct prefix_rd *)bgp_dest_get_prefix(
- path->net->pdest);
- if (memcmp(prd_route->val, prd_rule->val, ECOMMUNITY_SIZE) == 0)
- return RMAP_MATCH;
- }
+ prd_route = (struct prefix_rd *)bgp_dest_get_prefix(path->net->pdest);
+ if (memcmp(prd_route->val, prd_rule->val, ECOMMUNITY_SIZE) == 0)
+ return RMAP_MATCH;
return RMAP_NOMATCH;
}
/* Route map commands for VRF route leak with source vrf matching */
static enum route_map_cmd_result_t
route_match_vrl_source_vrf(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
struct bgp_path_info *path;
char *vrf_name;
- if (type == RMAP_BGP) {
- vrf_name = rule;
- path = (struct bgp_path_info *)object;
+ vrf_name = rule;
+ path = (struct bgp_path_info *)object;
- if (strncmp(vrf_name, "n/a", VRF_NAMSIZ) == 0)
- return RMAP_NOMATCH;
+ if (strncmp(vrf_name, "n/a", VRF_NAMSIZ) == 0)
+ return RMAP_NOMATCH;
- if (path->extra == NULL)
- return RMAP_NOMATCH;
+ if (path->extra == NULL)
+ return RMAP_NOMATCH;
- if (strncmp(vrf_name, vrf_id_to_name(
- path->extra->bgp_orig->vrf_id), VRF_NAMSIZ)
- == 0)
- return RMAP_MATCH;
- }
+ if (strncmp(vrf_name, vrf_id_to_name(path->extra->bgp_orig->vrf_id),
+ VRF_NAMSIZ)
+ == 0)
+ return RMAP_MATCH;
return RMAP_NOMATCH;
}
/* Match function return 1 if match is success else return zero. */
static enum route_map_cmd_result_t
-route_match_local_pref(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_local_pref(void *rule, const struct prefix *prefix, void *object)
{
uint32_t *local_pref;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- local_pref = rule;
- path = object;
+ local_pref = rule;
+ path = object;
- if (path->attr->local_pref == *local_pref)
- return RMAP_MATCH;
- else
- return RMAP_NOMATCH;
- }
- return RMAP_NOMATCH;
+ if (path->attr->local_pref == *local_pref)
+ return RMAP_MATCH;
+ else
+ return RMAP_NOMATCH;
}
/*
/* Match function return 1 if match is success else return zero. */
static enum route_map_cmd_result_t
-route_match_metric(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_metric(void *rule, const struct prefix *prefix, void *object)
{
struct rmap_value *rv;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- rv = rule;
- path = object;
- return route_value_match(rv, path->attr->med);
- }
- return RMAP_NOMATCH;
+ rv = rule;
+ path = object;
+ return route_value_match(rv, path->attr->med);
}
/* Route map commands for metric matching. */
/* Match function for as-path match. I assume given object is */
static enum route_map_cmd_result_t
-route_match_aspath(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_aspath(void *rule, const struct prefix *prefix, void *object)
{
struct as_list *as_list;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- as_list = as_list_lookup((char *)rule);
- if (as_list == NULL)
- return RMAP_NOMATCH;
+ as_list = as_list_lookup((char *)rule);
+ if (as_list == NULL)
+ return RMAP_NOMATCH;
- path = object;
+ path = object;
- /* Perform match. */
- return ((as_list_apply(as_list, path->attr->aspath)
- == AS_FILTER_DENY)
- ? RMAP_NOMATCH
- : RMAP_MATCH);
- }
- return RMAP_NOMATCH;
+ /* Perform match. */
+ return ((as_list_apply(as_list, path->attr->aspath) == AS_FILTER_DENY)
+ ? RMAP_NOMATCH
+ : RMAP_MATCH);
}
/* Compile function for as-path match. */
/* Match function for community match. */
static enum route_map_cmd_result_t
-route_match_community(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_community(void *rule, const struct prefix *prefix, void *object)
{
struct community_list *list;
struct bgp_path_info *path;
struct rmap_community *rcom = rule;
- if (type == RMAP_BGP) {
- path = object;
- rcom = rule;
+ path = object;
+ rcom = rule;
- list = community_list_lookup(bgp_clist, rcom->name,
- rcom->name_hash,
- COMMUNITY_LIST_MASTER);
- if (!list)
- return RMAP_NOMATCH;
+ list = community_list_lookup(bgp_clist, rcom->name, rcom->name_hash,
+ COMMUNITY_LIST_MASTER);
+ if (!list)
+ return RMAP_NOMATCH;
- if (rcom->exact) {
- if (community_list_exact_match(path->attr->community,
- list))
- return RMAP_MATCH;
- } else {
- if (community_list_match(path->attr->community, list))
- return RMAP_MATCH;
- }
+ if (rcom->exact) {
+ if (community_list_exact_match(path->attr->community, list))
+ return RMAP_MATCH;
+ } else {
+ if (community_list_match(path->attr->community, list))
+ return RMAP_MATCH;
}
+
return RMAP_NOMATCH;
}
/* Match function for lcommunity match. */
static enum route_map_cmd_result_t
-route_match_lcommunity(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_lcommunity(void *rule, const struct prefix *prefix, void *object)
{
struct community_list *list;
struct bgp_path_info *path;
struct rmap_community *rcom = rule;
- if (type == RMAP_BGP) {
- path = object;
+ path = object;
- list = community_list_lookup(bgp_clist, rcom->name,
- rcom->name_hash,
- LARGE_COMMUNITY_LIST_MASTER);
- if (!list)
- return RMAP_NOMATCH;
+ list = community_list_lookup(bgp_clist, rcom->name, rcom->name_hash,
+ LARGE_COMMUNITY_LIST_MASTER);
+ if (!list)
+ return RMAP_NOMATCH;
- if (rcom->exact) {
- if (lcommunity_list_exact_match(
- path->attr->lcommunity,
- list))
- return RMAP_MATCH;
- } else {
- if (lcommunity_list_match(
- path->attr->lcommunity,
- list))
- return RMAP_MATCH;
- }
+ if (rcom->exact) {
+ if (lcommunity_list_exact_match(path->attr->lcommunity, list))
+ return RMAP_MATCH;
+ } else {
+ if (lcommunity_list_match(path->attr->lcommunity, list))
+ return RMAP_MATCH;
}
+
return RMAP_NOMATCH;
}
/* Match function for extcommunity match. */
static enum route_map_cmd_result_t
-route_match_ecommunity(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_ecommunity(void *rule, const struct prefix *prefix, void *object)
{
struct community_list *list;
struct bgp_path_info *path;
struct rmap_community *rcom = rule;
- if (type == RMAP_BGP) {
- path = object;
+ path = object;
- list = community_list_lookup(bgp_clist, rcom->name,
- rcom->name_hash,
- EXTCOMMUNITY_LIST_MASTER);
- if (!list)
- return RMAP_NOMATCH;
+ list = community_list_lookup(bgp_clist, rcom->name, rcom->name_hash,
+ EXTCOMMUNITY_LIST_MASTER);
+ if (!list)
+ return RMAP_NOMATCH;
+
+ if (ecommunity_list_match(path->attr->ecommunity, list))
+ return RMAP_MATCH;
- if (ecommunity_list_match(path->attr->ecommunity, list))
- return RMAP_MATCH;
- }
return RMAP_NOMATCH;
}
/* `match origin' */
static enum route_map_cmd_result_t
-route_match_origin(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_origin(void *rule, const struct prefix *prefix, void *object)
{
uint8_t *origin;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- origin = rule;
- path = object;
+ origin = rule;
+ path = object;
- if (path->attr->origin == *origin)
- return RMAP_MATCH;
- }
+ if (path->attr->origin == *origin)
+ return RMAP_MATCH;
return RMAP_NOMATCH;
}
/* match probability { */
static enum route_map_cmd_result_t
-route_match_probability(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_probability(void *rule, const struct prefix *prefix, void *object)
{
long r = frr_weak_random();
/* Match function should return 1 if match is success else return
zero. */
static enum route_map_cmd_result_t
-route_match_interface(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_interface(void *rule, const struct prefix *prefix, void *object)
{
struct interface *ifp;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- path = object;
+ path = object;
- if (!path)
- return RMAP_NOMATCH;
+ if (!path)
+ return RMAP_NOMATCH;
- ifp = if_lookup_by_name_all_vrf((char *)rule);
+ ifp = if_lookup_by_name_all_vrf((char *)rule);
- if (ifp == NULL || ifp->ifindex != path->attr->nh_ifindex)
- return RMAP_NOMATCH;
+ if (ifp == NULL || ifp->ifindex != path->attr->nh_ifindex)
+ return RMAP_NOMATCH;
- return RMAP_MATCH;
- }
- return RMAP_NOMATCH;
+ return RMAP_MATCH;
}
/* Route map `interface' match statement. `arg' should be
/* Match function return 1 if match is success else return zero. */
static enum route_map_cmd_result_t
-route_match_tag(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_tag(void *rule, const struct prefix *prefix, void *object)
{
route_tag_t *tag;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- tag = rule;
- path = object;
-
- return ((path->attr->tag == *tag) ? RMAP_MATCH : RMAP_NOMATCH);
- }
+ tag = rule;
+ path = object;
- return RMAP_NOMATCH;
+ return ((path->attr->tag == *tag) ? RMAP_MATCH : RMAP_NOMATCH);
}
};
static enum route_map_cmd_result_t
-route_set_srte_color(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_srte_color(void *rule, const struct prefix *prefix, void *object)
{
uint32_t *srte_color = rule;
struct bgp_path_info *path;
- if (type != RMAP_BGP)
- return RMAP_OKAY;
-
path = object;
path->attr->srte_color = *srte_color;
};
static enum route_map_cmd_result_t
-route_set_ip_nexthop(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_ip_nexthop(void *rule, const struct prefix *prefix, void *object)
{
struct rmap_ip_nexthop_set *rins = rule;
struct bgp_path_info *path;
struct peer *peer;
- if (type != RMAP_BGP)
- return RMAP_OKAY;
-
if (prefix->family == AF_INET6)
return RMAP_OKAY;
/* Set local preference. */
static enum route_map_cmd_result_t
-route_set_local_pref(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_local_pref(void *rule, const struct prefix *prefix, void *object)
{
struct rmap_value *rv;
struct bgp_path_info *path;
uint32_t locpref = 0;
- if (type == RMAP_BGP) {
- /* Fetch routemap's rule information. */
- rv = rule;
- path = object;
+ /* Fetch routemap's rule information. */
+ rv = rule;
+ path = object;
- /* Set local preference value. */
- if (path->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
- locpref = path->attr->local_pref;
+ /* Set local preference value. */
+ if (path->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))
+ locpref = path->attr->local_pref;
- path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF);
- path->attr->local_pref =
- route_value_adjust(rv, locpref, path->peer);
- }
+ path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF);
+ path->attr->local_pref = route_value_adjust(rv, locpref, path->peer);
return RMAP_OKAY;
}
/* Set weight. */
static enum route_map_cmd_result_t
-route_set_weight(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_weight(void *rule, const struct prefix *prefix, void *object)
{
struct rmap_value *rv;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- /* Fetch routemap's rule information. */
- rv = rule;
- path = object;
+ /* Fetch routemap's rule information. */
+ rv = rule;
+ path = object;
- /* Set weight value. */
- path->attr->weight = route_value_adjust(rv, 0, path->peer);
- }
+ /* Set weight value. */
+ path->attr->weight = route_value_adjust(rv, 0, path->peer);
return RMAP_OKAY;
}
/* `set distance DISTANCE */
static enum route_map_cmd_result_t
-route_set_distance(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_distance(void *rule, const struct prefix *prefix, void *object)
{
struct bgp_path_info *path = object;
struct rmap_value *rv = rule;
- if (type != RMAP_BGP)
- return RMAP_OKAY;
-
path->attr->distance = rv->value;
return RMAP_OKAY;
/* Set metric to attribute. */
static enum route_map_cmd_result_t
-route_set_metric(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_metric(void *rule, const struct prefix *prefix, void *object)
{
struct rmap_value *rv;
struct bgp_path_info *path;
uint32_t med = 0;
- if (type == RMAP_BGP) {
- /* Fetch routemap's rule information. */
- rv = rule;
- path = object;
+ /* Fetch routemap's rule information. */
+ rv = rule;
+ path = object;
- if (path->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
- med = path->attr->med;
+ if (path->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))
+ med = path->attr->med;
+
+ path->attr->med = route_value_adjust(rv, med, path->peer);
+ path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC);
- path->attr->med = route_value_adjust(rv, med, path->peer);
- path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC);
- }
return RMAP_OKAY;
}
/* `set table (1-4294967295)' */
-static enum route_map_cmd_result_t route_set_table_id(void *rule,
- const struct prefix *prefix,
- route_map_object_t type,
- void *object)
+static enum route_map_cmd_result_t
+route_set_table_id(void *rule, const struct prefix *prefix,
+
+ void *object)
{
struct rmap_value *rv;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- /* Fetch routemap's rule information. */
- rv = rule;
- path = object;
+ /* Fetch routemap's rule information. */
+ rv = rule;
+ path = object;
+
+ path->attr->rmap_table_id = rv->value;
- path->attr->rmap_table_id = rv->value;
- }
return RMAP_OKAY;
}
/* For AS path prepend mechanism. */
static enum route_map_cmd_result_t
-route_set_aspath_prepend(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_aspath_prepend(void *rule, const struct prefix *prefix, void *object)
{
struct aspath *aspath;
struct aspath *new;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- path = object;
-
- if (path->attr->aspath->refcnt)
- new = aspath_dup(path->attr->aspath);
- else
- new = path->attr->aspath;
+ path = object;
- if ((uintptr_t)rule > 10) {
- aspath = rule;
- aspath_prepend(aspath, new);
- } else {
- as_t as = aspath_leftmost(new);
- if (!as)
- as = path->peer->as;
- new = aspath_add_seq_n(new, as, (uintptr_t)rule);
- }
+ if (path->attr->aspath->refcnt)
+ new = aspath_dup(path->attr->aspath);
+ else
+ new = path->attr->aspath;
- path->attr->aspath = new;
+ if ((uintptr_t)rule > 10) {
+ aspath = rule;
+ aspath_prepend(aspath, new);
+ } else {
+ as_t as = aspath_leftmost(new);
+ if (!as)
+ as = path->peer->as;
+ new = aspath_add_seq_n(new, as, (uintptr_t)rule);
}
+ path->attr->aspath = new;
+
return RMAP_OKAY;
}
* Make a deep copy of existing AS_PATH, but for the first ASn only.
*/
static enum route_map_cmd_result_t
-route_set_aspath_exclude(void *rule, const struct prefix *dummy,
- route_map_object_t type, void *object)
+route_set_aspath_exclude(void *rule, const struct prefix *dummy, void *object)
{
struct aspath *new_path, *exclude_path;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- exclude_path = rule;
- path = object;
- if (path->attr->aspath->refcnt)
- new_path = aspath_dup(path->attr->aspath);
- else
- new_path = path->attr->aspath;
- path->attr->aspath =
- aspath_filter_exclude(new_path, exclude_path);
- }
+ exclude_path = rule;
+ path = object;
+ if (path->attr->aspath->refcnt)
+ new_path = aspath_dup(path->attr->aspath);
+ else
+ new_path = path->attr->aspath;
+ path->attr->aspath = aspath_filter_exclude(new_path, exclude_path);
+
return RMAP_OKAY;
}
/* For community set mechanism. */
static enum route_map_cmd_result_t
-route_set_community(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_community(void *rule, const struct prefix *prefix, void *object)
{
struct rmap_com_set *rcs;
struct bgp_path_info *path;
struct community *old;
struct community *merge;
- if (type == RMAP_BGP) {
- rcs = rule;
- path = object;
- attr = path->attr;
- old = attr->community;
-
- /* "none" case. */
- if (rcs->none) {
- attr->flag &= ~(ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES));
- attr->community = NULL;
- /* See the longer comment down below. */
- if (old && old->refcnt == 0)
- community_free(&old);
- return RMAP_OKAY;
- }
+ rcs = rule;
+ path = object;
+ attr = path->attr;
+ old = attr->community;
+
+ /* "none" case. */
+ if (rcs->none) {
+ attr->flag &= ~(ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES));
+ attr->community = NULL;
+ /* See the longer comment down below. */
+ if (old && old->refcnt == 0)
+ community_free(&old);
+ return RMAP_OKAY;
+ }
- /* "additive" case. */
- if (rcs->additive && old) {
- merge = community_merge(community_dup(old), rcs->com);
+ /* "additive" case. */
+ if (rcs->additive && old) {
+ merge = community_merge(community_dup(old), rcs->com);
- new = community_uniq_sort(merge);
- community_free(&merge);
- } else
- new = community_dup(rcs->com);
+ new = community_uniq_sort(merge);
+ community_free(&merge);
+ } else
+ new = community_dup(rcs->com);
- /* HACK: if the old community is not intern'd,
- * we should free it here, or all reference to it may be
- * lost.
- * Really need to cleanup attribute caching sometime.
- */
- if (old && old->refcnt == 0)
- community_free(&old);
+ /* HACK: if the old community is not intern'd,
+ * we should free it here, or all reference to it may be
+ * lost.
+ * Really need to cleanup attribute caching sometime.
+ */
+ if (old && old->refcnt == 0)
+ community_free(&old);
- /* will be interned by caller if required */
- attr->community = new;
+ /* will be interned by caller if required */
+ attr->community = new;
- attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
- }
+ attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
return RMAP_OKAY;
}
/* For lcommunity set mechanism. */
static enum route_map_cmd_result_t
-route_set_lcommunity(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_lcommunity(void *rule, const struct prefix *prefix, void *object)
{
struct rmap_lcom_set *rcs;
struct bgp_path_info *path;
struct lcommunity *old;
struct lcommunity *merge;
- if (type == RMAP_BGP) {
- rcs = rule;
- path = object;
- attr = path->attr;
- old = attr->lcommunity;
-
- /* "none" case. */
- if (rcs->none) {
- attr->flag &=
- ~(ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES));
- attr->lcommunity = NULL;
-
- /* See the longer comment down below. */
- if (old && old->refcnt == 0)
- lcommunity_free(&old);
- return RMAP_OKAY;
- }
-
- if (rcs->additive && old) {
- merge = lcommunity_merge(lcommunity_dup(old),
- rcs->lcom);
+ rcs = rule;
+ path = object;
+ attr = path->attr;
+ old = attr->lcommunity;
- new = lcommunity_uniq_sort(merge);
- lcommunity_free(&merge);
- } else
- new = lcommunity_dup(rcs->lcom);
+ /* "none" case. */
+ if (rcs->none) {
+ attr->flag &= ~(ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES));
+ attr->lcommunity = NULL;
- /* HACK: if the old large-community is not intern'd,
- * we should free it here, or all reference to it may be
- * lost.
- * Really need to cleanup attribute caching sometime.
- */
+ /* See the longer comment down below. */
if (old && old->refcnt == 0)
lcommunity_free(&old);
+ return RMAP_OKAY;
+ }
- /* will be intern()'d or attr_flush()'d by bgp_update_main() */
- attr->lcommunity = new;
+ if (rcs->additive && old) {
+ merge = lcommunity_merge(lcommunity_dup(old), rcs->lcom);
- attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
- }
+ new = lcommunity_uniq_sort(merge);
+ lcommunity_free(&merge);
+ } else
+ new = lcommunity_dup(rcs->lcom);
+
+ /* HACK: if the old large-community is not intern'd,
+ * we should free it here, or all reference to it may be
+ * lost.
+ * Really need to cleanup attribute caching sometime.
+ */
+ if (old && old->refcnt == 0)
+ lcommunity_free(&old);
+
+ /* will be intern()'d or attr_flush()'d by bgp_update_main() */
+ attr->lcommunity = new;
+
+ attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
return RMAP_OKAY;
}
/* For large community set mechanism. */
static enum route_map_cmd_result_t
-route_set_lcommunity_delete(void *rule, const struct prefix *pfx,
- route_map_object_t type, void *object)
+route_set_lcommunity_delete(void *rule, const struct prefix *pfx, void *object)
{
struct community_list *list;
struct lcommunity *merge;
struct bgp_path_info *path;
struct rmap_community *rcom = rule;
- if (type == RMAP_BGP) {
- if (!rcom)
- return RMAP_OKAY;
+ if (!rcom)
+ return RMAP_OKAY;
- path = object;
- list = community_list_lookup(bgp_clist, rcom->name,
- rcom->name_hash,
- LARGE_COMMUNITY_LIST_MASTER);
- old = path->attr->lcommunity;
-
- if (list && old) {
- merge = lcommunity_list_match_delete(
- lcommunity_dup(old), list);
- new = lcommunity_uniq_sort(merge);
- lcommunity_free(&merge);
-
- /* HACK: if the old community is not intern'd,
- * we should free it here, or all reference to it may be
- * lost.
- * Really need to cleanup attribute caching sometime.
- */
- if (old->refcnt == 0)
- lcommunity_free(&old);
-
- if (new->size == 0) {
- path->attr->lcommunity = NULL;
- path->attr->flag &= ~ATTR_FLAG_BIT(
- BGP_ATTR_LARGE_COMMUNITIES);
- lcommunity_free(&new);
- } else {
- path->attr->lcommunity = new;
- path->attr->flag |= ATTR_FLAG_BIT(
- BGP_ATTR_LARGE_COMMUNITIES);
- }
+ path = object;
+ list = community_list_lookup(bgp_clist, rcom->name, rcom->name_hash,
+ LARGE_COMMUNITY_LIST_MASTER);
+ old = path->attr->lcommunity;
+
+ if (list && old) {
+ merge = lcommunity_list_match_delete(lcommunity_dup(old), list);
+ new = lcommunity_uniq_sort(merge);
+ lcommunity_free(&merge);
+
+ /* HACK: if the old community is not intern'd,
+ * we should free it here, or all reference to it may be
+ * lost.
+ * Really need to cleanup attribute caching sometime.
+ */
+ if (old->refcnt == 0)
+ lcommunity_free(&old);
+
+ if (new->size == 0) {
+ path->attr->lcommunity = NULL;
+ path->attr->flag &=
+ ~ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
+ lcommunity_free(&new);
+ } else {
+ path->attr->lcommunity = new;
+ path->attr->flag |=
+ ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES);
}
}
/* For community set mechanism. */
static enum route_map_cmd_result_t
route_set_community_delete(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
struct community_list *list;
struct community *merge;
struct bgp_path_info *path;
struct rmap_community *rcom = rule;
- if (type == RMAP_BGP) {
- if (!rcom)
- return RMAP_OKAY;
+ if (!rcom)
+ return RMAP_OKAY;
- path = object;
- list = community_list_lookup(bgp_clist, rcom->name,
- rcom->name_hash,
- COMMUNITY_LIST_MASTER);
- old = path->attr->community;
-
- if (list && old) {
- merge = community_list_match_delete(community_dup(old),
- list);
- new = community_uniq_sort(merge);
- community_free(&merge);
-
- /* HACK: if the old community is not intern'd,
- * we should free it here, or all reference to it may be
- * lost.
- * Really need to cleanup attribute caching sometime.
- */
- if (old->refcnt == 0)
- community_free(&old);
-
- if (new->size == 0) {
- path->attr->community = NULL;
- path->attr->flag &=
- ~ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
- community_free(&new);
- } else {
- path->attr->community = new;
- path->attr->flag |=
- ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
- }
+ path = object;
+ list = community_list_lookup(bgp_clist, rcom->name, rcom->name_hash,
+ COMMUNITY_LIST_MASTER);
+ old = path->attr->community;
+
+ if (list && old) {
+ merge = community_list_match_delete(community_dup(old), list);
+ new = community_uniq_sort(merge);
+ community_free(&merge);
+
+ /* HACK: if the old community is not intern'd,
+ * we should free it here, or all reference to it may be
+ * lost.
+ * Really need to cleanup attribute caching sometime.
+ */
+ if (old->refcnt == 0)
+ community_free(&old);
+
+ if (new->size == 0) {
+ path->attr->community = NULL;
+ path->attr->flag &=
+ ~ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
+ community_free(&new);
+ } else {
+ path->attr->community = new;
+ path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES);
}
}
/* For community set mechanism. Used by _rt and _soo. */
static enum route_map_cmd_result_t
-route_set_ecommunity(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_ecommunity(void *rule, const struct prefix *prefix, void *object)
{
struct ecommunity *ecom;
struct ecommunity *new_ecom;
struct ecommunity *old_ecom;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- ecom = rule;
- path = object;
+ ecom = rule;
+ path = object;
- if (!ecom)
- return RMAP_OKAY;
+ if (!ecom)
+ return RMAP_OKAY;
- /* We assume additive for Extended Community. */
- old_ecom = path->attr->ecommunity;
+ /* We assume additive for Extended Community. */
+ old_ecom = path->attr->ecommunity;
- if (old_ecom) {
- new_ecom = ecommunity_merge(ecommunity_dup(old_ecom),
- ecom);
+ if (old_ecom) {
+ new_ecom = ecommunity_merge(ecommunity_dup(old_ecom), ecom);
- /* old_ecom->refcnt = 1 => owned elsewhere, e.g.
- * bgp_update_receive()
- * ->refcnt = 0 => set by a previous route-map
- * statement */
- if (!old_ecom->refcnt)
- ecommunity_free(&old_ecom);
- } else
- new_ecom = ecommunity_dup(ecom);
+ /* old_ecom->refcnt = 1 => owned elsewhere, e.g.
+ * bgp_update_receive()
+ * ->refcnt = 0 => set by a previous route-map
+ * statement */
+ if (!old_ecom->refcnt)
+ ecommunity_free(&old_ecom);
+ } else
+ new_ecom = ecommunity_dup(ecom);
- /* will be intern()'d or attr_flush()'d by bgp_update_main() */
- path->attr->ecommunity = new_ecom;
+ /* will be intern()'d or attr_flush()'d by bgp_update_main() */
+ path->attr->ecommunity = new_ecom;
+
+ path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
- path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);
- }
return RMAP_OKAY;
}
};
static enum route_map_cmd_result_t
-route_set_ecommunity_lb(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_ecommunity_lb(void *rule, const struct prefix *prefix, void *object)
{
struct rmap_ecomm_lb_set *rels = rule;
struct bgp_path_info *path;
struct ecommunity *old_ecom;
as_t as;
- if (type != RMAP_BGP)
- return RMAP_OKAY;
-
path = object;
peer = path->peer;
if (!peer || !peer->bgp)
/* For origin set. */
static enum route_map_cmd_result_t
-route_set_origin(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_origin(void *rule, const struct prefix *prefix, void *object)
{
uint8_t *origin;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- origin = rule;
- path = object;
+ origin = rule;
+ path = object;
- path->attr->origin = *origin;
- }
+ path->attr->origin = *origin;
return RMAP_OKAY;
}
/* For atomic aggregate set. */
static enum route_map_cmd_result_t
-route_set_atomic_aggregate(void *rule, const struct prefix *pfx,
- route_map_object_t type, void *object)
+route_set_atomic_aggregate(void *rule, const struct prefix *pfx, void *object)
{
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- path = object;
- path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE);
- }
+ path = object;
+ path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE);
return RMAP_OKAY;
}
};
static enum route_map_cmd_result_t
-route_set_aggregator_as(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_aggregator_as(void *rule, const struct prefix *prefix, void *object)
{
struct bgp_path_info *path;
struct aggregator *aggregator;
- if (type == RMAP_BGP) {
- path = object;
- aggregator = rule;
+ path = object;
+ aggregator = rule;
- path->attr->aggregator_as = aggregator->as;
- path->attr->aggregator_addr = aggregator->address;
- path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR);
- }
+ path->attr->aggregator_as = aggregator->as;
+ path->attr->aggregator_addr = aggregator->address;
+ path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR);
return RMAP_OKAY;
}
/* Set tag to object. object must be pointer to struct bgp_path_info */
static enum route_map_cmd_result_t
-route_set_tag(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_tag(void *rule, const struct prefix *prefix, void *object)
{
route_tag_t *tag;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- tag = rule;
- path = object;
+ tag = rule;
+ path = object;
- /* Set tag value */
- path->attr->tag = *tag;
- }
+ /* Set tag value */
+ path->attr->tag = *tag;
return RMAP_OKAY;
}
/* Set label-index to object. object must be pointer to struct bgp_path_info */
static enum route_map_cmd_result_t
-route_set_label_index(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_label_index(void *rule, const struct prefix *prefix, void *object)
{
struct rmap_value *rv;
struct bgp_path_info *path;
uint32_t label_index;
- if (type == RMAP_BGP) {
- /* Fetch routemap's rule information. */
- rv = rule;
- path = object;
+ /* Fetch routemap's rule information. */
+ rv = rule;
+ path = object;
- /* Set label-index value. */
- label_index = rv->value;
- if (label_index) {
- path->attr->label_index = label_index;
- path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID);
- }
+ /* Set label-index value. */
+ label_index = rv->value;
+ if (label_index) {
+ path->attr->label_index = label_index;
+ path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID);
}
return RMAP_OKAY;
/* `match ipv6 address IP_ACCESS_LIST' */
static enum route_map_cmd_result_t
-route_match_ipv6_address(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_ipv6_address(void *rule, const struct prefix *prefix, void *object)
{
struct access_list *alist;
- if (type == RMAP_BGP && prefix->family == AF_INET6) {
+ if (prefix->family == AF_INET6) {
alist = access_list_lookup(AFI_IP6, (char *)rule);
if (alist == NULL)
return RMAP_NOMATCH;
/* `match ipv6 next-hop IP_ADDRESS' */
static enum route_map_cmd_result_t
-route_match_ipv6_next_hop(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_ipv6_next_hop(void *rule, const struct prefix *prefix, void *object)
{
struct in6_addr *addr = rule;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- path = object;
-
- if (IPV6_ADDR_SAME(&path->attr->mp_nexthop_global, addr))
- return RMAP_MATCH;
+ path = object;
- if (path->attr->mp_nexthop_len
- == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
- && IPV6_ADDR_SAME(&path->attr->mp_nexthop_local, rule))
- return RMAP_MATCH;
+ if (IPV6_ADDR_SAME(&path->attr->mp_nexthop_global, addr))
+ return RMAP_MATCH;
- return RMAP_NOMATCH;
- }
+ if (path->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL
+ && IPV6_ADDR_SAME(&path->attr->mp_nexthop_local, rule))
+ return RMAP_MATCH;
return RMAP_NOMATCH;
}
/* `match ip next-hop IP_ADDRESS' */
static enum route_map_cmd_result_t
-route_match_ipv4_next_hop(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_ipv4_next_hop(void *rule, const struct prefix *prefix, void *object)
{
struct in_addr *addr = rule;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- path = object;
-
- if (path->attr->nexthop.s_addr == addr->s_addr ||
- (path->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4 &&
- IPV4_ADDR_SAME(&path->attr->mp_nexthop_global_in, addr)))
- return RMAP_MATCH;
+ path = object;
- return RMAP_NOMATCH;
- }
+ if (path->attr->nexthop.s_addr == addr->s_addr
+ || (path->attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4
+ && IPV4_ADDR_SAME(&path->attr->mp_nexthop_global_in, addr)))
+ return RMAP_MATCH;
return RMAP_NOMATCH;
}
static enum route_map_cmd_result_t
route_match_ipv6_address_prefix_list(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
- return route_match_address_prefix_list(rule, AFI_IP6, prefix, type,
- object);
+ return route_match_address_prefix_list(rule, AFI_IP6, prefix, object);
}
static void *route_match_ipv6_address_prefix_list_compile(const char *arg)
static enum route_map_cmd_result_t
route_match_ipv6_next_hop_type(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
struct bgp_path_info *path;
struct in6_addr *addr = rule;
- if (type == RMAP_BGP && prefix->family == AF_INET6) {
+ if (prefix->family == AF_INET6) {
path = (struct bgp_path_info *)object;
if (!path)
return RMAP_NOMATCH;
&& !path->attr->nh_ifindex)
return RMAP_MATCH;
}
+
return RMAP_NOMATCH;
}
/* Set nexthop to object. ojbect must be pointer to struct attr. */
static enum route_map_cmd_result_t
-route_set_ipv6_nexthop_global(void *rule, const struct prefix *p,
- route_map_object_t type, void *object)
+route_set_ipv6_nexthop_global(void *rule, const struct prefix *p, void *object)
{
struct in6_addr *address;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- /* Fetch routemap's rule information. */
- address = rule;
- path = object;
+ /* Fetch routemap's rule information. */
+ address = rule;
+ path = object;
- /* Set next hop value. */
- path->attr->mp_nexthop_global = *address;
+ /* Set next hop value. */
+ path->attr->mp_nexthop_global = *address;
- /* Set nexthop length. */
- if (path->attr->mp_nexthop_len == 0)
- path->attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL;
+ /* Set nexthop length. */
+ if (path->attr->mp_nexthop_len == 0)
+ path->attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL;
- SET_FLAG(path->attr->rmap_change_flags,
- BATTR_RMAP_IPV6_GLOBAL_NHOP_CHANGED);
- }
+ SET_FLAG(path->attr->rmap_change_flags,
+ BATTR_RMAP_IPV6_GLOBAL_NHOP_CHANGED);
return RMAP_OKAY;
}
/* Set next-hop preference value. */
static enum route_map_cmd_result_t
route_set_ipv6_nexthop_prefer_global(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
struct bgp_path_info *path;
struct peer *peer;
- if (type == RMAP_BGP) {
- /* Fetch routemap's rule information. */
- path = object;
- peer = path->peer;
+ /* Fetch routemap's rule information. */
+ path = object;
+ peer = path->peer;
- if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)
- || CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IMPORT)) {
- /* Set next hop preference to global */
- path->attr->mp_nexthop_prefer_global = true;
- SET_FLAG(path->attr->rmap_change_flags,
- BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED);
- } else {
- path->attr->mp_nexthop_prefer_global = false;
- SET_FLAG(path->attr->rmap_change_flags,
- BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED);
- }
+ if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)
+ || CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IMPORT)) {
+ /* Set next hop preference to global */
+ path->attr->mp_nexthop_prefer_global = true;
+ SET_FLAG(path->attr->rmap_change_flags,
+ BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED);
+ } else {
+ path->attr->mp_nexthop_prefer_global = false;
+ SET_FLAG(path->attr->rmap_change_flags,
+ BATTR_RMAP_IPV6_PREFER_GLOBAL_CHANGED);
}
+
return RMAP_OKAY;
}
/* Set nexthop to object. ojbect must be pointer to struct attr. */
static enum route_map_cmd_result_t
-route_set_ipv6_nexthop_local(void *rule, const struct prefix *p,
- route_map_object_t type, void *object)
+route_set_ipv6_nexthop_local(void *rule, const struct prefix *p, void *object)
{
struct in6_addr *address;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- /* Fetch routemap's rule information. */
- address = rule;
- path = object;
+ /* Fetch routemap's rule information. */
+ address = rule;
+ path = object;
- /* Set next hop value. */
- path->attr->mp_nexthop_local = *address;
+ /* Set next hop value. */
+ path->attr->mp_nexthop_local = *address;
- /* Set nexthop length. */
- if (path->attr->mp_nexthop_len
- != BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
- path->attr->mp_nexthop_len =
- BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL;
+ /* Set nexthop length. */
+ if (path->attr->mp_nexthop_len != BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
+ path->attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL;
- SET_FLAG(path->attr->rmap_change_flags,
- BATTR_RMAP_IPV6_LL_NHOP_CHANGED);
- }
+ SET_FLAG(path->attr->rmap_change_flags,
+ BATTR_RMAP_IPV6_LL_NHOP_CHANGED);
return RMAP_OKAY;
}
/* Set nexthop to object. ojbect must be pointer to struct attr. */
static enum route_map_cmd_result_t
-route_set_ipv6_nexthop_peer(void *rule, const struct prefix *pfx,
- route_map_object_t type, void *object)
+route_set_ipv6_nexthop_peer(void *rule, const struct prefix *pfx, void *object)
{
struct in6_addr peer_address;
struct bgp_path_info *path;
struct peer *peer;
- if (type == RMAP_BGP) {
- /* Fetch routemap's rule information. */
- 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) {
- peer_address = peer->su_remote->sin6.sin6_addr;
- /* Set next hop value and length in attribute. */
- if (IN6_IS_ADDR_LINKLOCAL(&peer_address)) {
- path->attr->mp_nexthop_local = peer_address;
- if (path->attr->mp_nexthop_len
- != BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
- path->attr->mp_nexthop_len =
- BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL;
- } else {
- path->attr->mp_nexthop_global = peer_address;
- if (path->attr->mp_nexthop_len == 0)
- path->attr->mp_nexthop_len =
- BGP_ATTR_NHLEN_IPV6_GLOBAL;
- }
+ /* Fetch routemap's rule information. */
+ path = object;
+ peer = path->peer;
- } else if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_OUT)) {
- /* The next hop value will be set as part of packet
- * rewrite.
- * Set the flags here to indicate that rewrite needs to
- * be done.
- * Also, clear the value - we clear both global and
- * link-local
- * nexthops, whether we send one or both is determined
- * elsewhere.
- */
- SET_FLAG(path->attr->rmap_change_flags,
- BATTR_RMAP_NEXTHOP_PEER_ADDRESS);
- /* clear next hop value. */
- memset(&(path->attr->mp_nexthop_global), 0,
- sizeof(struct in6_addr));
- memset(&(path->attr->mp_nexthop_local), 0,
- sizeof(struct in6_addr));
+ 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) {
+ peer_address = peer->su_remote->sin6.sin6_addr;
+ /* Set next hop value and length in attribute. */
+ if (IN6_IS_ADDR_LINKLOCAL(&peer_address)) {
+ path->attr->mp_nexthop_local = peer_address;
+ if (path->attr->mp_nexthop_len
+ != BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
+ path->attr->mp_nexthop_len =
+ BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL;
+ } else {
+ path->attr->mp_nexthop_global = peer_address;
+ if (path->attr->mp_nexthop_len == 0)
+ 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.
+ * Set the flags here to indicate that rewrite needs to
+ * be done.
+ * Also, clear the value - we clear both global and
+ * link-local
+ * nexthops, whether we send one or both is determined
+ * elsewhere.
+ */
+ SET_FLAG(path->attr->rmap_change_flags,
+ BATTR_RMAP_NEXTHOP_PEER_ADDRESS);
+ /* clear next hop value. */
+ memset(&(path->attr->mp_nexthop_global), 0,
+ sizeof(struct in6_addr));
+ memset(&(path->attr->mp_nexthop_local), 0,
+ sizeof(struct in6_addr));
}
return RMAP_OKAY;
/* `set ipv4 vpn next-hop A.B.C.D' */
static enum route_map_cmd_result_t
-route_set_vpnv4_nexthop(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_vpnv4_nexthop(void *rule, const struct prefix *prefix, void *object)
{
struct in_addr *address;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- /* Fetch routemap's rule information. */
- address = rule;
- path = object;
+ /* Fetch routemap's rule information. */
+ address = rule;
+ path = object;
- /* Set next hop value. */
- path->attr->mp_nexthop_global_in = *address;
- path->attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV4;
- }
+ /* Set next hop value. */
+ path->attr->mp_nexthop_global_in = *address;
+ path->attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV4;
return RMAP_OKAY;
}
/* `set ipv6 vpn next-hop A.B.C.D' */
static enum route_map_cmd_result_t
-route_set_vpnv6_nexthop(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_vpnv6_nexthop(void *rule, const struct prefix *prefix, void *object)
{
struct in6_addr *address;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- /* Fetch routemap's rule information. */
- address = rule;
- path = object;
+ /* Fetch routemap's rule information. */
+ address = rule;
+ path = object;
- /* Set next hop value. */
- memcpy(&path->attr->mp_nexthop_global, address,
- sizeof(struct in6_addr));
- path->attr->mp_nexthop_len = BGP_ATTR_NHLEN_VPNV6_GLOBAL;
- }
+ /* Set next hop value. */
+ memcpy(&path->attr->mp_nexthop_global, address,
+ sizeof(struct in6_addr));
+ path->attr->mp_nexthop_len = BGP_ATTR_NHLEN_VPNV6_GLOBAL;
return RMAP_OKAY;
}
/* For origin set. */
static enum route_map_cmd_result_t
-route_set_originator_id(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_set_originator_id(void *rule, const struct prefix *prefix, void *object)
{
struct in_addr *address;
struct bgp_path_info *path;
- if (type == RMAP_BGP) {
- address = rule;
- path = object;
+ address = rule;
+ path = object;
- path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID);
- path->attr->originator_id = *address;
- }
+ path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID);
+ path->attr->originator_id = *address;
return RMAP_OKAY;
}
* Match function return 1 if match is success else return 0
*/
static enum route_map_cmd_result_t
-route_match_tag(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_tag(void *rule, const struct prefix *prefix, void *object)
{
route_tag_t *tag;
struct nh_rmap_obj *nh_data;
- if (type == RMAP_ZEBRA) {
- tag = rule;
- nh_data = object;
+ tag = rule;
+ nh_data = object;
+
+ if (nh_data->tag == *tag)
+ return RMAP_MATCH;
- if (nh_data->tag == *tag)
- return RMAP_MATCH;
- }
return RMAP_NOMATCH;
}
/* `match interface IFNAME' */
/* Match function return 1 if match is success else return zero. */
static enum route_map_cmd_result_t
-route_match_interface(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_interface(void *rule, const struct prefix *prefix, void *object)
{
struct nh_rmap_obj *nh_data;
char *ifname = rule;
ifindex_t ifindex;
- if (type == RMAP_ZEBRA) {
- if (strcasecmp(ifname, "any") == 0)
- return RMAP_MATCH;
- nh_data = object;
- if (!nh_data || !nh_data->nexthop)
- return RMAP_NOMATCH;
- ifindex = ifname2ifindex(ifname, nh_data->vrf_id);
- if (ifindex == 0)
- return RMAP_NOMATCH;
- if (nh_data->nexthop->ifindex == ifindex)
- return RMAP_MATCH;
- }
+ if (strcasecmp(ifname, "any") == 0)
+ return RMAP_MATCH;
+ nh_data = object;
+ if (!nh_data || !nh_data->nexthop)
+ return RMAP_NOMATCH;
+ ifindex = ifname2ifindex(ifname, nh_data->vrf_id);
+ if (ifindex == 0)
+ return RMAP_NOMATCH;
+ if (nh_data->nexthop->ifindex == ifindex)
+ return RMAP_MATCH;
+
return RMAP_NOMATCH;
}
/* Match function return 1 if match is success else return zero. */
static enum route_map_cmd_result_t
-route_match_ip_next_hop(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_ip_next_hop(void *rule, const struct prefix *prefix, void *object)
{
struct access_list *alist;
struct nh_rmap_obj *nh_data;
struct prefix_ipv4 p;
- if (type == RMAP_ZEBRA) {
- nh_data = object;
- if (!nh_data)
- return RMAP_NOMATCH;
-
- switch (nh_data->nexthop->type) {
- case NEXTHOP_TYPE_IFINDEX:
- /* Interface routes can't match ip next-hop */
- return RMAP_NOMATCH;
- case NEXTHOP_TYPE_IPV4_IFINDEX:
- case NEXTHOP_TYPE_IPV4:
- p.family = AF_INET;
- p.prefix = nh_data->nexthop->gate.ipv4;
- p.prefixlen = IPV4_MAX_BITLEN;
- break;
- default:
- return RMAP_NOMATCH;
- }
- alist = access_list_lookup(AFI_IP, (char *)rule);
- if (alist == NULL)
- return RMAP_NOMATCH;
+ nh_data = object;
+ if (!nh_data)
+ return RMAP_NOMATCH;
- return (access_list_apply(alist, &p) == FILTER_DENY
- ? RMAP_NOMATCH
- : RMAP_MATCH);
+ switch (nh_data->nexthop->type) {
+ case NEXTHOP_TYPE_IFINDEX:
+ /* Interface routes can't match ip next-hop */
+ return RMAP_NOMATCH;
+ case NEXTHOP_TYPE_IPV4_IFINDEX:
+ case NEXTHOP_TYPE_IPV4:
+ p.family = AF_INET;
+ p.prefix = nh_data->nexthop->gate.ipv4;
+ p.prefixlen = IPV4_MAX_BITLEN;
+ break;
+ default:
+ return RMAP_NOMATCH;
}
- return RMAP_NOMATCH;
+ alist = access_list_lookup(AFI_IP, (char *)rule);
+ if (alist == NULL)
+ return RMAP_NOMATCH;
+
+ return (access_list_apply(alist, &p) == FILTER_DENY ? RMAP_NOMATCH
+ : RMAP_MATCH);
}
/* Route map `ip next-hop' match statement. `arg' should be
static enum route_map_cmd_result_t
route_match_ip_next_hop_prefix_list(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
struct prefix_list *plist;
struct nh_rmap_obj *nh_data;
struct prefix_ipv4 p;
- if (type == RMAP_ZEBRA) {
- nh_data = (struct nh_rmap_obj *)object;
- if (!nh_data)
- return RMAP_NOMATCH;
-
- switch (nh_data->nexthop->type) {
- case NEXTHOP_TYPE_IFINDEX:
- /* Interface routes can't match ip next-hop */
- return RMAP_NOMATCH;
- case NEXTHOP_TYPE_IPV4_IFINDEX:
- case NEXTHOP_TYPE_IPV4:
- p.family = AF_INET;
- p.prefix = nh_data->nexthop->gate.ipv4;
- p.prefixlen = IPV4_MAX_BITLEN;
- break;
- default:
- return RMAP_NOMATCH;
- }
- plist = prefix_list_lookup(AFI_IP, (char *)rule);
- if (plist == NULL)
- return RMAP_NOMATCH;
+ nh_data = (struct nh_rmap_obj *)object;
+ if (!nh_data)
+ return RMAP_NOMATCH;
- return (prefix_list_apply(plist, &p) == PREFIX_DENY
- ? RMAP_NOMATCH
- : RMAP_MATCH);
+ switch (nh_data->nexthop->type) {
+ case NEXTHOP_TYPE_IFINDEX:
+ /* Interface routes can't match ip next-hop */
+ return RMAP_NOMATCH;
+ case NEXTHOP_TYPE_IPV4_IFINDEX:
+ case NEXTHOP_TYPE_IPV4:
+ p.family = AF_INET;
+ p.prefix = nh_data->nexthop->gate.ipv4;
+ p.prefixlen = IPV4_MAX_BITLEN;
+ break;
+ default:
+ return RMAP_NOMATCH;
}
- return RMAP_NOMATCH;
+ plist = prefix_list_lookup(AFI_IP, (char *)rule);
+ if (plist == NULL)
+ return RMAP_NOMATCH;
+
+ return (prefix_list_apply(plist, &p) == PREFIX_DENY ? RMAP_NOMATCH
+ : RMAP_MATCH);
}
static void *route_match_ip_next_hop_prefix_list_compile(const char *arg)
zero. */
static enum route_map_cmd_result_t
route_match_address(afi_t afi, void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
struct access_list *alist;
- if (type == RMAP_ZEBRA) {
- alist = access_list_lookup(afi, (char *)rule);
- if (alist == NULL)
- return RMAP_NOMATCH;
+ alist = access_list_lookup(afi, (char *)rule);
+ if (alist == NULL)
+ return RMAP_NOMATCH;
- return (access_list_apply(alist, prefix) == FILTER_DENY
- ? RMAP_NOMATCH
- : RMAP_MATCH);
- }
- return RMAP_NOMATCH;
+ return (access_list_apply(alist, prefix) == FILTER_DENY ? RMAP_NOMATCH
+ : RMAP_MATCH);
}
static enum route_map_cmd_result_t
-route_match_ip_address(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_ip_address(void *rule, const struct prefix *prefix, void *object)
{
- return route_match_address(AFI_IP, rule, prefix, type, object);
+ return route_match_address(AFI_IP, rule, prefix, object);
}
static enum route_map_cmd_result_t
-route_match_ipv6_address(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_ipv6_address(void *rule, const struct prefix *prefix, void *object)
{
- return route_match_address(AFI_IP6, rule, prefix, type, object);
+ return route_match_address(AFI_IP6, rule, prefix, object);
}
/* Route map `ip address' match statement. `arg' should be
static enum route_map_cmd_result_t
route_match_address_prefix_list(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object, afi_t afi)
+ void *object, afi_t afi)
{
struct prefix_list *plist;
- if (type == RMAP_ZEBRA) {
- plist = prefix_list_lookup(afi, (char *)rule);
- if (plist == NULL)
- return RMAP_NOMATCH;
+ plist = prefix_list_lookup(afi, (char *)rule);
+ if (plist == NULL)
+ return RMAP_NOMATCH;
- return (prefix_list_apply(plist, prefix) == PREFIX_DENY
- ? RMAP_NOMATCH
- : RMAP_MATCH);
- }
- return RMAP_NOMATCH;
+ return (prefix_list_apply(plist, prefix) == PREFIX_DENY ? RMAP_NOMATCH
+ : RMAP_MATCH);
}
static enum route_map_cmd_result_t
route_match_ip_address_prefix_list(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
- return (route_match_address_prefix_list(rule, prefix, type, object,
- AFI_IP));
+ return (route_match_address_prefix_list(rule, prefix, object, AFI_IP));
}
static void *route_match_address_prefix_list_compile(const char *arg)
static enum route_map_cmd_result_t
route_match_ipv6_address_prefix_list(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
- return (route_match_address_prefix_list(rule, prefix, type, object,
- AFI_IP6));
+ return (route_match_address_prefix_list(rule, prefix, object, AFI_IP6));
}
static const struct route_map_rule_cmd
static enum route_map_cmd_result_t
route_match_ipv6_next_hop_type(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
struct nh_rmap_obj *nh_data;
- if (type == RMAP_ZEBRA && prefix->family == AF_INET6) {
+ if (prefix->family == AF_INET6) {
nh_data = (struct nh_rmap_obj *)object;
if (!nh_data)
return RMAP_NOMATCH;
if (nh_data->nexthop->type == NEXTHOP_TYPE_BLACKHOLE)
return RMAP_MATCH;
}
+
return RMAP_NOMATCH;
}
static enum route_map_cmd_result_t
route_match_address_prefix_len(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
uint32_t *prefixlen = (uint32_t *)rule;
- if (type == RMAP_ZEBRA) {
- return ((prefix->prefixlen == *prefixlen) ? RMAP_MATCH
- : RMAP_NOMATCH);
- }
- return RMAP_NOMATCH;
+ return ((prefix->prefixlen == *prefixlen) ? RMAP_MATCH : RMAP_NOMATCH);
}
static void *route_match_address_prefix_len_compile(const char *arg)
static enum route_map_cmd_result_t
route_match_ip_nexthop_prefix_len(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
uint32_t *prefixlen = (uint32_t *)rule;
struct nh_rmap_obj *nh_data;
struct prefix_ipv4 p;
- if (type == RMAP_ZEBRA) {
- nh_data = (struct nh_rmap_obj *)object;
- if (!nh_data || !nh_data->nexthop)
- return RMAP_NOMATCH;
+ nh_data = (struct nh_rmap_obj *)object;
+ if (!nh_data || !nh_data->nexthop)
+ return RMAP_NOMATCH;
- switch (nh_data->nexthop->type) {
- case NEXTHOP_TYPE_IFINDEX:
- /* Interface routes can't match ip next-hop */
- return RMAP_NOMATCH;
- case NEXTHOP_TYPE_IPV4_IFINDEX:
- case NEXTHOP_TYPE_IPV4:
- p.family = AF_INET;
- p.prefix = nh_data->nexthop->gate.ipv4;
- p.prefixlen = IPV4_MAX_BITLEN;
- break;
- default:
- return RMAP_NOMATCH;
- }
- return ((p.prefixlen == *prefixlen) ? RMAP_MATCH
- : RMAP_NOMATCH);
+ switch (nh_data->nexthop->type) {
+ case NEXTHOP_TYPE_IFINDEX:
+ /* Interface routes can't match ip next-hop */
+ return RMAP_NOMATCH;
+ case NEXTHOP_TYPE_IPV4_IFINDEX:
+ case NEXTHOP_TYPE_IPV4:
+ p.family = AF_INET;
+ p.prefix = nh_data->nexthop->gate.ipv4;
+ p.prefixlen = IPV4_MAX_BITLEN;
+ break;
+ default:
+ return RMAP_NOMATCH;
}
- return RMAP_NOMATCH;
+ return ((p.prefixlen == *prefixlen) ? RMAP_MATCH : RMAP_NOMATCH);
}
static const struct route_map_rule_cmd
static enum route_map_cmd_result_t
route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
- route_map_object_t type, void *object)
+ void *object)
{
struct nh_rmap_obj *nh_data;
- if (type == RMAP_ZEBRA && prefix->family == AF_INET) {
+ if (prefix->family == AF_INET) {
nh_data = (struct nh_rmap_obj *)object;
if (!nh_data)
return RMAP_NOMATCH;
if (nh_data->nexthop->type == NEXTHOP_TYPE_BLACKHOLE)
return RMAP_MATCH;
}
+
return RMAP_NOMATCH;
}
/* `match source-protocol PROTOCOL' */
static enum route_map_cmd_result_t
-route_match_source_protocol(void *rule, const struct prefix *p,
- route_map_object_t type, void *object)
+route_match_source_protocol(void *rule, const struct prefix *p, void *object)
{
uint32_t *rib_type = (uint32_t *)rule;
struct nh_rmap_obj *nh_data;
- if (type == RMAP_ZEBRA) {
- nh_data = (struct nh_rmap_obj *)object;
- if (!nh_data)
- return RMAP_NOMATCH;
+ nh_data = (struct nh_rmap_obj *)object;
+ if (!nh_data)
+ return RMAP_NOMATCH;
- return ((nh_data->source_protocol == *rib_type) ? RMAP_MATCH
- : RMAP_NOMATCH);
- }
- return RMAP_NOMATCH;
+ return ((nh_data->source_protocol == *rib_type) ? RMAP_MATCH
+ : RMAP_NOMATCH);
}
static void *route_match_source_protocol_compile(const char *arg)
/* `source-instance` */
static enum route_map_cmd_result_t
-route_match_source_instance(void *rule, const struct prefix *p,
- route_map_object_t type, void *object)
+route_match_source_instance(void *rule, const struct prefix *p, void *object)
{
uint8_t *instance = (uint8_t *)rule;
struct nh_rmap_obj *nh_data;
- if (type != RMAP_ZEBRA)
- return RMAP_NOMATCH;
-
nh_data = (struct nh_rmap_obj *)object;
if (!nh_data)
return RMAP_NOMATCH;
/* Set src. */
static enum route_map_cmd_result_t
-route_set_src(void *rule, const struct prefix *prefix, route_map_object_t type,
- void *object)
+route_set_src(void *rule, const struct prefix *prefix, void *object)
{
struct nh_rmap_obj *nh_data;
- if (type == RMAP_ZEBRA) {
- nh_data = (struct nh_rmap_obj *)object;
- nh_data->nexthop->rmap_src = *(union g_addr *)rule;
- }
+ nh_data = (struct nh_rmap_obj *)object;
+ nh_data->nexthop->rmap_src = *(union g_addr *)rule;
+
return RMAP_OKAY;
}
if (!rmap && PROTO_RM_NAME(zvrf, family, ZEBRA_ROUTE_MAX))
rmap = PROTO_RM_MAP(zvrf, family, ZEBRA_ROUTE_MAX);
if (rmap) {
- ret = route_map_apply(rmap, p, RMAP_ZEBRA, &nh_obj);
+ ret = route_map_apply(rmap, p, &nh_obj);
}
return (ret);
if (re_type >= 0 && re_type < ZEBRA_ROUTE_MAX)
rmap = route_map_lookup_by_name(rmap_name);
if (rmap) {
- ret = route_map_apply(rmap, p, RMAP_ZEBRA, &nh_obj);
+ ret = route_map_apply(rmap, p, &nh_obj);
}
return (ret);
if (!rmap && NHT_RM_MAP(zvrf, afi, ZEBRA_ROUTE_MAX))
rmap = NHT_RM_MAP(zvrf, afi, ZEBRA_ROUTE_MAX);
if (rmap)
- ret = route_map_apply(rmap, p, RMAP_ZEBRA, &nh_obj);
+ ret = route_map_apply(rmap, p, &nh_obj);
return ret;
}