]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_routemap.c
*: Convert some route map functions to return the enum
[mirror_frr.git] / bgpd / bgp_routemap.c
index dd3382a1e7d0ffa3f2f3963c40645ebbd6dbedd2..545ca19762997fd1d2e1db2b507090a7f9eee891 100644 (file)
@@ -2091,12 +2091,19 @@ route_set_lcommunity_delete(void *rule, const struct prefix *pfx,
 static void *route_set_lcommunity_delete_compile(const char *arg)
 {
        struct rmap_community *rcom;
+       char **splits;
+       int num;
 
-       rcom = XCALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(struct rmap_community));
+       frrstr_split(arg, " ", &splits, &num);
 
-       rcom->name = XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
+       rcom = XCALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(struct rmap_community));
+       rcom->name = XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, splits[0]);
        rcom->name_hash = bgp_clist_hash_key(rcom->name);
 
+       for (int i = 0; i < num; i++)
+               XFREE(MTYPE_TMP, splits[i]);
+       XFREE(MTYPE_TMP, splits);
+
        return rcom;
 }
 
@@ -2174,12 +2181,19 @@ route_set_community_delete(void *rule, const struct prefix *prefix,
 static void *route_set_community_delete_compile(const char *arg)
 {
        struct rmap_community *rcom;
+       char **splits;
+       int num;
 
-       rcom = XCALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(struct rmap_community));
+       frrstr_split(arg, " ", &splits, &num);
 
-       rcom->name = XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
+       rcom = XCALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(struct rmap_community));
+       rcom->name = XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, splits[0]);
        rcom->name_hash = bgp_clist_hash_key(rcom->name);
 
+       for (int i = 0; i < num; i++)
+               XFREE(MTYPE_TMP, splits[i]);
+       XFREE(MTYPE_TMP, splits);
+
        return rcom;
 }
 
@@ -3043,7 +3057,7 @@ static int bgp_route_match_add(struct vty *vty, const char *command,
 {
        VTY_DECLVAR_CONTEXT(route_map_index, index);
        int retval = CMD_SUCCESS;
-       int ret;
+       enum rmap_compile_rets ret;
 
        ret = route_map_add_match(index, command, arg, type);
        switch (ret) {
@@ -3060,6 +3074,11 @@ static int bgp_route_match_add(struct vty *vty, const char *command,
                        route_map_upd8_dependency(type, arg, index->map->name);
                }
                break;
+       case RMAP_DUPLICATE_RULE:
+               /*
+                * Intentionally doing nothing here.
+                */
+               break;
        }
 
        return retval;
@@ -3070,7 +3089,7 @@ static int bgp_route_match_delete(struct vty *vty, const char *command,
                                  const char *arg, route_map_event_t type)
 {
        VTY_DECLVAR_CONTEXT(route_map_index, index);
-       int ret;
+       enum rmap_compile_rets ret;
        int retval = CMD_SUCCESS;
        char *dep_name = NULL;
        const char *tmpstr;
@@ -3103,6 +3122,11 @@ static int bgp_route_match_delete(struct vty *vty, const char *command,
                if (type != RMAP_EVENT_MATCH_DELETED && dep_name)
                        route_map_upd8_dependency(type, dep_name, rmap_name);
                break;
+       case RMAP_DUPLICATE_RULE:
+               /*
+                * Nothing to do here
+                */
+               break;
        }
 
        XFREE(MTYPE_ROUTE_MAP_RULE, dep_name);
@@ -3392,31 +3416,34 @@ int bgp_route_map_update_timer(struct thread *thread)
 
 static void bgp_route_map_mark_update(const char *rmap_name)
 {
-       if (bm->t_rmap_update == NULL) {
-               struct listnode *node, *nnode;
-               struct bgp *bgp;
-
-               /* rmap_update_timer of 0 means don't do route updates */
-               if (bm->rmap_update_timer) {
-                       bm->t_rmap_update = NULL;
-                       thread_add_timer(bm->master, bgp_route_map_update_timer,
-                                        NULL, bm->rmap_update_timer,
-                                        &bm->t_rmap_update);
-
-                       /* Signal the groups that a route-map update event has
-                        * started */
-                       for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp))
-                               update_group_policy_update(bgp,
-                                                          BGP_POLICY_ROUTE_MAP,
-                                                          rmap_name, 1, 1);
-               } else {
-                       for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp))
-                               bgp_route_map_process_update(bgp, rmap_name, 0);
+       struct listnode *node, *nnode;
+       struct bgp *bgp;
+
+       /* If new update is received before the current timer timed out,
+        * turn it off and start a new timer.
+        */
+       if (bm->t_rmap_update != NULL)
+               THREAD_OFF(bm->t_rmap_update);
+
+       /* rmap_update_timer of 0 means don't do route updates */
+       if (bm->rmap_update_timer) {
+               thread_add_timer(bm->master, bgp_route_map_update_timer,
+                                NULL, bm->rmap_update_timer,
+                                &bm->t_rmap_update);
+
+               /* Signal the groups that a route-map update event has
+                * started */
+               for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp))
+                       update_group_policy_update(bgp,
+                                                  BGP_POLICY_ROUTE_MAP,
+                                                  rmap_name, 1, 1);
+       } else {
+               for (ALL_LIST_ELEMENTS(bm->bgp, node, nnode, bgp))
+                       bgp_route_map_process_update(bgp, rmap_name, 0);
 #if ENABLE_BGP_VNC
-                       zlog_debug("%s: calling vnc_routemap_update", __func__);
-                       vnc_routemap_update(bgp, __func__);
+               zlog_debug("%s: calling vnc_routemap_update", __func__);
+               vnc_routemap_update(bgp, __func__);
 #endif
-               }
        }
 }
 
@@ -4141,6 +4168,18 @@ DEFUN (no_set_aspath_prepend,
        return ret;
 }
 
+DEFUN (no_set_aspath_prepend_lastas,
+       no_set_aspath_prepend_lastas_cmd,
+       "no set as-path prepend last-as [(1-10)]",
+       NO_STR
+       SET_STR
+       "Transform BGP AS_PATH attribute\n"
+       "Prepend to the as-path\n"
+       "Use the peers AS-number\n"
+       "Number of times to insert\n")
+{
+       return no_set_aspath_prepend(self, vty, argc, argv);
+}
 
 DEFUN (set_aspath_exclude,
        set_aspath_exclude_cmd,
@@ -5106,6 +5145,7 @@ void bgp_route_map_init(void)
        install_element(RMAP_NODE, &set_aspath_prepend_lastas_cmd);
        install_element(RMAP_NODE, &set_aspath_exclude_cmd);
        install_element(RMAP_NODE, &no_set_aspath_prepend_cmd);
+       install_element(RMAP_NODE, &no_set_aspath_prepend_lastas_cmd);
        install_element(RMAP_NODE, &no_set_aspath_exclude_cmd);
        install_element(RMAP_NODE, &no_set_aspath_exclude_all_cmd);
        install_element(RMAP_NODE, &set_origin_cmd);