]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Add `set as-path replace <any|ASN>` cmd for route-maps 11086/head
authorDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 25 Apr 2022 07:34:36 +0000 (10:34 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Mon, 25 Apr 2022 11:05:22 +0000 (14:05 +0300)
```
route-map tstas permit 10
 set as-path replace 1
exit
```

Before:

```
donatas-laptop(config-router-af)# do show ip bgp 10.10.10.10/32
BGP routing table entry for 10.10.10.10/32, version 13
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  192.168.10.65
  65000 1 2 3 123
    192.168.10.65 from 192.168.10.65 (10.10.10.11)
      Origin IGP, metric 0, valid, external, best (First path received)
      Last update: Mon Apr 25 10:39:50 2022
```

After:

```
donatas-laptop(config-router-af)# do show ip bgp 10.10.10.10/32
BGP routing table entry for 10.10.10.10/32, version 15
Paths: (1 available, best #1, table default)
  Advertised to non peer-group peers:
  192.168.10.65
  65000 65010 2 3 123
    192.168.10.65 from 192.168.10.65 (10.10.10.11)
      Origin IGP, metric 0, valid, external, best (First path received)
      Last update: Mon Apr 25 10:40:16 2022
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 files changed:
bgpd/bgp_aspath.c
bgpd/bgp_aspath.h
bgpd/bgp_routemap.c
bgpd/bgp_routemap_nb.c
bgpd/bgp_routemap_nb.h
bgpd/bgp_routemap_nb_config.c
doc/user/bgp.rst
lib/routemap.h
lib/routemap_cli.c
tests/topotests/bgp_set_aspath_replace/__init__.py [new file with mode: 0644]
tests/topotests/bgp_set_aspath_replace/r1/bgpd.conf [new file with mode: 0644]
tests/topotests/bgp_set_aspath_replace/r1/zebra.conf [new file with mode: 0644]
tests/topotests/bgp_set_aspath_replace/r2/bgpd.conf [new file with mode: 0644]
tests/topotests/bgp_set_aspath_replace/r2/zebra.conf [new file with mode: 0644]
tests/topotests/bgp_set_aspath_replace/r3/bgpd.conf [new file with mode: 0644]
tests/topotests/bgp_set_aspath_replace/r3/zebra.conf [new file with mode: 0644]
tests/topotests/bgp_set_aspath_replace/test_bgp_set_aspath_replace.py [new file with mode: 0644]
yang/frr-bgp-route-map.yang

index fd644ebf0a6db9556b7dbfaba65471f6e5f6bd53..880e15fadbd3394d2bdc0f0c01826fc4f7361c17 100644 (file)
@@ -1258,6 +1258,28 @@ struct aspath *aspath_replace_specific_asn(struct aspath *aspath,
        return new;
 }
 
+/* Replace all ASNs with our own ASN */
+struct aspath *aspath_replace_all_asn(struct aspath *aspath, as_t our_asn)
+{
+       struct aspath *new;
+       struct assegment *seg;
+
+       new = aspath_dup(aspath);
+       seg = new->segments;
+
+       while (seg) {
+               int i;
+
+               for (i = 0; i < seg->length; i++)
+                       seg->as[i] = our_asn;
+
+               seg = seg->next;
+       }
+
+       aspath_str_update(new, false);
+       return new;
+}
+
 /* Replace all private ASNs with our own ASN */
 struct aspath *aspath_replace_private_asns(struct aspath *aspath, as_t asn,
                                           as_t peer_asn)
index 4b1681816795868c32c2ccf3923de6001d2be10a..912db7b254aa411cfaebe79c975466b08b070c7b 100644 (file)
@@ -112,6 +112,8 @@ extern bool aspath_single_asn_check(struct aspath *, as_t asn);
 extern struct aspath *aspath_replace_specific_asn(struct aspath *aspath,
                                                  as_t target_asn,
                                                  as_t our_asn);
+extern struct aspath *aspath_replace_all_asn(struct aspath *aspath,
+                                            as_t our_asn);
 extern struct aspath *aspath_replace_private_asns(struct aspath *aspath,
                                                  as_t asn, as_t peer_asn);
 extern struct aspath *aspath_remove_private_asns(struct aspath *aspath,
index 6c303a9e5fbc5863f8f785bb329d224d24b5039a..20ee2e4d492ca34106869714d7492a0e6e2236fa 100644 (file)
@@ -2174,6 +2174,57 @@ static const struct route_map_rule_cmd route_set_aspath_exclude_cmd = {
        route_aspath_free,
 };
 
+/* `set as-path replace AS-PATH` */
+static void *route_aspath_replace_compile(const char *arg)
+{
+       return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
+}
+
+static void route_aspath_replace_free(void *rule)
+{
+       XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
+}
+
+static enum route_map_cmd_result_t
+route_set_aspath_replace(void *rule, const struct prefix *dummy, void *object)
+{
+       struct aspath *aspath_new;
+       const char *replace = rule;
+       struct bgp_path_info *path = object;
+       as_t own_asn = path->peer->change_local_as ? path->peer->change_local_as
+                                                  : path->peer->local_as;
+
+       if (path->peer->sort != BGP_PEER_EBGP) {
+               zlog_warn(
+                       "`set as-path replace` is supported only for EBGP peers");
+               return RMAP_NOOP;
+       }
+
+       if (path->attr->aspath->refcnt)
+               aspath_new = aspath_dup(path->attr->aspath);
+       else
+               aspath_new = path->attr->aspath;
+
+       if (strmatch(replace, "any")) {
+               path->attr->aspath =
+                       aspath_replace_all_asn(aspath_new, own_asn);
+       } else {
+               as_t replace_asn = strtoul(replace, NULL, 10);
+
+               path->attr->aspath = aspath_replace_specific_asn(
+                       aspath_new, replace_asn, own_asn);
+       }
+
+       return RMAP_OKAY;
+}
+
+static const struct route_map_rule_cmd route_set_aspath_replace_cmd = {
+       "as-path replace",
+       route_set_aspath_replace,
+       route_aspath_replace_compile,
+       route_aspath_replace_free,
+};
+
 /* `set community COMMUNITY' */
 struct rmap_com_set {
        struct community *com;
@@ -5389,6 +5440,43 @@ DEFUN_YANG (set_aspath_prepend_lastas,
        return nb_cli_apply_changes(vty, NULL);
 }
 
+DEFPY_YANG (set_aspath_replace_asn,
+           set_aspath_replace_asn_cmd,
+           "set as-path replace <any|(1-4294967295)>$replace",
+           SET_STR
+           "Transform BGP AS_PATH attribute\n"
+           "Replace AS number to local AS number\n"
+           "Replace any AS number to local AS number\n"
+           "Replace a specific AS number to local AS number\n")
+{
+       const char *xpath =
+               "./set-action[action='frr-bgp-route-map:as-path-replace']";
+       char xpath_value[XPATH_MAXLEN];
+
+       nb_cli_enqueue_change(vty, xpath, NB_OP_CREATE, NULL);
+       snprintf(xpath_value, sizeof(xpath_value),
+                "%s/rmap-set-action/frr-bgp-route-map:replace-as-path", xpath);
+       nb_cli_enqueue_change(vty, xpath_value, NB_OP_MODIFY, replace);
+       return nb_cli_apply_changes(vty, NULL);
+}
+
+DEFPY_YANG (no_set_aspath_replace_asn,
+           no_set_aspath_replace_asn_cmd,
+           "no set as-path replace [<any|(1-4294967295)>]",
+           NO_STR
+           SET_STR
+           "Transform BGP AS_PATH attribute\n"
+           "Replace AS number to local AS number\n"
+           "Replace any AS number to local AS number\n"
+           "Replace a specific AS number to local AS number\n")
+{
+       const char *xpath =
+               "./set-action[action='frr-bgp-route-map:as-path-replace']";
+
+       nb_cli_enqueue_change(vty, xpath, NB_OP_DESTROY, NULL);
+       return nb_cli_apply_changes(vty, NULL);
+}
+
 DEFUN_YANG (no_set_aspath_prepend,
            no_set_aspath_prepend_cmd,
            "no set as-path prepend [(1-4294967295)]",
@@ -6727,6 +6815,7 @@ void bgp_route_map_init(void)
        route_map_install_set(&route_set_distance_cmd);
        route_map_install_set(&route_set_aspath_prepend_cmd);
        route_map_install_set(&route_set_aspath_exclude_cmd);
+       route_map_install_set(&route_set_aspath_replace_cmd);
        route_map_install_set(&route_set_origin_cmd);
        route_map_install_set(&route_set_atomic_aggregate_cmd);
        route_map_install_set(&route_set_aggregator_as_cmd);
@@ -6800,10 +6889,12 @@ void bgp_route_map_init(void)
        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);
+       install_element(RMAP_NODE, &set_aspath_replace_asn_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, &no_set_aspath_replace_asn_cmd);
        install_element(RMAP_NODE, &set_origin_cmd);
        install_element(RMAP_NODE, &no_set_origin_cmd);
        install_element(RMAP_NODE, &set_atomic_aggregate_cmd);
index caf1553ec135e68537beafecf71d325105b7eb03..585596e1aafa41cb5bc3fa43a9156d1876e7b7c1 100644 (file)
@@ -296,6 +296,13 @@ const struct frr_yang_module_info frr_bgp_route_map_info = {
                                .destroy = lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_destroy,
                        }
                },
+               {
+                       .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:replace-as-path",
+                       .cbs = {
+                               .modify = lib_route_map_entry_set_action_rmap_set_action_replace_as_path_modify,
+                               .destroy = lib_route_map_entry_set_action_rmap_set_action_replace_as_path_destroy,
+                       }
+               },
                {
                        .xpath = "/frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-none",
                        .cbs = {
index e0b3a6926f77e2ab74bebc4d1fbe509f6097cf7d..a01adf7d5dcff3f839f707c44536500a4a16ed12 100644 (file)
@@ -108,6 +108,10 @@ int lib_route_map_entry_set_action_rmap_set_action_last_as_modify(struct nb_cb_m
 int lib_route_map_entry_set_action_rmap_set_action_last_as_destroy(struct nb_cb_destroy_args *args);
 int lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_modify(struct nb_cb_modify_args *args);
 int lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_destroy(struct nb_cb_destroy_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_replace_as_path_modify(
+       struct nb_cb_modify_args *args);
+int lib_route_map_entry_set_action_rmap_set_action_replace_as_path_destroy(
+       struct nb_cb_destroy_args *args);
 int lib_route_map_entry_set_action_rmap_set_action_community_none_modify(struct nb_cb_modify_args *args);
 int lib_route_map_entry_set_action_rmap_set_action_community_none_destroy(struct nb_cb_destroy_args *args);
 int lib_route_map_entry_set_action_rmap_set_action_community_string_modify(struct nb_cb_modify_args *args);
index 773538ee41dd354291e6b4bbba95004f2afa3387..b87877b1e08196d32131dce98d253a1a41555e21 100644 (file)
@@ -2207,6 +2207,58 @@ lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_destroy(
        return NB_OK;
 }
 
+/*
+ * XPath:
+ * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:replace-as-path
+ */
+int lib_route_map_entry_set_action_rmap_set_action_replace_as_path_modify(
+       struct nb_cb_modify_args *args)
+{
+       struct routemap_hook_context *rhc;
+       const char *type;
+       int rv;
+
+       switch (args->event) {
+       case NB_EV_VALIDATE:
+       case NB_EV_PREPARE:
+       case NB_EV_ABORT:
+               break;
+       case NB_EV_APPLY:
+               /* Add configuration. */
+               rhc = nb_running_get_entry(args->dnode, NULL, true);
+               type = yang_dnode_get_string(args->dnode, NULL);
+
+               /* Set destroy information. */
+               rhc->rhc_shook = generic_set_delete;
+               rhc->rhc_rule = "as-path replace";
+               rhc->rhc_event = RMAP_EVENT_SET_DELETED;
+
+               rv = generic_set_add(rhc->rhc_rmi, "as-path replace", type,
+                                    args->errmsg, args->errmsg_len);
+               if (rv != CMD_SUCCESS) {
+                       rhc->rhc_shook = NULL;
+                       return NB_ERR_INCONSISTENCY;
+               }
+       }
+
+       return NB_OK;
+}
+
+int lib_route_map_entry_set_action_rmap_set_action_replace_as_path_destroy(
+       struct nb_cb_destroy_args *args)
+{
+       switch (args->event) {
+       case NB_EV_VALIDATE:
+       case NB_EV_PREPARE:
+       case NB_EV_ABORT:
+               break;
+       case NB_EV_APPLY:
+               return lib_route_map_entry_set_destroy(args);
+       }
+
+       return NB_OK;
+}
+
 /*
  * XPath:
  * /frr-route-map:lib/route-map/entry/set-action/rmap-set-action/frr-bgp-route-map:community-none
index e7adad91b7646db5e82683b89007262bca613401..6f99b41140412efa5939723881dcdd263d71b9f9 100644 (file)
@@ -1983,6 +1983,11 @@ Using AS Path in Route Map
    Prepend the existing last AS number (the leftmost ASN) to the AS_PATH.
    The no form of this command removes this set operation from the route-map.
 
+.. clicmd:: set as-path replace <any|ASN>
+
+   Replace a specific AS number to local AS number. ``any`` replaces each
+   AS number in the AS-PATH with the local AS number.
+
 .. _bgp-communities-attribute:
 
 Communities Attribute
index 3ef60222bfeb983f94024743b3e9ebdde7ba4e77..13dafe6849edb6d1b645b65a1ed2b6c69ed7ea13 100644 (file)
@@ -370,6 +370,7 @@ DECLARE_QOBJ_TYPE(route_map);
        (strmatch(A, "frr-bgp-route-map:as-path-prepend"))
 #define IS_SET_AS_EXCLUDE(A)                                                   \
        (strmatch(A, "frr-bgp-route-map:as-path-exclude"))
+#define IS_SET_AS_REPLACE(A) (strmatch(A, "frr-bgp-route-map:as-path-replace"))
 #define IS_SET_IPV6_NH_GLOBAL(A)                                               \
        (strmatch(A, "frr-bgp-route-map:ipv6-nexthop-global"))
 #define IS_SET_IPV6_VPN_NH(A)                                                  \
index 315007be1c544ad6f7f5398a22ccf31194bce5bc..ff98a14c4122f3fba2aa33a8bd339ef30dd6166d 100644 (file)
@@ -1197,6 +1197,11 @@ void route_map_action_show(struct vty *vty, const struct lyd_node *dnode,
                        yang_dnode_get_string(
                                dnode,
                                "./rmap-set-action/frr-bgp-route-map:exclude-as-path"));
+       } else if (IS_SET_AS_REPLACE(action)) {
+               vty_out(vty, " set as-path replace %s\n",
+                       yang_dnode_get_string(
+                               dnode,
+                               "./rmap-set-action/frr-bgp-route-map:replace-as-path"));
        } else if (IS_SET_AS_PREPEND(action)) {
                if (yang_dnode_exists(
                            dnode,
diff --git a/tests/topotests/bgp_set_aspath_replace/__init__.py b/tests/topotests/bgp_set_aspath_replace/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/topotests/bgp_set_aspath_replace/r1/bgpd.conf b/tests/topotests/bgp_set_aspath_replace/r1/bgpd.conf
new file mode 100644 (file)
index 0000000..1e98f4e
--- /dev/null
@@ -0,0 +1,17 @@
+!
+router bgp 65001
+ no bgp ebgp-requires-policy
+ neighbor 192.168.1.2 remote-as external
+ neighbor 192.168.1.2 timers 3 10
+ address-family ipv4 unicast
+  neighbor 192.168.1.2 route-map r2 in
+ exit-address-family
+!
+ip prefix-list p1 seq 5 permit 172.16.255.31/32
+!
+route-map r2 permit 10
+ match ip address prefix-list p1
+ set as-path replace 65003
+route-map r2 permit 20
+ set as-path replace any
+!
diff --git a/tests/topotests/bgp_set_aspath_replace/r1/zebra.conf b/tests/topotests/bgp_set_aspath_replace/r1/zebra.conf
new file mode 100644 (file)
index 0000000..acf120b
--- /dev/null
@@ -0,0 +1,6 @@
+!
+interface r1-eth0
+ ip address 192.168.1.1/24
+!
+ip forwarding
+!
diff --git a/tests/topotests/bgp_set_aspath_replace/r2/bgpd.conf b/tests/topotests/bgp_set_aspath_replace/r2/bgpd.conf
new file mode 100644 (file)
index 0000000..23367f9
--- /dev/null
@@ -0,0 +1,8 @@
+!
+router bgp 65002
+ no bgp ebgp-requires-policy
+ neighbor 192.168.1.1 remote-as external
+ neighbor 192.168.1.1 timers 3 10
+ neighbor 192.168.2.1 remote-as external
+ neighbor 192.168.2.1 timers 3 10
+!
diff --git a/tests/topotests/bgp_set_aspath_replace/r2/zebra.conf b/tests/topotests/bgp_set_aspath_replace/r2/zebra.conf
new file mode 100644 (file)
index 0000000..f229954
--- /dev/null
@@ -0,0 +1,9 @@
+!
+interface r2-eth0
+ ip address 192.168.1.2/24
+!
+interface r2-eth1
+ ip address 192.168.2.2/24
+!
+ip forwarding
+!
diff --git a/tests/topotests/bgp_set_aspath_replace/r3/bgpd.conf b/tests/topotests/bgp_set_aspath_replace/r3/bgpd.conf
new file mode 100644 (file)
index 0000000..b7a7ced
--- /dev/null
@@ -0,0 +1,9 @@
+!
+router bgp 65003
+ no bgp ebgp-requires-policy
+ neighbor 192.168.2.2 remote-as external
+ neighbor 192.168.2.2 timers 3 10
+ address-family ipv4 unicast
+  redistribute connected
+ exit-address-family
+!
diff --git a/tests/topotests/bgp_set_aspath_replace/r3/zebra.conf b/tests/topotests/bgp_set_aspath_replace/r3/zebra.conf
new file mode 100644 (file)
index 0000000..3fa6c64
--- /dev/null
@@ -0,0 +1,10 @@
+!
+int lo
+ ip address 172.16.255.31/32
+ ip address 172.16.255.32/32
+!
+interface r3-eth0
+ ip address 192.168.2.1/24
+!
+ip forwarding
+!
diff --git a/tests/topotests/bgp_set_aspath_replace/test_bgp_set_aspath_replace.py b/tests/topotests/bgp_set_aspath_replace/test_bgp_set_aspath_replace.py
new file mode 100644 (file)
index 0000000..d5549ae
--- /dev/null
@@ -0,0 +1,103 @@
+#!/usr/bin/env python
+
+#
+# test_bgp_set_aspath_replace.py
+#
+# Copyright (c) 2022 by
+# Donatas Abraitis <donatas.abraitis@gmail.com>
+#
+# Permission to use, copy, modify, and/or distribute this software
+# for any purpose with or without fee is hereby granted, provided
+# that the above copyright notice and this permission notice appear
+# in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
+# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+#
+
+"""
+Test if `set as-path replace` is working correctly for route-maps.
+"""
+
+import os
+import sys
+import json
+import pytest
+import functools
+
+CWD = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(CWD, "../"))
+
+# pylint: disable=C0413
+from lib import topotest
+from lib.topogen import Topogen, TopoRouter, get_topogen
+
+pytestmark = [pytest.mark.bgpd]
+
+
+def build_topo(tgen):
+    for routern in range(1, 5):
+        tgen.add_router("r{}".format(routern))
+
+    switch = tgen.add_switch("s1")
+    switch.add_link(tgen.gears["r1"])
+    switch.add_link(tgen.gears["r2"])
+
+    switch = tgen.add_switch("s2")
+    switch.add_link(tgen.gears["r2"])
+    switch.add_link(tgen.gears["r3"])
+
+
+def setup_module(mod):
+    tgen = Topogen(build_topo, mod.__name__)
+    tgen.start_topology()
+
+    router_list = tgen.routers()
+
+    for i, (rname, router) in enumerate(router_list.items(), 1):
+        router.load_config(
+            TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname))
+        )
+        router.load_config(
+            TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname))
+        )
+
+    tgen.start_router()
+
+
+def teardown_module(mod):
+    tgen = get_topogen()
+    tgen.stop_topology()
+
+
+def test_bgp_maximum_prefix_out():
+    tgen = get_topogen()
+
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    def _bgp_converge(router):
+        output = json.loads(router.vtysh_cmd("show bgp ipv4 unicast json"))
+        expected = {
+            "routes": {
+                "172.16.255.31/32": [{"path": "65002 65001"}],
+                "172.16.255.32/32": [{"path": "65001 65001"}],
+            }
+        }
+        return topotest.json_cmp(output, expected)
+
+    test_func = functools.partial(_bgp_converge, tgen.gears["r1"])
+    _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+
+    assert result is None, "Failed overriding incoming AS-PATH with route-map"
+
+
+if __name__ == "__main__":
+    args = ["-s"] + sys.argv[1:]
+    sys.exit(pytest.main(args))
index 74008bc0786670fb55d6db90f2352612246f7b6a..eaa7891f0c6b7647d7f5fb2c289d01f1222b8c65 100644 (file)
@@ -282,6 +282,12 @@ module frr-bgp-route-map {
       "Set the BGP AS-path attribute";
   }
 
+  identity as-path-replace {
+    base frr-route-map:rmap-set-type;
+    description
+      "Replace ASNs to local AS number";
+  }
+
   identity set-community {
     base frr-route-map:rmap-set-type;
     description
@@ -793,6 +799,15 @@ module frr-bgp-route-map {
       }
     }
 
+    case as-path-replace {
+      when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'frr-bgp-route-map:as-path-replace')";
+      leaf replace-as-path {
+        type string;
+        description
+          "Replace ASNs to local AS number";
+      }
+    }
+
     case community {
       when "derived-from-or-self(/frr-route-map:lib/frr-route-map:route-map/frr-route-map:entry/frr-route-map:set-action/frr-route-map:action, 'frr-bgp-route-map:set-community')";
       choice community {