summaryrefslogtreecommitdiff
path: root/zebra/zebra_routemap.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/zebra_routemap.c')
-rw-r--r--zebra/zebra_routemap.c728
1 files changed, 207 insertions, 521 deletions
diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c
index 041f67826b..6ec43e592c 100644
--- a/zebra/zebra_routemap.c
+++ b/zebra/zebra_routemap.c
@@ -13,10 +13,9 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with GNU Zebra; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <zebra.h>
@@ -25,6 +24,7 @@
#include "zebra_memory.h"
#include "prefix.h"
#include "rib.h"
+#include "vty.h"
#include "routemap.h"
#include "command.h"
#include "filter.h"
@@ -56,6 +56,8 @@ struct nh_rmap_obj
static void zebra_route_map_set_delay_timer(u_int32_t value);
+
+
/* Add zebra route map rule */
static int
zebra_route_match_add(struct vty *vty,
@@ -138,54 +140,6 @@ zebra_route_match_delete (struct vty *vty,
return CMD_SUCCESS;
}
-/* Add zebra route map rule. */
-static int
-zebra_route_set_add (struct vty *vty,
- const char *command, const char *arg)
-{
- VTY_DECLVAR_CONTEXT (route_map_index, index);
- int ret;
-
- ret = route_map_add_set (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "%% Zebra Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "%% Zebra Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- return CMD_SUCCESS;
-}
-
-/* Delete zebra route map rule. */
-static int
-zebra_route_set_delete (struct vty *vty,
- const char *command, const char *arg)
-{
- VTY_DECLVAR_CONTEXT (route_map_index, index);
- int ret;
-
- ret = route_map_delete_set (index, command, arg);
- if (ret)
- {
- switch (ret)
- {
- case RMAP_RULE_MISSING:
- vty_out (vty, "%% Zebra Can't find rule.%s", VTY_NEWLINE);
- return CMD_WARNING;
- case RMAP_COMPILE_ERROR:
- vty_out (vty, "%% Zebra Argument is malformed.%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- return CMD_SUCCESS;
-}
-
/* 'match tag TAG'
* Match function return 1 if match is success else return 0
*/
@@ -210,8 +164,8 @@ route_match_tag (void *rule, struct prefix *prefix,
/* Route map commands for tag matching */
static struct route_map_rule_cmd route_match_tag_cmd =
{
- "tag",
- route_match_tag,
+ "tag",
+ route_match_tag,
route_map_rule_tag_compile,
route_map_rule_tag_free,
};
@@ -234,7 +188,7 @@ route_match_interface (void *rule, struct prefix *prefix,
nh_data = object;
if (!nh_data || !nh_data->nexthop)
return RMAP_NOMATCH;
- ifindex = ifname2ifindex_vrf (ifname, nh_data->vrf_id);
+ ifindex = ifname2ifindex (ifname, nh_data->vrf_id);
if (ifindex == 0)
return RMAP_NOMATCH;
if (nh_data->nexthop->ifindex == ifindex)
@@ -266,240 +220,9 @@ struct route_map_rule_cmd route_match_interface_cmd =
route_match_interface_free
};
-DEFUN (match_interface,
- match_interface_cmd,
- "match interface WORD",
- MATCH_STR
- "match first hop interface of route\n"
- "Interface name\n")
-{
- return zebra_route_match_add (vty, "interface", argv[0],
- RMAP_EVENT_MATCH_ADDED);
-}
-
-DEFUN (no_match_interface,
- no_match_interface_cmd,
- "no match interface",
- NO_STR
- MATCH_STR
- "Match first hop interface of route\n")
-{
- if (argc == 0)
- return zebra_route_match_delete (vty, "interface", NULL, RMAP_EVENT_MATCH_DELETED);
-
- return zebra_route_match_delete (vty, "interface", argv[0], RMAP_EVENT_MATCH_DELETED);
-}
-
-ALIAS (no_match_interface,
- no_match_interface_val_cmd,
- "no match interface WORD",
- NO_STR
- MATCH_STR
- "Match first hop interface of route\n"
- "Interface name\n")
-
-DEFUN (match_tag,
- match_tag_cmd,
- "match tag <1-4294967295>",
- MATCH_STR
- "Match tag of route\n"
- "Tag value\n")
-{
- return zebra_route_match_add (vty, "tag", argv[0],
- RMAP_EVENT_MATCH_ADDED);
-}
-
-DEFUN (no_match_tag,
- no_match_tag_cmd,
- "no match tag",
- NO_STR
- MATCH_STR
- "Match tag of route\n")
-{
- if (argc == 0)
- return zebra_route_match_delete (vty, "tag", NULL,
- RMAP_EVENT_MATCH_DELETED);
-
- return zebra_route_match_delete (vty, "tag", argv[0],
- RMAP_EVENT_MATCH_DELETED);
-}
-
-ALIAS (no_match_tag,
- no_match_tag_val_cmd,
- "no match tag <1-4294967295>",
- NO_STR
- MATCH_STR
- "Match tag of route\n")
-
-DEFUN (match_ip_next_hop,
- match_ip_next_hop_cmd,
- "match ip next-hop (<1-199>|<1300-2699>|WORD)",
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-{
- return zebra_route_match_add (vty, "ip next-hop", argv[0], RMAP_EVENT_FILTER_ADDED);
-}
-
-DEFUN (no_match_ip_next_hop,
- no_match_ip_next_hop_cmd,
- "no match ip next-hop",
- NO_STR
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n")
-{
- if (argc == 0)
- return zebra_route_match_delete (vty, "ip next-hop", NULL,
- RMAP_EVENT_FILTER_DELETED);
-
- return zebra_route_match_delete (vty, "ip next-hop", argv[0],
- RMAP_EVENT_FILTER_DELETED);
-}
-
-ALIAS (no_match_ip_next_hop,
- no_match_ip_next_hop_val_cmd,
- "no match ip next-hop (<1-199>|<1300-2699>|WORD)",
- NO_STR
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-
-DEFUN (match_ip_next_hop_prefix_list,
- match_ip_next_hop_prefix_list_cmd,
- "match ip next-hop prefix-list WORD",
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- return zebra_route_match_add (vty, "ip next-hop prefix-list",
- argv[0], RMAP_EVENT_PLIST_ADDED);
-}
-
-DEFUN (no_match_ip_next_hop_prefix_list,
- no_match_ip_next_hop_prefix_list_cmd,
- "no match ip next-hop prefix-list",
- NO_STR
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "Match entries of prefix-lists\n")
-{
- if (argc == 0)
- return zebra_route_match_delete (vty,
- "ip next-hop prefix-list", NULL,
- RMAP_EVENT_PLIST_DELETED);
-
- return zebra_route_match_delete (vty,
- "ip next-hop prefix-list", argv[0],
- RMAP_EVENT_PLIST_DELETED);
-}
-
-ALIAS (no_match_ip_next_hop_prefix_list,
- no_match_ip_next_hop_prefix_list_val_cmd,
- "no match ip next-hop prefix-list WORD",
- NO_STR
- MATCH_STR
- IP_STR
- "Match next-hop address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-
-DEFUN (match_ip_address,
- match_ip_address_cmd,
- "match ip address (<1-199>|<1300-2699>|WORD)",
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-
-{
- return zebra_route_match_add (vty, "ip address", argv[0],
- RMAP_EVENT_FILTER_ADDED);
-}
-
-DEFUN (no_match_ip_address,
- no_match_ip_address_cmd,
- "no match ip address",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n")
-{
- if (argc == 0)
- return zebra_route_match_delete (vty, "ip address", NULL,
- RMAP_EVENT_FILTER_DELETED);
-
- return zebra_route_match_delete (vty, "ip address", argv[0],
- RMAP_EVENT_FILTER_DELETED);
-}
-
-ALIAS (no_match_ip_address,
- no_match_ip_address_val_cmd,
- "no match ip address (<1-199>|<1300-2699>|WORD)",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "IP access-list number\n"
- "IP access-list number (expanded range)\n"
- "IP Access-list name\n")
-
-DEFUN (match_ip_address_prefix_list,
- match_ip_address_prefix_list_cmd,
- "match ip address prefix-list WORD",
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-{
- return zebra_route_match_add (vty, "ip address prefix-list",
- argv[0], RMAP_EVENT_PLIST_ADDED);
-}
-
-DEFUN (no_match_ip_address_prefix_list,
- no_match_ip_address_prefix_list_cmd,
- "no match ip address prefix-list",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n")
-{
- if (argc == 0)
- return zebra_route_match_delete (vty,
- "ip address prefix-list", NULL,
- RMAP_EVENT_PLIST_DELETED);
-
- return zebra_route_match_delete (vty,
- "ip address prefix-list", argv[0],
- RMAP_EVENT_PLIST_DELETED);
-}
-
-ALIAS (no_match_ip_address_prefix_list,
- no_match_ip_address_prefix_list_val_cmd,
- "no match ip address prefix-list WORD",
- NO_STR
- MATCH_STR
- IP_STR
- "Match address of route\n"
- "Match entries of prefix-lists\n"
- "IP prefix-list name\n")
-
DEFUN (match_ip_address_prefix_len,
match_ip_address_prefix_len_cmd,
- "match ip address prefix-len NUMBER",
+ "match ip address prefix-len (0-32)",
MATCH_STR
IP_STR
"Match prefix length of ip address\n"
@@ -507,40 +230,29 @@ DEFUN (match_ip_address_prefix_len,
"Prefix length\n")
{
return zebra_route_match_add (vty, "ip address prefix-len",
- argv[0], RMAP_EVENT_MATCH_ADDED);
+ argv[4]->arg, RMAP_EVENT_MATCH_ADDED);
}
DEFUN (no_match_ip_address_prefix_len,
no_match_ip_address_prefix_len_cmd,
- "no match ip address prefix-len",
+ "no match ip address prefix-len [(0-32)]",
NO_STR
MATCH_STR
IP_STR
- "Match prefixlen of ip address of route\n"
- "prefix length of ip address\n")
+ "Match prefix length of ip address\n"
+ "Match prefix length of ip address\n"
+ "Prefix length\n")
{
- if (argc == 0)
- return zebra_route_match_delete (vty,
- "ip address prefix-len", NULL,
- RMAP_EVENT_MATCH_DELETED);
-
+ char *plen = (argc == 6) ? argv[5]->arg : NULL;
return zebra_route_match_delete (vty,
- "ip address prefix-len", argv[0],
+ "ip address prefix-len", plen,
RMAP_EVENT_MATCH_DELETED);
}
-ALIAS (no_match_ip_address_prefix_len,
- no_match_ip_address_prefix_len_val_cmd,
- "no match ip address prefix-len NUMBER",
- NO_STR
- MATCH_STR
- IP_STR
- "Match prefixlen of ip address of route\n"
- "prefix length of ip address\n")
DEFUN (match_ip_nexthop_prefix_len,
match_ip_nexthop_prefix_len_cmd,
- "match ip next-hop prefix-len NUMBER",
+ "match ip next-hop prefix-len (0-32)",
MATCH_STR
IP_STR
"Match prefixlen of nexthop ip address\n"
@@ -548,96 +260,95 @@ DEFUN (match_ip_nexthop_prefix_len,
"Prefix length\n")
{
return zebra_route_match_add (vty, "ip next-hop prefix-len",
- argv[0], RMAP_EVENT_MATCH_ADDED);
+ argv[4]->arg, RMAP_EVENT_MATCH_ADDED);
}
DEFUN (no_match_ip_nexthop_prefix_len,
no_match_ip_nexthop_prefix_len_cmd,
- "no match ip next-hop prefix-len",
+ "no match ip next-hop prefix-len [(0-32)]",
NO_STR
MATCH_STR
IP_STR
"Match prefixlen of nexthop ip address\n"
- "Match prefix length of nexthop\n")
+ "Match prefix length of nexthop\n"
+ "Prefix length\n")
{
- if (argc == 0)
- return zebra_route_match_delete (vty,
- "ip next-hop prefix-len", NULL,
- RMAP_EVENT_MATCH_DELETED);
-
+ char *plen = (argc == 6) ? argv[5]->arg : NULL;
return zebra_route_match_delete (vty,
- "ip next-hop prefix-len", argv[0],
+ "ip next-hop prefix-len", plen,
RMAP_EVENT_MATCH_DELETED);
}
-ALIAS (no_match_ip_nexthop_prefix_len,
- no_match_ip_nexthop_prefix_len_val_cmd,
- "no match ip next-hop prefix-len NUMBER",
- MATCH_STR
- "Match prefixlen of ip address of route\n"
- "prefix length of ip address\n")
DEFUN (match_source_protocol,
match_source_protocol_cmd,
- "match source-protocol (bgp|ospf|rip|ripng|isis|ospf6|connected|system|kernel|static)",
+ "match source-protocol <bgp|ospf|rip|ripng|isis|ospf6|connected|system|kernel|static>",
MATCH_STR
- "Match protocol via which the route was learnt\n")
-{
+ "Match protocol via which the route was learnt\n"
+ "BGP protocol\n"
+ "OSPF protocol\n"
+ "RIP protocol\n"
+ "RIPNG protocol\n"
+ "ISIS protocol\n"
+ "OSPF6 protocol\n"
+ "Routes from directly connected peer\n"
+ "Routes from system configuration\n"
+ "Routes from kernel\n"
+ "Statically configured routes\n")
+{
+ char *proto = argv[2]->text;
int i;
- i = proto_name2num(argv[0]);
+ i = proto_name2num(proto);
if (i < 0)
{
- vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
- VTY_NEWLINE);
+ vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE);
return CMD_WARNING;
}
- return zebra_route_match_add (vty, "source-protocol",
- argv[0], RMAP_EVENT_MATCH_ADDED);
+ return zebra_route_match_add (vty, "source-protocol", proto, RMAP_EVENT_MATCH_ADDED);
}
DEFUN (no_match_source_protocol,
no_match_source_protocol_cmd,
- "no match source-protocol (bgp|ospf|rip|ripng|isis|ospf6|connected|system|kernel|static)",
+ "no match source-protocol [<bgp|ospf|rip|ripng|isis|ospf6|connected|system|kernel|static>]",
NO_STR
MATCH_STR
- "No match protocol via which the route was learnt\n")
-{
- int i;
-
- if (argc >= 1)
- {
- i = proto_name2num(argv[0]);
- if (i < 0)
- {
- vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
- VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
- return zebra_route_match_delete (vty,
- "source-protocol", argv[0] ? argv[0] : NULL,
- RMAP_EVENT_MATCH_DELETED);
+ "No match protocol via which the route was learnt\n"
+ "BGP protocol\n"
+ "OSPF protocol\n"
+ "RIP protocol\n"
+ "RIPNG protocol\n"
+ "ISIS protocol\n"
+ "OSPF6 protocol\n"
+ "Routes from directly connected peer\n"
+ "Routes from system configuration\n"
+ "Routes from kernel\n"
+ "Statically configured routes\n")
+{
+ char *proto = (argc == 4) ? argv[3]->text : NULL;
+ return zebra_route_match_delete (vty, "source-protocol", proto, RMAP_EVENT_MATCH_DELETED);
}
/* set functions */
DEFUN (set_src,
set_src_cmd,
- "set src (A.B.C.D|X:X::X:X)",
+ "set src <A.B.C.D|X:X::X:X>",
SET_STR
"src address for route\n"
- "src address\n")
+ "IPv4 src address\n"
+ "IPv6 src address\n")
{
+ int idx_ip = 2;
union g_addr src;
struct interface *pif = NULL;
int family;
struct prefix p;
struct vrf *vrf;
- if (inet_pton(AF_INET, argv[0], &src.ipv4) != 1)
+ if (inet_pton(AF_INET, argv[idx_ip]->arg, &src.ipv4) != 1)
{
- if (inet_pton(AF_INET6, argv[0], &src.ipv6) != 1)
+ if (inet_pton(AF_INET6, argv[idx_ip]->arg, &src.ipv6) != 1)
{
vty_out (vty, "%% not a valid IPv4/v6 address%s", VTY_NEWLINE);
return CMD_WARNING;
@@ -656,18 +367,18 @@ DEFUN (set_src,
if (!zebra_check_addr(&p))
{
- vty_out (vty, "%% not a valid source IPv4/v6 address%s", VTY_NEWLINE);
- return CMD_WARNING;
+ vty_out (vty, "%% not a valid source IPv4/v6 address%s", VTY_NEWLINE);
+ return CMD_WARNING;
}
RB_FOREACH (vrf, vrf_id_head, &vrfs_by_id)
{
if (family == AF_INET)
- pif = if_lookup_exact_address_vrf ((void *)&src.ipv4, AF_INET,
- vrf->vrf_id);
+ pif = if_lookup_exact_address ((void *)&src.ipv4, AF_INET,
+ vrf->vrf_id);
else if (family == AF_INET6)
- pif = if_lookup_exact_address_vrf ((void *)&src.ipv6, AF_INET6,
- vrf->vrf_id);
+ pif = if_lookup_exact_address ((void *)&src.ipv6, AF_INET6,
+ vrf->vrf_id);
if (pif != NULL)
break;
@@ -678,31 +389,37 @@ DEFUN (set_src,
vty_out (vty, "%% not a local address%s", VTY_NEWLINE);
return CMD_WARNING;
}
- return zebra_route_set_add (vty, "src", argv[0]);
+
+ VTY_DECLVAR_CONTEXT (route_map_index, index);
+ return generic_set_add (vty, index, "src", argv[idx_ip]->arg);
}
DEFUN (no_set_src,
no_set_src_cmd,
- "no set src {A.B.C.D|X:X::X:X}",
+ "no set src [<A.B.C.D|X:X::X:X>]",
NO_STR
SET_STR
- "Source address for route\n")
+ "Source address for route\n"
+ "IPv4 address\n"
+ "IPv6 address\n")
{
- if (argc == 0)
- return zebra_route_set_delete (vty, "src", NULL);
-
- return zebra_route_set_delete (vty, "src", argv[0]);
+ char *ip = (argc == 4) ? argv[3]->arg : NULL;
+ VTY_DECLVAR_CONTEXT (route_map_index, index);
+ return generic_set_delete (vty, index, "src", ip);
}
DEFUN (zebra_route_map_timer,
zebra_route_map_timer_cmd,
- "zebra route-map delay-timer <0-600>",
+ "zebra route-map delay-timer (0-600)",
+ "Zebra information\n"
+ "Set route-map parameters\n"
"Time to wait before route-map updates are processed\n"
"0 means event-driven updates are disabled\n")
{
+ int idx_number = 3;
u_int32_t rmap_delay_timer;
- VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[0], 0, 600);
+ VTY_GET_INTEGER_RANGE ("delay-timer", rmap_delay_timer, argv[idx_number]->arg, 0, 600);
zebra_route_map_set_delay_timer(rmap_delay_timer);
return (CMD_SUCCESS);
@@ -710,23 +427,18 @@ DEFUN (zebra_route_map_timer,
DEFUN (no_zebra_route_map_timer,
no_zebra_route_map_timer_cmd,
- "no zebra route-map delay-timer",
+ "no zebra route-map delay-timer [(0-600)]",
NO_STR
- "Time to wait before route-map updates are processed\n"
- "Reset delay-timer to default value, 30 secs\n")
+ "Zebra information\n"
+ "Set route-map parameters\n"
+ "Reset delay-timer to default value, 30 secs\n"
+ "0 means event-driven updates are disabled\n")
{
zebra_route_map_set_delay_timer(ZEBRA_RMAP_DEFAULT_UPDATE_TIMER);
return (CMD_SUCCESS);
}
-ALIAS (no_zebra_route_map_timer,
- no_zebra_route_map_timer_val_cmd,
- "no zebra route-map delay-timer <0-600>",
- NO_STR
- "Time to wait before route-map updates are processed\n"
- "Reset delay-timer to default value, 30 secs\n"
- "0 means event-driven updates are disabled\n")
DEFUN (ip_protocol,
ip_protocol_cmd,
@@ -734,32 +446,34 @@ DEFUN (ip_protocol,
IP_STR
"Filter routing info exchanged between zebra and protocol\n"
FRR_IP_PROTOCOL_MAP_HELP_STR_ZEBRA
+ "Specify route-map\n"
"Route map name\n")
{
+ char *proto = argv[2]->text;
+ char *rmap = argv[4]->arg;
int i;
- if (strcasecmp(argv[0], "any") == 0)
+ if (strcasecmp(proto, "any") == 0)
i = ZEBRA_ROUTE_MAX;
else
- i = proto_name2num(argv[0]);
+ i = proto_name2num(proto);
if (i < 0)
{
- vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
- VTY_NEWLINE);
+ vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE);
return CMD_WARNING;
}
if (proto_rm[AFI_IP][i])
{
- if (strcmp(proto_rm[AFI_IP][i], argv[1]) == 0)
+ if (strcmp(proto_rm[AFI_IP][i], rmap) == 0)
return CMD_SUCCESS;
XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
}
- proto_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]);
+ proto_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap);
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug ("%u: IPv4 Routemap config for protocol %s, scheduling RIB processing",
- VRF_DEFAULT, argv[0]);
+ VRF_DEFAULT, proto);
rib_update(VRF_DEFAULT, RIB_UPDATE_RMAP_CHANGE);
return CMD_SUCCESS;
@@ -767,51 +481,45 @@ DEFUN (ip_protocol,
DEFUN (no_ip_protocol,
no_ip_protocol_cmd,
- "no ip protocol " FRR_IP_PROTOCOL_MAP_STR_ZEBRA,
+ "no ip protocol " FRR_IP_PROTOCOL_MAP_STR_ZEBRA " [route-map ROUTE-MAP]",
NO_STR
IP_STR
"Stop filtering routing info between zebra and protocol\n"
FRR_IP_PROTOCOL_MAP_HELP_STR_ZEBRA
- "Protocol from which to stop filtering routes\n")
+ "Specify route map\n"
+ "Route map name\n")
{
+ char *proto = argv[3]->text;
+ char *rmap = (argc == 6) ? argv[5]->arg : NULL;
int i;
- if (strcasecmp(argv[0], "any") == 0)
+ if (strcasecmp(proto, "any") == 0)
i = ZEBRA_ROUTE_MAX;
else
- i = proto_name2num(argv[0]);
+ i = proto_name2num(proto);
+
if (i < 0)
{
- vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
- VTY_NEWLINE);
+ vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE);
return CMD_WARNING;
}
+
if (!proto_rm[AFI_IP][i])
return CMD_SUCCESS;
- if ((argc == 2 && strcmp(argv[1], proto_rm[AFI_IP][i]) == 0) ||
- (argc < 2))
+ if (!rmap || strcmp (rmap, proto_rm[AFI_IP][i]) == 0)
{
XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP][i]);
proto_rm[AFI_IP][i] = NULL;
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug ("%u: IPv4 Routemap unconfig for protocol %s, scheduling RIB processing",
- VRF_DEFAULT, argv[0]);
+ VRF_DEFAULT, proto);
rib_update(VRF_DEFAULT, RIB_UPDATE_RMAP_CHANGE);
}
return CMD_SUCCESS;
}
-ALIAS (no_ip_protocol,
- no_ip_protocol_val_cmd,
- "no ip protocol " FRR_IP_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP",
- NO_STR
- IP_STR
- "Stop filtering routing info between zebra and protocol\n"
- FRR_IP_PROTOCOL_MAP_HELP_STR_ZEBRA
- "route map name")
-
DEFUN (show_ip_protocol,
show_ip_protocol_cmd,
"show ip protocol",
@@ -847,32 +555,34 @@ DEFUN (ipv6_protocol,
IP6_STR
"Filter IPv6 routing info exchanged between zebra and protocol\n"
FRR_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA
+ "Specify route map\n"
"Route map name\n")
{
+ char *proto = argv[2]->text;
+ char *rmap = argv[4]->arg;
int i;
- if (strcasecmp(argv[0], "any") == 0)
+ if (strcasecmp(proto, "any") == 0)
i = ZEBRA_ROUTE_MAX;
else
- i = proto_name2num(argv[0]);
+ i = proto_name2num(proto);
if (i < 0)
{
- vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
- VTY_NEWLINE);
+ vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE);
return CMD_WARNING;
}
if (proto_rm[AFI_IP6][i])
{
- if (strcmp(proto_rm[AFI_IP6][i], argv[1]) == 0)
+ if (strcmp(proto_rm[AFI_IP6][i], rmap) == 0)
return CMD_SUCCESS;
XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP6][i]);
}
- proto_rm[AFI_IP6][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]);
+ proto_rm[AFI_IP6][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap);
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug ("%u: IPv6 Routemap config for protocol %s, scheduling RIB processing",
- VRF_DEFAULT, argv[0]);
+ VRF_DEFAULT, proto);
rib_update(VRF_DEFAULT, RIB_UPDATE_RMAP_CHANGE);
return CMD_SUCCESS;
@@ -880,52 +590,44 @@ DEFUN (ipv6_protocol,
DEFUN (no_ipv6_protocol,
no_ipv6_protocol_cmd,
- "no ipv6 protocol " FRR_IP6_PROTOCOL_MAP_STR_ZEBRA,
+ "no ipv6 protocol " FRR_IP6_PROTOCOL_MAP_STR_ZEBRA " [route-map ROUTE-MAP]",
NO_STR
IP6_STR
"Stop filtering IPv6 routing info between zebra and protocol\n"
FRR_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA
- "Protocol from which to stop filtering routes\n")
+ "Specify route map\n"
+ "Route map name\n")
{
+ const char *proto = argv[3]->text;
+ const char *rmap = (argc == 6) ? argv[5]->arg : NULL;
int i;
- if (strcasecmp(argv[0], "any") == 0)
+ if (strcasecmp(proto, "any") == 0)
i = ZEBRA_ROUTE_MAX;
else
- i = proto_name2num(argv[0]);
+ i = proto_name2num(proto);
if (i < 0)
{
- vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
- VTY_NEWLINE);
+ vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE);
return CMD_WARNING;
}
if (!proto_rm[AFI_IP6][i])
return CMD_SUCCESS;
- if ((argc == 2 && strcmp(argv[1], proto_rm[AFI_IP6][i]) == 0) ||
- (argc < 2))
+ if (!rmap || strcmp(rmap, proto_rm[AFI_IP6][i]) == 0)
{
XFREE (MTYPE_ROUTE_MAP_NAME, proto_rm[AFI_IP6][i]);
proto_rm[AFI_IP6][i] = NULL;
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug ("%u: IPv6 Routemap unconfig for protocol %s, scheduling RIB processing",
- VRF_DEFAULT, argv[0]);
+ VRF_DEFAULT, proto);
rib_update(VRF_DEFAULT, RIB_UPDATE_RMAP_CHANGE);
}
return CMD_SUCCESS;
}
-ALIAS (no_ipv6_protocol,
- no_ipv6_protocol_val_cmd,
- "no ipv6 protocol " FRR_IP6_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP",
- NO_STR
- IP6_STR
- "Stop filtering IPv6 routing info between zebra and protocol\n"
- FRR_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA
- "route map name")
-
DEFUN (show_ipv6_protocol,
show_ipv6_protocol_cmd,
"show ipv6 protocol",
@@ -961,29 +663,31 @@ DEFUN (ip_protocol_nht_rmap,
IP_STR
"Filter Next Hop tracking route resolution\n"
FRR_IP_PROTOCOL_MAP_HELP_STR_ZEBRA
+ "Specify route map\n"
"Route map name\n")
{
+ char *proto = argv[2]->text;
+ char *rmap = argv[4]->arg;
int i;
- if (strcasecmp(argv[0], "any") == 0)
+ if (strcasecmp(proto, "any") == 0)
i = ZEBRA_ROUTE_MAX;
else
- i = proto_name2num(argv[0]);
+ i = proto_name2num(proto);
if (i < 0)
{
- vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
- VTY_NEWLINE);
+ vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE);
return CMD_WARNING;
}
if (nht_rm[AFI_IP][i])
{
- if (strcmp(nht_rm[AFI_IP][i], argv[1]) == 0)
+ if (strcmp(nht_rm[AFI_IP][i], rmap) == 0)
return CMD_SUCCESS;
XFREE (MTYPE_ROUTE_MAP_NAME, nht_rm[AFI_IP][i]);
}
- nht_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]);
+ nht_rm[AFI_IP][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap);
zebra_evaluate_rnh(0, AF_INET, 1, RNH_NEXTHOP_TYPE, NULL);
return CMD_SUCCESS;
@@ -991,29 +695,30 @@ DEFUN (ip_protocol_nht_rmap,
DEFUN (no_ip_protocol_nht_rmap,
no_ip_protocol_nht_rmap_cmd,
- "no ip nht " FRR_IP_PROTOCOL_MAP_STR_ZEBRA,
+ "no ip nht " FRR_IP_PROTOCOL_MAP_STR_ZEBRA " [route-map ROUTE-MAP]",
NO_STR
IP_STR
"Filter Next Hop tracking route resolution\n"
- FRR_IP_PROTOCOL_MAP_HELP_STR_ZEBRA)
+ FRR_IP_PROTOCOL_MAP_HELP_STR_ZEBRA
+ "Specify route map\n"
+ "Route map name\n")
{
- int i;
+ int idx = 0;
+ char *proto = argv[3]->text;
+ char *rmap = argv_find (argv, argc, "ROUTE-MAP", &idx) ? argv[idx]->arg : NULL;
+
+ int i = strmatch(proto, "any") ? ZEBRA_ROUTE_MAX : proto_name2num(proto);
- if (strcasecmp(argv[0], "any") == 0)
- i = ZEBRA_ROUTE_MAX;
- else
- i = proto_name2num(argv[0]);
if (i < 0)
{
- vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
- VTY_NEWLINE);
- return CMD_WARNING;
+ vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE);
+ return CMD_WARNING;
}
+
if (!nht_rm[AFI_IP][i])
return CMD_SUCCESS;
- if ((argc == 2 && strcmp(argv[1], nht_rm[AFI_IP][i]) == 0) ||
- (argc < 2))
+ if (!rmap || strcmp(rmap, nht_rm[AFI_IP][i]) == 0)
{
XFREE (MTYPE_ROUTE_MAP_NAME, nht_rm[AFI_IP][i]);
nht_rm[AFI_IP][i] = NULL;
@@ -1022,19 +727,12 @@ DEFUN (no_ip_protocol_nht_rmap,
return CMD_SUCCESS;
}
-ALIAS (no_ip_protocol_nht_rmap,
- no_ip_protocol_nht_rmap_val_cmd,
- "no ip nht " FRR_IP_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP",
- IP_STR
- "Filter Next Hop tracking route resolution\n"
- FRR_IP_PROTOCOL_MAP_HELP_STR_ZEBRA
- "Route map name\n")
-
DEFUN (show_ip_protocol_nht,
show_ip_protocol_nht_cmd,
"show ip nht route-map",
- SHOW_STR
- IP_STR
+ SHOW_STR
+ IP_STR
+ "IP nexthop tracking table\n"
"IP Next Hop tracking filtering status\n")
{
int i;
@@ -1065,23 +763,25 @@ DEFUN (ipv6_protocol_nht_rmap,
IP6_STR
"Filter Next Hop tracking route resolution\n"
FRR_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA
+ "Specify route map\n"
"Route map name\n")
{
+ char *proto = argv[2]->text;
+ char *rmap = argv[4]->arg;
int i;
- if (strcasecmp(argv[0], "any") == 0)
+ if (strcasecmp(proto, "any") == 0)
i = ZEBRA_ROUTE_MAX;
else
- i = proto_name2num(argv[0]);
+ i = proto_name2num(proto);
if (i < 0)
{
- vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
- VTY_NEWLINE);
+ vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE);
return CMD_WARNING;
}
if (nht_rm[AFI_IP6][i])
XFREE (MTYPE_ROUTE_MAP_NAME, nht_rm[AFI_IP6][i]);
- nht_rm[AFI_IP6][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, argv[1]);
+ nht_rm[AFI_IP6][i] = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap);
zebra_evaluate_rnh(0, AF_INET6, 1, RNH_NEXTHOP_TYPE, NULL);
return CMD_SUCCESS;
@@ -1089,28 +789,31 @@ DEFUN (ipv6_protocol_nht_rmap,
DEFUN (no_ipv6_protocol_nht_rmap,
no_ipv6_protocol_nht_rmap_cmd,
- "no ipv6 nht " FRR_IP6_PROTOCOL_MAP_STR_ZEBRA,
+ "no ipv6 nht " FRR_IP6_PROTOCOL_MAP_STR_ZEBRA " [route-map ROUTE-MAP]",
NO_STR
IP6_STR
"Filter Next Hop tracking route resolution\n"
- FRR_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA)
+ FRR_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA
+ "Specify route map\n"
+ "Route map name\n")
{
+ char *proto = argv[3]->text;
+ char *rmap = (argc == 6) ? argv[5]->arg : NULL;
int i;
- if (strcasecmp(argv[0], "any") == 0)
+ if (strcasecmp(proto, "any") == 0)
i = ZEBRA_ROUTE_MAX;
else
- i = proto_name2num(argv[0]);
+ i = proto_name2num(proto);
if (i < 0)
{
- vty_out (vty, "invalid protocol name \"%s\"%s", argv[0] ? argv[0] : "",
- VTY_NEWLINE);
- return CMD_WARNING;
+ vty_out (vty, "invalid protocol name \"%s\"%s", proto, VTY_NEWLINE);
+ return CMD_WARNING;
}
- if (nht_rm[AFI_IP6][i] && argc == 2 && strcmp(argv[1], nht_rm[AFI_IP6][i]))
+ if (nht_rm[AFI_IP6][i] && rmap && strcmp(rmap, nht_rm[AFI_IP6][i]))
{
- vty_out (vty, "invalid route-map \"%s\"%s", argv[1], VTY_NEWLINE);
+ vty_out (vty, "invalid route-map \"%s\"%s", rmap, VTY_NEWLINE);
return CMD_WARNING;
}
@@ -1125,21 +828,13 @@ DEFUN (no_ipv6_protocol_nht_rmap,
return CMD_SUCCESS;
}
-ALIAS (no_ipv6_protocol_nht_rmap,
- no_ipv6_protocol_nht_rmap_val_cmd,
- "no ipv6 nht " FRR_IP6_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP",
- NO_STR
- IP6_STR
- "Filter Next Hop tracking route resolution\n"
- FRR_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA
- "Route map name\n")
-
DEFUN (show_ipv6_protocol_nht,
show_ipv6_protocol_nht_cmd,
"show ipv6 nht route-map",
- SHOW_STR
- IP6_STR
- "IPv6 protocol Next Hop filtering status\n")
+ SHOW_STR
+ IP6_STR
+ "Next Hop filtering status\n"
+ "Route-map\n")
{
int i;
@@ -1544,10 +1239,7 @@ route_set_src_compile (const char *arg)
{
union g_addr src, *psrc;
- if (
-#ifdef HAVE_IPV6
- (inet_pton(AF_INET6, arg, &src.ipv6) == 1) ||
-#endif /* HAVE_IPV6 */
+ if ((inet_pton(AF_INET6, arg, &src.ipv6) == 1) ||
(src.ipv4.s_addr && (inet_pton(AF_INET, arg, &src.ipv4) == 1)))
{
psrc = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (union g_addr));
@@ -1659,7 +1351,7 @@ zebra_del_import_table_route_map (afi_t afi, uint32_t table)
}
route_map_result_t
-zebra_import_table_route_map_check (int family, int rib_type, struct prefix *p,
+zebra_import_table_route_map_check (int family, int re_type, struct prefix *p,
struct nexthop *nexthop, vrf_id_t vrf_id, route_tag_t tag, const char *rmap_name)
{
struct route_map *rmap = NULL;
@@ -1668,11 +1360,11 @@ zebra_import_table_route_map_check (int family, int rib_type, struct prefix *p,
nh_obj.nexthop = nexthop;
nh_obj.vrf_id = vrf_id;
- nh_obj.source_protocol = rib_type;
+ nh_obj.source_protocol = re_type;
nh_obj.metric = 0;
nh_obj.tag = tag;
- if (rib_type >= 0 && rib_type < ZEBRA_ROUTE_MAX)
+ 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);
@@ -1683,17 +1375,17 @@ zebra_import_table_route_map_check (int family, int rib_type, struct prefix *p,
route_map_result_t
zebra_nht_route_map_check (int family, int client_proto, struct prefix *p,
- struct rib * rib, struct nexthop *nexthop)
+ struct route_entry * re, struct nexthop *nexthop)
{
struct route_map *rmap = NULL;
route_map_result_t ret = RMAP_MATCH;
struct nh_rmap_obj nh_obj;
nh_obj.nexthop = nexthop;
- nh_obj.vrf_id = rib->vrf_id;
- nh_obj.source_protocol = rib->type;
- nh_obj.metric = rib->metric;
- nh_obj.tag = rib->tag;
+ nh_obj.vrf_id = re->vrf_id;
+ nh_obj.source_protocol = re->type;
+ nh_obj.metric = re->metric;
+ nh_obj.tag = re->tag;
if (client_proto >= 0 && client_proto < ZEBRA_ROUTE_MAX)
rmap = route_map_lookup_by_name (nht_rm[family][client_proto]);
@@ -1710,10 +1402,11 @@ static void
zebra_route_map_mark_update (const char *rmap_name)
{
/* rmap_update_timer of 0 means don't do route updates */
- if (zebra_rmap_update_timer && !zebra_t_rmap_update)
- zebra_t_rmap_update =
- thread_add_timer(zebrad.master, zebra_route_map_update_timer, NULL,
- zebra_rmap_update_timer);
+ if (zebra_rmap_update_timer && !zebra_t_rmap_update) {
+ zebra_t_rmap_update = NULL;
+ thread_add_timer(zebrad.master, zebra_route_map_update_timer, NULL, zebra_rmap_update_timer,
+ &zebra_t_rmap_update);
+ }
}
static void
@@ -1788,23 +1481,18 @@ zebra_route_map_init ()
{
install_element (CONFIG_NODE, &ip_protocol_cmd);
install_element (CONFIG_NODE, &no_ip_protocol_cmd);
- install_element (CONFIG_NODE, &no_ip_protocol_val_cmd);
install_element (VIEW_NODE, &show_ip_protocol_cmd);
install_element (CONFIG_NODE, &ipv6_protocol_cmd);
install_element (CONFIG_NODE, &no_ipv6_protocol_cmd);
- install_element (CONFIG_NODE, &no_ipv6_protocol_val_cmd);
install_element (VIEW_NODE, &show_ipv6_protocol_cmd);
install_element (CONFIG_NODE, &ip_protocol_nht_rmap_cmd);
install_element (CONFIG_NODE, &no_ip_protocol_nht_rmap_cmd);
- install_element (CONFIG_NODE, &no_ip_protocol_nht_rmap_val_cmd);
install_element (VIEW_NODE, &show_ip_protocol_nht_cmd);
install_element (CONFIG_NODE, &ipv6_protocol_nht_rmap_cmd);
install_element (CONFIG_NODE, &no_ipv6_protocol_nht_rmap_cmd);
- install_element (CONFIG_NODE, &no_ipv6_protocol_nht_rmap_val_cmd);
install_element (VIEW_NODE, &show_ipv6_protocol_nht_cmd);
install_element (CONFIG_NODE, &zebra_route_map_timer_cmd);
install_element (CONFIG_NODE, &no_zebra_route_map_timer_cmd);
- install_element (CONFIG_NODE, &no_zebra_route_map_timer_val_cmd);
route_map_init ();
@@ -1812,6 +1500,24 @@ zebra_route_map_init ()
route_map_delete_hook (zebra_route_map_delete);
route_map_event_hook (zebra_route_map_event);
+ route_map_match_interface_hook (generic_match_add);
+ route_map_no_match_interface_hook (generic_match_delete);
+
+ route_map_match_ip_address_hook (generic_match_add);
+ route_map_no_match_ip_address_hook (generic_match_delete);
+
+ route_map_match_ip_address_prefix_list_hook (generic_match_add);
+ route_map_no_match_ip_address_prefix_list_hook (generic_match_delete);
+
+ route_map_match_ip_next_hop_hook (generic_match_add);
+ route_map_no_match_ip_next_hop_hook (generic_match_delete);
+
+ route_map_match_ip_next_hop_prefix_list_hook (generic_match_add);
+ route_map_no_match_ip_next_hop_prefix_list_hook (generic_match_delete);
+
+ route_map_match_tag_hook (generic_match_add);
+ route_map_no_match_tag_hook (generic_match_delete);
+
route_map_install_match (&route_match_tag_cmd);
route_map_install_match (&route_match_interface_cmd);
route_map_install_match (&route_match_ip_next_hop_cmd);
@@ -1824,30 +1530,10 @@ zebra_route_map_init ()
/* */
route_map_install_set (&route_set_src_cmd);
/* */
- install_element (RMAP_NODE, &match_tag_cmd);
- install_element (RMAP_NODE, &no_match_tag_cmd);
- install_element (RMAP_NODE, &no_match_tag_val_cmd);
- install_element (RMAP_NODE, &match_interface_cmd);
- install_element (RMAP_NODE, &no_match_interface_cmd);
- install_element (RMAP_NODE, &no_match_interface_val_cmd);
- install_element (RMAP_NODE, &match_ip_next_hop_cmd);
- install_element (RMAP_NODE, &no_match_ip_next_hop_cmd);
- install_element (RMAP_NODE, &no_match_ip_next_hop_val_cmd);
- install_element (RMAP_NODE, &match_ip_next_hop_prefix_list_cmd);
- install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd);
- install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_val_cmd);
- install_element (RMAP_NODE, &match_ip_address_cmd);
- install_element (RMAP_NODE, &no_match_ip_address_cmd);
- install_element (RMAP_NODE, &no_match_ip_address_val_cmd);
- install_element (RMAP_NODE, &match_ip_address_prefix_list_cmd);
- install_element (RMAP_NODE, &no_match_ip_address_prefix_list_cmd);
- install_element (RMAP_NODE, &no_match_ip_address_prefix_list_val_cmd);
install_element (RMAP_NODE, &match_ip_nexthop_prefix_len_cmd);
install_element (RMAP_NODE, &no_match_ip_nexthop_prefix_len_cmd);
- install_element (RMAP_NODE, &no_match_ip_nexthop_prefix_len_val_cmd);
install_element (RMAP_NODE, &match_ip_address_prefix_len_cmd);
install_element (RMAP_NODE, &no_match_ip_address_prefix_len_cmd);
- install_element (RMAP_NODE, &no_match_ip_address_prefix_len_val_cmd);
install_element (RMAP_NODE, &match_source_protocol_cmd);
install_element (RMAP_NODE, &no_match_source_protocol_cmd);
/* */