Add the ability to specify the metric (relative priority) … (#1507)

This commit is contained in:
Volker Theile 2023-03-07 23:17:05 +01:00 committed by GitHub
parent c55342b4e9
commit 23d6dd4595
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 507 additions and 113 deletions

View File

@ -8,6 +8,9 @@ openmediavault (6.3.3-1) stable; urgency=low
via scheduled tasks, e.g. `images@daily_20230228T095758`.
Please delete your existing scheduled tasks and recreate
them to take advantage of the new naming scheme.
* Add the ability to specify the metric (relative priority)
of the default route set via the `Gateway` option in the
network interface page.
-- Volker Theile <volker.theile@openmediavault.org> Tue, 28 Feb 2023 00:08:49 +0100

View File

@ -28,11 +28,22 @@ network:
- {{ interface.address6 }}/{{ interface.netmask6 }}
{%- endif %}
{%- endif %}
{%- if (interface.method == "static" and interface.gateway | is_ipv4) or (interface.method6 == "static" and interface.gateway6 | is_ipv6) %}
routes:
{%- if interface.method == "static" and interface.gateway | is_ipv4 %}
gateway4: {{ interface.gateway }}
- to: 0.0.0.0/0
via: {{ interface.gateway }}
{%- if interface.routemetric > 0 %}
metric: {{ interface.routemetric }}
{%- endif %}
{%- endif %}
{%- if interface.method6 == "static" and interface.gateway6 | is_ipv6 %}
gateway6: {{ interface.gateway6 }}
- to: ::/0
via: {{ interface.gateway6 }}
{%- if interface.routemetric6 != 1 %}
metric: {{ interface.routemetric6 }}
{%- endif %}
{%- endif %}
{%- endif %}
{%- if interface.method6 in ["auto", "dhcp"] %}
accept-ra: true

View File

@ -28,11 +28,22 @@ network:
- {{ interface.address6 }}/{{ interface.netmask6 }}
{%- endif %}
{%- endif %}
{%- if (interface.method == "static" and interface.gateway | is_ipv4) or (interface.method6 == "static" and interface.gateway6 | is_ipv6) %}
routes:
{%- if interface.method == "static" and interface.gateway | is_ipv4 %}
gateway4: {{ interface.gateway }}
- to: 0.0.0.0/0
via: {{ interface.gateway }}
{%- if interface.routemetric > 0 %}
metric: {{ interface.routemetric }}
{%- endif %}
{%- endif %}
{%- if interface.method6 == "static" and interface.gateway6 | is_ipv6 %}
gateway6: {{ interface.gateway6 }}
- to: ::/0
via: {{ interface.gateway6 }}
{%- if interface.routemetric6 != 1 %}
metric: {{ interface.routemetric6 }}
{%- endif %}
{%- endif %}
{%- endif %}
{%- if interface.method6 in ["auto", "dhcp"] %}
accept-ra: true

View File

@ -14,11 +14,22 @@ network:
- {{ interface.address6 }}/{{ interface.netmask6 }}
{%- endif %}
{%- endif %}
{%- if (interface.method == "static" and interface.gateway | is_ipv4) or (interface.method6 == "static" and interface.gateway6 | is_ipv6) %}
routes:
{%- if interface.method == "static" and interface.gateway | is_ipv4 %}
gateway4: {{ interface.gateway }}
- to: 0.0.0.0/0
via: {{ interface.gateway }}
{%- if interface.routemetric > 0 %}
metric: {{ interface.routemetric }}
{%- endif %}
{%- endif %}
{%- if interface.method6 == "static" and interface.gateway6 | is_ipv6 %}
gateway6: {{ interface.gateway6 }}
- to: ::/0
via: {{ interface.gateway6 }}
{%- if interface.routemetric6 != 1 %}
metric: {{ interface.routemetric6 }}
{%- endif %}
{%- endif %}
{%- endif %}
{%- if interface.method6 in ["auto", "dhcp"] %}
accept-ra: true

View File

@ -11,11 +11,22 @@ network:
- {{ interface.address6 }}/{{ interface.netmask6 }}
{%- endif %}
{%- endif %}
{%- if (interface.method == "static" and interface.gateway | is_ipv4) or (interface.method6 == "static" and interface.gateway6 | is_ipv6) %}
routes:
{%- if interface.method == "static" and interface.gateway | is_ipv4 %}
gateway4: {{ interface.gateway }}
- to: 0.0.0.0/0
via: {{ interface.gateway }}
{%- if interface.routemetric > 0 %}
metric: {{ interface.routemetric }}
{%- endif %}
{%- endif %}
{%- if interface.method6 == "static" and interface.gateway6 | is_ipv6 %}
gateway6: {{ interface.gateway6 }}
- to: ::/0
via: {{ interface.gateway6 }}
{%- if interface.routemetric6 != 1 %}
metric: {{ interface.routemetric6 }}
{%- endif %}
{%- endif %}
{%- endif %}
{%- if interface.method6 in ["auto", "dhcp"] %}
accept-ra: true

View File

@ -11,11 +11,22 @@ network:
- {{ interface.address6 }}/{{ interface.netmask6 }}
{%- endif %}
{%- endif %}
{%- if (interface.method == "static" and interface.gateway | is_ipv4) or (interface.method6 == "static" and interface.gateway6 | is_ipv6) %}
routes:
{%- if interface.method == "static" and interface.gateway | is_ipv4 %}
gateway4: {{ interface.gateway }}
- to: 0.0.0.0/0
via: {{ interface.gateway }}
{%- if interface.routemetric > 0 %}
metric: {{ interface.routemetric }}
{%- endif %}
{%- endif %}
{%- if interface.method6 == "static" and interface.gateway6 | is_ipv6 %}
gateway6: {{ interface.gateway6 }}
- to: ::/0
via: {{ interface.gateway6 }}
{%- if interface.routemetric6 != 1 %}
metric: {{ interface.routemetric6 }}
{%- endif %}
{%- endif %}
{%- endif %}
{%- if interface.method6 in ["auto", "dhcp"] %}
accept-ra: true

View File

@ -0,0 +1,29 @@
#!/bin/sh
#
# This file is part of OpenMediaVault.
#
# @license http://www.gnu.org/licenses/gpl.html GPL Version 3
# @author Volker Theile <volker.theile@openmediavault.org>
# @copyright Copyright (c) 2009-2023 Volker Theile
#
# OpenMediaVault is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# OpenMediaVault 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 OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.
set -e
. /usr/share/openmediavault/scripts/helper-functions
omv_config_add_key "/config/system/network/interfaces/interface" "routemetric" "0"
omv_config_add_key "/config/system/network/interfaces/interface" "routemetric6" "1"
exit 0

View File

@ -66,12 +66,12 @@ grep -iP "^\s*iface\s+(eth[0-9]+|en[a-z0-9]+)\s+(inet|inet6)\s+(static|dhcp)" ${
fi
jq --null-input --compact-output "{uuid: \"${OMV_CONFIGOBJECT_NEW_UUID}\", \
devicename: \"${devname}\", type: \"ethernet\", method6: \"manual\", \
address6: \"\", netmask6: 64, gateway6: \"\", \
address6: \"\", netmask6: 64, gateway6: \"\", routemetric6: 1, \
dnsnameservers: \"${dnsnameservers}\", dnssearch: \"\", \
wol: false, mtu: 0, \
comment: \"\", method: \"${method}\", \
address: \"${address}\", netmask: \"${netmask}\", \
gateway: \"${gateway}\"}" |
gateway: \"${gateway}\", routemetric: 0}" |
omv-confdbadm update "conf.system.network.interface" -
fi
done

View File

@ -35,6 +35,12 @@
"gateway": {
"type": "string"
},
"routemetric": {
"type": "integer",
"minimum": 0,
"maximum": 65535,
"default": 0
},
"method6": {
"type": "string",
"enum": [ "auto", "dhcp", "static", "manual" ],
@ -52,6 +58,12 @@
"gateway6": {
"type": "string"
},
"routemetric6": {
"type": "integer",
"minimum": 0,
"maximum": 65535,
"default": 1
},
"dnsnameservers": {
"type": "string",
"pattern": "^((\\S+\\s+)*\\S+)?$"

View File

@ -30,6 +30,12 @@
"type": "string",
"required": true
},
"routemetric": {
"type": "integer",
"minimum": 0,
"maximum": 65535,
"required": true
},
"method6": {
"type": "string",
"enum": [ "auto", "static", "manual", "dhcp" ],
@ -49,6 +55,12 @@
"type": "string",
"required": true
},
"routemetric6": {
"type": "integer",
"minimum": 0,
"maximum": 65535,
"required": true
},
"dnsnameservers": {
"type": "string",
"pattern": "^((\\S+[,;])*\\S+)?$",
@ -107,6 +119,12 @@
"type": "string",
"required": true
},
"routemetric": {
"type": "integer",
"minimum": 0,
"maximum": 65535,
"required": true
},
"method6": {
"type": "string",
"enum": [ "auto", "static", "manual", "dhcp" ],
@ -126,6 +144,12 @@
"type": "string",
"required": true
},
"routemetric6": {
"type": "integer",
"minimum": 0,
"maximum": 65535,
"required": true
},
"dnsnameservers": {
"type": "string",
"pattern": "^((\\S+[,;])*\\S+)?$",
@ -216,6 +240,12 @@
"type": "string",
"required": true
},
"routemetric": {
"type": "integer",
"minimum": 0,
"maximum": 65535,
"required": true
},
"method6": {
"type": "string",
"enum": [ "auto", "static", "manual", "dhcp" ],
@ -235,6 +265,12 @@
"type": "string",
"required": true
},
"routemetric6": {
"type": "integer",
"minimum": 0,
"maximum": 65535,
"required": true
},
"dnsnameservers": {
"type": "string",
"pattern": "^((\\S+[,;])*\\S+)?$",
@ -303,6 +339,12 @@
"type": "string",
"required": true
},
"routemetric": {
"type": "integer",
"minimum": 0,
"maximum": 65535,
"required": true
},
"method6": {
"type": "string",
"enum": [ "auto", "static", "manual", "dhcp" ],
@ -322,6 +364,12 @@
"type": "string",
"required": true
},
"routemetric6": {
"type": "integer",
"minimum": 0,
"maximum": 65535,
"required": true
},
"dnsnameservers": {
"type": "string",
"pattern": "^((\\S+[,;])*\\S+)?$",
@ -393,6 +441,12 @@
"type": "string",
"required": true
},
"routemetric": {
"type": "integer",
"minimum": 0,
"maximum": 65535,
"required": true
},
"method6": {
"type": "string",
"enum": ["auto", "static", "manual", "dhcp"],
@ -412,6 +466,12 @@
"type": "string",
"required": true
},
"routemetric6": {
"type": "integer",
"minimum": 0,
"maximum": 65535,
"required": true
},
"dnsnameservers": {
"type": "string",
"pattern": "^((\\S+[,;])*\\S+)?$",

View File

@ -19,7 +19,6 @@
# You should have received a copy of the GNU General Public License
# along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.
import ipaddress
import re
import sys
import dialog
@ -43,11 +42,13 @@ class Module(openmediavault.firstaid.IModule):
address = ""
netmask = ""
gateway = ""
routemetric = 0
method = "manual"
address6 = ""
method6 = "manual"
netmask6 = 64
gateway6 = ""
routemetric6 = 1
wol = False
dns_nameservers = ""
wpa_ssid = None
@ -385,10 +386,12 @@ class Module(openmediavault.firstaid.IModule):
"address": address,
"netmask": netmask,
"gateway": gateway,
"routemetric": routemetric,
"method6": method6,
"address6": address6,
"netmask6": netmask6,
"gateway6": gateway6,
"routemetric6": routemetric6,
"dnsnameservers": dns_nameservers,
"dnssearch": "",
"mtu": 0,

View File

@ -143,10 +143,12 @@
<address>xxx.xxx.xxx.xxx</address>
<netmask>xxx.xxx.xxx.xxx</netmask>
<gateway>xxx.xxx.xxx.xxx</gateway>
<routemetric>0-65535</routemetric>
<method6>auto|dhcp|static|manual</method6>
<address6>xxxx:xxxx:...:xxxx</address6>
<netmask6>0-128</netmask6>
<gateway6>xxxx:xxxx:...:xxxx</gateway6>
<routemetric6>0-65535</routemetric6>
<dnsnameservers>xxx yyy zzz</dnsnameservers>
<dnssearch></dnssearch>
<mtu>0...n</mtu>

View File

@ -340,17 +340,40 @@ export class InterfaceBondFormPageComponent extends BaseFormPageComponent {
]
},
{
type: 'textInput',
name: 'gateway',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv4'
},
modifiers: [
type: 'container',
fields: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method' }, arg1: 'static' }
type: 'textInput',
name: 'gateway',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv4'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method' }, arg1: 'static' }
}
],
flex: 75
},
{
type: 'numberInput',
name: 'routemetric',
label: gettext('Metric'),
value: 0,
validators: {
min: 0,
max: 65535,
patternType: 'integer'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method' }, arg1: 'static' }
}
]
}
]
},
@ -410,17 +433,40 @@ export class InterfaceBondFormPageComponent extends BaseFormPageComponent {
]
},
{
type: 'textInput',
name: 'gateway6',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv6'
},
modifiers: [
type: 'container',
fields: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method6' }, arg1: 'static' }
type: 'textInput',
name: 'gateway6',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv6'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method6' }, arg1: 'static' }
}
],
flex: 75
},
{
type: 'numberInput',
name: 'routemetric6',
label: gettext('Metric'),
value: 1,
validators: {
min: 0,
max: 65535,
patternType: 'integer'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method6' }, arg1: 'static' }
}
]
}
]
},

