diff mbox

[OpenWrt-Devel] base-files: fix generating network configuration

Message ID 1451476827-18140-1-git-send-email-yszhou4tech@gmail.com
State Rejected
Headers show

Commit Message

Yousong Zhou Dec. 30, 2015, noon UTC
With the default /e/c/network present, board_detect won't create a new
config from board.json.  Move this default configuration to
generate_static_network of config_generate instead.

This should fix the issue on malta target and should not affect other
targets that provide its own default network config

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
---
 package/base-files/files/bin/config_generate |  8 ++++++++
 package/base-files/files/etc/config/network  | 18 ------------------
 2 files changed, 8 insertions(+), 18 deletions(-)
 delete mode 100644 package/base-files/files/etc/config/network

Comments

Jo-Philipp Wich Dec. 30, 2015, 12:12 p.m. UTC | #1
Hi Yousong.

NAK - thats by design. If a network config is present then there is no
point in regenerating it.

I'd prefer if the Malta target would simply drop its default config and
switch to board.d, this could be useful to e.g. dynamically handle
different amounts of eth* devices:

 eth0 -> lan
 eth0, eth1 -> lan, wan
 eth0, eth1, eth2 -> lan(eth0+eth1), wan(eth2)

~ Jow

On 30.12.2015 13:00, Yousong Zhou wrote:
> With the default /e/c/network present, board_detect won't create a new
> config from board.json.  Move this default configuration to
> generate_static_network of config_generate instead.
> 
> This should fix the issue on malta target and should not affect other
> targets that provide its own default network config
> 
> Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
> ---
>  package/base-files/files/bin/config_generate |  8 ++++++++
>  package/base-files/files/etc/config/network  | 18 ------------------
>  2 files changed, 8 insertions(+), 18 deletions(-)
>  delete mode 100644 package/base-files/files/etc/config/network
> 
> diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate
> index 9218788..39a0c60 100755
> --- a/package/base-files/files/bin/config_generate
> +++ b/package/base-files/files/bin/config_generate
> @@ -14,6 +14,14 @@ generate_static_network() {
>  		set network.loopback.proto='static'
>  		set network.loopback.ipaddr='127.0.0.1'
>  		set network.loopback.netmask='255.0.0.0'
> +		delete network.lan
> +		network.lan=interface
> +		network.lan.type='bridge'
> +		network.lan.ifname='eth1'
> +		network.lan.proto='static'
> +		network.lan.ipaddr='192.168.1.1'
> +		network.lan.netmask='255.255.255.0'
> +		network.lan.ip6assign='60'
>  		delete network.globals
>  		set network.globals='globals'
>  		set network.globals.ula_prefix='auto'
> diff --git a/package/base-files/files/etc/config/network b/package/base-files/files/etc/config/network
> deleted file mode 100644
> index d3cd3c6..0000000
> --- a/package/base-files/files/etc/config/network
> +++ /dev/null
> @@ -1,18 +0,0 @@
> -# Copyright (C) 2006 OpenWrt.org
> -
> -config interface loopback
> -	option ifname	lo
> -	option proto	static
> -	option ipaddr	127.0.0.1
> -	option netmask	255.0.0.0
> -
> -config interface lan
> -	option ifname	eth0
> -	option type 	bridge
> -	option proto	static
> -	option ipaddr	192.168.1.1
> -	option netmask	255.255.255.0
> -	option ip6assign 60
> -
> -config globals globals
> -	option ula_prefix auto
>
Yousong Zhou Dec. 30, 2015, 12:32 p.m. UTC | #2
On 30 December 2015 at 20:12, Jo-Philipp Wich <jow@openwrt.org> wrote:
> Hi Yousong.
>
> NAK - thats by design. If a network config is present then there is no
> point in regenerating it.
>
> I'd prefer if the Malta target would simply drop its default config and
> switch to board.d, this could be useful to e.g. dynamically handle
> different amounts of eth* devices:
>

The default network config was provided by package/base-files, not
malta target...

                yousong

>  eth0 -> lan
>  eth0, eth1 -> lan, wan
>  eth0, eth1, eth2 -> lan(eth0+eth1), wan(eth2)
>
> ~ Jow
>
> On 30.12.2015 13:00, Yousong Zhou wrote:
>> With the default /e/c/network present, board_detect won't create a new
>> config from board.json.  Move this default configuration to
>> generate_static_network of config_generate instead.
>>
>> This should fix the issue on malta target and should not affect other
>> targets that provide its own default network config
>>
>> Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
>> ---
>>  package/base-files/files/bin/config_generate |  8 ++++++++
>>  package/base-files/files/etc/config/network  | 18 ------------------
>>  2 files changed, 8 insertions(+), 18 deletions(-)
>>  delete mode 100644 package/base-files/files/etc/config/network
>>
>> diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate
>> index 9218788..39a0c60 100755
>> --- a/package/base-files/files/bin/config_generate
>> +++ b/package/base-files/files/bin/config_generate
>> @@ -14,6 +14,14 @@ generate_static_network() {
>>               set network.loopback.proto='static'
>>               set network.loopback.ipaddr='127.0.0.1'
>>               set network.loopback.netmask='255.0.0.0'
>> +             delete network.lan
>> +             network.lan=interface
>> +             network.lan.type='bridge'
>> +             network.lan.ifname='eth1'
>> +             network.lan.proto='static'
>> +             network.lan.ipaddr='192.168.1.1'
>> +             network.lan.netmask='255.255.255.0'
>> +             network.lan.ip6assign='60'
>>               delete network.globals
>>               set network.globals='globals'
>>               set network.globals.ula_prefix='auto'
>> diff --git a/package/base-files/files/etc/config/network b/package/base-files/files/etc/config/network
>> deleted file mode 100644
>> index d3cd3c6..0000000
>> --- a/package/base-files/files/etc/config/network
>> +++ /dev/null
>> @@ -1,18 +0,0 @@
>> -# Copyright (C) 2006 OpenWrt.org
>> -
>> -config interface loopback
>> -     option ifname   lo
>> -     option proto    static
>> -     option ipaddr   127.0.0.1
>> -     option netmask  255.0.0.0
>> -
>> -config interface lan
>> -     option ifname   eth0
>> -     option type     bridge
>> -     option proto    static
>> -     option ipaddr   192.168.1.1
>> -     option netmask  255.255.255.0
>> -     option ip6assign 60
>> -
>> -config globals globals
>> -     option ula_prefix auto
>>
>
Roman Yeryomin Dec. 31, 2015, 12:33 p.m. UTC | #3
On 30 December 2015 at 14:32, Yousong Zhou <yszhou4tech@gmail.com> wrote:
> On 30 December 2015 at 20:12, Jo-Philipp Wich <jow@openwrt.org> wrote:
>> Hi Yousong.
>>
>> NAK - thats by design. If a network config is present then there is no
>> point in regenerating it.
>>
>> I'd prefer if the Malta target would simply drop its default config and
>> switch to board.d, this could be useful to e.g. dynamically handle
>> different amounts of eth* devices:
>>
>
> The default network config was provided by package/base-files, not
> malta target...

You can easily override it, no need to modify defaults.

Regards,
Roman
Yousong Zhou Jan. 2, 2016, 10:34 a.m. UTC | #4
Hi,

On 31 December 2015 at 20:33, Roman Yeryomin <leroi.lists@gmail.com> wrote:
> On 30 December 2015 at 14:32, Yousong Zhou <yszhou4tech@gmail.com> wrote:
>> On 30 December 2015 at 20:12, Jo-Philipp Wich <jow@openwrt.org> wrote:
>>> Hi Yousong.
>>>
>>> NAK - thats by design. If a network config is present then there is no
>>> point in regenerating it.
>>>
>>> I'd prefer if the Malta target would simply drop its default config and
>>> switch to board.d, this could be useful to e.g. dynamically handle
>>> different amounts of eth* devices:
>>>

From git log, malta has been using board.d for quite a while.

>>
>> The default network config was provided by package/base-files, not
>> malta target...
>
> You can easily override it, no need to modify defaults.
>

So I thought I might have missed something, and was wondering why
malta and to this moment why still no bug reports for other targets
like ar71xx, the default network config provided by package/base-files
should have prevented the board.d mechanism from generating
board-specific network config for all of them.

Well, looks like malta misses a base-files.mk to rm the default network config.

                yousong
diff mbox

Patch

diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate
index 9218788..39a0c60 100755
--- a/package/base-files/files/bin/config_generate
+++ b/package/base-files/files/bin/config_generate
@@ -14,6 +14,14 @@  generate_static_network() {
 		set network.loopback.proto='static'
 		set network.loopback.ipaddr='127.0.0.1'
 		set network.loopback.netmask='255.0.0.0'
+		delete network.lan
+		network.lan=interface
+		network.lan.type='bridge'
+		network.lan.ifname='eth1'
+		network.lan.proto='static'
+		network.lan.ipaddr='192.168.1.1'
+		network.lan.netmask='255.255.255.0'
+		network.lan.ip6assign='60'
 		delete network.globals
 		set network.globals='globals'
 		set network.globals.ula_prefix='auto'
diff --git a/package/base-files/files/etc/config/network b/package/base-files/files/etc/config/network
deleted file mode 100644
index d3cd3c6..0000000
--- a/package/base-files/files/etc/config/network
+++ /dev/null
@@ -1,18 +0,0 @@ 
-# Copyright (C) 2006 OpenWrt.org
-
-config interface loopback
-	option ifname	lo
-	option proto	static
-	option ipaddr	127.0.0.1
-	option netmask	255.0.0.0
-
-config interface lan
-	option ifname	eth0
-	option type 	bridge
-	option proto	static
-	option ipaddr	192.168.1.1
-	option netmask	255.255.255.0
-	option ip6assign 60
-
-config globals globals
-	option ula_prefix auto