origin : Done
tag : Done
weight : Done
+ table : Done
o Local extensions
}
/* Route map commands for ip address matching. */
-struct route_map_rule_cmd route_match_peer_cmd = {"peer", route_match_peer,
- route_match_peer_compile,
- route_match_peer_free};
+static const struct route_map_rule_cmd route_match_peer_cmd = {
+ "peer",
+ route_match_peer,
+ route_match_peer_compile,
+ route_match_peer_free
+};
#if defined(HAVE_LUA)
static enum route_map_cmd_result_t
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
}
-struct route_map_rule_cmd route_match_command_cmd = {
+static const struct route_map_rule_cmd route_match_command_cmd = {
"command",
route_match_command,
route_match_command_compile,
}
/* Route map commands for ip address matching. */
-struct route_map_rule_cmd route_match_ip_address_cmd = {
- "ip address", route_match_ip_address, route_match_ip_address_compile,
- route_match_ip_address_free};
+static const struct route_map_rule_cmd route_match_ip_address_cmd = {
+ "ip address",
+ route_match_ip_address,
+ route_match_ip_address_compile,
+ route_match_ip_address_free
+};
/* `match ip next-hop IP_ADDRESS' */
}
/* Route map commands for ip next-hop matching. */
-struct route_map_rule_cmd route_match_ip_next_hop_cmd = {
- "ip next-hop", route_match_ip_next_hop, route_match_ip_next_hop_compile,
- route_match_ip_next_hop_free};
+static const struct route_map_rule_cmd route_match_ip_next_hop_cmd = {
+ "ip next-hop",
+ route_match_ip_next_hop,
+ route_match_ip_next_hop_compile,
+ route_match_ip_next_hop_free
+};
/* `match ip route-source ACCESS-LIST' */
}
/* Route map commands for ip route-source matching. */
-struct route_map_rule_cmd route_match_ip_route_source_cmd = {
- "ip route-source", route_match_ip_route_source,
- route_match_ip_route_source_compile, route_match_ip_route_source_free};
+static const struct route_map_rule_cmd route_match_ip_route_source_cmd = {
+ "ip route-source",
+ route_match_ip_route_source,
+ route_match_ip_route_source_compile,
+ route_match_ip_route_source_free
+};
static enum route_map_cmd_result_t
route_match_prefix_list_flowspec(afi_t afi, struct prefix_list *plist,
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
}
-struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd = {
- "ip address prefix-list", route_match_ip_address_prefix_list,
+static const struct route_map_rule_cmd
+ route_match_ip_address_prefix_list_cmd = {
+ "ip address prefix-list",
+ route_match_ip_address_prefix_list,
route_match_ip_address_prefix_list_compile,
- route_match_ip_address_prefix_list_free};
+ route_match_ip_address_prefix_list_free
+};
/* `match ip next-hop prefix-list PREFIX_LIST' */
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
}
-struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd = {
- "ip next-hop prefix-list", route_match_ip_next_hop_prefix_list,
+static const struct route_map_rule_cmd
+ route_match_ip_next_hop_prefix_list_cmd = {
+ "ip next-hop prefix-list",
+ route_match_ip_next_hop_prefix_list,
route_match_ip_next_hop_prefix_list_compile,
- route_match_ip_next_hop_prefix_list_free};
+ route_match_ip_next_hop_prefix_list_free
+};
/* `match ip next-hop type <blackhole>' */
if (type == RMAP_BGP && prefix->family == AF_INET) {
path = (struct bgp_path_info *)object;
- if (!path || !path->attr)
+ if (!path)
return RMAP_NOMATCH;
/* If nexthop interface's index can't be resolved and nexthop is
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
}
-static struct route_map_rule_cmd route_match_ip_next_hop_type_cmd = {
- "ip next-hop type", route_match_ip_next_hop_type,
+static const struct route_map_rule_cmd
+ route_match_ip_next_hop_type_cmd = {
+ "ip next-hop type",
+ route_match_ip_next_hop_type,
route_match_ip_next_hop_type_compile,
- route_match_ip_next_hop_type_free};
+ route_match_ip_next_hop_type_free
+};
/* `match ip route-source prefix-list PREFIX_LIST' */
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
}
-struct route_map_rule_cmd route_match_ip_route_source_prefix_list_cmd = {
- "ip route-source prefix-list", route_match_ip_route_source_prefix_list,
+static const struct route_map_rule_cmd
+ route_match_ip_route_source_prefix_list_cmd = {
+ "ip route-source prefix-list",
+ route_match_ip_route_source_prefix_list,
route_match_ip_route_source_prefix_list_compile,
- route_match_ip_route_source_prefix_list_free};
+ route_match_ip_route_source_prefix_list_free
+};
/* `match evpn default-route' */
}
/* Route map commands for default-route matching. */
-struct route_map_rule_cmd route_match_evpn_default_route_cmd = {
- "evpn default-route", route_match_evpn_default_route, NULL, NULL};
+static const struct route_map_rule_cmd
+ route_match_evpn_default_route_cmd = {
+ "evpn default-route",
+ route_match_evpn_default_route,
+ NULL,
+ NULL
+};
/* `match mac address MAC_ACCESS_LIST' */
}
/* Route map commands for mac address matching. */
-struct route_map_rule_cmd route_match_mac_address_cmd = {
- "mac address", route_match_mac_address, route_match_mac_address_compile,
- route_match_mac_address_free};
+static const struct route_map_rule_cmd route_match_mac_address_cmd = {
+ "mac address",
+ route_match_mac_address,
+ route_match_mac_address_compile,
+ route_match_mac_address_free
+};
/*
* Match function returns:
* For any other tunnel type, return noop to ignore
* this check.
*/
- if (path->attr && path->attr->encap_tunneltype !=
- BGP_ENCAP_TYPE_VXLAN)
+ if (path->attr->encap_tunneltype != BGP_ENCAP_TYPE_VXLAN)
return RMAP_NOOP;
/*
}
/* Route map commands for vni matching. */
-struct route_map_rule_cmd route_match_evpn_vni_cmd = {
- "evpn vni", route_match_vni, route_match_vni_compile,
- route_match_vni_free};
+static const struct route_map_rule_cmd route_match_evpn_vni_cmd = {
+ "evpn vni",
+ route_match_vni,
+ route_match_vni_compile,
+ route_match_vni_free
+};
/* `match evpn route-type' */
}
/* Route map commands for evpn route-type matching. */
-struct route_map_rule_cmd route_match_evpn_route_type_cmd = {
- "evpn route-type", route_match_evpn_route_type,
- route_match_evpn_route_type_compile, route_match_evpn_route_type_free};
+static const struct route_map_rule_cmd route_match_evpn_route_type_cmd = {
+ "evpn route-type",
+ route_match_evpn_route_type,
+ route_match_evpn_route_type_compile,
+ route_match_evpn_route_type_free
+};
+
+/* `match rd' */
+
+/* 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)
+{
+ struct prefix_rd *prd_rule = NULL;
+ struct prefix_rd *prd_route = NULL;
+ struct bgp_path_info *path = NULL;
+
+ if (type == RMAP_BGP) {
+ if (prefix->family != AF_EVPN)
+ return RMAP_NOMATCH;
+
+ prd_rule = (struct prefix_rd *)rule;
+ path = (struct bgp_path_info *)object;
+
+ if (path->net == NULL || path->net->prn == NULL)
+ return RMAP_NOMATCH;
+
+ prd_route = (struct prefix_rd *)&path->net->prn->p;
+ if (memcmp(prd_route->val, prd_rule->val, ECOMMUNITY_SIZE) == 0)
+ return RMAP_MATCH;
+ }
+
+ return RMAP_NOMATCH;
+}
+
+/* Route map `rd' match statement. */
+static void *route_match_rd_compile(const char *arg)
+{
+ struct prefix_rd *prd;
+ int ret;
+
+ prd = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(struct prefix_rd));
+
+ ret = str2prefix_rd(arg, prd);
+ if (!ret) {
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, prd);
+ return NULL;
+ }
+
+ return prd;
+}
+
+/* Free route map's compiled `rd' value. */
+static void route_match_rd_free(void *rule)
+{
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
+}
+
+/* Route map commands for rd matching. */
+static const struct route_map_rule_cmd route_match_evpn_rd_cmd = {
+ "evpn rd",
+ route_match_rd,
+ route_match_rd_compile,
+ route_match_rd_free
+};
/* Route map commands for VRF route leak with source vrf matching */
static enum route_map_cmd_result_t
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
}
-struct route_map_rule_cmd route_match_vrl_source_vrf_cmd = {
- "source-vrf", route_match_vrl_source_vrf,
+static const struct route_map_rule_cmd route_match_vrl_source_vrf_cmd = {
+ "source-vrf",
+ route_match_vrl_source_vrf,
route_match_vrl_source_vrf_compile,
- route_match_vrl_source_vrf_free};
+ route_match_vrl_source_vrf_free
+};
/* `match local-preference LOCAL-PREF' */
return RMAP_NOMATCH;
}
-/* Route map `match local-preference' match statement.
- `arg' is local-pref value */
+/*
+ * Route map `match local-preference' match statement.
+ * `arg' is local-pref value
+ */
static void *route_match_local_pref_compile(const char *arg)
{
uint32_t *local_pref;
}
/* Route map commands for metric matching. */
-struct route_map_rule_cmd route_match_local_pref_cmd = {
- "local-preference", route_match_local_pref,
- route_match_local_pref_compile, route_match_local_pref_free};
+static const struct route_map_rule_cmd route_match_local_pref_cmd = {
+ "local-preference",
+ route_match_local_pref,
+ route_match_local_pref_compile,
+ route_match_local_pref_free
+};
/* `match metric METRIC' */
}
/* Route map commands for metric matching. */
-struct route_map_rule_cmd route_match_metric_cmd = {
- "metric", route_match_metric, route_value_compile, route_value_free,
+static const struct route_map_rule_cmd route_match_metric_cmd = {
+ "metric",
+ route_match_metric,
+ route_value_compile,
+ route_value_free,
};
/* `match as-path ASPATH' */
}
/* Route map commands for aspath matching. */
-struct route_map_rule_cmd route_match_aspath_cmd = {
- "as-path", route_match_aspath, route_match_aspath_compile,
- route_match_aspath_free};
+static const struct route_map_rule_cmd route_match_aspath_cmd = {
+ "as-path",
+ route_match_aspath,
+ route_match_aspath_compile,
+ route_match_aspath_free
+};
/* `match community COMMUNIY' */
struct rmap_community {
XFREE(MTYPE_ROUTE_MAP_COMPILED, rcom);
}
+/*
+ * In routemap processing there is a need to add the
+ * name as a rule_key in the dependency table. Routemap
+ * lib is unaware of rule_key when exact-match clause
+ * is in use. routemap lib uses the compiled output to
+ * get the rule_key value.
+ */
+static void *route_match_get_community_key(void *rule)
+{
+ struct rmap_community *rcom;
+
+ rcom = rule;
+ return rcom->name;
+}
+
+
/* Route map commands for community matching. */
-struct route_map_rule_cmd route_match_community_cmd = {
- "community", route_match_community, route_match_community_compile,
- route_match_community_free};
+static const struct route_map_rule_cmd route_match_community_cmd = {
+ "community",
+ route_match_community,
+ route_match_community_compile,
+ route_match_community_free,
+ route_match_get_community_key
+};
/* Match function for lcommunity match. */
static enum route_map_cmd_result_t
}
/* Route map commands for community matching. */
-struct route_map_rule_cmd route_match_lcommunity_cmd = {
- "large-community", route_match_lcommunity,
- route_match_lcommunity_compile, route_match_lcommunity_free};
+static const struct route_map_rule_cmd route_match_lcommunity_cmd = {
+ "large-community",
+ route_match_lcommunity,
+ route_match_lcommunity_compile,
+ route_match_lcommunity_free,
+ route_match_get_community_key
+};
/* Match function for extcommunity match. */
}
/* Route map commands for community matching. */
-struct route_map_rule_cmd route_match_ecommunity_cmd = {
- "extcommunity", route_match_ecommunity, route_match_ecommunity_compile,
- route_match_ecommunity_free};
+static const struct route_map_rule_cmd route_match_ecommunity_cmd = {
+ "extcommunity",
+ route_match_ecommunity,
+ route_match_ecommunity_compile,
+ route_match_ecommunity_free
+};
/* `match nlri` and `set nlri` are replaced by `address-family ipv4`
and `address-family vpnv4'. */
}
/* Route map commands for origin matching. */
-struct route_map_rule_cmd route_match_origin_cmd = {
- "origin", route_match_origin, route_match_origin_compile,
- route_match_origin_free};
+static const struct route_map_rule_cmd route_match_origin_cmd = {
+ "origin",
+ route_match_origin,
+ route_match_origin_compile,
+ route_match_origin_free
+};
/* match probability { */
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
}
-struct route_map_rule_cmd route_match_probability_cmd = {
- "probability", route_match_probability, route_match_probability_compile,
- route_match_probability_free};
+static const struct route_map_rule_cmd route_match_probability_cmd = {
+ "probability",
+ route_match_probability,
+ route_match_probability_compile,
+ route_match_probability_free
+};
/* `match interface IFNAME' */
/* Match function should return 1 if match is success else return
if (type == RMAP_BGP) {
path = object;
- if (!path || !path->attr)
+ if (!path)
return RMAP_NOMATCH;
ifp = if_lookup_by_name_all_vrf((char *)rule);
}
/* Route map commands for ip address matching. */
-struct route_map_rule_cmd route_match_interface_cmd = {
- "interface", route_match_interface, route_match_interface_compile,
- route_match_interface_free};
+static const struct route_map_rule_cmd route_match_interface_cmd = {
+ "interface",
+ route_match_interface,
+ route_match_interface_compile,
+ route_match_interface_free
+};
/* } */
/* Route map commands for tag matching. */
-static struct route_map_rule_cmd route_match_tag_cmd = {
- "tag", route_match_tag, route_map_rule_tag_compile,
+static const struct route_map_rule_cmd route_match_tag_cmd = {
+ "tag",
+ route_match_tag,
+ route_map_rule_tag_compile,
route_map_rule_tag_free,
};
}
/* Route map commands for ip nexthop set. */
-struct route_map_rule_cmd route_set_ip_nexthop_cmd = {
- "ip next-hop", route_set_ip_nexthop, route_set_ip_nexthop_compile,
- route_set_ip_nexthop_free};
+static const struct route_map_rule_cmd route_set_ip_nexthop_cmd = {
+ "ip next-hop",
+ route_set_ip_nexthop,
+ route_set_ip_nexthop_compile,
+ route_set_ip_nexthop_free
+};
/* `set local-preference LOCAL_PREF' */
}
/* Set local preference rule structure. */
-struct route_map_rule_cmd route_set_local_pref_cmd = {
- "local-preference", route_set_local_pref, route_value_compile,
+static const struct route_map_rule_cmd route_set_local_pref_cmd = {
+ "local-preference",
+ route_set_local_pref,
+ route_value_compile,
route_value_free,
};
}
/* Set local preference rule structure. */
-struct route_map_rule_cmd route_set_weight_cmd = {
- "weight", route_set_weight, route_value_compile, route_value_free,
+static const struct route_map_rule_cmd route_set_weight_cmd = {
+ "weight",
+ route_set_weight,
+ route_value_compile,
+ route_value_free,
+};
+
+/* `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)
+{
+ 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 distance rule structure */
+static const struct route_map_rule_cmd route_set_distance_cmd = {
+ "distance",
+ route_set_distance,
+ route_value_compile,
+ route_value_free,
};
/* `set metric METRIC' */
}
/* Set metric rule structure. */
-struct route_map_rule_cmd route_set_metric_cmd = {
- "metric", route_set_metric, route_value_compile, route_value_free,
+static const struct route_map_rule_cmd route_set_metric_cmd = {
+ "metric",
+ route_set_metric,
+ route_value_compile,
+ route_value_free,
+};
+
+/* `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)
+{
+ struct rmap_value *rv;
+ struct bgp_path_info *path;
+
+ if (type == RMAP_BGP) {
+ /* Fetch routemap's rule information. */
+ rv = rule;
+ path = object;
+
+ path->attr->rmap_table_id = rv->value;
+ }
+ return RMAP_OKAY;
+}
+
+/* Set table_id rule structure. */
+static const struct route_map_rule_cmd route_set_table_id_cmd = {
+ "table",
+ route_set_table_id,
+ route_value_compile,
+ route_value_free
};
/* `set as-path prepend ASPATH' */
/* Set as-path prepend rule structure. */
-struct route_map_rule_cmd route_set_aspath_prepend_cmd = {
- "as-path prepend", route_set_aspath_prepend,
- route_set_aspath_prepend_compile, route_set_aspath_prepend_free,
+static const struct route_map_rule_cmd route_set_aspath_prepend_cmd = {
+ "as-path prepend",
+ route_set_aspath_prepend,
+ route_set_aspath_prepend_compile,
+ route_set_aspath_prepend_free,
};
/* `set as-path exclude ASn' */
}
/* Set ASn exlude rule structure. */
-struct route_map_rule_cmd route_set_aspath_exclude_cmd = {
- "as-path exclude", route_set_aspath_exclude, route_aspath_compile,
+static const struct route_map_rule_cmd route_set_aspath_exclude_cmd = {
+ "as-path exclude",
+ route_set_aspath_exclude,
+ route_aspath_compile,
route_aspath_free,
};
}
/* Set community rule structure. */
-struct route_map_rule_cmd route_set_community_cmd = {
- "community", route_set_community, route_set_community_compile,
+static const struct route_map_rule_cmd route_set_community_cmd = {
+ "community",
+ route_set_community,
+ route_set_community_compile,
route_set_community_free,
};
}
/* Set community rule structure. */
-struct route_map_rule_cmd route_set_lcommunity_cmd = {
- "large-community", route_set_lcommunity, route_set_lcommunity_compile,
+static const struct route_map_rule_cmd route_set_lcommunity_cmd = {
+ "large-community",
+ route_set_lcommunity,
+ route_set_lcommunity_compile,
route_set_lcommunity_free,
};
}
/* Set lcommunity rule structure. */
-struct route_map_rule_cmd route_set_lcommunity_delete_cmd = {
- "large-comm-list", route_set_lcommunity_delete,
- route_set_lcommunity_delete_compile, route_set_lcommunity_delete_free,
+static const struct route_map_rule_cmd route_set_lcommunity_delete_cmd = {
+ "large-comm-list",
+ route_set_lcommunity_delete,
+ route_set_lcommunity_delete_compile,
+ route_set_lcommunity_delete_free,
};
}
/* Set community rule structure. */
-struct route_map_rule_cmd route_set_community_delete_cmd = {
- "comm-list", route_set_community_delete,
- route_set_community_delete_compile, route_set_community_delete_free,
+static const struct route_map_rule_cmd route_set_community_delete_cmd = {
+ "comm-list",
+ route_set_community_delete,
+ route_set_community_delete_compile,
+ route_set_community_delete_free,
};
/* `set extcommunity rt COMMUNITY' */
}
/* Set community rule structure. */
-struct route_map_rule_cmd route_set_ecommunity_rt_cmd = {
- "extcommunity rt", route_set_ecommunity,
- route_set_ecommunity_rt_compile, route_set_ecommunity_free,
+static const struct route_map_rule_cmd route_set_ecommunity_rt_cmd = {
+ "extcommunity rt",
+ route_set_ecommunity,
+ route_set_ecommunity_rt_compile,
+ route_set_ecommunity_free,
};
/* `set extcommunity soo COMMUNITY' */
}
/* Set community rule structure. */
-struct route_map_rule_cmd route_set_ecommunity_soo_cmd = {
- "extcommunity soo", route_set_ecommunity,
- route_set_ecommunity_soo_compile, route_set_ecommunity_free,
+static const struct route_map_rule_cmd route_set_ecommunity_soo_cmd = {
+ "extcommunity soo",
+ route_set_ecommunity,
+ route_set_ecommunity_soo_compile,
+ route_set_ecommunity_free,
};
/* `set origin ORIGIN' */
}
/* Set origin rule structure. */
-struct route_map_rule_cmd route_set_origin_cmd = {
- "origin", route_set_origin, route_set_origin_compile,
+static const struct route_map_rule_cmd route_set_origin_cmd = {
+ "origin",
+ route_set_origin,
+ route_set_origin_compile,
route_set_origin_free,
};
}
/* Set atomic aggregate rule structure. */
-struct route_map_rule_cmd route_set_atomic_aggregate_cmd = {
- "atomic-aggregate", route_set_atomic_aggregate,
- route_set_atomic_aggregate_compile, route_set_atomic_aggregate_free,
+static const struct route_map_rule_cmd route_set_atomic_aggregate_cmd = {
+ "atomic-aggregate",
+ route_set_atomic_aggregate,
+ route_set_atomic_aggregate_compile,
+ route_set_atomic_aggregate_free,
};
/* `set aggregator as AS A.B.C.D' */
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
}
-struct route_map_rule_cmd route_set_aggregator_as_cmd = {
- "aggregator as", route_set_aggregator_as,
- route_set_aggregator_as_compile, route_set_aggregator_as_free,
+static const struct route_map_rule_cmd route_set_aggregator_as_cmd = {
+ "aggregator as",
+ route_set_aggregator_as,
+ route_set_aggregator_as_compile,
+ route_set_aggregator_as_free,
};
/* Set tag to object. object must be pointer to struct bgp_path_info */
}
/* Route map commands for tag set. */
-static struct route_map_rule_cmd route_set_tag_cmd = {
- "tag", route_set_tag, route_map_rule_tag_compile,
+static const struct route_map_rule_cmd route_set_tag_cmd = {
+ "tag",
+ route_set_tag,
+ route_map_rule_tag_compile,
route_map_rule_tag_free,
};
}
/* Route map commands for label-index set. */
-static struct route_map_rule_cmd route_set_label_index_cmd = {
- "label-index", route_set_label_index, route_value_compile,
+static const struct route_map_rule_cmd route_set_label_index_cmd = {
+ "label-index",
+ route_set_label_index,
+ route_value_compile,
route_value_free,
};
}
/* Route map commands for ip address matching. */
-struct route_map_rule_cmd route_match_ipv6_address_cmd = {
- "ipv6 address", route_match_ipv6_address,
- route_match_ipv6_address_compile, route_match_ipv6_address_free};
+static const struct route_map_rule_cmd route_match_ipv6_address_cmd = {
+ "ipv6 address",
+ route_match_ipv6_address,
+ route_match_ipv6_address_compile,
+ route_match_ipv6_address_free
+};
/* `match ipv6 next-hop IP_ADDRESS' */
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
}
-struct route_map_rule_cmd route_match_ipv6_next_hop_cmd = {
- "ipv6 next-hop", route_match_ipv6_next_hop,
- route_match_ipv6_next_hop_compile, route_match_ipv6_next_hop_free};
+static const struct route_map_rule_cmd route_match_ipv6_next_hop_cmd = {
+ "ipv6 next-hop",
+ route_match_ipv6_next_hop,
+ route_match_ipv6_next_hop_compile,
+ route_match_ipv6_next_hop_free
+};
/* `match ipv6 address prefix-list PREFIX_LIST' */
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
}
-struct route_map_rule_cmd route_match_ipv6_address_prefix_list_cmd = {
- "ipv6 address prefix-list", route_match_ipv6_address_prefix_list,
+static const struct route_map_rule_cmd
+ route_match_ipv6_address_prefix_list_cmd = {
+ "ipv6 address prefix-list",
+ route_match_ipv6_address_prefix_list,
route_match_ipv6_address_prefix_list_compile,
- route_match_ipv6_address_prefix_list_free};
+ route_match_ipv6_address_prefix_list_free
+};
/* `match ipv6 next-hop type <TYPE>' */
if (type == RMAP_BGP && prefix->family == AF_INET6) {
path = (struct bgp_path_info *)object;
- if (!path || !path->attr)
+ if (!path)
return RMAP_NOMATCH;
if (IPV6_ADDR_SAME(&path->attr->mp_nexthop_global, addr)
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
}
-struct route_map_rule_cmd route_match_ipv6_next_hop_type_cmd = {
- "ipv6 next-hop type", route_match_ipv6_next_hop_type,
+static const struct route_map_rule_cmd
+ route_match_ipv6_next_hop_type_cmd = {
+ "ipv6 next-hop type",
+ route_match_ipv6_next_hop_type,
route_match_ipv6_next_hop_type_compile,
- route_match_ipv6_next_hop_type_free};
+ route_match_ipv6_next_hop_type_free
+};
/* `set ipv6 nexthop global IP_ADDRESS' */
}
/* Route map commands for ip nexthop set. */
-struct route_map_rule_cmd route_set_ipv6_nexthop_global_cmd = {
- "ipv6 next-hop global", route_set_ipv6_nexthop_global,
+static const struct route_map_rule_cmd
+ route_set_ipv6_nexthop_global_cmd = {
+ "ipv6 next-hop global",
+ route_set_ipv6_nexthop_global,
route_set_ipv6_nexthop_global_compile,
- route_set_ipv6_nexthop_global_free};
+ route_set_ipv6_nexthop_global_free
+};
/* Set next-hop preference value. */
static enum route_map_cmd_result_t
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)
+ || 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,
}
/* Route map commands for ip nexthop set preferred. */
-struct route_map_rule_cmd route_set_ipv6_nexthop_prefer_global_cmd = {
- "ipv6 next-hop prefer-global", route_set_ipv6_nexthop_prefer_global,
+static const struct route_map_rule_cmd
+ route_set_ipv6_nexthop_prefer_global_cmd = {
+ "ipv6 next-hop prefer-global",
+ route_set_ipv6_nexthop_prefer_global,
route_set_ipv6_nexthop_prefer_global_compile,
- route_set_ipv6_nexthop_prefer_global_free};
+ route_set_ipv6_nexthop_prefer_global_free
+};
/* `set ipv6 nexthop local IP_ADDRESS' */
}
/* Route map commands for ip nexthop set. */
-struct route_map_rule_cmd route_set_ipv6_nexthop_local_cmd = {
- "ipv6 next-hop local", route_set_ipv6_nexthop_local,
+static const struct route_map_rule_cmd
+ route_set_ipv6_nexthop_local_cmd = {
+ "ipv6 next-hop local",
+ route_set_ipv6_nexthop_local,
route_set_ipv6_nexthop_local_compile,
- route_set_ipv6_nexthop_local_free};
+ route_set_ipv6_nexthop_local_free
+};
/* `set ipv6 nexthop peer-address' */
}
/* Route map commands for ip nexthop set. */
-struct route_map_rule_cmd route_set_ipv6_nexthop_peer_cmd = {
- "ipv6 next-hop peer-address", route_set_ipv6_nexthop_peer,
- route_set_ipv6_nexthop_peer_compile, route_set_ipv6_nexthop_peer_free};
+static const struct route_map_rule_cmd route_set_ipv6_nexthop_peer_cmd = {
+ "ipv6 next-hop peer-address",
+ route_set_ipv6_nexthop_peer,
+ route_set_ipv6_nexthop_peer_compile,
+ route_set_ipv6_nexthop_peer_free
+};
/* `set ipv4 vpn next-hop A.B.C.D' */
}
/* Route map commands for ipv4 next-hop set. */
-struct route_map_rule_cmd route_set_vpnv4_nexthop_cmd = {
- "ipv4 vpn next-hop", route_set_vpnv4_nexthop,
- route_set_vpnv4_nexthop_compile, route_set_vpn_nexthop_free};
+static const struct route_map_rule_cmd route_set_vpnv4_nexthop_cmd = {
+ "ipv4 vpn next-hop",
+ route_set_vpnv4_nexthop,
+ route_set_vpnv4_nexthop_compile,
+ route_set_vpn_nexthop_free
+};
/* Route map commands for ipv6 next-hop set. */
-struct route_map_rule_cmd route_set_vpnv6_nexthop_cmd = {
- "ipv6 vpn next-hop", route_set_vpnv6_nexthop,
- route_set_vpnv6_nexthop_compile, route_set_vpn_nexthop_free};
+static const struct route_map_rule_cmd route_set_vpnv6_nexthop_cmd = {
+ "ipv6 vpn next-hop",
+ route_set_vpnv6_nexthop,
+ route_set_vpnv6_nexthop_compile,
+ route_set_vpn_nexthop_free
+};
/* `set originator-id' */
}
/* Set originator-id rule structure. */
-struct route_map_rule_cmd route_set_originator_id_cmd = {
- "originator-id", route_set_originator_id,
- route_set_originator_id_compile, route_set_originator_id_free,
+static const struct route_map_rule_cmd route_set_originator_id_cmd = {
+ "originator-id",
+ route_set_originator_id,
+ route_set_originator_id_compile,
+ route_set_originator_id_free,
};
/* Add bgp route map rule. */
retval = CMD_WARNING_CONFIG_FAILED;
break;
case RMAP_COMPILE_SUCCESS:
- if (type != RMAP_EVENT_MATCH_ADDED) {
- route_map_upd8_dependency(type, arg, index->map->name);
- }
- break;
- case RMAP_DUPLICATE_RULE:
/*
* Intentionally doing nothing here.
*/
rmap_name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, index->map->name);
}
- ret = route_map_delete_match(index, command, dep_name);
+ ret = route_map_delete_match(index, command, dep_name, type);
switch (ret) {
case RMAP_RULE_MISSING:
vty_out(vty, "%% BGP Can't find rule.\n");
retval = CMD_WARNING_CONFIG_FAILED;
break;
case RMAP_COMPILE_SUCCESS:
- if (type != RMAP_EVENT_MATCH_DELETED && dep_name)
- route_map_upd8_dependency(type, dep_name, rmap_name);
- break;
- case RMAP_DUPLICATE_RULE:
/*
* Nothing to do here
*/
RMAP_EVENT_MATCH_DELETED);
}
+DEFUN (match_evpn_rd,
+ match_evpn_rd_cmd,
+ "match evpn rd ASN:NN_OR_IP-ADDRESS:NN",
+ MATCH_STR
+ EVPN_HELP_STR
+ "Route Distinguisher\n"
+ "ASN:XX or A.B.C.D:XX\n")
+{
+ return bgp_route_match_add(vty, "evpn rd", argv[3]->arg,
+ RMAP_EVENT_MATCH_ADDED);
+}
+
+DEFUN (no_match_evpn_rd,
+ no_match_evpn_rd_cmd,
+ "no match evpn rd ASN:NN_OR_IP-ADDRESS:NN",
+ NO_STR
+ MATCH_STR
+ EVPN_HELP_STR
+ "Route Distinguisher\n"
+ "ASN:XX or A.B.C.D:XX\n")
+{
+ return bgp_route_match_delete(vty, "evpn rd", argv[4]->arg,
+ RMAP_EVENT_MATCH_DELETED);
+}
+
DEFPY(match_vrl_source_vrf,
match_vrl_source_vrf_cmd,
"match source-vrf NAME$vrf_name",
RMAP_EVENT_MATCH_DELETED);
}
+DEFUN (set_table_id,
+ set_table_id_cmd,
+ "set table (1-4294967295)",
+ SET_STR
+ "export route to non-main kernel table\n"
+ "Kernel routing table id\n")
+{
+ int idx_id = 2;
+
+ VTY_DECLVAR_CONTEXT(route_map_index, index);
+
+ return generic_set_add(vty, index, "table", argv[idx_id]->arg);
+}
+
+DEFUN (no_set_table_id,
+ no_set_table_id_cmd,
+ "no set table",
+ NO_STR
+ SET_STR
+ "export route to non-main kernel table\n")
+{
+ VTY_DECLVAR_CONTEXT(route_map_index, index);
+
+ return generic_set_delete(vty, index, "table", NULL);
+}
+
DEFUN (set_ip_nexthop_peer,
set_ip_nexthop_peer_cmd,
"[no] set ip next-hop peer-address",
"unchanged");
}
+DEFUN (set_distance,
+ set_distance_cmd,
+ "set distance (0-255)",
+ SET_STR
+ "BGP Administrative Distance to use\n"
+ "Distance value\n")
+{
+ int idx_number = 2;
+
+ return generic_set_add(vty, VTY_GET_CONTEXT(route_map_index),
+ "distance", argv[idx_number]->arg);
+}
+
+DEFUN (no_set_distance,
+ no_set_distance_cmd,
+ "no set distance [(0-255)]",
+ NO_STR SET_STR
+ "BGP Administrative Distance to use\n"
+ "Distance value\n")
+{
+ return generic_set_delete(vty, VTY_GET_CONTEXT(route_map_index),
+ "distance", NULL);
+}
DEFUN (set_local_pref,
set_local_pref_cmd,
route_map_install_match(&route_match_mac_address_cmd);
route_map_install_match(&route_match_evpn_vni_cmd);
route_map_install_match(&route_match_evpn_route_type_cmd);
+ route_map_install_match(&route_match_evpn_rd_cmd);
route_map_install_match(&route_match_evpn_default_route_cmd);
route_map_install_match(&route_match_vrl_source_vrf_cmd);
+ route_map_install_set(&route_set_table_id_cmd);
route_map_install_set(&route_set_ip_nexthop_cmd);
route_map_install_set(&route_set_local_pref_cmd);
route_map_install_set(&route_set_weight_cmd);
route_map_install_set(&route_set_label_index_cmd);
route_map_install_set(&route_set_metric_cmd);
+ route_map_install_set(&route_set_distance_cmd);
route_map_install_set(&route_set_aspath_prepend_cmd);
route_map_install_set(&route_set_aspath_exclude_cmd);
route_map_install_set(&route_set_origin_cmd);
install_element(RMAP_NODE, &no_match_evpn_vni_cmd);
install_element(RMAP_NODE, &match_evpn_route_type_cmd);
install_element(RMAP_NODE, &no_match_evpn_route_type_cmd);
+ install_element(RMAP_NODE, &match_evpn_rd_cmd);
+ install_element(RMAP_NODE, &no_match_evpn_rd_cmd);
install_element(RMAP_NODE, &match_evpn_default_route_cmd);
install_element(RMAP_NODE, &no_match_evpn_default_route_cmd);
install_element(RMAP_NODE, &match_vrl_source_vrf_cmd);
install_element(RMAP_NODE, &match_probability_cmd);
install_element(RMAP_NODE, &no_match_probability_cmd);
+ install_element(RMAP_NODE, &no_set_table_id_cmd);
+ install_element(RMAP_NODE, &set_table_id_cmd);
install_element(RMAP_NODE, &set_ip_nexthop_peer_cmd);
install_element(RMAP_NODE, &set_ip_nexthop_unchanged_cmd);
install_element(RMAP_NODE, &set_local_pref_cmd);
+ install_element(RMAP_NODE, &set_distance_cmd);
+ install_element(RMAP_NODE, &no_set_distance_cmd);
install_element(RMAP_NODE, &no_set_local_pref_cmd);
install_element(RMAP_NODE, &set_weight_cmd);
install_element(RMAP_NODE, &set_label_index_cmd);