From 82f97584fbc708f4089b1b4f7e6fdc7e07b2db4e Mon Sep 17 00:00:00 2001 From: Daniel Walton Date: Thu, 6 Oct 2016 19:56:13 +0000 Subject: [PATCH] all: removed all DEFUN command stomps Signed-off-by: Daniel Walton Reviewed-by: Donald Sharp --- bgpd/bgp_route.c | 4 +- bgpd/bgp_routemap.c | 631 +++----------------- isisd/isis_routemap.c | 280 +-------- lib/routemap.c | 1138 ++++++++++++++++++++++++++++++++++++- lib/routemap.h | 165 ++++++ ospf6d/ospf6_asbr.c | 43 +- ospf6d/ospf6_zebra.c | 27 - ospf6d/ospf6d.c | 1 - ospfd/ospf_routemap.c | 268 +-------- ospfd/ospf_zebra.h | 2 - pimd/pim_routemap.c | 1 + ripd/rip_routemap.c | 433 +------------- ripd/rip_zebra.c | 42 -- ripd/ripd.h | 1 - ripngd/ripng_routemap.c | 289 +--------- ripngd/ripng_zebra.c | 26 - ripngd/ripngd.h | 1 - vtysh/extract.pl.in | 12 +- zebra/connected.c | 1 + zebra/kernel_null.c | 1 + zebra/redistribute_null.c | 1 + zebra/zebra_fpm_netlink.c | 1 + zebra/zebra_rnh_null.c | 1 + zebra/zebra_routemap.c | 256 +-------- zebra/zebra_static.c | 1 + zebra/zebra_vrf.c | 1 + zebra/zserv.h | 2 +- zebra/zserv_null.c | 1 + 28 files changed, 1514 insertions(+), 2116 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 832a43779..9f3c9baae 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -7732,7 +7732,7 @@ bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str, /* BGP route print out function. */ DEFUN (show_ip_bgp_ipv4, show_ip_bgp_ipv4_cmd, - "show [ip] bgp [ WORD] [] [|regexp .LINE|route-map WORD|prefix-list WORD|filter-list WORD|community [exact-match]|community-list <(1-500)|WORD> [exact-match]|A.B.C.D/M longer-prefixes|X:X::X:X/M longer-prefixes>] [json]", + "show [ip] bgp [ WORD] [] [|route-map WORD|prefix-list WORD|filter-list WORD|community [exact-match]|community-list <(1-500)|WORD> [exact-match]|A.B.C.D/M longer-prefixes|X:X::X:X/M longer-prefixes>] [json]", SHOW_STR IP_STR BGP_STR @@ -7752,8 +7752,6 @@ DEFUN (show_ip_bgp_ipv4, "Display detailed information about dampening\n" "Display flap statistics of routes\n" "Display paths suppressed due to dampening\n" - "Display routes matching the AS path regular expression\n" - "A regular-expression to match the BGP AS paths\n" "Display routes matching the route-map\n" "A route-map to match on\n" "Display routes conforming to the prefix-list\n" diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 730dfbda7..33a29e8f4 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -22,6 +22,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "prefix.h" #include "filter.h" +#include "vty.h" #include "routemap.h" #include "command.h" #include "linklist.h" @@ -2614,52 +2615,6 @@ bgp_route_match_delete (struct vty *vty, struct route_map_index *index, return CMD_SUCCESS; } -/* Add bgp route map rule. */ -static int -bgp_route_set_add (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_add_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - -/* Delete bgp route map rule. */ -static int -bgp_route_set_delete (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_delete_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - /* * This is the workhorse routine for processing in/out routemap * modifications. @@ -3036,79 +2991,6 @@ DEFUN (no_match_peer, } - -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") -{ - int idx_acl = 3; - return bgp_route_match_add (vty, vty->index, "ip address", argv[idx_acl]->arg, - RMAP_EVENT_FILTER_ADDED); -} - - -DEFUN (no_match_ip_address, - no_match_ip_address_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") -{ - int idx_word = 4; - if (argc <= idx_word) - return bgp_route_match_delete (vty, vty->index, "ip address", NULL, - RMAP_EVENT_FILTER_DELETED); - return bgp_route_match_delete (vty, vty->index, "ip address", argv[idx_word]->arg, - RMAP_EVENT_FILTER_DELETED); -} - - -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") -{ - int idx_acl = 3; - return bgp_route_match_add (vty, vty->index, "ip next-hop", argv[idx_acl]->arg, - RMAP_EVENT_FILTER_ADDED); -} - - -DEFUN (no_match_ip_next_hop, - no_match_ip_next_hop_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") -{ - int idx_word = 4; - if (argc <= idx_word) - return bgp_route_match_delete (vty, vty->index, "ip next-hop", NULL, - RMAP_EVENT_FILTER_DELETED); - return bgp_route_match_delete (vty, vty->index, "ip next-hop", argv[idx_word]->arg, - RMAP_EVENT_FILTER_DELETED); -} - - /* match probability */ DEFUN (match_probability, match_probability_cmd, @@ -3176,73 +3058,6 @@ DEFUN (no_match_ip_route_source, } -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") -{ - int idx_word = 4; - return bgp_route_match_add (vty, vty->index, "ip address prefix-list", - argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED); -} - - -DEFUN (no_match_ip_address_prefix_list, - no_match_ip_address_prefix_list_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") -{ - int idx_word = 5; - if (argc <= idx_word) - return bgp_route_match_delete (vty, vty->index, "ip address prefix-list", - NULL, RMAP_EVENT_PLIST_DELETED); - return bgp_route_match_delete (vty, vty->index, "ip address prefix-list", - argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED); -} - - -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") -{ - int idx_word = 4; - return bgp_route_match_add (vty, vty->index, "ip next-hop prefix-list", - argv[idx_word]->arg, 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 [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") -{ - int idx_word = 5; - if (argc <= idx_word) - return bgp_route_match_delete (vty, vty->index, "ip next-hop prefix-list", - NULL, RMAP_EVENT_PLIST_DELETED); - return bgp_route_match_delete (vty, vty->index, "ip next-hop prefix-list", - argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED); -} - - DEFUN (match_ip_route_source_prefix_list, match_ip_route_source_prefix_list_cmd, "match ip route-source prefix-list WORD", @@ -3277,37 +3092,6 @@ DEFUN (no_match_ip_route_source_prefix_list, } -DEFUN (match_metric, - match_metric_cmd, - "match metric (0-4294967295)", - MATCH_STR - "Match metric of route\n" - "Metric value\n") -{ - int idx_number = 2; - return bgp_route_match_add (vty, vty->index, "metric", argv[idx_number]->arg, - RMAP_EVENT_MATCH_ADDED); -} - - -DEFUN (no_match_metric, - no_match_metric_cmd, - "no match metric [(0-4294967295)]", - NO_STR - MATCH_STR - "Match metric of route\n" - "Metric value\n") -{ - int idx_number = 3; - if (argc <= idx_number) - return bgp_route_match_delete (vty, vty->index, "metric", - NULL, RMAP_EVENT_MATCH_DELETED); - return bgp_route_match_delete (vty, vty->index, "metric", - argv[idx_number]->arg, - RMAP_EVENT_MATCH_DELETED); -} - - DEFUN (match_local_pref, match_local_pref_cmd, "match local-preference (0-4294967295)", @@ -3491,88 +3275,6 @@ DEFUN (no_match_origin, RMAP_EVENT_MATCH_DELETED); } - -DEFUN (match_interface, - match_interface_cmd, - "match interface WORD", - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") -{ - int idx_word = 2; - return bgp_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg, - RMAP_EVENT_MATCH_ADDED); -} - - -DEFUN (no_match_interface, - no_match_interface_cmd, - "no match interface [WORD]", - NO_STR - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") -{ - return bgp_route_match_delete (vty, vty->index, "interface", argv[3]->arg, - RMAP_EVENT_MATCH_DELETED); -} - - -DEFUN (match_tag, - match_tag_cmd, - "match tag (1-65535)", - MATCH_STR - "Match tag of route\n" - "Tag value\n") -{ - int idx_number = 2; - return bgp_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg, - RMAP_EVENT_MATCH_ADDED); -} - - -DEFUN (no_match_tag, - no_match_tag_cmd, - "no match tag [(1-65535)]", - NO_STR - MATCH_STR - "Match tag of route\n" - "Tag value\n") -{ - return bgp_route_match_delete (vty, vty->index, "tag", argv[3]->arg, - RMAP_EVENT_MATCH_DELETED); -} - - -DEFUN (set_ip_nexthop, - set_ip_nexthop_cmd, - "set ip next-hop A.B.C.D", - SET_STR - IP_STR - "Next hop address\n" - "IP address of next hop\n") -{ - int idx_ipv4 = 3; - union sockunion su; - int ret; - - ret = str2sockunion (argv[idx_ipv4]->arg, &su); - if (ret < 0) - { - vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (su.sin.sin_addr.s_addr == 0 || - IPV4_CLASS_DE(su.sin.sin_addr.s_addr)) - { - vty_out (vty, "%% nexthop address cannot be 0.0.0.0, multicast " - "or reserved%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_route_set_add (vty, vty->index, "ip next-hop", argv[idx_ipv4]->arg); -} - DEFUN (set_ip_nexthop_peer, set_ip_nexthop_peer_cmd, "set ip next-hop peer-address", @@ -3581,7 +3283,7 @@ DEFUN (set_ip_nexthop_peer, "Next hop address\n" "Use peer address (for BGP only)\n") { - return bgp_route_set_add (vty, vty->index, "ip next-hop", "peer-address"); + return generic_set_add (vty, vty->index, "ip next-hop", "peer-address"); } DEFUN (set_ip_nexthop_unchanged, @@ -3592,55 +3294,7 @@ DEFUN (set_ip_nexthop_unchanged, "Next hop address\n" "Don't modify existing Next hop address\n") { - return bgp_route_set_add (vty, vty->index, "ip next-hop", "unchanged"); -} - - -DEFUN (no_set_ip_nexthop, - no_set_ip_nexthop_cmd, - "no set ip next-hop []", - NO_STR - SET_STR - "Next hop address\n" - "Use peer address (for BGP only)\n" - "IP address of next hop\n") -{ - int idx_peer = 4; - if (argc <= idx_peer) - return bgp_route_set_delete (vty, vty->index, "ip next-hop", NULL); - return bgp_route_set_delete (vty, vty->index, "ip next-hop", argv[idx_peer]->arg); -} - - -DEFUN (set_metric, - set_metric_cmd, - "set metric <(0-4294967295)|rtt|+rtt|-rtt|+metric|-metric>", - SET_STR - "Metric value for destination routing protocol\n" - "Metric value\n" - "Assign round trip time\n" - "Add round trip time\n" - "Subtract round trip time\n" - "Add metric\n" - "Subtract metric\n") -{ - int idx_number = 2; - return bgp_route_set_add (vty, vty->index, "metric", argv[idx_number]->arg); -} - - -DEFUN (no_set_metric, - no_set_metric_cmd, - "no set metric [(0-4294967295)]", - NO_STR - SET_STR - "Metric value for destination routing protocol\n" - "Metric value\n") -{ - int idx_number = 3; - if (argc <= idx_number) - return bgp_route_set_delete (vty, vty->index, "metric", NULL); - return bgp_route_set_delete (vty, vty->index, "metric", argv[idx_number]->arg); + return generic_set_add (vty, vty->index, "ip next-hop", "unchanged"); } @@ -3652,7 +3306,7 @@ DEFUN (set_local_pref, "Preference value\n") { int idx_number = 2; - return bgp_route_set_add (vty, vty->index, "local-preference", argv[idx_number]->arg); + return generic_set_add (vty, vty->index, "local-preference", argv[idx_number]->arg); } @@ -3666,8 +3320,8 @@ DEFUN (no_set_local_pref, { int idx_localpref = 3; if (argc <= idx_localpref) - return bgp_route_set_delete (vty, vty->index, "local-preference", NULL); - return bgp_route_set_delete (vty, vty->index, "local-preference", argv[idx_localpref]->arg); + return generic_set_delete (vty, vty->index, "local-preference", NULL); + return generic_set_delete (vty, vty->index, "local-preference", argv[idx_localpref]->arg); } @@ -3679,7 +3333,7 @@ DEFUN (set_weight, "Weight value\n") { int idx_number = 2; - return bgp_route_set_add (vty, vty->index, "weight", argv[idx_number]->arg); + return generic_set_add (vty, vty->index, "weight", argv[idx_number]->arg); } @@ -3693,8 +3347,8 @@ DEFUN (no_set_weight, { int idx_weight = 3; if (argc <= idx_weight) - return bgp_route_set_delete (vty, vty->index, "weight", NULL); - return bgp_route_set_delete (vty, vty->index, "weight", argv[idx_weight]->arg); + return generic_set_delete (vty, vty->index, "weight", NULL); + return generic_set_delete (vty, vty->index, "weight", argv[idx_weight]->arg); } @@ -3711,7 +3365,7 @@ DEFUN (set_aspath_prepend_asn, char *str; str = argv_concat (argv, argc, idx_asn); - ret = bgp_route_set_add (vty, vty->index, "as-path prepend", str); + ret = generic_set_add (vty, vty->index, "as-path prepend", str); XFREE (MTYPE_TMP, str); return ret; @@ -3743,7 +3397,7 @@ DEFUN (no_set_aspath_prepend, char *str; str = argv_concat (argv, argc, idx_asn); - ret = bgp_route_set_delete (vty, vty->index, "as-path prepend", str); + ret = generic_set_delete (vty, vty->index, "as-path prepend", str); XFREE (MTYPE_TMP, str); return ret; } @@ -3762,7 +3416,7 @@ DEFUN (set_aspath_exclude, char *str; str = argv_concat (argv, argc, idx_asn); - ret = bgp_route_set_add (vty, vty->index, "as-path exclude", str); + ret = generic_set_add (vty, vty->index, "as-path exclude", str); XFREE (MTYPE_TMP, str); return ret; } @@ -3781,7 +3435,7 @@ DEFUN (no_set_aspath_exclude, char *str; str = argv_concat (argv, argc, idx_asn); - ret = bgp_route_set_delete (vty, vty->index, "as-path exclude", str); + ret = generic_set_delete (vty, vty->index, "as-path exclude", str); XFREE (MTYPE_TMP, str); return ret; } @@ -3870,11 +3524,11 @@ DEFUN (set_community, argstr = XCALLOC (MTYPE_TMP, strlen (str) + strlen (" additive") + 1); strcpy (argstr, str); strcpy (argstr + strlen (str), " additive"); - ret = bgp_route_set_add (vty, vty->index, "community", argstr); + ret = generic_set_add (vty, vty->index, "community", argstr); XFREE (MTYPE_TMP, argstr); } else - ret = bgp_route_set_add (vty, vty->index, "community", str); + ret = generic_set_add (vty, vty->index, "community", str); community_free (com); @@ -3888,7 +3542,7 @@ DEFUN (set_community_none, "BGP community attribute\n" "No community attribute\n") { - return bgp_route_set_add (vty, vty->index, "community", "none"); + return generic_set_add (vty, vty->index, "community", "none"); } DEFUN (no_set_community, @@ -3898,7 +3552,7 @@ DEFUN (no_set_community, SET_STR "BGP community attribute\n") { - return bgp_route_set_delete (vty, vty->index, "community", NULL); + return generic_set_delete (vty, vty->index, "community", NULL); } @@ -3920,7 +3574,7 @@ DEFUN (set_community_delete, strcpy (str, argv[idx_comm_list]->arg); strcpy (str + strlen (argv[idx_comm_list]->arg), " delete"); - bgp_route_set_add (vty, vty->index, "comm-list", str); + generic_set_add (vty, vty->index, "comm-list", str); XFREE (MTYPE_TMP, str); return CMD_SUCCESS; @@ -3933,7 +3587,7 @@ DEFUN (no_set_community_delete, SET_STR "set BGP community list (for deletion)\n") { - return bgp_route_set_delete (vty, vty->index, "comm-list", NULL); + return generic_set_delete (vty, vty->index, "comm-list", NULL); } @@ -3950,7 +3604,7 @@ DEFUN (set_ecommunity_rt, char *str; str = argv_concat (argv, argc, idx_asn_nn); - ret = bgp_route_set_add (vty, vty->index, "extcommunity rt", str); + ret = generic_set_add (vty, vty->index, "extcommunity rt", str); XFREE (MTYPE_TMP, str); return ret; @@ -3964,7 +3618,7 @@ DEFUN (no_set_ecommunity_rt, "BGP extended community attribute\n" "Route Target extended community\n") { - return bgp_route_set_delete (vty, vty->index, "extcommunity rt", NULL); + return generic_set_delete (vty, vty->index, "extcommunity rt", NULL); } @@ -3981,7 +3635,7 @@ DEFUN (set_ecommunity_soo, char *str; str = argv_concat (argv, argc, idx_asn_nn); - ret = bgp_route_set_add (vty, vty->index, "extcommunity soo", str); + ret = generic_set_add (vty, vty->index, "extcommunity soo", str); XFREE (MTYPE_TMP, str); return ret; } @@ -3995,7 +3649,7 @@ DEFUN (no_set_ecommunity_soo, "BGP extended community attribute\n" "Site-of-Origin extended community\n") { - return bgp_route_set_delete (vty, vty->index, "extcommunity soo", NULL); + return generic_set_delete (vty, vty->index, "extcommunity soo", NULL); } @@ -4010,11 +3664,11 @@ DEFUN (set_origin, { int idx_origin = 2; if (strncmp (argv[idx_origin]->arg, "igp", 2) == 0) - return bgp_route_set_add (vty, vty->index, "origin", "igp"); + return generic_set_add (vty, vty->index, "origin", "igp"); if (strncmp (argv[idx_origin]->arg, "egp", 1) == 0) - return bgp_route_set_add (vty, vty->index, "origin", "egp"); + return generic_set_add (vty, vty->index, "origin", "egp"); if (strncmp (argv[idx_origin]->arg, "incomplete", 2) == 0) - return bgp_route_set_add (vty, vty->index, "origin", "incomplete"); + return generic_set_add (vty, vty->index, "origin", "incomplete"); return CMD_WARNING; } @@ -4027,7 +3681,7 @@ DEFUN (no_set_origin, SET_STR "BGP origin code\n") { - return bgp_route_set_delete (vty, vty->index, "origin", NULL); + return generic_set_delete (vty, vty->index, "origin", NULL); } @@ -4037,7 +3691,7 @@ DEFUN (set_atomic_aggregate, SET_STR "BGP atomic aggregate attribute\n" ) { - return bgp_route_set_add (vty, vty->index, "atomic-aggregate", NULL); + return generic_set_add (vty, vty->index, "atomic-aggregate", NULL); } DEFUN (no_set_atomic_aggregate, @@ -4047,7 +3701,7 @@ DEFUN (no_set_atomic_aggregate, SET_STR "BGP atomic aggregate attribute\n" ) { - return bgp_route_set_delete (vty, vty->index, "atomic-aggregate", NULL); + return generic_set_delete (vty, vty->index, "atomic-aggregate", NULL); } DEFUN (set_aggregator_as, @@ -4077,7 +3731,7 @@ DEFUN (set_aggregator_as, sprintf (argstr, "%s %s", argv[idx_number]->arg, argv[idx_ipv4]->arg); - ret = bgp_route_set_add (vty, vty->index, "aggregator as", argstr); + ret = generic_set_add (vty, vty->index, "aggregator as", argstr); XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr); @@ -4102,7 +3756,7 @@ DEFUN (no_set_aggregator_as, char *argstr; if (argc <= idx_asn) - return bgp_route_set_delete (vty, vty->index, "aggregator as", NULL); + return generic_set_delete (vty, vty->index, "aggregator as", NULL); ret = inet_aton (argv[idx_ip]->arg, &address); if (ret == 0) @@ -4116,7 +3770,7 @@ DEFUN (no_set_aggregator_as, sprintf (argstr, "%s %s", argv[idx_asn]->arg, argv[idx_ip]->arg); - ret = bgp_route_set_delete (vty, vty->index, "aggregator as", argstr); + ret = generic_set_delete (vty, vty->index, "aggregator as", argstr); XFREE (MTYPE_ROUTE_MAP_COMPILED, argstr); @@ -4124,62 +3778,7 @@ DEFUN (no_set_aggregator_as, } -DEFUN (set_tag, - set_tag_cmd, - "set tag (1-65535)", - SET_STR - "Tag value for routing protocol\n" - "Tag value\n") -{ - int idx_number = 2; - return bgp_route_set_add (vty, vty->index, "tag", argv[idx_number]->arg); -} - - -DEFUN (no_set_tag, - no_set_tag_cmd, - "no set tag [(1-65535)]", - NO_STR - SET_STR - "Tag value for routing protocol\n" - "Tag value\n") -{ - int idx_number = 3; - if (argc <= idx_number) - return bgp_route_set_delete (vty, vty->index, "tag", NULL); - return bgp_route_set_delete (vty, vty->index, "tag", argv[idx_number]->arg); -} - - - #ifdef HAVE_IPV6 -DEFUN (match_ipv6_address, - match_ipv6_address_cmd, - "match ipv6 address WORD", - MATCH_STR - IPV6_STR - "Match IPv6 address of route\n" - "IPv6 access-list name\n") -{ - int idx_word = 3; - return bgp_route_match_add (vty, vty->index, "ipv6 address", argv[idx_word]->arg, - RMAP_EVENT_FILTER_ADDED); -} - -DEFUN (no_match_ipv6_address, - no_match_ipv6_address_cmd, - "no match ipv6 address WORD", - NO_STR - MATCH_STR - IPV6_STR - "Match IPv6 address of route\n" - "IPv6 access-list name\n") -{ - int idx_word = 4; - return bgp_route_match_delete (vty, vty->index, "ipv6 address", argv[idx_word]->arg, - RMAP_EVENT_FILTER_DELETED); -} - DEFUN (match_ipv6_next_hop, match_ipv6_next_hop_cmd, "match ipv6 next-hop X:X::X:X", @@ -4207,34 +3806,6 @@ DEFUN (no_match_ipv6_next_hop, RMAP_EVENT_MATCH_DELETED); } -DEFUN (match_ipv6_address_prefix_list, - match_ipv6_address_prefix_list_cmd, - "match ipv6 address prefix-list WORD", - MATCH_STR - IPV6_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") -{ - int idx_word = 4; - return bgp_route_match_add (vty, vty->index, "ipv6 address prefix-list", - argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED); -} - -DEFUN (no_match_ipv6_address_prefix_list, - no_match_ipv6_address_prefix_list_cmd, - "no match ipv6 address prefix-list WORD", - NO_STR - MATCH_STR - IPV6_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") -{ - int idx_word = 5; - return bgp_route_match_delete (vty, vty->index, "ipv6 address prefix-list", - argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED); -} DEFUN (set_ipv6_nexthop_peer, set_ipv6_nexthop_peer_cmd, @@ -4244,7 +3815,7 @@ DEFUN (set_ipv6_nexthop_peer, "Next hop address\n" "Use peer address (for BGP only)\n") { - return bgp_route_set_add (vty, vty->index, "ipv6 next-hop peer-address", NULL); + return generic_set_add (vty, vty->index, "ipv6 next-hop peer-address", NULL); } DEFUN (no_set_ipv6_nexthop_peer, @@ -4256,7 +3827,7 @@ DEFUN (no_set_ipv6_nexthop_peer, "IPv6 next-hop address\n" "Use peer address (for BGP only)\n") { - return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop peer-address", NULL); + return generic_set_delete (vty, vty->index, "ipv6 next-hop peer-address", NULL); } DEFUN (set_ipv6_nexthop_prefer_global, @@ -4267,7 +3838,7 @@ DEFUN (set_ipv6_nexthop_prefer_global, "IPv6 next-hop address\n" "Prefer global over link-local if both exist\n") { - return bgp_route_set_add (vty, vty->index, "ipv6 next-hop prefer-global", NULL);; + return generic_set_add (vty, vty->index, "ipv6 next-hop prefer-global", NULL);; } DEFUN (no_set_ipv6_nexthop_prefer_global, @@ -4279,7 +3850,7 @@ DEFUN (no_set_ipv6_nexthop_prefer_global, "IPv6 next-hop address\n" "Prefer global over link-local if both exist\n") { - return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop prefer-global", NULL); + return generic_set_delete (vty, vty->index, "ipv6 next-hop prefer-global", NULL); } DEFUN (set_ipv6_nexthop_global, @@ -4310,7 +3881,7 @@ DEFUN (set_ipv6_nexthop_global, return CMD_WARNING; } - return bgp_route_set_add (vty, vty->index, "ipv6 next-hop global", argv[idx_ipv6]->arg); + return generic_set_add (vty, vty->index, "ipv6 next-hop global", argv[idx_ipv6]->arg); } @@ -4326,56 +3897,9 @@ DEFUN (no_set_ipv6_nexthop_global, { int idx_ipv6 = 5; if (argc <= idx_ipv6) - return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop global", NULL); - return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop global", argv[idx_ipv6]->arg); -} - - -DEFUN (set_ipv6_nexthop_local, - set_ipv6_nexthop_local_cmd, - "set ipv6 next-hop local X:X::X:X", - SET_STR - IPV6_STR - "IPv6 next-hop address\n" - "IPv6 local address\n" - "IPv6 address of next hop\n") -{ - int idx_ipv6 = 4; - struct in6_addr addr; - int ret; - - ret = inet_pton (AF_INET6, argv[idx_ipv6]->arg, &addr); - if (!ret) - { - vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (!IN6_IS_ADDR_LINKLOCAL(&addr)) - { - vty_out (vty, "%% Invalid link-local nexthop address%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[idx_ipv6]->arg); -} - - -DEFUN (no_set_ipv6_nexthop_local, - no_set_ipv6_nexthop_local_cmd, - "no set ipv6 next-hop local [X:X::X:X]", - NO_STR - SET_STR - IPV6_STR - "IPv6 next-hop address\n" - "IPv6 local address\n" - "IPv6 address of next hop\n") -{ - int idx_ipv6 = 5; - if (argc <= idx_ipv6) - 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[5]->arg); + return generic_set_delete (vty, vty->index, "ipv6 next-hop global", NULL); + return generic_set_delete (vty, vty->index, "ipv6 next-hop global", argv[idx_ipv6]->arg); } - #endif /* HAVE_IPV6 */ DEFUN (set_vpnv4_nexthop, @@ -4387,7 +3911,7 @@ DEFUN (set_vpnv4_nexthop, "IP address of next hop\n") { int idx_ipv4 = 3; - return bgp_route_set_add (vty, vty->index, "vpnv4 next-hop", argv[idx_ipv4]->arg); + return generic_set_add (vty, vty->index, "vpnv4 next-hop", argv[idx_ipv4]->arg); } @@ -4402,8 +3926,8 @@ DEFUN (no_set_vpnv4_nexthop, { int idx_ipv4 = 4; if (argc <= idx_ipv4) - return bgp_route_set_delete (vty, vty->index, "vpnv4 next-hop", NULL); - return bgp_route_set_delete (vty, vty->index, "vpnv4 next-hop", argv[idx_ipv4]->arg); + return generic_set_delete (vty, vty->index, "vpnv4 next-hop", NULL); + return generic_set_delete (vty, vty->index, "vpnv4 next-hop", argv[idx_ipv4]->arg); } @@ -4415,7 +3939,7 @@ DEFUN (set_originator_id, "IP address of originator\n") { int idx_ipv4 = 2; - return bgp_route_set_add (vty, vty->index, "originator-id", argv[idx_ipv4]->arg); + return generic_set_add (vty, vty->index, "originator-id", argv[idx_ipv4]->arg); } @@ -4429,8 +3953,8 @@ DEFUN (no_set_originator_id, { int idx_id = 3; if (argc < idx_id) - return bgp_route_set_delete (vty, vty->index, "originator-id", NULL); - return bgp_route_set_delete (vty, vty->index, "originator-id", argv[idx_id]->arg); + return generic_set_delete (vty, vty->index, "originator-id", NULL); + return generic_set_delete (vty, vty->index, "originator-id", argv[idx_id]->arg); } @@ -4444,6 +3968,45 @@ bgp_route_map_init (void) route_map_delete_hook (bgp_route_map_delete); route_map_event_hook (bgp_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_ipv6_address_hook (generic_match_add); + route_map_no_match_ipv6_address_hook (generic_match_delete); + + route_map_match_ipv6_address_prefix_list_hook (generic_match_add); + route_map_no_match_ipv6_address_prefix_list_hook (generic_match_delete); + + route_map_match_metric_hook (generic_match_add); + route_map_no_match_metric_hook (generic_match_delete); + + route_map_match_tag_hook (generic_match_add); + route_map_no_match_tag_hook (generic_match_delete); + + route_map_set_ip_nexthop_hook (generic_set_add); + route_map_no_set_ip_nexthop_hook (generic_set_delete); + + route_map_set_ipv6_nexthop_local_hook (generic_set_add); + route_map_no_set_ipv6_nexthop_local_hook (generic_set_delete); + + route_map_set_metric_hook (generic_set_add); + route_map_no_set_metric_hook (generic_set_delete); + + route_map_set_tag_hook (generic_set_add); + route_map_no_set_tag_hook (generic_set_delete); + route_map_install_match (&route_match_peer_cmd); route_map_install_match (&route_match_local_pref_cmd); route_map_install_match (&route_match_ip_address_cmd); @@ -4482,23 +4045,13 @@ bgp_route_map_init (void) install_element (RMAP_NODE, &match_peer_cmd); install_element (RMAP_NODE, &match_peer_local_cmd); install_element (RMAP_NODE, &no_match_peer_cmd); - install_element (RMAP_NODE, &match_ip_address_cmd); - install_element (RMAP_NODE, &no_match_ip_address_cmd); - install_element (RMAP_NODE, &match_ip_next_hop_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_cmd); install_element (RMAP_NODE, &match_ip_route_source_cmd); install_element (RMAP_NODE, &no_match_ip_route_source_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, &match_ip_next_hop_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd); install_element (RMAP_NODE, &match_ip_route_source_prefix_list_cmd); install_element (RMAP_NODE, &no_match_ip_route_source_prefix_list_cmd); install_element (RMAP_NODE, &match_aspath_cmd); install_element (RMAP_NODE, &no_match_aspath_cmd); - install_element (RMAP_NODE, &match_metric_cmd); - install_element (RMAP_NODE, &no_match_metric_cmd); install_element (RMAP_NODE, &match_local_pref_cmd); install_element (RMAP_NODE, &no_match_local_pref_cmd); install_element (RMAP_NODE, &match_community_cmd); @@ -4510,21 +4063,13 @@ bgp_route_map_init (void) install_element (RMAP_NODE, &no_match_origin_cmd); install_element (RMAP_NODE, &match_probability_cmd); install_element (RMAP_NODE, &no_match_probability_cmd); - install_element (RMAP_NODE, &match_interface_cmd); - install_element (RMAP_NODE, &no_match_interface_cmd); - install_element (RMAP_NODE, &match_tag_cmd); - install_element (RMAP_NODE, &no_match_tag_cmd); - install_element (RMAP_NODE, &set_ip_nexthop_cmd); install_element (RMAP_NODE, &set_ip_nexthop_peer_cmd); install_element (RMAP_NODE, &set_ip_nexthop_unchanged_cmd); - install_element (RMAP_NODE, &no_set_ip_nexthop_cmd); install_element (RMAP_NODE, &set_local_pref_cmd); install_element (RMAP_NODE, &no_set_local_pref_cmd); install_element (RMAP_NODE, &set_weight_cmd); install_element (RMAP_NODE, &no_set_weight_cmd); - install_element (RMAP_NODE, &set_metric_cmd); - install_element (RMAP_NODE, &no_set_metric_cmd); install_element (RMAP_NODE, &set_aspath_prepend_asn_cmd); install_element (RMAP_NODE, &set_aspath_prepend_lastas_cmd); install_element (RMAP_NODE, &set_aspath_exclude_cmd); @@ -4549,8 +4094,6 @@ bgp_route_map_init (void) install_element (RMAP_NODE, &no_set_vpnv4_nexthop_cmd); install_element (RMAP_NODE, &set_originator_id_cmd); install_element (RMAP_NODE, &no_set_originator_id_cmd); - install_element (RMAP_NODE, &set_tag_cmd); - install_element (RMAP_NODE, &no_set_tag_cmd); #ifdef HAVE_IPV6 route_map_install_match (&route_match_ipv6_address_cmd); @@ -4561,18 +4104,12 @@ bgp_route_map_init (void) route_map_install_set (&route_set_ipv6_nexthop_local_cmd); route_map_install_set (&route_set_ipv6_nexthop_peer_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); install_element (RMAP_NODE, &no_match_ipv6_next_hop_cmd); - install_element (RMAP_NODE, &match_ipv6_address_prefix_list_cmd); - install_element (RMAP_NODE, &no_match_ipv6_address_prefix_list_cmd); install_element (RMAP_NODE, &set_ipv6_nexthop_global_cmd); install_element (RMAP_NODE, &no_set_ipv6_nexthop_global_cmd); install_element (RMAP_NODE, &set_ipv6_nexthop_prefer_global_cmd); install_element (RMAP_NODE, &no_set_ipv6_nexthop_prefer_global_cmd); - install_element (RMAP_NODE, &set_ipv6_nexthop_local_cmd); - install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_cmd); install_element (RMAP_NODE, &set_ipv6_nexthop_peer_cmd); install_element (RMAP_NODE, &no_set_ipv6_nexthop_peer_cmd); #endif /* HAVE_IPV6 */ diff --git a/isisd/isis_routemap.c b/isisd/isis_routemap.c index 72caa5a09..93267afe9 100644 --- a/isisd/isis_routemap.c +++ b/isisd/isis_routemap.c @@ -250,282 +250,30 @@ static struct route_map_rule_cmd route_set_metric_cmd = route_set_metric_free }; -/* ------------------------------------------------------------*/ - -static int -isis_route_match_add(struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_add_match (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - -static int -isis_route_match_delete(struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_delete_match (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - -static int -isis_route_set_add(struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_add_set(index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - - return CMD_SUCCESS; -} - -static int -isis_route_set_delete (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_delete_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - - return CMD_SUCCESS; -} - -/* ------------------------------------------------------------*/ - -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") -{ - int idx_acl = 3; - return isis_route_match_add(vty, vty->index, "ip address", argv[idx_acl]->arg); -} - - -DEFUN (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") -{ - int idx_acl = 4; - if (argc == 4) - return isis_route_match_delete(vty, vty->index, "ip address", NULL); - return isis_route_match_delete(vty, vty->index, "ip address", argv[idx_acl]->arg); -} - - -/* ------------------------------------------------------------*/ - -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") -{ - int idx_word = 4; - return isis_route_match_add(vty, vty->index, "ip address prefix-list", argv[idx_word]->arg); -} - - -DEFUN (no_match_ip_address_prefix_list, - no_match_ip_address_prefix_list_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") -{ - int idx_word = 5; - if (argc == 5) - return isis_route_match_delete (vty, vty->index, "ip address prefix-list", NULL); - return isis_route_match_delete (vty, vty->index, "ip address prefix-list", argv[idx_word]->arg); -} - - -/* ------------------------------------------------------------*/ - -DEFUN (match_ipv6_address, - match_ipv6_address_cmd, - "match ipv6 address WORD", - MATCH_STR - IPV6_STR - "Match IPv6 address of route\n" - "IPv6 access-list name\n") -{ - int idx_word = 3; - return isis_route_match_add(vty, vty->index, "ipv6 address", argv[idx_word]->arg); -} - - -DEFUN (no_match_ipv6_address, - no_match_ipv6_address_val_cmd, - "no match ipv6 address [WORD]", - NO_STR - MATCH_STR - IPV6_STR - "Match IPv6 address of route\n" - "IPv6 access-list name\n") -{ - int idx_word = 4; - if (argc == 4) - return isis_route_match_delete(vty, vty->index, "ipv6 address", NULL); - return isis_route_match_delete(vty, vty->index, "ipv6 address", argv[idx_word]->arg); -} - - -/* ------------------------------------------------------------*/ - -DEFUN (match_ipv6_address_prefix_list, - match_ipv6_address_prefix_list_cmd, - "match ipv6 address prefix-list WORD", - MATCH_STR - IPV6_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") -{ - int idx_word = 4; - return isis_route_match_add(vty, vty->index, "ipv6 address prefix-list", argv[idx_word]->arg); -} - -DEFUN (no_match_ipv6_address_prefix_list, - no_match_ipv6_address_prefix_list_cmd, - "no match ipv6 address prefix-list [WORD]", - NO_STR - MATCH_STR - IPV6_STR - "Match address of route\n" - "Match entries of prefix-lists\n" - "IP prefix-list name\n") +void +isis_route_map_init(void) { - int idx_word = 5; - if (argc == 5) - return isis_route_match_delete (vty, vty->index, "ipv6 address prefix-list", NULL); - return isis_route_match_delete (vty, vty->index, "ipv6 address prefix-list", argv[idx_word]->arg); -} + route_map_init(); + route_map_init_vty(); + 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); -/* set metric already exists e.g. in the ospf routemap. vtysh doesn't cope well with different - * commands at the same node, therefore add set metric with the same 32-bit range as ospf and - * verify that the input is a valid isis metric */ -DEFUN (set_metric, - set_metric_cmd, - "set metric (0-4294967295)", - SET_STR - "Metric vale for destination routing protocol\n" - "Metric value\n") -{ - int idx_number = 2; - return isis_route_set_add(vty, vty->index, "metric", argv[idx_number]->arg); -} + route_map_match_ipv6_address_hook (generic_match_add); + route_map_no_match_ipv6_address_hook (generic_match_delete); -DEFUN (no_set_metric, - no_set_metric_val_cmd, - "no set metric [(0-4294967295)]", - NO_STR - SET_STR - "Metric value for destination routing protocol\n" - "Metric value\n") -{ - int idx_number = 3; - if (argc == 3) - return isis_route_set_delete(vty, vty->index, "metric", NULL); - return isis_route_set_delete(vty, vty->index, "metric", argv[idx_number]->arg); -} + route_map_match_ipv6_address_prefix_list_hook (generic_match_add); + route_map_no_match_ipv6_address_prefix_list_hook (generic_match_delete); -void -isis_route_map_init(void) -{ - route_map_init(); - route_map_init_vty(); + route_map_set_metric_hook (generic_set_add); + route_map_no_set_metric_hook (generic_set_delete); route_map_install_match(&route_match_ip_address_cmd); - install_element(RMAP_NODE, &match_ip_address_cmd); - install_element(RMAP_NODE, &no_match_ip_address_val_cmd); - route_map_install_match(&route_match_ip_address_prefix_list_cmd); - install_element(RMAP_NODE, &match_ip_address_prefix_list_cmd); - install_element(RMAP_NODE, &no_match_ip_address_prefix_list_cmd); - route_map_install_match(&route_match_ipv6_address_cmd); - install_element(RMAP_NODE, &match_ipv6_address_cmd); - install_element(RMAP_NODE, &no_match_ipv6_address_val_cmd); - route_map_install_match(&route_match_ipv6_address_prefix_list_cmd); - install_element(RMAP_NODE, &match_ipv6_address_prefix_list_cmd); - install_element(RMAP_NODE, &no_match_ipv6_address_prefix_list_cmd); - route_map_install_set(&route_set_metric_cmd); - install_element(RMAP_NODE, &set_metric_cmd); - install_element(RMAP_NODE, &no_set_metric_val_cmd); } diff --git a/lib/routemap.c b/lib/routemap.c index 2e8637bcb..a68b6210b 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -24,9 +24,9 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "memory.h" #include "vector.h" #include "prefix.h" +#include "vty.h" #include "routemap.h" #include "command.h" -#include "vty.h" #include "log.h" #include "hash.h" @@ -44,6 +44,594 @@ static vector route_match_vec; /* Vector for route set rules. */ static vector route_set_vec; +struct route_map_match_set_hooks +{ + /* match interface */ + int (*match_interface) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match interface */ + int (*no_match_interface) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* match ip address */ + int (*match_ip_address) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match ip address */ + int (*no_match_ip_address) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* match ip address prefix list */ + int (*match_ip_address_prefix_list) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match ip address prefix list */ + int (*no_match_ip_address_prefix_list) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* match ip next hop */ + int (*match_ip_next_hop) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match ip next hop */ + int (*no_match_ip_next_hop) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* match ip next hop prefix list */ + int (*match_ip_next_hop_prefix_list) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match ip next hop prefix list */ + int (*no_match_ip_next_hop_prefix_list) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* match ipv6 address */ + int (*match_ipv6_address) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match ipv6 address */ + int (*no_match_ipv6_address) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + + /* match ipv6 address prefix list */ + int (*match_ipv6_address_prefix_list) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match ipv6 address prefix list */ + int (*no_match_ipv6_address_prefix_list) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* match metric */ + int (*match_metric) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match metric */ + int (*no_match_metric) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* match tag */ + int (*match_tag) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match tag */ + int (*no_match_tag) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* set ip nexthop */ + int (*set_ip_nexthop) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg); + + /* no set ip nexthop */ + int (*no_set_ip_nexthop) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg); + + /* set ipv6 nexthop local */ + int (*set_ipv6_nexthop_local) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg); + + /* no set ipv6 nexthop local */ + int (*no_set_ipv6_nexthop_local) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg); + + /* set metric */ + int (*set_metric) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg); + + /* no set metric */ + int (*no_set_metric) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg); + + /* set tag */ + int (*set_tag) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg); + + /* no set tag */ + int (*no_set_tag) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg); + +}; + +struct route_map_match_set_hooks rmap_match_set_hook; + +/* match interface */ +void +route_map_match_interface_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_interface = func; +} + +/* no match interface */ +void +route_map_no_match_interface_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_interface = func; +} + +/* match ip address */ +void +route_map_match_ip_address_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_ip_address = func; +} + +/* no match ip address */ +void +route_map_no_match_ip_address_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_ip_address = func; +} + +/* match ip address prefix list */ +void +route_map_match_ip_address_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_ip_address_prefix_list = func; +} + +/* no match ip address prefix list */ +void +route_map_no_match_ip_address_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_ip_address_prefix_list = func; +} + +/* match ip next hop */ +void +route_map_match_ip_next_hop_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_ip_next_hop = func; +} + +/* no match ip next hop */ +void +route_map_no_match_ip_next_hop_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_ip_next_hop = func; +} + +/* match ip next hop prefix list */ +void +route_map_match_ip_next_hop_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_ip_next_hop_prefix_list = func; +} + +/* no match ip next hop prefix list */ +void +route_map_no_match_ip_next_hop_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_ip_next_hop_prefix_list = func; +} + +/* match ipv6 address */ +void +route_map_match_ipv6_address_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_ipv6_address = func; +} + +/* no match ipv6 address */ +void +route_map_no_match_ipv6_address_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_ipv6_address = func; +} + + +/* match ipv6 address prefix list */ +void +route_map_match_ipv6_address_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_ipv6_address_prefix_list = func; +} + +/* no match ipv6 address prefix list */ +void +route_map_no_match_ipv6_address_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_ipv6_address_prefix_list = func; +} + +/* match metric */ +void +route_map_match_metric_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_metric = func; +} + +/* no match metric */ +void +route_map_no_match_metric_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_metric = func; +} + +/* match tag */ +void +route_map_match_tag_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.match_tag = func; +} + +/* no match tag */ +void +route_map_no_match_tag_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)) +{ + rmap_match_set_hook.no_match_tag = func; +} + +/* set ip nexthop */ +void +route_map_set_ip_nexthop_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)) +{ + rmap_match_set_hook.set_ip_nexthop = func; +} + +/* no set ip nexthop */ +void +route_map_no_set_ip_nexthop_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)) +{ + rmap_match_set_hook.no_set_ip_nexthop = func; +} + +/* set ipv6 nexthop local */ +void +route_map_set_ipv6_nexthop_local_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)) +{ + rmap_match_set_hook.set_ipv6_nexthop_local = func; +} + +/* no set ipv6 nexthop local */ +void +route_map_no_set_ipv6_nexthop_local_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)) +{ + rmap_match_set_hook.no_set_ipv6_nexthop_local = func; +} + +/* set metric */ +void +route_map_set_metric_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)) +{ + rmap_match_set_hook.set_metric = func; +} + +/* no set metric */ +void +route_map_no_set_metric_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)) +{ + rmap_match_set_hook.no_set_metric = func; +} + +/* set tag */ +void +route_map_set_tag_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)) +{ + rmap_match_set_hook.set_tag = func; +} + +/* no set tag */ +void +route_map_no_set_tag_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)) +{ + rmap_match_set_hook.no_set_tag = func; +} + +int +generic_match_add (struct vty *vty, struct route_map_index *index, + const char *command, const char *arg, + route_map_event_t type) +{ + int ret; + + ret = route_map_add_match (index, command, arg); + if (ret) + { + switch (ret) + { + case RMAP_RULE_MISSING: + vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); + return CMD_WARNING; + case RMAP_COMPILE_ERROR: + vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); + return CMD_WARNING; + } + } + + if (type != RMAP_EVENT_MATCH_ADDED) + { + route_map_upd8_dependency (type, arg, index->map->name); + } + return CMD_SUCCESS; +} + +int +generic_match_delete (struct vty *vty, struct route_map_index *index, + const char *command, const char *arg, + route_map_event_t type) +{ + int ret; + char *dep_name = NULL; + const char *tmpstr; + char *rmap_name = NULL; + + if (type != RMAP_EVENT_MATCH_DELETED) + { + /* ignore the mundane, the types without any dependency */ + if (arg == NULL) + { + if ((tmpstr = route_map_get_match_arg(index, command)) != NULL) + dep_name = XSTRDUP(MTYPE_ROUTE_MAP_RULE, tmpstr); + } + else + { + dep_name = XSTRDUP(MTYPE_ROUTE_MAP_RULE, arg); + } + rmap_name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, index->map->name); + } + + ret = route_map_delete_match (index, command, dep_name); + if (ret) + { + switch (ret) + { + case RMAP_RULE_MISSING: + vty_out (vty, "%% BGP Can't find rule.%s", VTY_NEWLINE); + break; + case RMAP_COMPILE_ERROR: + vty_out (vty, "%% BGP Argument is malformed.%s", VTY_NEWLINE); + break; + } + if (dep_name) + XFREE(MTYPE_ROUTE_MAP_RULE, dep_name); + if (rmap_name) + XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name); + return CMD_WARNING; + } + + if (type != RMAP_EVENT_MATCH_DELETED && dep_name) + route_map_upd8_dependency(type, dep_name, rmap_name); + + if (dep_name) + XFREE(MTYPE_ROUTE_MAP_RULE, dep_name); + if (rmap_name) + XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name); + + return CMD_SUCCESS; +} + +int +generic_set_add (struct vty *vty, struct route_map_index *index, + const char *command, const char *arg) +{ + int ret; + + ret = route_map_add_set (index, command, arg); + if (ret) + { + switch (ret) + { + case RMAP_RULE_MISSING: + vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); + return CMD_WARNING; + case RMAP_COMPILE_ERROR: + vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); + return CMD_WARNING; + } + } + return CMD_SUCCESS; +} + +int +generic_set_delete (struct vty *vty, struct route_map_index *index, + const char *command, const char *arg) +{ + int ret; + + ret = route_map_delete_set (index, command, arg); + if (ret) + { + switch (ret) + { + case RMAP_RULE_MISSING: + vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE); + return CMD_WARNING; + case RMAP_COMPILE_ERROR: + vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE); + return CMD_WARNING; + } + } + return CMD_SUCCESS; +} + + /* Route map rule. This rule has both `match' rule and `set' rule. */ struct route_map_rule { @@ -1396,7 +1984,515 @@ route_map_notify_dependencies (const char *affected_name, route_map_event_t even XFREE (MTYPE_ROUTE_MAP_NAME, name); } + /* VTY related functions. */ +DEFUN (match_interface, + match_interface_cmd, + "match interface WORD", + MATCH_STR + "match first hop interface of route\n" + "Interface name\n") +{ + int idx_word = 2; + + if (rmap_match_set_hook.match_interface) + return rmap_match_set_hook.match_interface (vty, vty->index, "interface", argv[idx_word]->arg, RMAP_EVENT_MATCH_ADDED); + return CMD_SUCCESS; +} + +DEFUN (no_match_interface, + no_match_interface_cmd, + "no match interface [INTERFACE]", + NO_STR + MATCH_STR + "Match first hop interface of route\n" + "Interface name\n") +{ + char *iface = (argc == 4) ? argv[3]->arg : NULL; + + if (rmap_match_set_hook.no_match_interface) + return rmap_match_set_hook.no_match_interface (vty, vty->index, "interface", iface, RMAP_EVENT_MATCH_DELETED); + return CMD_SUCCESS; +} + + +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") +{ + int idx_acl = 3; + + if (rmap_match_set_hook.match_ip_address) + return rmap_match_set_hook.match_ip_address (vty, vty->index, "ip address", argv[idx_acl]->arg, + RMAP_EVENT_FILTER_ADDED); + return CMD_SUCCESS; +} + + +DEFUN (no_match_ip_address, + no_match_ip_address_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") +{ + int idx_word = 4; + + if (rmap_match_set_hook.no_match_ip_address) + { + if (argc <= idx_word) + return rmap_match_set_hook.no_match_ip_address (vty, vty->index, "ip address", NULL, + RMAP_EVENT_FILTER_DELETED); + return rmap_match_set_hook.no_match_ip_address (vty, vty->index, "ip address", argv[idx_word]->arg, + RMAP_EVENT_FILTER_DELETED); + } + return CMD_SUCCESS; +} + + +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") +{ + int idx_word = 4; + if (rmap_match_set_hook.match_ip_address_prefix_list) + return rmap_match_set_hook.match_ip_address_prefix_list (vty, vty->index, "ip address prefix-list", + argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED); + return CMD_SUCCESS; +} + + +DEFUN (no_match_ip_address_prefix_list, + no_match_ip_address_prefix_list_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") +{ + int idx_word = 5; + + if (rmap_match_set_hook.no_match_ip_address_prefix_list) + { + if (argc <= idx_word) + return rmap_match_set_hook.no_match_ip_address_prefix_list (vty, vty->index, "ip address prefix-list", + NULL, RMAP_EVENT_PLIST_DELETED); + return rmap_match_set_hook.no_match_ip_address_prefix_list(vty, vty->index, "ip address prefix-list", + argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED); + } + return CMD_SUCCESS; +} + + +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") +{ + int idx_acl = 3; + if (rmap_match_set_hook.match_ip_next_hop) + return rmap_match_set_hook.match_ip_next_hop (vty, vty->index, "ip next-hop", argv[idx_acl]->arg, + RMAP_EVENT_FILTER_ADDED); + return CMD_SUCCESS; +} + + +DEFUN (no_match_ip_next_hop, + no_match_ip_next_hop_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") +{ + int idx_word = 4; + + if (rmap_match_set_hook.no_match_ip_next_hop) + { + if (argc <= idx_word) + return rmap_match_set_hook.no_match_ip_next_hop (vty, vty->index, "ip next-hop", NULL, + RMAP_EVENT_FILTER_DELETED); + return rmap_match_set_hook.no_match_ip_next_hop (vty, vty->index, "ip next-hop", argv[idx_word]->arg, + RMAP_EVENT_FILTER_DELETED); + } + return CMD_SUCCESS; +} + + +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") +{ + int idx_word = 4; + if (rmap_match_set_hook.match_ip_next_hop_prefix_list) + return rmap_match_set_hook.match_ip_next_hop_prefix_list (vty, vty->index, "ip next-hop prefix-list", + argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED); + return CMD_SUCCESS; +} + +DEFUN (no_match_ip_next_hop_prefix_list, + no_match_ip_next_hop_prefix_list_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") +{ + int idx_word = 5; + + if (rmap_match_set_hook.no_match_ip_next_hop) + { + if (argc <= idx_word) + return rmap_match_set_hook.no_match_ip_next_hop (vty, vty->index, "ip next-hop prefix-list", + NULL, RMAP_EVENT_PLIST_DELETED); + return rmap_match_set_hook.no_match_ip_next_hop (vty, vty->index, "ip next-hop prefix-list", + argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED); + } + return CMD_SUCCESS; +} + + +DEFUN (match_ipv6_address, + match_ipv6_address_cmd, + "match ipv6 address WORD", + MATCH_STR + IPV6_STR + "Match IPv6 address of route\n" + "IPv6 access-list name\n") +{ + int idx_word = 3; + if (rmap_match_set_hook.match_ipv6_address) + return rmap_match_set_hook.match_ipv6_address (vty, vty->index, "ipv6 address", argv[idx_word]->arg, + RMAP_EVENT_FILTER_ADDED); + return CMD_SUCCESS; +} + +DEFUN (no_match_ipv6_address, + no_match_ipv6_address_cmd, + "no match ipv6 address WORD", + NO_STR + MATCH_STR + IPV6_STR + "Match IPv6 address of route\n" + "IPv6 access-list name\n") +{ + int idx_word = 4; + if (rmap_match_set_hook.no_match_ipv6_address) + return rmap_match_set_hook.no_match_ipv6_address (vty, vty->index, "ipv6 address", argv[idx_word]->arg, + RMAP_EVENT_FILTER_DELETED); + return CMD_SUCCESS; +} + + +DEFUN (match_ipv6_address_prefix_list, + match_ipv6_address_prefix_list_cmd, + "match ipv6 address prefix-list WORD", + MATCH_STR + IPV6_STR + "Match address of route\n" + "Match entries of prefix-lists\n" + "IP prefix-list name\n") +{ + int idx_word = 4; + if (rmap_match_set_hook.match_ipv6_address_prefix_list) + return rmap_match_set_hook.match_ipv6_address_prefix_list (vty, vty->index, "ipv6 address prefix-list", + argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED); + return CMD_SUCCESS; +} + +DEFUN (no_match_ipv6_address_prefix_list, + no_match_ipv6_address_prefix_list_cmd, + "no match ipv6 address prefix-list WORD", + NO_STR + MATCH_STR + IPV6_STR + "Match address of route\n" + "Match entries of prefix-lists\n" + "IP prefix-list name\n") +{ + int idx_word = 5; + if (rmap_match_set_hook.no_match_ipv6_address_prefix_list) + return rmap_match_set_hook.no_match_ipv6_address_prefix_list(vty, vty->index, "ipv6 address prefix-list", + argv[idx_word]->arg, RMAP_EVENT_PLIST_DELETED); + return CMD_SUCCESS; +} + + +DEFUN (match_metric, + match_metric_cmd, + "match metric (0-4294967295)", + MATCH_STR + "Match metric of route\n" + "Metric value\n") +{ + int idx_number = 2; + if (rmap_match_set_hook.match_metric) + return rmap_match_set_hook.match_metric(vty, vty->index, "metric", argv[idx_number]->arg, + RMAP_EVENT_MATCH_ADDED); + return CMD_SUCCESS; +} + + +DEFUN (no_match_metric, + no_match_metric_cmd, + "no match metric [(0-4294967295)]", + NO_STR + MATCH_STR + "Match metric of route\n" + "Metric value\n") +{ + int idx_number = 3; + if (rmap_match_set_hook.no_match_metric) + { + if (argc <= idx_number) + return rmap_match_set_hook.no_match_metric (vty, vty->index, "metric", + NULL, RMAP_EVENT_MATCH_DELETED); + return rmap_match_set_hook.no_match_metric(vty, vty->index, "metric", + argv[idx_number]->arg, + RMAP_EVENT_MATCH_DELETED); + } + return CMD_SUCCESS; +} + + +DEFUN (match_tag, + match_tag_cmd, + "match tag (1-65535)", + MATCH_STR + "Match tag of route\n" + "Tag value\n") +{ + int idx_number = 2; + if (rmap_match_set_hook.match_tag) + return rmap_match_set_hook.match_tag(vty, vty->index, "tag", argv[idx_number]->arg, + RMAP_EVENT_MATCH_ADDED); + return CMD_SUCCESS; +} + + +DEFUN (no_match_tag, + no_match_tag_cmd, + "no match tag [(1-65535)]", + NO_STR + MATCH_STR + "Match tag of route\n" + "Tag value\n") +{ + if (rmap_match_set_hook.no_match_tag) + return rmap_match_set_hook.no_match_tag (vty, vty->index, "tag", argv[3]->arg, + RMAP_EVENT_MATCH_DELETED); + return CMD_SUCCESS; +} + + +DEFUN (set_ip_nexthop, + set_ip_nexthop_cmd, + "set ip next-hop A.B.C.D", + SET_STR + IP_STR + "Next hop address\n" + "IP address of next hop\n") +{ + int idx_ipv4 = 3; + union sockunion su; + int ret; + + ret = str2sockunion (argv[idx_ipv4]->arg, &su); + if (ret < 0) + { + vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE); + return CMD_WARNING; + } + if (su.sin.sin_addr.s_addr == 0 || + IPV4_CLASS_DE(su.sin.sin_addr.s_addr)) + { + vty_out (vty, "%% nexthop address cannot be 0.0.0.0, multicast " + "or reserved%s", VTY_NEWLINE); + return CMD_WARNING; + } + + if (rmap_match_set_hook.set_ip_nexthop) + return rmap_match_set_hook.set_ip_nexthop(vty, vty->index, "ip next-hop", argv[idx_ipv4]->arg); + return CMD_SUCCESS; +} + + +DEFUN (no_set_ip_nexthop, + no_set_ip_nexthop_cmd, + "no set ip next-hop []", + NO_STR + SET_STR + "Next hop address\n" + "Use peer address (for BGP only)\n" + "IP address of next hop\n") +{ + int idx_peer = 4; + + if (rmap_match_set_hook.no_set_ip_nexthop) + { + if (argc <= idx_peer) + return rmap_match_set_hook.no_set_ip_nexthop (vty, vty->index, "ip next-hop", NULL); + return rmap_match_set_hook.no_set_ip_nexthop (vty, vty->index, "ip next-hop", argv[idx_peer]->arg); + } + return CMD_SUCCESS; +} + + +DEFUN (set_ipv6_nexthop_local, + set_ipv6_nexthop_local_cmd, + "set ipv6 next-hop local X:X::X:X", + SET_STR + IPV6_STR + "IPv6 next-hop address\n" + "IPv6 local address\n" + "IPv6 address of next hop\n") +{ + int idx_ipv6 = 4; + struct in6_addr addr; + int ret; + + ret = inet_pton (AF_INET6, argv[idx_ipv6]->arg, &addr); + if (!ret) + { + vty_out (vty, "%% Malformed nexthop address%s", VTY_NEWLINE); + return CMD_WARNING; + } + if (!IN6_IS_ADDR_LINKLOCAL(&addr)) + { + vty_out (vty, "%% Invalid link-local nexthop address%s", VTY_NEWLINE); + return CMD_WARNING; + } + + if (rmap_match_set_hook.set_ipv6_nexthop_local) + return rmap_match_set_hook.set_ipv6_nexthop_local (vty, vty->index, "ipv6 next-hop local", argv[idx_ipv6]->arg); + return CMD_SUCCESS; +} + + +DEFUN (no_set_ipv6_nexthop_local, + no_set_ipv6_nexthop_local_cmd, + "no set ipv6 next-hop local [X:X::X:X]", + NO_STR + SET_STR + IPV6_STR + "IPv6 next-hop address\n" + "IPv6 local address\n" + "IPv6 address of next hop\n") +{ + int idx_ipv6 = 5; + if (rmap_match_set_hook.no_set_ipv6_nexthop_local) + { + if (argc <= idx_ipv6) + return rmap_match_set_hook.no_set_ipv6_nexthop_local (vty, vty->index, "ipv6 next-hop local", NULL); + return rmap_match_set_hook.no_set_ipv6_nexthop_local (vty, vty->index, "ipv6 next-hop local", argv[5]->arg); + } + return CMD_SUCCESS; +} + +DEFUN (set_metric, + set_metric_cmd, + "set metric <(0-4294967295)|rtt|+rtt|-rtt|+metric|-metric>", + SET_STR + "Metric value for destination routing protocol\n" + "Metric value\n" + "Assign round trip time\n" + "Add round trip time\n" + "Subtract round trip time\n" + "Add metric\n" + "Subtract metric\n") +{ + int idx_number = 2; + if (rmap_match_set_hook.set_metric) + return rmap_match_set_hook.set_metric (vty, vty->index, "metric", argv[idx_number]->arg); + return CMD_SUCCESS; +} + + +DEFUN (no_set_metric, + no_set_metric_cmd, + "no set metric [(0-4294967295)]", + NO_STR + SET_STR + "Metric value for destination routing protocol\n" + "Metric value\n") +{ + int idx_number = 3; + if (rmap_match_set_hook.no_set_metric) + { + if (argc <= idx_number) + return rmap_match_set_hook.no_set_metric (vty, vty->index, "metric", NULL); + return rmap_match_set_hook.no_set_metric (vty, vty->index, "metric", argv[idx_number]->arg); + } + return CMD_SUCCESS; +} + + +DEFUN (set_tag, + set_tag_cmd, + "set tag (1-65535)", + SET_STR + "Tag value for routing protocol\n" + "Tag value\n") +{ + int idx_number = 2; + if (rmap_match_set_hook.set_tag) + return rmap_match_set_hook.set_tag (vty, vty->index, "tag", argv[idx_number]->arg); + return CMD_SUCCESS; +} + + +DEFUN (no_set_tag, + no_set_tag_cmd, + "no set tag [(1-65535)]", + NO_STR + SET_STR + "Tag value for routing protocol\n" + "Tag value\n") +{ + int idx_number = 3; + if (rmap_match_set_hook.no_set_tag) + { + if (argc <= idx_number) + return rmap_match_set_hook.no_set_tag (vty, vty->index, "tag", NULL); + return rmap_match_set_hook.no_set_tag (vty, vty->index, "tag", argv[idx_number]->arg); + } + return CMD_SUCCESS; +} + + + DEFUN (route_map, route_map_cmd, "route-map WORD (1-65535)", @@ -1823,4 +2919,44 @@ route_map_init_vty (void) /* Install show command */ install_element (ENABLE_NODE, &rmap_show_name_cmd); + + install_element (RMAP_NODE, &match_interface_cmd); + install_element (RMAP_NODE, &no_match_interface_cmd); + + install_element (RMAP_NODE, &match_ip_address_cmd); + install_element (RMAP_NODE, &no_match_ip_address_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, &match_ip_next_hop_cmd); + install_element (RMAP_NODE, &no_match_ip_next_hop_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, &match_ipv6_address_cmd); + install_element (RMAP_NODE, &no_match_ipv6_address_cmd); + + install_element (RMAP_NODE, &match_ipv6_address_prefix_list_cmd); + install_element (RMAP_NODE, &no_match_ipv6_address_prefix_list_cmd); + + install_element (RMAP_NODE, &match_metric_cmd); + install_element (RMAP_NODE, &no_match_metric_cmd); + + install_element (RMAP_NODE, &match_tag_cmd); + install_element (RMAP_NODE, &no_match_tag_cmd); + + install_element (RMAP_NODE, &set_ip_nexthop_cmd); + install_element (RMAP_NODE, &no_set_ip_nexthop_cmd); + + install_element (RMAP_NODE, &set_ipv6_nexthop_local_cmd); + install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_cmd); + + install_element (RMAP_NODE, &set_metric_cmd); + install_element (RMAP_NODE, &no_set_metric_cmd); + + install_element (RMAP_NODE, &set_tag_cmd); + install_element (RMAP_NODE, &no_set_tag_cmd); + } diff --git a/lib/routemap.h b/lib/routemap.h index 7006e43f6..a6d312333 100644 --- a/lib/routemap.h +++ b/lib/routemap.h @@ -228,4 +228,169 @@ extern void route_map_upd8_dependency (route_map_event_t type, const char *arg, extern void route_map_notify_dependencies (const char *affected_name, route_map_event_t event); +extern int generic_match_add (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + +extern int generic_match_delete (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); +extern int generic_set_add (struct vty *vty, struct route_map_index *index, + const char *command, const char *arg); +extern int generic_set_delete (struct vty *vty, struct route_map_index *index, + const char *command, const char *arg); + + +/* match interface */ +extern void route_map_match_interface_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match interface */ +extern void route_map_no_match_interface_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* match ip address */ +extern void route_map_match_ip_address_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match ip address */ +extern void route_map_no_match_ip_address_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* match ip address prefix list */ +extern void route_map_match_ip_address_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match ip address prefix list */ +extern void route_map_no_match_ip_address_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* match ip next hop */ +extern void route_map_match_ip_next_hop_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match ip next hop */ +extern void route_map_no_match_ip_next_hop_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* match ip next hop prefix list */ +extern void route_map_match_ip_next_hop_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match ip next hop prefix list */ +extern void route_map_no_match_ip_next_hop_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* match ipv6 address */ +extern void route_map_match_ipv6_address_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match ipv6 address */ +extern void route_map_no_match_ipv6_address_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* match ipv6 address prefix list */ +extern void route_map_match_ipv6_address_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match ipv6 address prefix list */ +extern void route_map_no_match_ipv6_address_prefix_list_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* match metric */ +extern void route_map_match_metric_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match metric */ +extern void route_map_no_match_metric_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* match tag */ +extern void route_map_match_tag_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* no match tag */ +extern void route_map_no_match_tag_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type)); +/* set ip nexthop */ +extern void route_map_set_ip_nexthop_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)); +/* no set ip nexthop */ +extern void route_map_no_set_ip_nexthop_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)); +/* set ipv6 nexthop local */ +extern void route_map_set_ipv6_nexthop_local_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)); +/* no set ipv6 nexthop local */ +extern void route_map_no_set_ipv6_nexthop_local_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)); +/* set metric */ +extern void route_map_set_metric_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)); +/* no set metric */ +extern void route_map_no_set_metric_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)); +/* set tag */ +extern void route_map_set_tag_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)); +/* no set tag */ +extern void route_map_no_set_tag_hook (int (*func) (struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg)); #endif /* _ZEBRA_ROUTEMAP_H */ diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index 8489d3366..07ddb9cc8 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -1070,7 +1070,6 @@ DEFUN (ospf6_routemap_no_match_interface, return route_map_command_status (vty, ret); } - /* add "set metric-type" */ DEFUN (ospf6_routemap_set_metric_type, ospf6_routemap_set_metric_type_cmd, @@ -1102,41 +1101,6 @@ DEFUN (ospf6_routemap_no_set_metric_type, return route_map_command_status (vty, ret); } -/* add "set metric" */ -DEFUN (set_metric, - set_metric_cmd, - "set metric (0-4294967295)", - "Set value\n" - "Metric value\n" - "Metric value\n") -{ - int idx_number = 2; - int ret = route_map_add_set ((struct route_map_index *) vty->index, - "metric", argv[idx_number]->arg); - return route_map_command_status (vty, ret); -} - -/* delete "set metric" */ -DEFUN (no_set_metric, - no_set_metric_cmd, - "no set metric [(0-4294967295)]", - NO_STR - SET_STR - "Metric value for destination routing protocol\n") -{ - int idx_number = 3; - int ret = 0; - - if (argc == 3) - ret = route_map_delete_set ((struct route_map_index *) vty->index, - "metric", NULL); - else - ret = route_map_delete_set ((struct route_map_index *) vty->index, - "metric", argv[idx_number]->arg); - return route_map_command_status (vty, ret); -} - - /* add "set forwarding-address" */ DEFUN (ospf6_routemap_set_forwarding, ospf6_routemap_set_forwarding_cmd, @@ -1174,6 +1138,9 @@ ospf6_routemap_init (void) route_map_add_hook (ospf6_asbr_routemap_update); route_map_delete_hook (ospf6_asbr_routemap_update); + route_map_set_metric_hook (generic_set_add); + route_map_no_set_metric_hook (generic_set_delete); + route_map_install_match (&ospf6_routemap_rule_match_address_prefixlist_cmd); route_map_install_match (&ospf6_routemap_rule_match_interface_cmd); @@ -1193,10 +1160,6 @@ ospf6_routemap_init (void) install_element (RMAP_NODE, &ospf6_routemap_set_metric_type_cmd); install_element (RMAP_NODE, &ospf6_routemap_no_set_metric_type_cmd); - /* ASE Metric */ - install_element (RMAP_NODE, &set_metric_cmd); - install_element (RMAP_NODE, &no_set_metric_cmd); - /* ASE Metric */ install_element (RMAP_NODE, &ospf6_routemap_set_forwarding_cmd); install_element (RMAP_NODE, &ospf6_routemap_no_set_forwarding_cmd); diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index ded8041cb..fd87c5a56 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -318,30 +318,6 @@ DEFUN (show_zebra, return CMD_SUCCESS; } -DEFUN (router_zebra, - router_zebra_cmd, - "router zebra", - "Enable a routing process\n" - "Make connection to zebra daemon\n") -{ - vty->node = ZEBRA_NODE; - zclient->enable = 1; - zclient_start (zclient); - return CMD_SUCCESS; -} - -DEFUN (no_router_zebra, - no_router_zebra_cmd, - "no router zebra", - NO_STR - "Configure routing process\n" - "Disable connection to zebra daemon\n") -{ - zclient->enable = 0; - zclient_stop (zclient); - return CMD_SUCCESS; -} - /* Zebra configuration write function. */ static int config_write_ospf6_zebra (struct vty *vty) @@ -695,9 +671,6 @@ ospf6_zebra_init (struct thread_master *master) /* Install command element for zebra node. */ install_element (VIEW_NODE, &show_zebra_cmd); install_element (ENABLE_NODE, &show_zebra_cmd); - install_element (CONFIG_NODE, &router_zebra_cmd); - install_element (CONFIG_NODE, &no_router_zebra_cmd); - install_default (ZEBRA_NODE); install_element (ZEBRA_NODE, &redistribute_ospf6_cmd); install_element (ZEBRA_NODE, &no_redistribute_ospf6_cmd); diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c index 3e2db84a6..8042c7322 100644 --- a/ospf6d/ospf6d.c +++ b/ospf6d/ospf6d.c @@ -686,7 +686,6 @@ DEFUN (show_ipv6_ospf6_database_type_id_router, u_int32_t id = 0; u_int32_t adv_router = 0; - // dwalton is this needed? OSPF6_CMD_CHECK_RUNNING (); type = parse_type_spec (idx_lsa, argc, argv); diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c index 33ddc67fc..ebe426cee 100644 --- a/ospfd/ospf_routemap.c +++ b/ospfd/ospf_routemap.c @@ -27,6 +27,7 @@ #include "memory.h" #include "prefix.h" #include "table.h" +#include "vty.h" #include "routemap.h" #include "command.h" #include "log.h" @@ -163,53 +164,6 @@ ospf_route_match_add (struct vty *vty, struct route_map_index *index, return CMD_SUCCESS; } -static int -ospf_route_set_add (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_add_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% OSPF Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% OSPF Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - - return CMD_SUCCESS; -} - -/* Delete rip route map rule. */ -static int -ospf_route_set_delete (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_delete_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% OSPF Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% OSPF Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - - return CMD_SUCCESS; -} - /* `match ip netxthop ' */ /* Match function return 1 if match is success else return zero. */ static route_map_result_t @@ -720,161 +674,6 @@ DEFUN (no_match_ip_nexthop, } -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") -{ - int idx_word = 4; - return ospf_route_match_add (vty, vty->index, "ip next-hop prefix-list", - argv[idx_word]->arg); -} - -DEFUN (no_match_ip_next_hop_prefix_list, - no_match_ip_next_hop_prefix_list_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") -{ - char *pl = (argc == 6) ? argv[5]->arg : NULL; - return ospf_route_match_delete (vty, vty->index, "ip next-hop prefix-list", pl); -} - - -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") -{ - int idx_acl = 3; - return ospf_route_match_add (vty, vty->index, "ip address", argv[idx_acl]->arg); -} - -DEFUN (no_match_ip_address, - no_match_ip_address_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") -{ - char *al = (argc == 5) ? argv[4]->arg : NULL; - return ospf_route_match_delete (vty, vty->index, "ip address", al); -} - -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") -{ - int idx_word = 4; - return ospf_route_match_add (vty, vty->index, "ip address prefix-list", - argv[idx_word]->arg); -} - -DEFUN (no_match_ip_address_prefix_list, - no_match_ip_address_prefix_list_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") -{ - char *pl = (argc == 6) ? argv[5]->arg : NULL; - return ospf_route_match_delete (vty, vty->index, "ip address prefix-list", pl); -} - -DEFUN (match_interface, - match_interface_cmd, - "match interface WORD", - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") -{ - int idx_word = 2; - return ospf_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg); -} - -DEFUN (no_match_interface, - no_match_interface_cmd, - "no match interface [INTERFACE]", - NO_STR - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") -{ - char *iface = (argc == 4) ? argv[3]->arg : NULL; - return ospf_route_match_delete (vty, vty->index, "interface", iface); -} - -DEFUN (match_tag, - match_tag_cmd, - "match tag (1-65535)", - MATCH_STR - "Match tag of route\n" - "Tag value\n") -{ - int idx_number = 2; - return ospf_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg); -} - -DEFUN (no_match_tag, - no_match_tag_cmd, - "no match tag [(1-65535)]", - NO_STR - MATCH_STR - "Match tag of route\n" - "Tag value\n") -{ - char *tag = (argc == 4) ? argv[3]->arg : NULL; - return ospf_route_match_delete (vty, vty->index, "tag", tag); -} - -DEFUN (set_metric, - set_metric_cmd, - "set metric (0-4294967295)", - SET_STR - "Metric value for destination routing protocol\n" - "Metric value\n") -{ - int idx_number = 2; - return ospf_route_set_add (vty, vty->index, "metric", argv[idx_number]->arg); -} - -DEFUN (no_set_metric, - no_set_metric_cmd, - "no set metric [(0-4294967295)]", - NO_STR - SET_STR - "Metric value for destination routing protocol\n" - "Metric value\n") -{ - char *mval = (argc == 4) ? argv[3]->arg : NULL; - return ospf_route_set_delete (vty, vty->index, "metric", mval); -} - DEFUN (set_metric_type, set_metric_type_cmd, "set metric-type ", @@ -884,7 +683,7 @@ DEFUN (set_metric_type, "OSPF[6] external type 2 metric\n") { char *ext = argv[2]->text; - return ospf_route_set_add (vty, vty->index, "metric-type", ext); + return generic_set_add (vty, vty->index, "metric-type", ext); } DEFUN (no_set_metric_type, @@ -897,33 +696,9 @@ DEFUN (no_set_metric_type, "OSPF[6] external type 2 metric\n") { char *ext = (argc == 4) ? argv[3]->text : NULL; - return ospf_route_set_delete (vty, vty->index, "metric-type", ext); -} - -DEFUN (set_tag, - set_tag_cmd, - "set tag (1-65535)", - SET_STR - "Tag value for routing protocol\n" - "Tag value\n") -{ - int idx_number = 2; - return ospf_route_set_add (vty, vty->index, "tag", argv[idx_number]->arg); -} - -DEFUN (no_set_tag, - no_set_tag_cmd, - "no set tag [(1-65535)]", - NO_STR - SET_STR - "Tag value for routing protocol\n" - "Tag value\n") -{ - char *tag = (argc == 4) ? argv[3]->arg : NULL; - return ospf_route_set_delete (vty, vty->index, "tag", tag); + return generic_set_delete (vty, vty->index, "metric-type", ext); } - /* Route-map init */ void ospf_route_map_init (void) @@ -934,6 +709,27 @@ ospf_route_map_init (void) route_map_add_hook (ospf_route_map_update); route_map_delete_hook (ospf_route_map_update); route_map_event_hook (ospf_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_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_set_metric_hook (generic_set_add); + route_map_no_set_metric_hook (generic_set_delete); + + route_map_set_tag_hook (generic_set_add); + route_map_no_set_tag_hook (generic_set_delete); route_map_install_match (&route_match_ip_nexthop_cmd); route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd); @@ -948,21 +744,7 @@ ospf_route_map_init (void) install_element (RMAP_NODE, &match_ip_nexthop_cmd); install_element (RMAP_NODE, &no_match_ip_nexthop_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, &match_ip_address_cmd); - install_element (RMAP_NODE, &no_match_ip_address_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, &match_interface_cmd); - install_element (RMAP_NODE, &no_match_interface_cmd); - install_element (RMAP_NODE, &match_tag_cmd); - install_element (RMAP_NODE, &no_match_tag_cmd); - - install_element (RMAP_NODE, &set_metric_cmd); - install_element (RMAP_NODE, &no_set_metric_cmd); + install_element (RMAP_NODE, &set_metric_type_cmd); install_element (RMAP_NODE, &no_set_metric_type_cmd); - install_element (RMAP_NODE, &set_tag_cmd); - install_element (RMAP_NODE, &no_set_tag_cmd); } diff --git a/ospfd/ospf_zebra.h b/ospfd/ospf_zebra.h index 7cfae417e..8e93ed269 100644 --- a/ospfd/ospf_zebra.h +++ b/ospfd/ospf_zebra.h @@ -42,8 +42,6 @@ struct ospf_distance }; /* Prototypes */ -extern void ospf_zclient_start (void); - extern void ospf_zebra_add (struct prefix_ipv4 *, struct ospf_route *); extern void ospf_zebra_delete (struct prefix_ipv4 *, struct ospf_route *); diff --git a/pimd/pim_routemap.c b/pimd/pim_routemap.c index adfd4fd2c..3689d23a8 100644 --- a/pimd/pim_routemap.c +++ b/pimd/pim_routemap.c @@ -22,6 +22,7 @@ #include #include "if.h" +#include "vty.h" #include "routemap.h" #include "pimd.h" diff --git a/ripd/rip_routemap.c b/ripd/rip_routemap.c index e1017cfb2..3cdfd8adf 100644 --- a/ripd/rip_routemap.c +++ b/ripd/rip_routemap.c @@ -24,6 +24,7 @@ #include "memory.h" #include "prefix.h" +#include "vty.h" #include "routemap.h" #include "command.h" #include "filter.h" @@ -45,104 +46,6 @@ struct rip_metric_modifier u_char metric; }; -/* Add rip route map rule. */ -static int -rip_route_match_add (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_add_match (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% RIP Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% RIP Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - -/* Delete rip route map rule. */ -static int -rip_route_match_delete (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_delete_match (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% RIP Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% RIP Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - -/* Add rip route map rule. */ -static int -rip_route_set_add (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_add_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% RIP Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - /* rip, ripng and other protocols share the set metric command - but only values from 0 to 16 are valid for rip and ripng - if metric is out of range for rip and ripng, it is not for - other protocols. Do not return an error */ - if (strcmp(command, "metric")) { - vty_out (vty, "%% RIP Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - } - return CMD_SUCCESS; -} - -/* Delete rip route map rule. */ -static int -rip_route_set_delete (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_delete_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "%% RIP Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "%% RIP Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - /* Hook function for updating route_map assignment. */ /* ARGSUSED */ static void @@ -735,288 +638,6 @@ static struct route_map_rule_cmd route_set_tag_cmd = #define MATCH_STR "Match values from routing table\n" #define SET_STR "Set values in destination routing protocol\n" -DEFUN (match_metric, - match_metric_cmd, - "match metric (0-4294967295)", - MATCH_STR - "Match metric of route\n" - "Metric value\n") -{ - int idx_number = 2; - return rip_route_match_add (vty, vty->index, "metric", argv[idx_number]->arg); -} - -DEFUN (no_match_metric, - no_match_metric_cmd, - "no match metric [(0-4294967295)]", - NO_STR - MATCH_STR - "Match metric of route\n" - "Metric value\n") -{ - char *mval = (argc == 4) ? argv[3]->arg : NULL; - return rip_route_match_delete (vty, vty->index, "metric", mval); -} - - -DEFUN (match_interface, - match_interface_cmd, - "match interface WORD", - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") -{ - int idx_word = 2; - return rip_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg); -} - -DEFUN (no_match_interface, - no_match_interface_cmd, - "no match interface [INTERFACE]", - NO_STR - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") -{ - char *iface = (argc == 4) ? argv[3]->arg : NULL; - return rip_route_match_delete (vty, vty->index, "interface", iface); -} - -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") -{ - int idx_acl = 3; - return rip_route_match_add (vty, vty->index, "ip next-hop", argv[idx_acl]->arg); -} - -DEFUN (no_match_ip_next_hop, - no_match_ip_next_hop_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") -{ - char *al = (argc == 5) ? argv[4]->arg : NULL; - return rip_route_match_delete (vty, vty->index, "ip next-hop", al); -} - -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") -{ - int idx_word = 4; - return rip_route_match_add (vty, vty->index, "ip next-hop prefix-list", argv[idx_word]->arg); -} - -DEFUN (no_match_ip_next_hop_prefix_list, - no_match_ip_next_hop_prefix_list_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") -{ - char *plist = (argc == 6) ? argv[5]->arg : NULL; - return rip_route_match_delete (vty, vty->index, "ip next-hop prefix-list", plist); -} - - -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") - -{ - int idx_acl = 3; - return rip_route_match_add (vty, vty->index, "ip address", argv[idx_acl]->arg); -} - -DEFUN (no_match_ip_address, - no_match_ip_address_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") -{ - char *al = (argc == 5) ? argv[4]->arg : NULL; - return rip_route_match_delete (vty, vty->index, "ip address", al); -} - - -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") -{ - int idx_word = 4; - return rip_route_match_add (vty, vty->index, "ip address prefix-list", argv[idx_word]->arg); -} - -DEFUN (no_match_ip_address_prefix_list, - no_match_ip_address_prefix_list_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") -{ - char *plist = (argc == 6) ? argv[5]->arg : NULL; - return rip_route_match_delete (vty, vty->index, "ip address prefix-list", plist); -} - - -DEFUN (match_tag, - match_tag_cmd, - "match tag (1-65535)", - MATCH_STR - "Match tag of route\n" - "Metric value\n") -{ - int idx_number = 2; - return rip_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg); -} - -DEFUN (no_match_tag, - no_match_tag_cmd, - "no match tag [(1-65535)]", - NO_STR - MATCH_STR - "Match tag of route\n" - "Metric value\n") -{ - char *mval = (argc == 4) ? argv[3]->arg : NULL; - return rip_route_match_delete (vty, vty->index, "tag", mval); -} - - -/* set functions */ - -DEFUN (set_metric, - set_metric_cmd, - "set metric <(0-4294967295)|+metric|-metric>", - SET_STR - "Metric value for destination routing protocol\n" - "Metric value\n" - "Add metric\n" - "Subtract metric\n") -{ - char *metric = argv[2]->type == WORD_TKN ? argv[2]->text : argv[2]->arg; - return rip_route_set_add (vty, vty->index, "metric", metric); -} - -DEFUN (no_set_metric, - no_set_metric_cmd, - "no set metric <(0-4294967295)|+metric|-metric>", - NO_STR - SET_STR - "Metric value for destination routing protocol\n" - "Metric value\n" - "Add metric\n" - "Subtract metric\n") -{ - char *metric = argv[3]->type == WORD_TKN ? argv[3]->text : argv[3]->arg; - return rip_route_set_delete (vty, vty->index, "metric", metric); -} - -DEFUN (set_ip_nexthop, - set_ip_nexthop_cmd, - "set ip next-hop A.B.C.D", - SET_STR - IP_STR - "Next hop address\n" - "IP address of next hop\n") -{ - int idx_ipv4 = 3; - union sockunion su; - int ret; - - ret = str2sockunion (argv[idx_ipv4]->arg, &su); - if (ret < 0) - { - vty_out (vty, "%% Malformed next-hop address%s", VTY_NEWLINE); - return CMD_WARNING; - } - if (su.sin.sin_addr.s_addr == 0 || - IPV4_CLASS_DE(su.sin.sin_addr.s_addr)) - { - vty_out (vty, "%% nexthop address cannot be 0.0.0.0, multicast " - "or reserved%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return rip_route_set_add (vty, vty->index, "ip next-hop", argv[idx_ipv4]->arg); -} - -DEFUN (no_set_ip_nexthop, - no_set_ip_nexthop_cmd, - "no set ip next-hop [A.B.C.D]", - NO_STR - SET_STR - IP_STR - "Next hop address\n" - "IP address of next hop\n") -{ - char *addr = (argc == 5) ? argv[4]->arg : NULL; - return rip_route_set_delete (vty, vty->index, "ip next-hop", addr); -} - - -DEFUN (set_tag, - set_tag_cmd, - "set tag (1-65535)", - SET_STR - "Tag value for routing protocol\n" - "Tag value\n") -{ - int idx_number = 2; - return rip_route_set_add (vty, vty->index, "tag", argv[idx_number]->arg); -} - -DEFUN (no_set_tag, - no_set_tag_cmd, - "no set tag [(1-65535)]", - NO_STR - SET_STR - "Tag value for routing protocol\n" - "Tag value\n") -{ - char *tag = (argc == 4) ? argv[3]->arg : NULL; - return rip_route_set_delete (vty, vty->index, "tag", tag); -} - void rip_route_map_reset () { @@ -1032,6 +653,36 @@ rip_route_map_init () route_map_add_hook (rip_route_map_update); route_map_delete_hook (rip_route_map_update); + 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_metric_hook (generic_match_add); + route_map_no_match_metric_hook (generic_match_delete); + + route_map_match_tag_hook (generic_match_add); + route_map_no_match_tag_hook (generic_match_delete); + + route_map_set_ip_nexthop_hook (generic_set_add); + route_map_no_set_ip_nexthop_hook (generic_set_delete); + + route_map_set_metric_hook (generic_set_add); + route_map_no_set_metric_hook (generic_set_delete); + + route_map_set_tag_hook (generic_set_add); + route_map_no_set_tag_hook (generic_set_delete); + route_map_install_match (&route_match_metric_cmd); route_map_install_match (&route_match_interface_cmd); route_map_install_match (&route_match_ip_next_hop_cmd); @@ -1043,26 +694,4 @@ rip_route_map_init () route_map_install_set (&route_set_metric_cmd); route_map_install_set (&route_set_ip_nexthop_cmd); route_map_install_set (&route_set_tag_cmd); - - install_element (RMAP_NODE, &match_metric_cmd); - install_element (RMAP_NODE, &no_match_metric_cmd); - install_element (RMAP_NODE, &match_interface_cmd); - install_element (RMAP_NODE, &no_match_interface_cmd); - install_element (RMAP_NODE, &match_ip_next_hop_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_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, &match_ip_address_cmd); - install_element (RMAP_NODE, &no_match_ip_address_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, &match_tag_cmd); - install_element (RMAP_NODE, &no_match_tag_cmd); - - install_element (RMAP_NODE, &set_metric_cmd); - install_element (RMAP_NODE, &no_set_metric_cmd); - install_element (RMAP_NODE, &set_ip_nexthop_cmd); - install_element (RMAP_NODE, &no_set_ip_nexthop_cmd); - install_element (RMAP_NODE, &set_tag_cmd); - install_element (RMAP_NODE, &no_set_tag_cmd); } diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index f4cca7e8a..756a77cff 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -251,46 +251,6 @@ static struct { {0, 0, NULL} }; -DEFUN (router_zebra, - router_zebra_cmd, - "router zebra", - "Enable a routing process\n" - "Make connection to zebra daemon\n") -{ - vty->node = ZEBRA_NODE; - zclient->enable = 1; - zclient_start (zclient); - return CMD_SUCCESS; -} - -DEFUN (no_router_zebra, - no_router_zebra_cmd, - "no router zebra", - NO_STR - "Enable a routing process\n" - "Make connection to zebra daemon\n") -{ - zclient->enable = 0; - zclient_stop (zclient); - return CMD_SUCCESS; -} - -#if 0 -static int -rip_redistribute_set (int type) -{ - if (vrf_bitmap_check (zclient->redist[AFI_IP][type], VRF_DEFAULT)) - return CMD_SUCCESS; - - vrf_bitmap_set (zclient->redist[AFI_IP][type], VRF_DEFAULT); - - if (zclient->sock > 0) - zebra_redistribute_send (ZEBRA_REDISTRIBUTE_ADD, zclient, API_IP, type); - - return CMD_SUCCESS; -} -#endif - static int rip_redistribute_unset (int type) { @@ -747,8 +707,6 @@ rip_zclient_init (struct thread_master *master) install_node (&zebra_node, config_write_zebra); /* Install command elements to zebra node. */ - install_element (CONFIG_NODE, &router_zebra_cmd); - install_element (CONFIG_NODE, &no_router_zebra_cmd); install_default (ZEBRA_NODE); install_element (ZEBRA_NODE, &rip_redistribute_rip_cmd); install_element (ZEBRA_NODE, &no_rip_redistribute_rip_cmd); diff --git a/ripd/ripd.h b/ripd/ripd.h index 7c77b26d4..e6b18e3f0 100644 --- a/ripd/ripd.h +++ b/ripd/ripd.h @@ -392,7 +392,6 @@ extern void rip_route_map_init (void); extern void rip_route_map_reset (void); extern void rip_snmp_init (void); extern void rip_zclient_init(struct thread_master *); -extern void rip_zclient_start (void); extern void rip_zclient_reset (void); extern void rip_offset_init (void); extern int if_check_address (struct in_addr addr); diff --git a/ripngd/ripng_routemap.c b/ripngd/ripng_routemap.c index 6ecf08466..9e032e97f 100644 --- a/ripngd/ripng_routemap.c +++ b/ripngd/ripng_routemap.c @@ -24,6 +24,7 @@ #include "if.h" #include "memory.h" #include "prefix.h" +#include "vty.h" #include "routemap.h" #include "command.h" #include "sockunion.h" @@ -42,95 +43,6 @@ struct rip_metric_modifier u_char metric; }; - -static int -ripng_route_match_add (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_add_match (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - -static int -ripng_route_match_delete (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_delete_match (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - -static int -ripng_route_set_add (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_add_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - -static int -ripng_route_set_delete (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - int ret; - - ret = route_map_delete_set (index, command, arg); - if (ret) - { - switch (ret) - { - case RMAP_RULE_MISSING: - vty_out (vty, "RIPng Can't find rule.%s", VTY_NEWLINE); - return CMD_WARNING; - case RMAP_COMPILE_ERROR: - vty_out (vty, "RIPng Argument is malformed.%s", VTY_NEWLINE); - return CMD_WARNING; - } - } - return CMD_SUCCESS; -} - /* `match metric METRIC' */ /* Match function return 1 if match is success else return zero. */ static route_map_result_t @@ -500,172 +412,6 @@ static struct route_map_rule_cmd route_set_tag_cmd = #define MATCH_STR "Match values from routing table\n" #define SET_STR "Set values in destination routing protocol\n" -DEFUN (match_metric, - match_metric_cmd, - "match metric (0-4294967295)", - MATCH_STR - "Match metric of route\n" - "Metric value\n") -{ - int idx_number = 2; - return ripng_route_match_add (vty, vty->index, "metric", argv[idx_number]->arg); -} - -DEFUN (no_match_metric, - no_match_metric_cmd, - "no match metric [(0-4294967295)]", - NO_STR - MATCH_STR - "Match metric of route\n" - "Metric value\n") -{ - char *mval = (argc == 4) ? argv[3]->arg : NULL; - return ripng_route_match_delete (vty, vty->index, "metric", mval); -} - - -DEFUN (match_interface, - match_interface_cmd, - "match interface WORD", - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") -{ - int idx_word = 2; - return ripng_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg); -} - -DEFUN (no_match_interface, - no_match_interface_cmd, - "no match interface [INTERFACE]", - NO_STR - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") -{ - char *iface = (argc == 4) ? argv[3]->arg : NULL; - return ripng_route_match_delete (vty, vty->index, "interface", iface); -} - - -DEFUN (match_tag, - match_tag_cmd, - "match tag (1-65535)", - MATCH_STR - "Match tag of route\n" - "Metric value\n") -{ - int idx_number = 2; - return ripng_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg); -} - -DEFUN (no_match_tag, - no_match_tag_cmd, - "no match tag [(1-65535)]", - NO_STR - MATCH_STR - "Match tag of route\n" - "Metric value\n") -{ - char *mval = (argc == 4) ? argv[3]->arg : NULL; - return ripng_route_match_delete (vty, vty->index, "tag", mval); -} - - -/* set functions */ - -DEFUN (set_metric, - set_metric_cmd, - "set metric (0-4294967295)", - "Set value\n" - "Metric value for destination routing protocol\n" - "Metric value\n") -{ - int idx_number = 2; - return ripng_route_set_add (vty, vty->index, "metric", argv[idx_number]->arg); -} - -DEFUN (no_set_metric, - no_set_metric_cmd, - "no set metric [(0-4294967295)]", - NO_STR - SET_STR - "Metric value for destination routing protocol\n" - "Metric value\n") -{ - char *mval = (argc == 4) ? argv[3]->arg : NULL; - return ripng_route_set_delete (vty, vty->index, "metric", mval); -} - - -DEFUN (set_ipv6_nexthop_local, - set_ipv6_nexthop_local_cmd, - "set ipv6 next-hop local X:X::X:X", - SET_STR - IPV6_STR - "IPv6 next-hop address\n" - "IPv6 local address\n" - "IPv6 address of next hop\n") -{ - int idx_ipv6 = 4; - union sockunion su; - int ret; - - ret = str2sockunion (argv[idx_ipv6]->arg, &su); - if (ret < 0) - { - vty_out (vty, "%% Malformed next-hop local address%s", VTY_NEWLINE); - return CMD_WARNING; - } - - if (!IN6_IS_ADDR_LINKLOCAL(&su.sin6.sin6_addr)) - { - vty_out (vty, "%% Invalid link-local nexthop address%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return ripng_route_set_add (vty, vty->index, "ipv6 next-hop local", argv[idx_ipv6]->arg); -} - -DEFUN (no_set_ipv6_nexthop_local, - no_set_ipv6_nexthop_local_cmd, - "no set ipv6 next-hop local [X:X::X:X]", - NO_STR - SET_STR - IPV6_STR - "IPv6 next-hop address\n" - "IPv6 local address\n" - "IPv6 address of next hop\n") -{ - char *addr = (argc == 6) ? argv[5]->arg : NULL; - return ripng_route_set_delete (vty, vty->index, "ipv6 next-hop local", addr); -} - - -DEFUN (set_tag, - set_tag_cmd, - "set tag (1-65535)", - SET_STR - "Tag value for routing protocol\n" - "Tag value\n") -{ - int idx_number = 2; - return ripng_route_set_add (vty, vty->index, "tag", argv[idx_number]->arg); -} - -DEFUN (no_set_tag, - no_set_tag_cmd, - "no set tag [(1-65535)]", - NO_STR - SET_STR - "Tag value for routing protocol\n" - "Tag value\n") -{ - char *tag = (argc == 4) ? argv[3]->arg : NULL; - return ripng_route_set_delete (vty, vty->index, "tag", tag); -} - - void ripng_route_map_reset () { @@ -679,25 +425,28 @@ ripng_route_map_init () route_map_init (); route_map_init_vty (); + route_map_match_interface_hook (generic_match_add); + route_map_no_match_interface_hook (generic_match_delete); + + route_map_match_metric_hook (generic_match_add); + route_map_no_match_metric_hook (generic_match_delete); + + route_map_match_tag_hook (generic_match_add); + route_map_no_match_tag_hook (generic_match_delete); + + route_map_set_ipv6_nexthop_local_hook (generic_set_add); + route_map_no_set_ipv6_nexthop_local_hook (generic_set_delete); + + route_map_set_metric_hook (generic_set_add); + route_map_no_set_metric_hook (generic_set_delete); + + route_map_set_tag_hook (generic_set_add); + route_map_no_set_tag_hook (generic_set_delete); + route_map_install_match (&route_match_metric_cmd); route_map_install_match (&route_match_interface_cmd); route_map_install_match (&route_match_tag_cmd); - route_map_install_set (&route_set_metric_cmd); route_map_install_set (&route_set_ipv6_nexthop_local_cmd); route_map_install_set (&route_set_tag_cmd); - - install_element (RMAP_NODE, &match_metric_cmd); - install_element (RMAP_NODE, &no_match_metric_cmd); - install_element (RMAP_NODE, &match_interface_cmd); - install_element (RMAP_NODE, &no_match_interface_cmd); - install_element (RMAP_NODE, &match_tag_cmd); - install_element (RMAP_NODE, &no_match_tag_cmd); - - install_element (RMAP_NODE, &set_metric_cmd); - install_element (RMAP_NODE, &no_set_metric_cmd); - install_element (RMAP_NODE, &set_ipv6_nexthop_local_cmd); - install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_cmd); - install_element (RMAP_NODE, &set_tag_cmd); - install_element (RMAP_NODE, &no_set_tag_cmd); } diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c index c8527539f..1190b1873 100644 --- a/ripngd/ripng_zebra.c +++ b/ripngd/ripng_zebra.c @@ -280,30 +280,6 @@ ripng_redistribute_clean () } } -DEFUN (router_zebra, - router_zebra_cmd, - "router zebra", - "Enable a routing process\n" - "Make connection to zebra daemon\n") -{ - vty->node = ZEBRA_NODE; - zclient->enable = 1; - zclient_start (zclient); - return CMD_SUCCESS; -} - -DEFUN (no_router_zebra, - no_router_zebra_cmd, - "no router zebra", - NO_STR - "Disable a routing process\n" - "Stop connection to zebra daemon\n") -{ - zclient->enable = 0; - zclient_stop (zclient); - return CMD_SUCCESS; -} - DEFUN (ripng_redistribute_ripng, ripng_redistribute_ripng_cmd, "redistribute ripng", @@ -556,8 +532,6 @@ zebra_init (struct thread_master *master) install_node (&zebra_node, zebra_config_write); /* Install command element for zebra node. */ - install_element (CONFIG_NODE, &router_zebra_cmd); - install_element (CONFIG_NODE, &no_router_zebra_cmd); install_default (ZEBRA_NODE); install_element (ZEBRA_NODE, &ripng_redistribute_ripng_cmd); install_element (ZEBRA_NODE, &no_ripng_redistribute_ripng_cmd); diff --git a/ripngd/ripngd.h b/ripngd/ripngd.h index 5337eb88f..031ca963d 100644 --- a/ripngd/ripngd.h +++ b/ripngd/ripngd.h @@ -358,7 +358,6 @@ extern void ripng_route_map_reset (void); extern void ripng_terminate (void); /* zclient_init() is done by ripng_zebra.c:zebra_init() */ extern void zebra_init(struct thread_master *); -extern void ripng_zclient_start (void); extern void ripng_zclient_reset (void); extern void ripng_offset_init (void); diff --git a/vtysh/extract.pl.in b/vtysh/extract.pl.in index 5c8e6a4d2..bcebe2cc4 100755 --- a/vtysh/extract.pl.in +++ b/vtysh/extract.pl.in @@ -212,11 +212,6 @@ foreach (@ARGV) { } } -my $bad_cli_stomps = 71; -# Currently we have $bad_cli_stomps. This was determined by -# running this script and counting up the collisions from what -# was returned. -# # When we have cli commands that map to the same function name, we # can introduce subtle bugs due to code not being called when # we think it is. @@ -224,12 +219,9 @@ my $bad_cli_stomps = 71; # If extract.pl fails with a error message and you've been # modifying the cli, then go back and fix your code to # not have cli command function collisions. -# -# If you've removed a cli overwrite, you can safely subtract -# one from $bad_cli_stomps. If you've added to the problem # please fix your code before submittal -if ($cli_stomp != $bad_cli_stomps) { - warn "Expected $bad_cli_stomps command line stomps, but got $cli_stomp instead\n"; +if ($cli_stomp) { + warn "There are $cli_stomp command line stomps\n"; exit $cli_stomp; } diff --git a/zebra/connected.c b/zebra/connected.c index 290973a5c..97eb79d57 100644 --- a/zebra/connected.c +++ b/zebra/connected.c @@ -32,6 +32,7 @@ #include "memory.h" #include "zebra_memory.h" +#include "vty.h" #include "zebra/debug.h" #include "zebra/zserv.h" #include "zebra/redistribute.h" diff --git a/zebra/kernel_null.c b/zebra/kernel_null.c index 17b3c7bc8..0770ab0bb 100644 --- a/zebra/kernel_null.c +++ b/zebra/kernel_null.c @@ -24,6 +24,7 @@ #include #include +#include "vty.h" #include "zebra/zserv.h" #include "zebra/rt.h" #include "zebra/redistribute.h" diff --git a/zebra/redistribute_null.c b/zebra/redistribute_null.c index 85d3bd2f1..4446627dd 100644 --- a/zebra/redistribute_null.c +++ b/zebra/redistribute_null.c @@ -20,6 +20,7 @@ */ #include +#include "vty.h" #include "zebra/rib.h" #include "zebra/zserv.h" diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c index f7d013628..c5a6a4969 100644 --- a/zebra/zebra_fpm_netlink.c +++ b/zebra/zebra_fpm_netlink.c @@ -27,6 +27,7 @@ #include "log.h" #include "rib.h" +#include "vty.h" #include "zserv.h" #include "zebra_ns.h" diff --git a/zebra/zebra_rnh_null.c b/zebra/zebra_rnh_null.c index 3ec8be027..b7809d314 100644 --- a/zebra/zebra_rnh_null.c +++ b/zebra/zebra_rnh_null.c @@ -1,4 +1,5 @@ #include +#include "vty.h" #include "zebra/rib.h" #include "zebra/zserv.h" #include "zebra/zebra_rnh.h" diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index 6b861d780..fddc4fd7b 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -25,6 +25,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 +57,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, struct route_map_index *index, @@ -136,52 +139,6 @@ zebra_route_match_delete (struct vty *vty, struct route_map_index *index, return CMD_SUCCESS; } -/* Add zebra route map rule. */ -static int -zebra_route_set_add (struct vty *vty, struct route_map_index *index, - const char *command, const char *arg) -{ - 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, struct route_map_index *index, - const char *command, const char *arg) -{ - 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 */ @@ -294,179 +251,6 @@ 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") -{ - int idx_word = 2; - return zebra_route_match_add (vty, vty->index, "interface", argv[idx_word]->arg, - RMAP_EVENT_MATCH_ADDED); -} - -DEFUN (no_match_interface, - no_match_interface_cmd, - "no match interface [WORD]", - NO_STR - MATCH_STR - "Match first hop interface of route\n" - "Interface name\n") -{ - char *iface = (argc == 4) ? argv[3]->arg : NULL; - return zebra_route_match_delete (vty, vty->index, "interface", iface, RMAP_EVENT_MATCH_DELETED); -} - - -DEFUN (match_tag, - match_tag_cmd, - "match tag (1-65535)", - MATCH_STR - "Match tag of route\n" - "Tag value\n") -{ - int idx_number = 2; - return zebra_route_match_add (vty, vty->index, "tag", argv[idx_number]->arg, - RMAP_EVENT_MATCH_ADDED); -} - -DEFUN (no_match_tag, - no_match_tag_cmd, - "no match tag [(1-65535)]", - NO_STR - MATCH_STR - "Match tag of route\n") -{ - char *tag = (argc == 4) ? argv[3]->arg : NULL; - return zebra_route_match_delete (vty, vty->index, "tag", tag, RMAP_EVENT_MATCH_DELETED); -} - - -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") -{ - int idx_acl = 3; - return zebra_route_match_add (vty, vty->index, "ip next-hop", argv[idx_acl]->arg, RMAP_EVENT_FILTER_ADDED); -} - -DEFUN (no_match_ip_next_hop, - no_match_ip_next_hop_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") -{ - char *al = (argc == 5) ? argv[4]->arg : NULL; - return zebra_route_match_delete (vty, vty->index, "ip next-hop", al, RMAP_EVENT_FILTER_DELETED); -} - - -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") -{ - int idx_word = 4; - return zebra_route_match_add (vty, vty->index, "ip next-hop prefix-list", - argv[idx_word]->arg, 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 [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") -{ - char *plist = (argc == 6) ? argv[5]->arg : NULL; - return zebra_route_match_delete (vty, vty->index, - "ip next-hop prefix-list", plist, - RMAP_EVENT_PLIST_DELETED); -} - - -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") - -{ - int idx_acl = 3; - return zebra_route_match_add (vty, vty->index, "ip address", argv[idx_acl]->arg, - RMAP_EVENT_FILTER_ADDED); -} - -DEFUN (no_match_ip_address, - no_match_ip_address_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") -{ - char *al = (argc == 5) ? argv[4]->arg : NULL; - return zebra_route_match_delete (vty, vty->index, "ip address", al, RMAP_EVENT_FILTER_DELETED); -} - - -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") -{ - int idx_word = 4; - return zebra_route_match_add (vty, vty->index, "ip address prefix-list", - argv[idx_word]->arg, RMAP_EVENT_PLIST_ADDED); -} - -DEFUN (no_match_ip_address_prefix_list, - no_match_ip_address_prefix_list_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") -{ - char *plist = (argc == 6) ? argv[5]->arg : NULL; - return zebra_route_match_delete (vty, vty->index, - "ip address prefix-list", plist, - RMAP_EVENT_PLIST_DELETED); -} - - DEFUN (match_ip_address_prefix_len, match_ip_address_prefix_len_cmd, "match ip address prefix-len (0-32)", @@ -615,7 +399,7 @@ DEFUN (set_src, vty_out (vty, "%% not a local address%s", VTY_NEWLINE); return CMD_WARNING; } - return zebra_route_set_add (vty, vty->index, "src", argv[idx_ip]->arg); + return generic_set_add (vty, vty->index, "src", argv[idx_ip]->arg); } DEFUN (no_set_src, @@ -626,7 +410,7 @@ DEFUN (no_set_src, "Source address for route\n") { char *ip = (argc == 4) ? argv[3]->arg : NULL; - return zebra_route_set_delete (vty, vty->index, "src", ip); + return generic_set_delete (vty, vty->index, "src", ip); } DEFUN (zebra_route_map_timer, @@ -1729,6 +1513,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); @@ -1741,18 +1543,6 @@ 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, &match_interface_cmd); - install_element (RMAP_NODE, &no_match_interface_cmd); - install_element (RMAP_NODE, &match_ip_next_hop_cmd); - install_element (RMAP_NODE, &no_match_ip_next_hop_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, &match_ip_address_cmd); - install_element (RMAP_NODE, &no_match_ip_address_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, &match_ip_nexthop_prefix_len_cmd); install_element (RMAP_NODE, &no_match_ip_nexthop_prefix_len_cmd); install_element (RMAP_NODE, &match_ip_address_prefix_len_cmd); diff --git a/zebra/zebra_static.c b/zebra/zebra_static.c index 18efe26d9..d05b6e13a 100644 --- a/zebra/zebra_static.c +++ b/zebra/zebra_static.c @@ -25,6 +25,7 @@ #include #include +#include "vty.h" #include "zebra/debug.h" #include "zebra/rib.h" #include "zebra/zserv.h" diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c index 890d749ca..7625b9676 100644 --- a/zebra/zebra_vrf.c +++ b/zebra/zebra_vrf.c @@ -25,6 +25,7 @@ #include "linklist.h" #include "memory.h" +#include "vty.h" #include "zebra/debug.h" #include "zebra/zserv.h" #include "zebra/rib.h" diff --git a/zebra/zserv.h b/zebra/zserv.h index 3667f5b2b..4487957a0 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -25,10 +25,10 @@ #include "rib.h" #include "if.h" #include "workqueue.h" +#include "vrf.h" #include "routemap.h" #include "vty.h" #include "zclient.h" -#include "vrf.h" #include "zebra/zebra_ns.h" /* Default port information. */ diff --git a/zebra/zserv_null.c b/zebra/zserv_null.c index acab22d96..4b52abb22 100644 --- a/zebra/zserv_null.c +++ b/zebra/zserv_null.c @@ -23,6 +23,7 @@ #include #include +#include #include #include -- 2.39.5