diff options
Diffstat (limited to 'bgpd/bgp_routemap.c')
-rw-r--r-- | bgpd/bgp_routemap.c | 121 |
1 files changed, 11 insertions, 110 deletions
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index aa7dbce1..81ff48db 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -92,107 +92,15 @@ o Cisco route-map origin : Done tag : (This will not be implemented by bgpd) weight : Done - pathlimit : Done o Local extention set ipv6 next-hop global: Done set ipv6 next-hop local : Done - set pathlimit ttl : Done 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 - */ -static void * -route_pathlimit_compile (const char *arg) -{ - unsigned long tmp; - u_int32_t *val; - char *endptr = NULL; - - /* 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; -} - -static void -route_pathlimit_free (void *rule) -{ - XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); -} - -static route_map_result_t -route_match_pathlimit_as (void *rule, struct prefix *prefix, route_map_object_t type, - void *object) -{ - 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; -} - -/* 'match pathlimit as' */ -struct route_map_rule_cmd route_match_pathlimit_as_cmd = -{ - "pathlimit as", - route_match_pathlimit_as, - route_pathlimit_compile, - route_pathlimit_free -}; - -/* Set pathlimit TTL. */ -static route_map_result_t -route_set_pathlimit_ttl (void *rule, struct prefix *prefix, - route_map_object_t type, void *object) -{ - 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); - attr->pathlimit.ttl = ttl; - attr->pathlimit.as = 0; - } - - return RMAP_OKAY; -} - -/* Set local preference rule structure. */ -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 @@ -3743,17 +3651,17 @@ ALIAS (no_set_originator_id, "BGP originator ID attribute\n" "IP address of originator\n") -DEFUN (set_pathlimit_ttl, +DEFUN_DEPRECATED (set_pathlimit_ttl, set_pathlimit_ttl_cmd, "set pathlimit ttl <1-255>", SET_STR "BGP AS-Pathlimit attribute\n" "Set AS-Path Hop-count TTL\n") { - return bgp_route_set_add (vty, vty->index, "pathlimit ttl", argv[0]); + return CMD_SUCCESS; } -DEFUN (no_set_pathlimit_ttl, +DEFUN_DEPRECATED (no_set_pathlimit_ttl, no_set_pathlimit_ttl_cmd, "no set pathlimit ttl", NO_STR @@ -3761,10 +3669,7 @@ DEFUN (no_set_pathlimit_ttl, "BGP AS-Pathlimit attribute\n" "Set AS-Path Hop-count TTL\n") { - 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]); + return CMD_SUCCESS; } ALIAS (no_set_pathlimit_ttl, @@ -3775,17 +3680,17 @@ ALIAS (no_set_pathlimit_ttl, "BGP AS-Pathlimit attribute\n" "Set AS-Path Hop-count TTL\n") -DEFUN (match_pathlimit_as, +DEFUN_DEPRECATED (match_pathlimit_as, match_pathlimit_as_cmd, "match pathlimit as <1-65535>", MATCH_STR "BGP AS-Pathlimit attribute\n" "Match Pathlimit AS number\n") { - return bgp_route_match_add (vty, vty->index, "pathlimit as", argv[0]); + return CMD_SUCCESS; } -DEFUN (no_match_pathlimit_as, +DEFUN_DEPRECATED (no_match_pathlimit_as, no_match_pathlimit_as_cmd, "no match pathlimit as", NO_STR @@ -3793,10 +3698,7 @@ DEFUN (no_match_pathlimit_as, "BGP AS-Pathlimit attribute\n" "Match Pathlimit AS number\n") { - 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]); + return CMD_SUCCESS; } ALIAS (no_match_pathlimit_as, @@ -3959,10 +3861,9 @@ bgp_route_map_init (void) install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_val_cmd); #endif /* HAVE_IPV6 */ - /* AS-Pathlimit */ - route_map_install_match (&route_match_pathlimit_as_cmd); - route_map_install_set (&route_set_pathlimit_ttl_cmd); - + /* AS-Pathlimit: functionality removed, commands kept for + * compatibility. + */ install_element (RMAP_NODE, &set_pathlimit_ttl_cmd); install_element (RMAP_NODE, &no_set_pathlimit_ttl_cmd); install_element (RMAP_NODE, &no_set_pathlimit_ttl_val_cmd); |