summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--interface-definitions/include/bgp-update-source.xml.i2
-rw-r--r--interface-definitions/include/static-route-interface.xml.i (renamed from interface-definitions/include/static-route-next-hop-interface.xml.i)4
-rw-r--r--interface-definitions/include/static-route-vrf.xml.i (renamed from interface-definitions/include/static-route-next-hop-vrf.xml.i)2
-rw-r--r--interface-definitions/include/static-route.xml.i8
-rw-r--r--interface-definitions/include/static-route6.xml.i8
-rw-r--r--interface-definitions/protocols-bgp.xml.in2
-rw-r--r--interface-definitions/protocols-ospf.xml.in5
-rw-r--r--interface-definitions/protocols-ospfv3.xml.in2
-rwxr-xr-xsrc/validators/fqdn2
-rwxr-xr-xsrc/validators/interface-name27
10 files changed, 44 insertions, 18 deletions
diff --git a/interface-definitions/include/bgp-update-source.xml.i b/interface-definitions/include/bgp-update-source.xml.i
index c1db2e2c1..a8b212720 100644
--- a/interface-definitions/include/bgp-update-source.xml.i
+++ b/interface-definitions/include/bgp-update-source.xml.i
@@ -21,7 +21,7 @@
<constraint>
<validator name="ipv4-address"/>
<validator name="ipv6-address"/>
- <regex>^(br|bond|dum|en|eth|gnv|peth|tun|vti|vxlan|wg|wlan)[0-9]+|lo$</regex>
+ <validator name="interface-name"/>
</constraint>
</properties>
</leafNode>
diff --git a/interface-definitions/include/static-route-next-hop-interface.xml.i b/interface-definitions/include/static-route-interface.xml.i
index 01c253597..0f10837df 100644
--- a/interface-definitions/include/static-route-next-hop-interface.xml.i
+++ b/interface-definitions/include/static-route-interface.xml.i
@@ -1,4 +1,4 @@
-<!-- included start from static-route-next-hop-interface.xml.i -->
+<!-- included start from static-route-interface.xml.i -->
<leafNode name="interface">
<properties>
<help>Gateway interface name</help>
@@ -10,7 +10,7 @@
<description>Gateway interface name</description>
</valueHelp>
<constraint>
- <regex>^(br|bond|dum|en|eth|gnv|peth|tun|vti|vxlan|wg|wlan)[0-9]+|lo$</regex>
+ <validator name="interface-name"/>
</constraint>
</properties>
</leafNode>
diff --git a/interface-definitions/include/static-route-next-hop-vrf.xml.i b/interface-definitions/include/static-route-vrf.xml.i
index ae2515a12..70f8b0be8 100644
--- a/interface-definitions/include/static-route-next-hop-vrf.xml.i
+++ b/interface-definitions/include/static-route-vrf.xml.i
@@ -1,4 +1,4 @@
-<!-- included start from static-route-next-hop-vrf.xml.i -->
+<!-- included start from static-route-vrf.xml.i -->
<leafNode name="vrf">
<properties>
<help>VRF to leak route</help>
diff --git a/interface-definitions/include/static-route.xml.i b/interface-definitions/include/static-route.xml.i
index 1f79aaca8..6225025ca 100644
--- a/interface-definitions/include/static-route.xml.i
+++ b/interface-definitions/include/static-route.xml.i
@@ -42,13 +42,13 @@
<description>Gateway interface name</description>
</valueHelp>
<constraint>
- <regex>^(br|bond|dum|en|eth|gnv|peth|tun|vti|vxlan|wg|wlan)[0-9]+|lo$</regex>
+ <validator name="interface-name"/>
</constraint>
</properties>
<children>
#include <include/generic-disable-node.xml.i>
#include <include/static-route-distance.xml.i>
- #include <include/static-route-next-hop-vrf.xml.i>
+ #include <include/static-route-vrf.xml.i>
</children>
</tagNode>
<tagNode name="next-hop">
@@ -65,8 +65,8 @@
<children>
#include <include/generic-disable-node.xml.i>
#include <include/static-route-distance.xml.i>
- #include <include/static-route-next-hop-interface.xml.i>
- #include <include/static-route-next-hop-vrf.xml.i>
+ #include <include/static-route-interface.xml.i>
+ #include <include/static-route-vrf.xml.i>
</children>
</tagNode>
</children>
diff --git a/interface-definitions/include/static-route6.xml.i b/interface-definitions/include/static-route6.xml.i
index 1ff6bbead..25d4d22a2 100644
--- a/interface-definitions/include/static-route6.xml.i
+++ b/interface-definitions/include/static-route6.xml.i
@@ -42,13 +42,13 @@
<description>Gateway interface name</description>
</valueHelp>
<constraint>
- <regex>^(br|bond|dum|en|eth|gnv|peth|tun|vti|vxlan|wg|wlan)[0-9]+|lo$</regex>
+ <validator name="interface-name"/>
</constraint>
</properties>
<children>
#include <include/generic-disable-node.xml.i>
#include <include/static-route-distance.xml.i>
- #include <include/static-route-next-hop-vrf.xml.i>
+ #include <include/static-route-vrf.xml.i>
</children>
</tagNode>
<tagNode name="next-hop">
@@ -65,8 +65,8 @@
<children>
#include <include/generic-disable-node.xml.i>
#include <include/static-route-distance.xml.i>
- #include <include/static-route-next-hop-interface.xml.i>
- #include <include/static-route-next-hop-vrf.xml.i>
+ #include <include/static-route-interface.xml.i>
+ #include <include/static-route-vrf.xml.i>
</children>
</tagNode>
</children>
diff --git a/interface-definitions/protocols-bgp.xml.in b/interface-definitions/protocols-bgp.xml.in
index 3edacb0ca..e5122fe8d 100644
--- a/interface-definitions/protocols-bgp.xml.in
+++ b/interface-definitions/protocols-bgp.xml.in
@@ -307,7 +307,7 @@
<constraint>
<validator name="ipv4-address"/>
<validator name="ipv6-address"/>
- <regex>^(br|bond|dum|en|eth|gnv|peth|tun|vti|vxlan|wg|wlan)[0-9]+|lo$</regex>
+ <validator name="interface-name"/>
</constraint>
</properties>
<children>
diff --git a/interface-definitions/protocols-ospf.xml.in b/interface-definitions/protocols-ospf.xml.in
index 7a5cef6ef..ca848c289 100644
--- a/interface-definitions/protocols-ospf.xml.in
+++ b/interface-definitions/protocols-ospf.xml.in
@@ -697,7 +697,8 @@
<description>Default to suppress routing updates on all interfaces</description>
</valueHelp>
<constraint>
- <regex>^(br|bond|dum|en|eth|gnv|peth|tun|vti|vxlan|wg|wlan)[0-9]+|lo|default$</regex>
+ <regex>^(default)$</regex>
+ <validator name="interface-name"/>
</constraint>
<multi/>
</properties>
@@ -713,7 +714,7 @@
<description>Interface to be passive (i.e. suppress routing updates)</description>
</valueHelp>
<constraint>
- <regex>^(br|bond|dum|en|eth|gnv|peth|tun|vti|vxlan|wg|wlan)[0-9]+|lo$</regex>
+ <validator name="interface-name"/>
</constraint>
<multi/>
</properties>
diff --git a/interface-definitions/protocols-ospfv3.xml.in b/interface-definitions/protocols-ospfv3.xml.in
index 7f80f9f9d..bd6a55b45 100644
--- a/interface-definitions/protocols-ospfv3.xml.in
+++ b/interface-definitions/protocols-ospfv3.xml.in
@@ -52,7 +52,7 @@
<description>Interface used for routing information exchange</description>
</valueHelp>
<constraint>
- <regex>^(br|bond|dum|en|eth|gnv|peth|tun|vti|vxlan|wg|wlan)[0-9]+|lo$</regex>
+ <validator name="interface-name"/>
</constraint>
<multi/>
</properties>
diff --git a/src/validators/fqdn b/src/validators/fqdn
index 347ffda42..66276c093 100755
--- a/src/validators/fqdn
+++ b/src/validators/fqdn
@@ -17,11 +17,9 @@
import re
import sys
-
# pattern copied from: https://www.regextester.com/103452
pattern = "(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9]\.)+[a-zA-Z]{2,63}$)"
-
if __name__ == '__main__':
if len(sys.argv) != 2:
sys.exit(1)
diff --git a/src/validators/interface-name b/src/validators/interface-name
new file mode 100755
index 000000000..32cd42fbd
--- /dev/null
+++ b/src/validators/interface-name
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2021 VyOS maintainers and contributors
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 or later as
+# published by the Free Software Foundation.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import re
+import sys
+
+pattern = '^(br|bond|dum|en|eth|gnv|peth|pppoe|tun|vti|vtun|vxlan|wg|wlan)[0-9]+|lo$'
+
+if __name__ == '__main__':
+ if len(sys.argv) != 2:
+ sys.exit(1)
+ if not re.match(pattern, sys.argv[1]):
+ sys.exit(1)
+ sys.exit(0)