View File

@ -157,17 +157,40 @@ export class InterfaceBridgeFormPageComponent extends BaseFormPageComponent {
]
},
{
type: 'textInput',
name: 'gateway',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv4'
},
modifiers: [
type: 'container',
fields: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method' }, arg1: 'static' }
type: 'textInput',
name: 'gateway',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv4'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method' }, arg1: 'static' }
}
],
flex: 75
},
{
type: 'numberInput',
name: 'routemetric',
label: gettext('Metric'),
value: 0,
validators: {
min: 0,
max: 65535,
patternType: 'integer'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method' }, arg1: 'static' }
}
]
}
]
},
@ -227,17 +250,40 @@ export class InterfaceBridgeFormPageComponent extends BaseFormPageComponent {
]
},
{
type: 'textInput',
name: 'gateway6',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv6'
},
modifiers: [
type: 'container',
fields: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method6' }, arg1: 'static' }
type: 'textInput',
name: 'gateway6',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv6'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method6' }, arg1: 'static' }
}
],
flex: 75
},
{
type: 'numberInput',
name: 'routemetric6',
label: gettext('Metric'),
value: 1,
validators: {
min: 0,
max: 65535,
patternType: 'integer'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method6' }, arg1: 'static' }
}
]
}
]
},

View File

@ -146,17 +146,40 @@ export class InterfaceEthernetFormPageComponent extends BaseFormPageComponent {
]
},
{
type: 'textInput',
name: 'gateway',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv4'
},
modifiers: [
type: 'container',
fields: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method' }, arg1: 'static' }
type: 'textInput',
name: 'gateway',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv4'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method' }, arg1: 'static' }
}
],
flex: 75
},
{
type: 'numberInput',
name: 'routemetric',
label: gettext('Metric'),
value: 0,
validators: {
min: 0,
max: 65535,
patternType: 'integer'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method' }, arg1: 'static' }
}
]
}
]
},
@ -216,17 +239,40 @@ export class InterfaceEthernetFormPageComponent extends BaseFormPageComponent {
]
},
{
type: 'textInput',
name: 'gateway6',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv6'
},
modifiers: [
type: 'container',
fields: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method6' }, arg1: 'static' }
type: 'textInput',
name: 'gateway6',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv6'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method6' }, arg1: 'static' }
}
],
flex: 75
},
{
type: 'numberInput',
name: 'routemetric6',
label: gettext('Metric'),
value: 1,
validators: {
min: 0,
max: 65535,
patternType: 'integer'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method6' }, arg1: 'static' }
}
]
}
]
},

