diff options
Diffstat (limited to 'bgpd/bgp_routemap.c')
-rw-r--r-- | bgpd/bgp_routemap.c | 362 |
1 files changed, 186 insertions, 176 deletions
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index aa7dbce1..64f2a90c 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -102,8 +102,8 @@ o Local extention set as-path exclude : Done match pathlimit as : Done -*/ - +*/ + /* Compiles either AS or TTL argument. It is amused the VTY code * has already range-checked the values to be suitable as TTL or ASN */ @@ -117,16 +117,16 @@ route_pathlimit_compile (const char *arg) /* TTL or AS value shoud be integer. */ if (! all_digit (arg)) return NULL; - + tmp = strtoul (arg, &endptr, 10); if (*endptr != '\0' || tmp == ULONG_MAX || tmp > UINT32_MAX) return NULL; - + if (!(val = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t)))) return NULL; - + *val = tmp; - + return val; } @@ -143,16 +143,16 @@ route_match_pathlimit_as (void *rule, struct prefix *prefix, route_map_object_t struct bgp_info *info = object; struct attr *attr = info->attr; uint32_t as = *(uint32_t *)rule; - + if (type != RMAP_BGP) return RMAP_NOMATCH; - + if (!attr->pathlimit.as) return RMAP_NOMATCH; - + if (as == attr->pathlimit.as) return RMAP_MATCH; - + return RMAP_NOMATCH; } @@ -173,7 +173,7 @@ route_set_pathlimit_ttl (void *rule, struct prefix *prefix, struct bgp_info *info = object; struct attr *attr = info->attr; u_char ttl = *(uint32_t *)rule; - + if (type == RMAP_BGP) { attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AS_PATHLIMIT); @@ -185,14 +185,14 @@ route_set_pathlimit_ttl (void *rule, struct prefix *prefix, } /* Set local preference rule structure. */ -struct route_map_rule_cmd route_set_pathlimit_ttl_cmd = +struct route_map_rule_cmd route_set_pathlimit_ttl_cmd = { "pathlimit ttl", route_set_pathlimit_ttl, route_pathlimit_compile, route_pathlimit_free, }; - + /* 'match peer (A.B.C.D|X:X::X:X)' */ /* Compares the peer specified in the 'match peer' clause with the peer @@ -229,12 +229,12 @@ route_match_peer (void *rule, struct prefix *prefix, route_map_object_t type, ret = RMAP_MATCH; else ret = RMAP_NOMATCH; - + sockunion_free (su2); return ret; } sockunion_free (su2); - + if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) { if (sockunion_same (su, &peer->su)) @@ -294,7 +294,7 @@ struct route_map_rule_cmd route_match_peer_cmd = /* Match function should return 1 if match is success else return zero. */ static route_map_result_t -route_match_ip_address (void *rule, struct prefix *prefix, +route_match_ip_address (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct access_list *alist; @@ -305,7 +305,7 @@ route_match_ip_address (void *rule, struct prefix *prefix, alist = access_list_lookup (AFI_IP, (char *) rule); if (alist == NULL) return RMAP_NOMATCH; - + return (access_list_apply (alist, prefix) == FILTER_DENY ? RMAP_NOMATCH : RMAP_MATCH); } @@ -335,12 +335,12 @@ struct route_map_rule_cmd route_match_ip_address_cmd = route_match_ip_address_compile, route_match_ip_address_free }; - + /* `match ip next-hop IP_ADDRESS' */ /* Match function return 1 if match is success else return zero. */ static route_map_result_t -route_match_ip_next_hop (void *rule, struct prefix *prefix, +route_match_ip_next_hop (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct access_list *alist; @@ -387,12 +387,12 @@ struct route_map_rule_cmd route_match_ip_next_hop_cmd = route_match_ip_next_hop_compile, route_match_ip_next_hop_free }; - + /* `match ip route-source ACCESS-LIST' */ /* Match function return 1 if match is success else return zero. */ static route_map_result_t -route_match_ip_route_source (void *rule, struct prefix *prefix, +route_match_ip_route_source (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct access_list *alist; @@ -445,11 +445,11 @@ struct route_map_rule_cmd route_match_ip_route_source_cmd = route_match_ip_route_source_compile, route_match_ip_route_source_free }; - + /* `match ip address prefix-list PREFIX_LIST' */ static route_map_result_t -route_match_ip_address_prefix_list (void *rule, struct prefix *prefix, +route_match_ip_address_prefix_list (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct prefix_list *plist; @@ -459,7 +459,7 @@ route_match_ip_address_prefix_list (void *rule, struct prefix *prefix, plist = prefix_list_lookup (AFI_IP, (char *) rule); if (plist == NULL) return RMAP_NOMATCH; - + return (prefix_list_apply (plist, prefix) == PREFIX_DENY ? RMAP_NOMATCH : RMAP_MATCH); } @@ -485,7 +485,7 @@ struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd = route_match_ip_address_prefix_list_compile, route_match_ip_address_prefix_list_free }; - + /* `match ip next-hop prefix-list PREFIX_LIST' */ static route_map_result_t @@ -532,7 +532,7 @@ struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd = route_match_ip_next_hop_prefix_list_compile, route_match_ip_next_hop_prefix_list_free }; - + /* `match ip route-source prefix-list PREFIX_LIST' */ static route_map_result_t @@ -585,12 +585,12 @@ struct route_map_rule_cmd route_match_ip_route_source_prefix_list_cmd = route_match_ip_route_source_prefix_list_compile, route_match_ip_route_source_prefix_list_free }; - + /* `match metric METRIC' */ /* Match function return 1 if match is success else return zero. */ static route_map_result_t -route_match_metric (void *rule, struct prefix *prefix, +route_match_metric (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { u_int32_t *med; @@ -600,7 +600,7 @@ route_match_metric (void *rule, struct prefix *prefix, { med = rule; bgp_info = object; - + if (bgp_info->attr->med == *med) return RMAP_MATCH; else @@ -620,12 +620,12 @@ route_match_metric_compile (const char *arg) tmpval = strtoul (arg, &endptr, 10); if (*endptr != '\0' || tmpval == ULONG_MAX || tmpval > UINT32_MAX) return NULL; - + med = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t)); - + if (!med) return med; - + *med = tmpval; return med; } @@ -645,15 +645,15 @@ struct route_map_rule_cmd route_match_metric_cmd = route_match_metric_compile, route_match_metric_free }; - + /* `match as-path ASPATH' */ /* Match function for as-path match. I assume given object is */ static route_map_result_t -route_match_aspath (void *rule, struct prefix *prefix, +route_match_aspath (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { - + struct as_list *as_list; struct bgp_info *bgp_info; @@ -662,9 +662,9 @@ route_match_aspath (void *rule, struct prefix *prefix, as_list = as_list_lookup ((char *) rule); if (as_list == NULL) return RMAP_NOMATCH; - + bgp_info = object; - + /* Perform match. */ return ((as_list_apply (as_list, bgp_info->attr->aspath) == AS_FILTER_DENY) ? RMAP_NOMATCH : RMAP_MATCH); } @@ -686,14 +686,14 @@ route_match_aspath_free (void *rule) } /* Route map commands for aspath matching. */ -struct route_map_rule_cmd route_match_aspath_cmd = +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 { @@ -703,14 +703,14 @@ struct rmap_community /* Match function for community match. */ static route_map_result_t -route_match_community (void *rule, struct prefix *prefix, +route_match_community (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct community_list *list; struct bgp_info *bgp_info; struct rmap_community *rcom; - if (type == RMAP_BGP) + if (type == RMAP_BGP) { bgp_info = object; rcom = rule; @@ -765,34 +765,34 @@ route_match_community_free (void *rule) { struct rmap_community *rcom = rule; - XFREE (MTYPE_ROUTE_MAP_COMPILED, rcom->name); + XFREE (MTYPE_ROUTE_MAP_COMPILED, rcom->name); XFREE (MTYPE_ROUTE_MAP_COMPILED, rcom); } /* Route map commands for community matching. */ -struct route_map_rule_cmd route_match_community_cmd = +struct route_map_rule_cmd route_match_community_cmd = { "community", route_match_community, route_match_community_compile, route_match_community_free }; - + /* Match function for extcommunity match. */ static route_map_result_t -route_match_ecommunity (void *rule, struct prefix *prefix, +route_match_ecommunity (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct community_list *list; struct bgp_info *bgp_info; - if (type == RMAP_BGP) + if (type == RMAP_BGP) { bgp_info = object; - + if (!bgp_info->attr->extra) return RMAP_NOMATCH; - + list = community_list_lookup (bgp_clist, (char *) rule, EXTCOMMUNITY_LIST_MASTER); if (! list) @@ -819,20 +819,20 @@ route_match_ecommunity_free (void *rule) } /* Route map commands for community matching. */ -struct route_map_rule_cmd route_match_ecommunity_cmd = +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'. */ - + /* `match origin' */ static route_map_result_t -route_match_origin (void *rule, struct prefix *prefix, +route_match_origin (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { u_char *origin; @@ -842,7 +842,7 @@ route_match_origin (void *rule, struct prefix *prefix, { origin = rule; bgp_info = object; - + if (bgp_info->attr->origin == *origin) return RMAP_MATCH; } @@ -896,7 +896,9 @@ route_set_ip_nexthop (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct rmap_ip_nexthop_set *rins = rule; +#if 0 /* see below */ struct in_addr peer_address; +#endif struct bgp_info *bgp_info; struct peer *peer; @@ -907,27 +909,35 @@ route_set_ip_nexthop (void *rule, struct prefix *prefix, if (rins->peer_address) { - if ((CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN) || - CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT)) - && peer->su_remote + if ( (CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN) || + CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT) ) + && peer->su_remote && sockunion_family (peer->su_remote) == AF_INET) { +#if 0 /* the following (a) appears redundant and (b) leaks memory */ inet_aton (sockunion_su2str (peer->su_remote), &peer_address); bgp_info->attr->nexthop = peer_address; +#else + bgp_info->attr->nexthop = peer->su_remote->sin.sin_addr ; +#endif bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP); } else if (CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_OUT) && peer->su_local && sockunion_family (peer->su_local) == AF_INET) { +#if 0 /* the following (a) appears redundant and (b) leaks memory */ inet_aton (sockunion_su2str (peer->su_local), &peer_address); bgp_info->attr->nexthop = peer_address; +#else + bgp_info->attr->nexthop = peer->su_local->sin.sin_addr ; +#endif bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP); } } else { - /* Set next hop value. */ + /* Set next hop value. */ bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP); bgp_info->attr->nexthop = *rins->address; } @@ -976,7 +986,7 @@ route_set_ip_nexthop_free (void *rule) if (rins->address) XFREE (MTYPE_ROUTE_MAP_COMPILED, rins->address); - + XFREE (MTYPE_ROUTE_MAP_COMPILED, rins); } @@ -988,7 +998,7 @@ struct route_map_rule_cmd route_set_ip_nexthop_cmd = route_set_ip_nexthop_compile, route_set_ip_nexthop_free }; - + /* `set local-preference LOCAL_PREF' */ /* Set local preference. */ @@ -1004,8 +1014,8 @@ route_set_local_pref (void *rule, struct prefix *prefix, /* Fetch routemap's rule information. */ local_pref = rule; bgp_info = object; - - /* Set local preference value. */ + + /* Set local preference value. */ bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF); bgp_info->attr->local_pref = *local_pref; } @@ -1024,18 +1034,18 @@ route_set_local_pref_compile (const char *arg) /* Local preference value shoud be integer. */ if (! all_digit (arg)) return NULL; - + tmp = strtoul (arg, &endptr, 10); if (*endptr != '\0' || tmp == ULONG_MAX || tmp > UINT32_MAX) return NULL; - - local_pref = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t)); - + + local_pref = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t)); + if (!local_pref) return local_pref; - + *local_pref = tmp; - + return local_pref; } @@ -1047,14 +1057,14 @@ route_set_local_pref_free (void *rule) } /* Set local preference rule structure. */ -struct route_map_rule_cmd route_set_local_pref_cmd = +struct route_map_rule_cmd route_set_local_pref_cmd = { "local-preference", route_set_local_pref, route_set_local_pref_compile, route_set_local_pref_free, }; - + /* `set weight WEIGHT' */ /* Set weight. */ @@ -1070,8 +1080,8 @@ route_set_weight (void *rule, struct prefix *prefix, route_map_object_t type, /* Fetch routemap's rule information. */ weight = rule; bgp_info = object; - - /* Set weight value. */ + + /* Set weight value. */ if (*weight) (bgp_attr_extra_get (bgp_info->attr))->weight = *weight; else if (bgp_info->attr->extra) @@ -1097,14 +1107,14 @@ route_set_weight_compile (const char *arg) tmp = strtoul (arg, &endptr, 10); if (*endptr != '\0' || tmp == ULONG_MAX || tmp > UINT32_MAX) return NULL; - + weight = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t)); - + if (weight == NULL) return weight; - - *weight = tmp; - + + *weight = tmp; + return weight; } @@ -1116,19 +1126,19 @@ route_set_weight_free (void *rule) } /* Set local preference rule structure. */ -struct route_map_rule_cmd route_set_weight_cmd = +struct route_map_rule_cmd route_set_weight_cmd = { "weight", route_set_weight, route_set_weight_compile, route_set_weight_free, }; - + /* `set metric METRIC' */ /* Set metric to attribute. */ static route_map_result_t -route_set_metric (void *rule, struct prefix *prefix, +route_set_metric (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { char *metric; @@ -1214,14 +1224,14 @@ route_set_metric_free (void *rule) } /* Set metric rule structure. */ -struct route_map_rule_cmd route_set_metric_cmd = +struct route_map_rule_cmd route_set_metric_cmd = { "metric", route_set_metric, route_set_metric_compile, route_set_metric_free, }; - + /* `set as-path prepend ASPATH' */ /* For AS path prepend mechanism. */ @@ -1236,7 +1246,7 @@ route_set_aspath_prepend (void *rule, struct prefix *prefix, route_map_object_t { aspath = rule; binfo = object; - + if (binfo->attr->aspath->refcnt) new = aspath_dup (binfo->attr->aspath); else @@ -1270,14 +1280,14 @@ route_set_aspath_prepend_free (void *rule) } /* Set metric rule structure. */ -struct route_map_rule_cmd route_set_aspath_prepend_cmd = +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' */ /* For ASN exclude mechanism. @@ -1328,14 +1338,14 @@ route_set_aspath_exclude_free (void *rule) } /* Set ASn exlude rule structure. */ -struct route_map_rule_cmd route_set_aspath_exclude_cmd = +struct route_map_rule_cmd route_set_aspath_exclude_cmd = { "as-path exclude", route_set_aspath_exclude, route_set_aspath_exclude_compile, route_set_aspath_exclude_free, }; - + /* `set community COMMUNITY' */ struct rmap_com_set { @@ -1355,7 +1365,7 @@ route_set_community (void *rule, struct prefix *prefix, struct community *new = NULL; struct community *old; struct community *merge; - + if (type == RMAP_BGP) { rcs = rule; @@ -1375,8 +1385,8 @@ route_set_community (void *rule, struct prefix *prefix, if (rcs->additive && old) { merge = community_merge (community_dup (old), rcs->com); - - /* HACK: if the old community is not intern'd, + + /* 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. */ @@ -1387,7 +1397,7 @@ route_set_community (void *rule, struct prefix *prefix, } else new = community_dup (rcs->com); - + /* will be interned by caller if required */ attr->community = new; @@ -1406,7 +1416,7 @@ route_set_community_compile (const char *arg) char *sp; int additive = 0; int none = 0; - + if (strcmp (arg, "none") == 0) none = 1; else @@ -1428,12 +1438,12 @@ route_set_community_compile (const char *arg) if (! com) return NULL; } - + rcs = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_com_set)); rcs->com = com; rcs->additive = additive; rcs->none = none; - + return rcs; } @@ -1449,14 +1459,14 @@ route_set_community_free (void *rule) } /* Set community rule structure. */ -struct route_map_rule_cmd route_set_community_cmd = +struct route_map_rule_cmd route_set_community_cmd = { "community", route_set_community, route_set_community_compile, route_set_community_free, }; - + /* `set comm-list (<1-99>|<100-500>|WORD) delete' */ /* For community set mechanism. */ @@ -1538,12 +1548,12 @@ struct route_map_rule_cmd route_set_community_delete_cmd = route_set_community_delete_compile, route_set_community_delete_free, }; - + /* `set extcommunity rt COMMUNITY' */ /* For community set mechanism. */ static route_map_result_t -route_set_ecommunity_rt (void *rule, struct prefix *prefix, +route_set_ecommunity_rt (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct ecommunity *ecom; @@ -1555,10 +1565,10 @@ route_set_ecommunity_rt (void *rule, struct prefix *prefix, { ecom = rule; bgp_info = object; - + if (! ecom) return RMAP_OKAY; - + /* We assume additive for Extended Community. */ old_ecom = (bgp_attr_extra_get (bgp_info->attr))->ecommunity; @@ -1598,7 +1608,7 @@ route_set_ecommunity_rt_free (void *rule) } /* Set community rule structure. */ -struct route_map_rule_cmd route_set_ecommunity_rt_cmd = +struct route_map_rule_cmd route_set_ecommunity_rt_cmd = { "extcommunity rt", route_set_ecommunity_rt, @@ -1610,7 +1620,7 @@ struct route_map_rule_cmd route_set_ecommunity_rt_cmd = /* For community set mechanism. */ static route_map_result_t -route_set_ecommunity_soo (void *rule, struct prefix *prefix, +route_set_ecommunity_soo (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct ecommunity *ecom; @@ -1620,10 +1630,10 @@ route_set_ecommunity_soo (void *rule, struct prefix *prefix, { ecom = rule; bgp_info = object; - + if (! ecom) return RMAP_OKAY; - + bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES); (bgp_attr_extra_get (bgp_info->attr))->ecommunity = ecommunity_dup (ecom); } @@ -1639,7 +1649,7 @@ route_set_ecommunity_soo_compile (const char *arg) ecom = ecommunity_str2com (arg, ECOMMUNITY_SITE_ORIGIN, 0); if (! ecom) return NULL; - + return ecom; } @@ -1652,14 +1662,14 @@ route_set_ecommunity_soo_free (void *rule) } /* Set community rule structure. */ -struct route_map_rule_cmd route_set_ecommunity_soo_cmd = +struct route_map_rule_cmd route_set_ecommunity_soo_cmd = { "extcommunity soo", route_set_ecommunity_soo, route_set_ecommunity_soo_compile, route_set_ecommunity_soo_free, }; - + /* `set origin ORIGIN' */ /* For origin set. */ @@ -1673,7 +1683,7 @@ route_set_origin (void *rule, struct prefix *prefix, route_map_object_t type, vo { origin = rule; bgp_info = object; - + bgp_info->attr->origin = *origin; } @@ -1706,14 +1716,14 @@ route_set_origin_free (void *rule) } /* Set metric rule structure. */ -struct route_map_rule_cmd route_set_origin_cmd = +struct route_map_rule_cmd route_set_origin_cmd = { "origin", route_set_origin, route_set_origin_compile, route_set_origin_free, }; - + /* `set atomic-aggregate' */ /* For atomic aggregate set. */ @@ -1747,14 +1757,14 @@ route_set_atomic_aggregate_free (void *rule) } /* Set atomic aggregate rule structure. */ -struct route_map_rule_cmd route_set_atomic_aggregate_cmd = +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' */ struct aggregator { @@ -1763,7 +1773,7 @@ struct aggregator }; static route_map_result_t -route_set_aggregator_as (void *rule, struct prefix *prefix, +route_set_aggregator_as (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct bgp_info *bgp_info; @@ -1775,7 +1785,7 @@ route_set_aggregator_as (void *rule, struct prefix *prefix, bgp_info = object; aggregator = rule; ae = bgp_attr_extra_get (bgp_info->attr); - + ae->aggregator_as = aggregator->as; ae->aggregator_addr = aggregator->address; bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR); @@ -1806,19 +1816,19 @@ route_set_aggregator_as_free (void *rule) XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); } -struct route_map_rule_cmd route_set_aggregator_as_cmd = +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, }; - + #ifdef HAVE_IPV6 /* `match ipv6 address IP_ACCESS_LIST' */ static route_map_result_t -route_match_ipv6_address (void *rule, struct prefix *prefix, +route_match_ipv6_address (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct access_list *alist; @@ -1828,7 +1838,7 @@ route_match_ipv6_address (void *rule, struct prefix *prefix, alist = access_list_lookup (AFI_IP6, (char *) rule); if (alist == NULL) return RMAP_NOMATCH; - + return (access_list_apply (alist, prefix) == FILTER_DENY ? RMAP_NOMATCH : RMAP_MATCH); } @@ -1855,11 +1865,11 @@ struct route_map_rule_cmd route_match_ipv6_address_cmd = route_match_ipv6_address_compile, route_match_ipv6_address_free }; - + /* `match ipv6 next-hop IP_ADDRESS' */ static route_map_result_t -route_match_ipv6_next_hop (void *rule, struct prefix *prefix, +route_match_ipv6_next_hop (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct in6_addr *addr; @@ -1869,10 +1879,10 @@ route_match_ipv6_next_hop (void *rule, struct prefix *prefix, { addr = rule; bgp_info = object; - + if (!bgp_info->attr->extra) return RMAP_NOMATCH; - + if (IPV6_ADDR_SAME (&bgp_info->attr->extra->mp_nexthop_global, rule)) return RMAP_MATCH; @@ -1917,11 +1927,11 @@ struct route_map_rule_cmd route_match_ipv6_next_hop_cmd = route_match_ipv6_next_hop_compile, route_match_ipv6_next_hop_free }; - + /* `match ipv6 address prefix-list PREFIX_LIST' */ static route_map_result_t -route_match_ipv6_address_prefix_list (void *rule, struct prefix *prefix, +route_match_ipv6_address_prefix_list (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct prefix_list *plist; @@ -1931,7 +1941,7 @@ route_match_ipv6_address_prefix_list (void *rule, struct prefix *prefix, plist = prefix_list_lookup (AFI_IP6, (char *) rule); if (plist == NULL) return RMAP_NOMATCH; - + return (prefix_list_apply (plist, prefix) == PREFIX_DENY ? RMAP_NOMATCH : RMAP_MATCH); } @@ -1957,12 +1967,12 @@ struct route_map_rule_cmd route_match_ipv6_address_prefix_list_cmd = route_match_ipv6_address_prefix_list_compile, route_match_ipv6_address_prefix_list_free }; - + /* `set ipv6 nexthop global IP_ADDRESS' */ /* Set nexthop to object. ojbect must be pointer to struct attr. */ static route_map_result_t -route_set_ipv6_nexthop_global (void *rule, struct prefix *prefix, +route_set_ipv6_nexthop_global (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct in6_addr *address; @@ -1973,10 +1983,10 @@ route_set_ipv6_nexthop_global (void *rule, struct prefix *prefix, /* Fetch routemap's rule information. */ address = rule; bgp_info = object; - - /* Set next hop value. */ + + /* Set next hop value. */ (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global = *address; - + /* Set nexthop length. */ if (bgp_info->attr->extra->mp_nexthop_len == 0) bgp_info->attr->extra->mp_nexthop_len = 16; @@ -2021,12 +2031,12 @@ struct route_map_rule_cmd route_set_ipv6_nexthop_global_cmd = route_set_ipv6_nexthop_global_compile, route_set_ipv6_nexthop_global_free }; - + /* `set ipv6 nexthop local IP_ADDRESS' */ /* Set nexthop to object. ojbect must be pointer to struct attr. */ static route_map_result_t -route_set_ipv6_nexthop_local (void *rule, struct prefix *prefix, +route_set_ipv6_nexthop_local (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct in6_addr *address; @@ -2037,10 +2047,10 @@ route_set_ipv6_nexthop_local (void *rule, struct prefix *prefix, /* Fetch routemap's rule information. */ address = rule; bgp_info = object; - - /* Set next hop value. */ + + /* Set next hop value. */ (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_local = *address; - + /* Set nexthop length. */ if (bgp_info->attr->extra->mp_nexthop_len != 32) bgp_info->attr->extra->mp_nexthop_len = 32; @@ -2086,11 +2096,11 @@ struct route_map_rule_cmd route_set_ipv6_nexthop_local_cmd = route_set_ipv6_nexthop_local_free }; #endif /* HAVE_IPV6 */ - + /* `set vpnv4 nexthop A.B.C.D' */ static route_map_result_t -route_set_vpnv4_nexthop (void *rule, struct prefix *prefix, +route_set_vpnv4_nexthop (void *rule, struct prefix *prefix, route_map_object_t type, void *object) { struct in_addr *address; @@ -2101,8 +2111,8 @@ route_set_vpnv4_nexthop (void *rule, struct prefix *prefix, /* Fetch routemap's rule information. */ address = rule; bgp_info = object; - - /* Set next hop value. */ + + /* Set next hop value. */ (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global_in = *address; } @@ -2142,7 +2152,7 @@ struct route_map_rule_cmd route_set_vpnv4_nexthop_cmd = route_set_vpnv4_nexthop_compile, route_set_vpnv4_nexthop_free }; - + /* `set originator-id' */ /* For origin set. */ @@ -2152,11 +2162,11 @@ route_set_originator_id (void *rule, struct prefix *prefix, route_map_object_t t struct in_addr *address; struct bgp_info *bgp_info; - if (type == RMAP_BGP) + if (type == RMAP_BGP) { address = rule; bgp_info = object; - + bgp_info->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID); (bgp_attr_extra_get (bgp_info->attr))->originator_id = *address; } @@ -2192,14 +2202,14 @@ route_set_originator_id_free (void *rule) } /* Set metric rule structure. */ -struct route_map_rule_cmd route_set_originator_id_cmd = +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. */ static int bgp_route_match_add (struct vty *vty, struct route_map_index *index, @@ -2318,11 +2328,11 @@ bgp_route_map_update (const char *unused) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { filter = &peer->filter[afi][safi]; - + for (direct = RMAP_IN; direct < RMAP_MAX; direct++) { if (filter->map[direct].name) - filter->map[direct].map = + filter->map[direct].map = route_map_lookup_by_name (filter->map[direct].name); else filter->map[direct].map = NULL; @@ -2340,11 +2350,11 @@ bgp_route_map_update (const char *unused) for (safi = SAFI_UNICAST; safi < SAFI_MAX; safi++) { filter = &group->conf->filter[afi][safi]; - + for (direct = RMAP_IN; direct < RMAP_MAX; direct++) { if (filter->map[direct].name) - filter->map[direct].map = + filter->map[direct].map = route_map_lookup_by_name (filter->map[direct].name); else filter->map[direct].map = NULL; @@ -2398,7 +2408,7 @@ bgp_route_map_update (const char *unused) for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { if (bgp->rmap[ZEBRA_FAMILY_IPV4][i].name) - bgp->rmap[ZEBRA_FAMILY_IPV4][i].map = + bgp->rmap[ZEBRA_FAMILY_IPV4][i].map = route_map_lookup_by_name (bgp->rmap[ZEBRA_FAMILY_IPV4][i].name); #ifdef HAVE_IPV6 if (bgp->rmap[ZEBRA_FAMILY_IPV6][i].name) @@ -2408,7 +2418,7 @@ bgp_route_map_update (const char *unused) } } } - + DEFUN (match_peer, match_peer_cmd, "match peer (A.B.C.D|X:X::X:X)", @@ -2460,7 +2470,7 @@ ALIAS (no_match_peer, "Match peer address\n" "Static or Redistributed routes\n") -DEFUN (match_ip_address, +DEFUN (match_ip_address, match_ip_address_cmd, "match ip address (<1-199>|<1300-2699>|WORD)", MATCH_STR @@ -2473,7 +2483,7 @@ DEFUN (match_ip_address, return bgp_route_match_add (vty, vty->index, "ip address", argv[0]); } -DEFUN (no_match_ip_address, +DEFUN (no_match_ip_address, no_match_ip_address_cmd, "no match ip address", NO_STR @@ -2487,7 +2497,7 @@ DEFUN (no_match_ip_address, return bgp_route_match_delete (vty, vty->index, "ip address", argv[0]); } -ALIAS (no_match_ip_address, +ALIAS (no_match_ip_address, no_match_ip_address_val_cmd, "no match ip address (<1-199>|<1300-2699>|WORD)", NO_STR @@ -2498,7 +2508,7 @@ ALIAS (no_match_ip_address, "IP access-list number (expanded range)\n" "IP Access-list name\n") -DEFUN (match_ip_next_hop, +DEFUN (match_ip_next_hop, match_ip_next_hop_cmd, "match ip next-hop (<1-199>|<1300-2699>|WORD)", MATCH_STR @@ -2536,7 +2546,7 @@ ALIAS (no_match_ip_next_hop, "IP access-list number (expanded range)\n" "IP Access-list name\n") -DEFUN (match_ip_route_source, +DEFUN (match_ip_route_source, match_ip_route_source_cmd, "match ip route-source (<1-199>|<1300-2699>|WORD)", MATCH_STR @@ -2574,7 +2584,7 @@ ALIAS (no_match_ip_route_source, "IP access-list number (expanded range)\n" "IP standard access-list name\n") -DEFUN (match_ip_address_prefix_list, +DEFUN (match_ip_address_prefix_list, match_ip_address_prefix_list_cmd, "match ip address prefix-list WORD", MATCH_STR @@ -2611,7 +2621,7 @@ ALIAS (no_match_ip_address_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") -DEFUN (match_ip_next_hop_prefix_list, +DEFUN (match_ip_next_hop_prefix_list, match_ip_next_hop_prefix_list_cmd, "match ip next-hop prefix-list WORD", MATCH_STR @@ -2648,7 +2658,7 @@ ALIAS (no_match_ip_next_hop_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") -DEFUN (match_ip_route_source_prefix_list, +DEFUN (match_ip_route_source_prefix_list, match_ip_route_source_prefix_list_cmd, "match ip route-source prefix-list WORD", MATCH_STR @@ -2685,7 +2695,7 @@ ALIAS (no_match_ip_route_source_prefix_list, "Match entries of prefix-lists\n" "IP prefix-list name\n") -DEFUN (match_metric, +DEFUN (match_metric, match_metric_cmd, "match metric <0-4294967295>", MATCH_STR @@ -2716,7 +2726,7 @@ ALIAS (no_match_metric, "Match metric of route\n" "Metric value\n") -DEFUN (match_community, +DEFUN (match_community, match_community_cmd, "match community (<1-99>|<100-500>|WORD)", MATCH_STR @@ -2728,7 +2738,7 @@ DEFUN (match_community, return bgp_route_match_add (vty, vty->index, "community", argv[0]); } -DEFUN (match_community_exact, +DEFUN (match_community_exact, match_community_exact_cmd, "match community (<1-99>|<100-500>|WORD) exact-match", MATCH_STR @@ -2784,7 +2794,7 @@ ALIAS (no_match_community, "Community-list name\n" "Do exact matching of communities\n") -DEFUN (match_ecommunity, +DEFUN (match_ecommunity, match_ecommunity_cmd, "match extcommunity (<1-99>|<100-500>|WORD)", MATCH_STR @@ -2900,7 +2910,7 @@ DEFUN (set_ip_nexthop, vty_out (vty, "%% Malformed Next-hop address%s", VTY_NEWLINE); return CMD_WARNING; } - + return bgp_route_set_add (vty, vty->index, "ip next-hop", argv[0]); } @@ -3038,7 +3048,7 @@ DEFUN (no_set_weight, { if (argc == 0) return bgp_route_set_delete (vty, vty->index, "weight", NULL); - + return bgp_route_set_delete (vty, vty->index, "weight", argv[0]); } @@ -3463,7 +3473,7 @@ DEFUN (set_aggregator_as, char *argstr; VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX); - + ret = inet_aton (argv[1], &address); if (ret == 0) { @@ -3498,7 +3508,7 @@ DEFUN (no_set_aggregator_as, if (argv == 0) return bgp_route_set_delete (vty, vty->index, "aggregator as", NULL); - + VTY_GET_INTEGER_RANGE ("AS", as, argv[0], 1, BGP_AS4_MAX); ret = inet_aton (argv[1], &address); @@ -3530,9 +3540,9 @@ ALIAS (no_set_aggregator_as, "AS number\n" "IP address of aggregator\n") - + #ifdef HAVE_IPV6 -DEFUN (match_ipv6_address, +DEFUN (match_ipv6_address, match_ipv6_address_cmd, "match ipv6 address WORD", MATCH_STR @@ -3543,7 +3553,7 @@ DEFUN (match_ipv6_address, return bgp_route_match_add (vty, vty->index, "ipv6 address", argv[0]); } -DEFUN (no_match_ipv6_address, +DEFUN (no_match_ipv6_address, no_match_ipv6_address_cmd, "no match ipv6 address WORD", NO_STR @@ -3555,7 +3565,7 @@ DEFUN (no_match_ipv6_address, return bgp_route_match_delete (vty, vty->index, "ipv6 address", argv[0]); } -DEFUN (match_ipv6_next_hop, +DEFUN (match_ipv6_next_hop, match_ipv6_next_hop_cmd, "match ipv6 next-hop X:X::X:X", MATCH_STR @@ -3578,7 +3588,7 @@ DEFUN (no_match_ipv6_next_hop, return bgp_route_match_delete (vty, vty->index, "ipv6 next-hop", argv[0]); } -DEFUN (match_ipv6_address_prefix_list, +DEFUN (match_ipv6_address_prefix_list, match_ipv6_address_prefix_list_cmd, "match ipv6 address prefix-list WORD", MATCH_STR @@ -3663,7 +3673,7 @@ DEFUN (no_set_ipv6_nexthop_local, { if (argc == 0) return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop local", NULL); - + return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop local", argv[0]); } @@ -3731,7 +3741,7 @@ DEFUN (no_set_originator_id, { if (argc == 0) return bgp_route_set_delete (vty, vty->index, "originator-id", NULL); - + return bgp_route_set_delete (vty, vty->index, "originator-id", argv[0]); } @@ -3763,7 +3773,7 @@ DEFUN (no_set_pathlimit_ttl, { if (argc == 0) return bgp_route_set_delete (vty, vty->index, "pathlimit ttl", NULL); - + return bgp_route_set_delete (vty, vty->index, "pathlimit ttl", argv[0]); } @@ -3795,7 +3805,7 @@ DEFUN (no_match_pathlimit_as, { if (argc == 0) return bgp_route_match_delete (vty, vty->index, "pathlimit as", NULL); - + return bgp_route_match_delete (vty, vty->index, "pathlimit as", argv[0]); } @@ -3807,7 +3817,7 @@ ALIAS (no_match_pathlimit_as, "BGP AS-Pathlimit attribute\n" "Match Pathlimit ASN\n") - + /* Initialization of route map. */ void bgp_route_map_init (void) @@ -3944,7 +3954,7 @@ bgp_route_map_init (void) route_map_install_match (&route_match_ipv6_address_prefix_list_cmd); route_map_install_set (&route_set_ipv6_nexthop_global_cmd); route_map_install_set (&route_set_ipv6_nexthop_local_cmd); - + install_element (RMAP_NODE, &match_ipv6_address_cmd); install_element (RMAP_NODE, &no_match_ipv6_address_cmd); install_element (RMAP_NODE, &match_ipv6_next_hop_cmd); |