summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaul <paul>2003-04-19 15:49:49 +0000
committerpaul <paul>2003-04-19 15:49:49 +0000
commit73ffb25bec41d729b0dac34d17b6ccd4aa25803b (patch)
tree69906ad70c8dd767c51677480f8034a3be3f5edd
parent147193a28a19f2f98545b14ad38935423415f53e (diff)
Hasso Tepper
http://hasso.linux.ee/zebra/ht-routemap-18042003_5.patch Trivial fixes to sync daemon's route-map commands to have same syntax. Fixes a lot of errors with "match ..." and "set ..." commands when using vtysh.
-rw-r--r--bgpd/bgp_routemap.c95
-rw-r--r--ospf6d/ospf6_routemap.c92
-rw-r--r--ospfd/ospf_routemap.c34
-rw-r--r--ripd/rip_routemap.c29
-rw-r--r--ripngd/ripng_routemap.c22
-rwxr-xr-xvtysh/extract.pl2
-rw-r--r--vtysh/vtysh.c18
-rw-r--r--vtysh/vtysh.h2
8 files changed, 209 insertions, 85 deletions
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index 498a6005..5cfb5c8c 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -518,6 +518,52 @@ struct route_map_rule_cmd route_match_community_cmd =
route_match_community_free
};
+/* Match function for extcommunity match. */
+route_map_result_t
+route_match_ecommunity (void *rule, struct prefix *prefix,
+ route_map_object_t type, void *object)
+{
+ struct community_list *list;
+ struct bgp_info *bgp_info;
+
+ if (type == RMAP_BGP)
+ {
+ bgp_info = object;
+
+ list = community_list_lookup (bgp_clist, (char *) rule,
+ EXTCOMMUNITY_LIST_AUTO);
+ if (! list)
+ return RMAP_NOMATCH;
+
+ if (ecommunity_list_match (bgp_info->attr->ecommunity, list))
+ return RMAP_MATCH;
+ }
+ return RMAP_NOMATCH;
+}
+
+/* Compile function for extcommunity match. */
+void *
+route_match_ecommunity_compile (char *arg)
+{
+ return XSTRDUP (MTYPE_ROUTE_MAP_COMPILED, arg);
+}
+
+/* Compile function for extcommunity match. */
+void
+route_match_ecommunity_free (void *rule)
+{
+ XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
+}
+
+/* Route map commands for community matching. */
+struct route_map_rule_cmd route_match_ecommunity_cmd =
+{
+ "extcommunity",
+ route_match_ecommunity,
+ route_match_ecommunity_compile,
+ route_match_ecommunity_free
+};
+
/* `match nlri` and `set nlri` are replaced by `address-family ipv4`
and `address-family vpnv4'. */
@@ -2222,6 +2268,38 @@ ALIAS (no_match_community,
"Community-list name\n"
"Do exact matching of communities\n")
+DEFUN (match_ecommunity,
+ match_ecommunity_cmd,
+ "match extcommunity (<1-99>|<100-199>|WORD)",
+ MATCH_STR
+ "Match BGP/VPN extended community list\n"
+ "Extended community-list number (standard)\n"
+ "Extended community-list number (expanded)\n"
+ "Extended community-list name\n")
+{
+ return bgp_route_match_add (vty, vty->index, "extcommunity", argv[0]);
+}
+
+DEFUN (no_match_ecommunity,
+ no_match_ecommunity_cmd,
+ "no match extcommunity",
+ NO_STR
+ MATCH_STR
+ "Match BGP/VPN extended community list\n")
+{
+ return bgp_route_match_delete (vty, vty->index, "extcommunity", NULL);
+}
+
+ALIAS (no_match_ecommunity,
+ no_match_ecommunity_val_cmd,
+ "no match extcommunity (<1-99>|<100-199>|WORD)",
+ NO_STR
+ MATCH_STR
+ "Match BGP/VPN extended community list\n"
+ "Extended community-list number (standard)\n"
+ "Extended community-list number (expanded)\n"
+ "Extended community-list name\n")
+
DEFUN (match_aspath,
match_aspath_cmd,
"match as-path WORD",
@@ -2335,15 +2413,21 @@ ALIAS (no_set_ip_nexthop,
DEFUN (set_metric,
set_metric_cmd,
- "set metric (<0-4294967295>|<+/-metric>)",
+ "set metric <0-4294967295>",
SET_STR
"Metric value for destination routing protocol\n"
- "Metric value\n"
- "Add or subtract metric\n")
+ "Metric value\n")
{
return bgp_route_set_add (vty, vty->index, "metric", argv[0]);
}
+ALIAS (set_metric,
+ set_metric_addsub_cmd,
+ "set metric <+/-metric>",
+ SET_STR
+ "Metric value for destination routing protocol\n"
+ "Add or subtract BGP metric\n")
+
DEFUN (no_set_metric,
no_set_metric_cmd,
"no set metric",
@@ -3093,6 +3177,7 @@ bgp_route_map_init ()
route_map_install_match (&route_match_ip_next_hop_prefix_list_cmd);
route_map_install_match (&route_match_aspath_cmd);
route_map_install_match (&route_match_community_cmd);
+ route_map_install_match (&route_match_ecommunity_cmd);
route_map_install_match (&route_match_metric_cmd);
route_map_install_match (&route_match_origin_cmd);
@@ -3136,6 +3221,9 @@ bgp_route_map_init ()
install_element (RMAP_NODE, &no_match_community_cmd);
install_element (RMAP_NODE, &no_match_community_val_cmd);
install_element (RMAP_NODE, &no_match_community_exact_cmd);
+ install_element (RMAP_NODE, &match_ecommunity_cmd);
+ install_element (RMAP_NODE, &no_match_ecommunity_cmd);
+ install_element (RMAP_NODE, &no_match_ecommunity_val_cmd);
install_element (RMAP_NODE, &match_origin_cmd);
install_element (RMAP_NODE, &no_match_origin_cmd);
install_element (RMAP_NODE, &no_match_origin_val_cmd);
@@ -3150,6 +3238,7 @@ bgp_route_map_init ()
install_element (RMAP_NODE, &no_set_weight_cmd);
install_element (RMAP_NODE, &no_set_weight_val_cmd);
install_element (RMAP_NODE, &set_metric_cmd);
+ install_element (RMAP_NODE, &set_metric_addsub_cmd);
install_element (RMAP_NODE, &no_set_metric_cmd);
install_element (RMAP_NODE, &no_set_metric_val_cmd);
install_element (RMAP_NODE, &set_aspath_prepend_cmd);
diff --git a/ospf6d/ospf6_routemap.c b/ospf6d/ospf6_routemap.c
index 14df7940..f617e913 100644
--- a/ospf6d/ospf6_routemap.c
+++ b/ospf6d/ospf6_routemap.c
@@ -214,14 +214,14 @@ route_map_command_status (struct vty *vty, int ret)
}
/* add "match address" */
-DEFUN (ospf6_routemap_match_address_prefixlist,
- ospf6_routemap_match_address_prefixlist_cmd,
+DEFUN (match_ipv6_address_prefix_list,
+ match_ipv6_address_prefix_list_cmd,
"match ipv6 address prefix-list WORD",
- "Match values\n"
+ MATCH_STR
IPV6_STR
"Match address of route\n"
"Match entries of prefix-lists\n"
- "IPv6 prefix-list name\n")
+ "IP prefix-list name\n")
{
int ret = route_map_add_match ((struct route_map_index *) vty->index,
"ipv6 address prefix-list", argv[0]);
@@ -229,15 +229,15 @@ DEFUN (ospf6_routemap_match_address_prefixlist,
}
/* delete "match address" */
-DEFUN (ospf6_routemap_no_match_address_prefixlist,
- ospf6_routemap_no_match_address_prefixlist_cmd,
+DEFUN (no_match_ipv6_address_prefix_list,
+ no_match_ipv6_address_prefix_list_cmd,
"no match ipv6 address prefix-list WORD",
NO_STR
- "Match values\n"
+ MATCH_STR
IPV6_STR
"Match address of route\n"
"Match entries of prefix-lists\n"
- "IPv6 prefix-list name\n")
+ "IP prefix-list name\n")
{
int ret = route_map_delete_match ((struct route_map_index *) vty->index,
"ipv6 address prefix-list", argv[0]);
@@ -245,13 +245,13 @@ DEFUN (ospf6_routemap_no_match_address_prefixlist,
}
/* add "set metric-type" */
-DEFUN (ospf6_routemap_set_metric_type,
- ospf6_routemap_set_metric_type_cmd,
+DEFUN (set_metric_type,
+ set_metric_type_cmd,
"set metric-type (type-1|type-2)",
- "Set value\n"
- "Type of metric\n"
- "OSPF6 external type 1 metric\n"
- "OSPF6 external type 2 metric\n")
+ SET_STR
+ "Type of metric for destination routing protocol\n"
+ "OSPF[6] external type 1 metric\n"
+ "OSPF[6] external type 2 metric\n")
{
int ret = route_map_add_set ((struct route_map_index *) vty->index,
"metric-type", argv[0]);
@@ -259,26 +259,38 @@ DEFUN (ospf6_routemap_set_metric_type,
}
/* delete "set metric-type" */
-DEFUN (ospf6_routemap_no_set_metric_type,
- ospf6_routemap_no_set_metric_type_cmd,
- "no set metric-type (type-1|type-2)",
+DEFUN (no_set_metric_type,
+ no_set_metric_type_cmd,
+ "no set metric-type",
NO_STR
- "Set value\n"
- "Type of metric\n"
- "OSPF6 external type 1 metric\n"
- "OSPF6 external type 2 metric\n")
+ SET_STR
+ "Type of metric for destination routing protocol\n")
{
- int ret = route_map_delete_set ((struct route_map_index *) vty->index,
+ int ret;
+ if (argc == 0)
+ ret = route_map_delete_set ((struct route_map_index *) vty->index,
+ "metric-type", NULL);
+ else
+ ret = route_map_delete_set ((struct route_map_index *) vty->index,
"metric-type", argv[0]);
return route_map_command_status (vty, ret);
}
+ALIAS (no_set_metric_type,
+ no_set_metric_type_val_cmd,
+ "no set metric-type (type-1|type-2)",
+ NO_STR
+ SET_STR
+ "Type of metric for destination routing protocol\n"
+ "OSPF[6] external type 1 metric\n"
+ "OSPF[6] external type 2 metric\n")
+
/* add "set metric" */
DEFUN (set_metric,
set_metric_cmd,
"set metric <0-4294967295>",
- "Set value\n"
- "Metric value\n"
+ SET_STR
+ "Metric value for destination routing protocol\n"
"Metric value\n")
{
int ret = route_map_add_set ((struct route_map_index *) vty->index,
@@ -289,17 +301,29 @@ DEFUN (set_metric,
/* delete "set metric" */
DEFUN (no_set_metric,
no_set_metric_cmd,
- "no set metric <0-4294967295>",
+ "no set metric",
NO_STR
- "Set value\n"
- "Metric\n"
- "METRIC value\n")
+ SET_STR
+ "Metric value for destination routing protocol\n")
{
- int ret = route_map_delete_set ((struct route_map_index *) vty->index,
+ int ret;
+ if (argc == 0)
+ 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[0]);
return route_map_command_status (vty, ret);
}
+ALIAS (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")
+
/* add "set forwarding-address" */
DEFUN (ospf6_routemap_set_forwarding,
ospf6_routemap_set_forwarding_cmd,
@@ -341,16 +365,18 @@ ospf6_routemap_init ()
route_map_install_set (&ospf6_routemap_rule_set_forwarding_cmd);
/* Match address prefix-list */
- install_element (RMAP_NODE, &ospf6_routemap_match_address_prefixlist_cmd);
- install_element (RMAP_NODE, &ospf6_routemap_no_match_address_prefixlist_cmd);
+ install_element (RMAP_NODE, &match_ipv6_address_prefix_list_cmd);
+ install_element (RMAP_NODE, &no_match_ipv6_address_prefix_list_cmd);
/* ASE Metric Type (e.g. Type-1/Type-2) */
- install_element (RMAP_NODE, &ospf6_routemap_set_metric_type_cmd);
- install_element (RMAP_NODE, &ospf6_routemap_no_set_metric_type_cmd);
+ install_element (RMAP_NODE, &set_metric_type_cmd);
+ install_element (RMAP_NODE, &no_set_metric_type_cmd);
+ install_element (RMAP_NODE, &no_set_metric_type_val_cmd);
/* ASE Metric */
install_element (RMAP_NODE, &set_metric_cmd);
install_element (RMAP_NODE, &no_set_metric_cmd);
+ install_element (RMAP_NODE, &no_set_metric_val_cmd);
/* ASE Metric */
install_element (RMAP_NODE, &ospf6_routemap_set_forwarding_cmd);
diff --git a/ospfd/ospf_routemap.c b/ospfd/ospf_routemap.c
index a2b257fa..64822d61 100644
--- a/ospfd/ospf_routemap.c
+++ b/ospfd/ospf_routemap.c
@@ -43,28 +43,32 @@
void
ospf_route_map_update (char *name)
{
+ struct ospf *ospf;
int type;
/* If OSPF instatnce does not exist, return right now. */
- if (!ospf_top)
+ ospf = ospf_lookup ();
+ if (ospf == NULL)
return;
/* Update route-map */
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
{
- if (ROUTEMAP_NAME (type) && strcmp (ROUTEMAP_NAME (type), name) == 0)
+ if (ROUTEMAP_NAME (ospf, type)
+ && strcmp (ROUTEMAP_NAME (ospf, type), name) == 0)
{
/* Keep old route-map. */
- struct route_map *old = ROUTEMAP (type);
+ struct route_map *old = ROUTEMAP (ospf, type);
/* Update route-map. */
- ROUTEMAP (type) = route_map_lookup_by_name (ROUTEMAP_NAME (type));
+ ROUTEMAP (ospf, type) =
+ route_map_lookup_by_name (ROUTEMAP_NAME (ospf, type));
/* No update for this distribute type. */
- if (old == NULL && ROUTEMAP (type) == NULL)
+ if (old == NULL && ROUTEMAP (ospf, type) == NULL)
continue;
- ospf_distribute_list_update (type);
+ ospf_distribute_list_update (ospf, type);
}
}
}
@@ -72,19 +76,21 @@ ospf_route_map_update (char *name)
void
ospf_route_map_event (route_map_event_t event, char *name)
{
+ struct ospf *ospf;
int type;
/* If OSPF instatnce does not exist, return right now. */
- if (!ospf_top)
+ ospf = ospf_lookup ();
+ if (ospf == NULL)
return;
/* Update route-map. */
for (type = 0; type <= ZEBRA_ROUTE_MAX; type++)
{
- if (ROUTEMAP_NAME (type) && ROUTEMAP (type) &&
- !strcmp (ROUTEMAP_NAME (type), name))
+ if (ROUTEMAP_NAME (ospf, type) && ROUTEMAP (ospf, type)
+ && !strcmp (ROUTEMAP_NAME (ospf, type), name))
{
- ospf_distribute_list_update (type);
+ ospf_distribute_list_update (ospf, type);
}
}
}
@@ -750,8 +756,8 @@ DEFUN (set_metric_type,
"set metric-type (type-1|type-2)",
SET_STR
"Type of metric for destination routing protocol\n"
- "OSPF external type 1 metric\n"
- "OSPF external type 2 metric\n")
+ "OSPF[6] external type 1 metric\n"
+ "OSPF[6] external type 2 metric\n")
{
if (strcmp (argv[0], "1") == 0)
return ospf_route_set_add (vty, vty->index, "metric-type", "type-1");
@@ -780,8 +786,8 @@ ALIAS (no_set_metric_type,
NO_STR
SET_STR
"Type of metric for destination routing protocol\n"
- "OSPF external type 1 metric\n"
- "OSPF external type 2 metric\n")
+ "OSPF[6] external type 1 metric\n"
+ "OSPF[6] external type 2 metric\n")
/* Route-map init */
void
diff --git a/ripd/rip_routemap.c b/ripd/rip_routemap.c
index 791de412..8262f508 100644
--- a/ripd/rip_routemap.c
+++ b/ripd/rip_routemap.c
@@ -628,11 +628,13 @@ ALIAS (no_match_interface,
DEFUN (match_ip_next_hop,
match_ip_next_hop_cmd,
- "match ip next-hop WORD",
+ "match ip next-hop (<1-199>|<1300-2699>|WORD)",
MATCH_STR
IP_STR
"Match next-hop address of route\n"
- "IP access-list name\n")
+ "IP access-list number\n"
+ "IP access-list number (expanded range)\n"
+ "IP Access-list name\n")
{
return rip_route_match_add (vty, vty->index, "ip next-hop", argv[0]);
}
@@ -653,12 +655,14 @@ DEFUN (no_match_ip_next_hop,
ALIAS (no_match_ip_next_hop,
no_match_ip_next_hop_val_cmd,
- "no match ip next-hop WORD",
+ "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 name\n")
+ "IP access-list number\n"
+ "IP access-list number (expanded range)\n"
+ "IP Access-list name\n")
DEFUN (match_ip_next_hop_prefix_list,
match_ip_next_hop_prefix_list_cmd,
@@ -697,13 +701,16 @@ ALIAS (no_match_ip_next_hop_prefix_list,
"Match entries of prefix-lists\n"
"IP prefix-list name\n")
-DEFUN (match_ip_address,
+DEFUN (match_ip_address,
match_ip_address_cmd,
- "match ip address WORD",
+ "match ip address (<1-199>|<1300-2699>|WORD)",
MATCH_STR
IP_STR
"Match address of route\n"
- "IP access-list name\n")
+ "IP access-list number\n"
+ "IP access-list number (expanded range)\n"
+ "IP Access-list name\n")
+
{
return rip_route_match_add (vty, vty->index, "ip address", argv[0]);
}
@@ -722,14 +729,16 @@ DEFUN (no_match_ip_address,
return rip_route_match_delete (vty, vty->index, "ip address", argv[0]);
}
-ALIAS (no_match_ip_address,
+ALIAS (no_match_ip_address,
no_match_ip_address_val_cmd,
- "no match ip address WORD",
+ "no match ip address (<1-199>|<1300-2699>|WORD)",
NO_STR
MATCH_STR
IP_STR
"Match address of route\n"
- "IP access-list name\n")
+ "IP access-list number\n"
+ "IP access-list number (expanded range)\n"
+ "IP Access-list name\n")
DEFUN (match_ip_address_prefix_list,
match_ip_address_prefix_list_cmd,
diff --git a/ripngd/ripng_routemap.c b/ripngd/ripng_routemap.c
index f237e6b6..832f17c9 100644
--- a/ripngd/ripng_routemap.c
+++ b/ripngd/ripng_routemap.c
@@ -158,7 +158,9 @@ route_set_metric_compile (char *arg)
if (metric == LONG_MAX || *endptr != '\0')
return NULL;
- if (metric < 0 || metric > RIPNG_METRIC_INFINITY)
+ /* Commented out by Hasso Tepper, to avoid problems in vtysh. */
+ /* if (metric < 0 || metric > RIPNG_METRIC_INFINITY) */
+ if (metric < 0)
return NULL;
mod = XMALLOC (MTYPE_ROUTE_MAP_COMPILED,
@@ -314,15 +316,25 @@ DEFUN (set_metric,
DEFUN (no_set_metric,
no_set_metric_cmd,
- "no set metric <0-4294967295>",
+ "no set metric",
NO_STR
- "Set value\n"
- "Metric\n"
- "METRIC value\n")
+ SET_STR
+ "Metric value for destination routing protocol\n")
{
+ if (argc == 0)
+ return ripng_route_set_delete (vty, vty->index, "metric", NULL);
+
return ripng_route_set_delete (vty, vty->index, "metric", argv[0]);
}
+ALIAS (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")
+
void
ripng_route_map_init ()
{
diff --git a/vtysh/extract.pl b/vtysh/extract.pl
index 5d29f8ab..91c817b4 100755
--- a/vtysh/extract.pl
+++ b/vtysh/extract.pl
@@ -85,7 +85,7 @@ foreach (@ARGV) {
$protocol = "VTYSH_RIPD";
}
if ($file =~ /routemap.c/) {
- $protocol = "VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD";
+ $protocol = "VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD";
}
if ($file =~ /filter.c/) {
if ($defun_array[1] =~ m/ipv6/) {
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index 78830055..a3b21c7b 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -1174,21 +1174,6 @@ DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD,
NO_STR
"Interface specific description\n")
-DEFSH (VTYSH_RIPD|VTYSH_BGPD,
- 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")
-
-DEFSH (VTYSH_RMAP,
- set_metric_cmd,
- "set metric <0-4294967295>",
- SET_STR
- "Metric value for destination routing protocol\n"
- "Metric value\n")
-
DEFUNSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD|VTYSH_OSPF6D,
vtysh_exit_interface,
vtysh_exit_interface_cmd,
@@ -1909,9 +1894,6 @@ vtysh_init_vty ()
install_element (ENABLE_NODE, &vtysh_start_bash_cmd);
install_element (ENABLE_NODE, &vtysh_start_zsh_cmd);
- install_element (RMAP_NODE, &set_metric_cmd);
- install_element (RMAP_NODE, &set_ip_nexthop_cmd);
-
install_element (CONFIG_NODE, &vtysh_log_stdout_cmd);
install_element (CONFIG_NODE, &no_vtysh_log_stdout_cmd);
install_element (CONFIG_NODE, &vtysh_log_file_cmd);
diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h
index 5527d0da..08184df9 100644
--- a/vtysh/vtysh.h
+++ b/vtysh/vtysh.h
@@ -29,7 +29,7 @@
#define VTYSH_OSPF6D 0x10
#define VTYSH_BGPD 0x20
#define VTYSH_ALL VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD
-#define VTYSH_RMAP VTYSH_RIPD|VTYSH_OSPFD|VTYSH_BGPD
+#define VTYSH_RMAP VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_BGPD
#define VTYSH_INDEX_ZEBRA 0
#define VTYSH_INDEX_RIP 1