]> git.puffer.fish Git - matthieu/frr.git/commitdiff
Hasso Tepper
authorpaul <paul>
Sat, 19 Apr 2003 15:49:49 +0000 (15:49 +0000)
committerpaul <paul>
Sat, 19 Apr 2003 15:49:49 +0000 (15:49 +0000)
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.

bgpd/bgp_routemap.c
ospf6d/ospf6_routemap.c
ospfd/ospf_routemap.c
ripd/rip_routemap.c
ripngd/ripng_routemap.c
vtysh/extract.pl
vtysh/vtysh.c
vtysh/vtysh.h

index 498a600552819011993430238fd4a84a4fa65b04..5cfb5c8c744e7406d008854c7bd28a3e8a2f102f 100644 (file)
@@ -518,6 +518,52 @@ struct route_map_rule_cmd route_match_community_cmd =
   route_match_community_free
 };
 \f
+/* 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
+};
+\f
 /* `match nlri` and `set nlri` are replaced by `address-family ipv4`
    and `address-family vpnv4'.  */
 \f
@@ -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);
index 14df7940cba40b80c0069b0ad7357542d8163c01..f617e9133b7ba740a796abc6aac3b024cfbe370e 100644 (file)
@@ -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);
index a2b257facdc6bfeffd9cc21720478d6576d2ed27..64822d618bd72b0f34421ff1750e8617694eaa5c 100644 (file)
 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
index 791de412a37b2b059220cf8b635b1b6f08a3585b..8262f5082b188df85bf54549b79f755e5fb5cf4b 100644 (file)
@@ -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,
index f237e6b6b693175028d5ff6e3322f87a25617202..832f17c9515b86b102a8a03e7acd27452184f369 100644 (file)
@@ -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 ()
 {
index 5d29f8abf6c3455e2e502bc825d24a3bf2d6323e..91c817b4225aa24d0d88d2f2b012a773171d5851 100755 (executable)
@@ -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/) {
index 78830055b58a08c7e2b6d1c007512d25d4d1274c..a3b21c7bf32b043c7c384eaae9aec6085f359400 100644 (file)
@@ -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);
index 5527d0da8b5bf4156880d6294bf6a00358cf6514..08184df97136732e01a377da0c7d463ea412eb14 100644 (file)
@@ -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