@@ -14,6 +14,11 @@ set_classless_routes() {
}
setup_interface () {
+ local i
+ for i in $ALIAS; do
+ ubus call network.interface."$i" down '{}'
+ done
+
proto_init_update "*" 1
proto_add_ipv4_address "$ip" "${subnet:-255.255.255.0}"
# TODO: apply $broadcast
@@ -21,7 +26,6 @@ setup_interface () {
local ip_net
eval "$(ipcalc.sh "$ip/$mask")";ip_net="$NETWORK"
- local i
for i in $router; do
local gw_net
eval "$(ipcalc.sh "$i/$mask")";gw_net="$NETWORK"
@@ -93,6 +97,11 @@ setup_interface () {
deconfig_interface() {
proto_init_update "*" 0
proto_send_update "$INTERFACE"
+
+ local i
+ for i in $ALIAS; do
+ ubus call network.interface."$i" up '{}'
+ done
}
case "$1" in
@@ -25,6 +25,7 @@ proto_dhcp_init_config() {
proto_config_add_string mtu6rd
proto_config_add_string customroutes
proto_config_add_boolean classlessroute
+ proto_config_add_string 'alias'
}
proto_dhcp_add_sendopts() {
@@ -35,8 +36,8 @@ proto_dhcp_setup() {
local config="$1"
local iface="$2"
- local ipaddr hostname clientid vendorid broadcast release reqopts defaultreqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute
- json_get_vars ipaddr hostname clientid vendorid broadcast release reqopts defaultreqopts iface6rd delegate zone6rd zone mtu6rd customroutes classlessroute
+ local ipaddr hostname clientid vendorid broadcast release reqopts defaultreqopts iface6rd sendopts delegate zone6rd zone mtu6rd customroutes classlessroute alias
+ json_get_vars ipaddr hostname clientid vendorid broadcast release reqopts defaultreqopts iface6rd delegate zone6rd zone mtu6rd customroutes classlessroute alias
local opt dhcpopts
for opt in $reqopts; do
@@ -60,6 +61,12 @@ proto_dhcp_setup() {
# Request classless route option (see RFC 3442) by default
[ "$classlessroute" = "0" ] || append dhcpopts "-O 121"
+ proto_export "ALIAS=$alias"
+ local i
+ for i in $alias; do
+ ubus call network.interface."$i" up '{}'
+ done
+
proto_export "INTERFACE=$config"
proto_run_command "$config" udhcpc \
-p /var/run/udhcpc-$iface.pid \
The alias interfaces for interfaces with proto dhcp are very useful for specialised builds with proto dhcp on lan by default but with backup static addresses. The default way has one shortage. It left backup address configured on interface with address configured by odchp. This can lead to network overlapping (when dhcp server configured on the same subnet with alias interface) and to the addresses duplication inside broadcast domain (when more then one board with same firmware running in subnet). This patch introduces new option to dhcp proto. Just add option alias '<alias interface(s) name(s)>' to the interface configuration and it will automatically downs alias interfaces you specified upon dhcp address receiving. Signed-off-by: Yury Shvedov <yshvedov@wimarksystems.com> --- .../config/netifd/files/lib/netifd/dhcp.script | 11 ++++++++++- .../config/netifd/files/lib/netifd/proto/dhcp.sh | 11 +++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-)