View File

@ -168,17 +168,40 @@ export class InterfaceVlanFormPageComponent extends BaseFormPageComponent {
]
},
{
type: 'textInput',
name: 'gateway',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv4'
},
modifiers: [
type: 'container',
fields: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method' }, arg1: 'static' }
type: 'textInput',
name: 'gateway',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv4'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method' }, arg1: 'static' }
}
],
flex: 75
},
{
type: 'numberInput',
name: 'routemetric',
label: gettext('Metric'),
value: 0,
validators: {
min: 0,
max: 65535,
patternType: 'integer'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method' }, arg1: 'static' }
}
]
}
]
},
@ -238,17 +261,40 @@ export class InterfaceVlanFormPageComponent extends BaseFormPageComponent {
]
},
{
type: 'textInput',
name: 'gateway6',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv6'
},
modifiers: [
type: 'container',
fields: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method6' }, arg1: 'static' }
type: 'textInput',
name: 'gateway6',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv6'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method6' }, arg1: 'static' }
}
],
flex: 75
},
{
type: 'numberInput',
name: 'routemetric6',
label: gettext('Metric'),
value: 1,
validators: {
min: 0,
max: 65535,
patternType: 'integer'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method6' }, arg1: 'static' }
}
]
}
]
},

View File

@ -172,17 +172,40 @@ export class InterfaceWifiFormPageComponent extends BaseFormPageComponent {
]
},
{
type: 'textInput',
name: 'gateway',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv4'
},
modifiers: [
type: 'container',
fields: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method' }, arg1: 'static' }
type: 'textInput',
name: 'gateway',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv6'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method' }, arg1: 'static' }
}
],
flex: 75
},
{
type: 'numberInput',
name: 'routemetric',
label: gettext('Metric'),
value: 0,
validators: {
min: 0,
max: 65535,
patternType: 'integer'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method' }, arg1: 'static' }
}
]
}
]
},
@ -242,17 +265,40 @@ export class InterfaceWifiFormPageComponent extends BaseFormPageComponent {
]
},
{
type: 'textInput',
name: 'gateway6',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv6'
},
modifiers: [
type: 'container',
fields: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method6' }, arg1: 'static' }
type: 'textInput',
name: 'gateway6',
label: gettext('Gateway'),
value: '',
validators: {
patternType: 'ipv4'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method6' }, arg1: 'static' }
}
],
flex: 75
},
{
type: 'numberInput',
name: 'routemetric6',
label: gettext('Metric'),
value: 1,
validators: {
min: 0,
max: 65535,
patternType: 'integer'
},
modifiers: [
{
type: 'disabled',
constraint: { operator: 'ne', arg0: { prop: 'method6' }, arg1: 'static' }
}
]
}
]
},