diff --git a/interface-definitions/include/policy/local-route_rule_ipv4_address.xml.i b/interface-definitions/include/policy/ip-rule_rule_ipv4_address.xml.i
similarity index 100%
rename from interface-definitions/include/policy/local-route_rule_ipv4_address.xml.i
rename to interface-definitions/include/policy/ip-rule_rule_ipv4_address.xml.i
diff --git a/interface-definitions/include/policy/local-route_rule_ipv6_address.xml.i b/interface-definitions/include/policy/ip-rule_rule_ipv6_address.xml.i
similarity index 100%
rename from interface-definitions/include/policy/local-route_rule_ipv6_address.xml.i
rename to interface-definitions/include/policy/ip-rule_rule_ipv6_address.xml.i
diff --git a/interface-definitions/include/policy/local-route_rule_protocol.xml.i b/interface-definitions/include/policy/ip-rule_rule_protocol.xml.i
similarity index 100%
rename from interface-definitions/include/policy/local-route_rule_protocol.xml.i
rename to interface-definitions/include/policy/ip-rule_rule_protocol.xml.i
diff --git a/interface-definitions/include/version/policy-version.xml.i b/interface-definitions/include/version/policy-version.xml.i
index db727fea98..5c53a40321 100644
--- a/interface-definitions/include/version/policy-version.xml.i
+++ b/interface-definitions/include/version/policy-version.xml.i
@@ -1,3 +1,3 @@
-
+
diff --git a/interface-definitions/policy_local-route.xml.in b/interface-definitions/policy_ip-rule.xml.in
similarity index 86%
rename from interface-definitions/policy_local-route.xml.in
rename to interface-definitions/policy_ip-rule.xml.in
index 7a019154ac..babf4115c2 100644
--- a/interface-definitions/policy_local-route.xml.in
+++ b/interface-definitions/policy_ip-rule.xml.in
@@ -1,9 +1,9 @@
-
+
-
+
IPv4 policy route of local traffic
500
@@ -11,7 +11,7 @@
- Policy local-route rule set number
+ Policy ip-rule rule set number
u32:1-32765
@@ -53,13 +53,13 @@
- #include
+ #include
Source parameters
- #include
+ #include
#include
@@ -68,7 +68,7 @@
Destination parameters
- #include
+ #include
#include
@@ -77,7 +77,7 @@
-
+
IPv6 policy route of local traffic
500
@@ -85,7 +85,7 @@
- IPv6 policy local-route rule set number
+ IPv6 policy ip-rule rule set number
u32:1-32765
@@ -127,13 +127,13 @@
- #include
+ #include
Source parameters
- #include
+ #include
#include
@@ -142,7 +142,7 @@
Destination parameters
- #include
+ #include
#include
diff --git a/smoketest/scripts/cli/test_policy.py b/smoketest/scripts/cli/test_policy.py
index a0c6ab0550..bb4decf1b0 100755
--- a/smoketest/scripts/cli/test_policy.py
+++ b/smoketest/scripts/cli/test_policy.py
@@ -1488,7 +1488,7 @@ def test_route_map(self):
# Test set table for some sources
def test_table_id(self):
- path = base_path + ['local-route']
+ path = base_path + ['ip-rule']
sources = ['203.0.113.1', '203.0.113.2']
rule = '50'
@@ -1509,7 +1509,7 @@ def test_table_id(self):
# Test set table for fwmark
def test_fwmark_table_id(self):
- path = base_path + ['local-route']
+ path = base_path + ['ip-rule']
fwmk = '24'
rule = '101'
@@ -1529,7 +1529,7 @@ def test_fwmark_table_id(self):
# Test set table for destination
def test_destination_table_id(self):
- path = base_path + ['local-route']
+ path = base_path + ['ip-rule']
dst = '203.0.113.1'
rule = '102'
@@ -1549,7 +1549,7 @@ def test_destination_table_id(self):
# Test set table for destination and protocol
def test_protocol_destination_table_id(self):
- path = base_path + ['local-route']
+ path = base_path + ['ip-rule']
dst = '203.0.113.12'
rule = '85'
@@ -1571,7 +1571,7 @@ def test_protocol_destination_table_id(self):
# Test set table for destination, source, protocol, fwmark and port
def test_protocol_port_address_fwmark_table_id(self):
- path = base_path + ['local-route']
+ path = base_path + ['ip-rule']
dst = '203.0.113.5'
src_list = ['203.0.113.1', '203.0.113.2']
@@ -1621,7 +1621,7 @@ def test_protocol_port_address_fwmark_table_id(self):
# Test set table for sources with fwmark
def test_fwmark_sources_table_id(self):
- path = base_path + ['local-route']
+ path = base_path + ['ip-rule']
sources = ['203.0.113.11', '203.0.113.12']
fwmk = '23'
@@ -1644,7 +1644,7 @@ def test_fwmark_sources_table_id(self):
# Test set table for sources with iif
def test_iif_sources_table_id(self):
- path = base_path + ['local-route']
+ path = base_path + ['ip-rule']
sources = ['203.0.113.11', '203.0.113.12']
iif = 'lo'
@@ -1670,7 +1670,7 @@ def test_iif_sources_table_id(self):
# Test set table for sources and destinations with fwmark
def test_fwmark_sources_destination_table_id(self):
- path = base_path + ['local-route']
+ path = base_path + ['ip-rule']
sources = ['203.0.113.11', '203.0.113.12']
destinations = ['203.0.113.13', '203.0.113.15']
@@ -1698,7 +1698,7 @@ def test_fwmark_sources_destination_table_id(self):
# Test set table ipv6 for some sources ipv6
def test_ipv6_table_id(self):
- path = base_path + ['local-route6']
+ path = base_path + ['ip-rule6']
sources = ['2001:db8:123::/48', '2001:db8:126::/48']
rule = '50'
@@ -1719,7 +1719,7 @@ def test_ipv6_table_id(self):
# Test set table for fwmark ipv6
def test_fwmark_ipv6_table_id(self):
- path = base_path + ['local-route6']
+ path = base_path + ['ip-rule6']
fwmk = '24'
rule = '100'
@@ -1739,7 +1739,7 @@ def test_fwmark_ipv6_table_id(self):
# Test set table for destination ipv6
def test_destination_ipv6_table_id(self):
- path = base_path + ['local-route6']
+ path = base_path + ['ip-rule6']
dst = '2001:db8:1337::/126'
rule = '101'
@@ -1759,7 +1759,7 @@ def test_destination_ipv6_table_id(self):
# Test set table for sources with fwmark ipv6
def test_fwmark_sources_ipv6_table_id(self):
- path = base_path + ['local-route6']
+ path = base_path + ['ip-rule6']
sources = ['2001:db8:1338::/126', '2001:db8:1339::/126']
fwmk = '23'
@@ -1782,7 +1782,7 @@ def test_fwmark_sources_ipv6_table_id(self):
# Test set table for sources with iif ipv6
def test_iif_sources_ipv6_table_id(self):
- path = base_path + ['local-route6']
+ path = base_path + ['ip-rule6']
sources = ['2001:db8:1338::/126', '2001:db8:1339::/126']
iif = 'lo'
@@ -1807,7 +1807,7 @@ def test_iif_sources_ipv6_table_id(self):
# Test set table for sources and destinations with fwmark ipv6
def test_fwmark_sources_destination_ipv6_table_id(self):
- path = base_path + ['local-route6']
+ path = base_path + ['ip-rule6']
sources = ['2001:db8:1338::/126', '2001:db8:1339::/56']
destinations = ['2001:db8:13::/48', '2001:db8:16::/48']
@@ -1835,8 +1835,8 @@ def test_fwmark_sources_destination_ipv6_table_id(self):
# Test delete table for sources and destination with fwmark ipv4/ipv6
def test_delete_ipv4_ipv6_table_id(self):
- path = base_path + ['local-route']
- path_v6 = base_path + ['local-route6']
+ path = base_path + ['ip-rule']
+ path_v6 = base_path + ['ip-rule6']
sources = ['203.0.113.0/24', '203.0.114.5']
destinations = ['203.0.112.0/24', '203.0.116.5']
@@ -1891,7 +1891,7 @@ def test_delete_ipv4_ipv6_table_id(self):
# Test multiple commits ipv4
def test_multiple_commit_ipv4_table_id(self):
- path = base_path + ['local-route']
+ path = base_path + ['ip-rule']
sources = ['192.0.2.1', '192.0.2.2']
destination = '203.0.113.25'
diff --git a/src/conf_mode/policy_local-route.py b/src/conf_mode/policy_ip-rule.py
similarity index 96%
rename from src/conf_mode/policy_local-route.py
rename to src/conf_mode/policy_ip-rule.py
index f458f4e829..6363dbc773 100755
--- a/src/conf_mode/policy_local-route.py
+++ b/src/conf_mode/policy_ip-rule.py
@@ -37,12 +37,12 @@ def get_config(config=None):
pbr = conf.get_config_dict(base, key_mangling=('-', '_'), get_first_key=True)
- for route in ['local_route', 'local_route6']:
- dict_id = 'rule_remove' if route == 'local_route' else 'rule6_remove'
- route_key = 'local-route' if route == 'local_route' else 'local-route6'
+ for route in ['ip_rule', 'ip_rule6']:
+ dict_id = 'rule_remove' if route == 'ip_rule' else 'rule6_remove'
+ route_key = 'ip-rule' if route == 'ip_rule' else 'ip-rule6'
base_rule = base + [route_key, 'rule']
- # delete policy local-route
+ # delete policy ip-rule
dict = {}
tmp = node_changed(conf, base_rule, key_mangling=('-', '_'))
if tmp:
@@ -78,9 +78,9 @@ def get_config(config=None):
if not route in pbr:
continue
- # delete policy local-route rule x source x.x.x.x
- # delete policy local-route rule x fwmark x
- # delete policy local-route rule x destination x.x.x.x
+ # delete policy ip-rule rule x source x.x.x.x
+ # delete policy ip-rule rule x fwmark x
+ # delete policy ip-rule rule x destination x.x.x.x
if 'rule' in pbr[route]:
for rule, rule_config in pbr[route]['rule'].items():
src = leaf_node_changed(conf, base_rule + [rule, 'source', 'address'])
@@ -202,7 +202,7 @@ def verify(pbr):
if not pbr:
return None
- for route in ['local_route', 'local_route6']:
+ for route in ['ip_rule', 'ip_rule6']:
if not route in pbr:
continue
@@ -267,11 +267,11 @@ def apply(pbr):
call(f'ip{v6} rule del prio {rule} {f_src}{f_dst}{f_proto}{f_src_port}{f_dst_port}{f_fwmk}{f_iif}{f_table}')
# Generate new config
- for route in ['local_route', 'local_route6']:
+ for route in ['ip_rule', 'ip_rule6']:
if not route in pbr:
continue
- v6 = " -6" if route == 'local_route6' else ""
+ v6 = " -6" if route == 'ip_rule6' else ""
pbr_route = pbr[route]
if 'rule' in pbr_route:
diff --git a/src/migration-scripts/policy/8-to-9 b/src/migration-scripts/policy/8-to-9
new file mode 100644
index 0000000000..378f757a19
--- /dev/null
+++ b/src/migration-scripts/policy/8-to-9
@@ -0,0 +1,38 @@
+# Copyright 2022-2024 VyOS maintainers and contributors
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library. If not, see .
+
+# T5654: Migrate to
+# T5654: Migrate to
+
+from vyos.configtree import ConfigTree
+
+base = ['policy']
+
+def migrate(config: ConfigTree) -> None:
+ if not config.exists(base):
+ # Nothing to do
+ return
+
+ if config.exists(base + ['local-route']):
+ config.set(base + ['ip-rule'])
+ for rule in config.list_nodes(base + ['local-route']):
+ config.copy(base + ['local-route', rule], base + ['ip-rule', rule])
+ config.delete(base + ['local-route'])
+
+ if config.exists(base + ['local-route6']):
+ config.set(base + ['ip-rule6'])
+ for rule in config.list_nodes(base + ['local-route6']):
+ config.copy(base + ['local-route6', rule], base + ['ip-rule6', rule])
+ config.delete(base + ['local-route6'])