diff mbox

[OpenWrt-Devel,5/5] malta: use "static" proto for lan interface

Message ID 1446036929-19163-6-git-send-email-yszhou4tech@gmail.com
State Superseded
Headers show

Commit Message

Yousong Zhou Oct. 28, 2015, 12:55 p.m. UTC
This is almost the default config of OpenWrt targets (currently even
those sunxi boards with only one ethernet interface use static IP
address for its lan interface).

While at it, also configure a wan interface if eth1 exists.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
---
 target/linux/malta/base-files/etc/uci-defaults/02-network |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Florian Fainelli Oct. 28, 2015, 4:19 p.m. UTC | #1
On Oct 28, 2015 5:56 AM, "Yousong Zhou" <yszhou4tech@gmail.com> wrote:
>
> This is almost the default config of OpenWrt targets (currently even
> those sunxi boards with only one ethernet interface use static IP
> address for its lan interface).

And this is intend intended, because Malta is primarily used under qemu,
from which you get your network to be NAT'd or bridged from/with the host.
Your change would force an user to reconfigure the network on boot, and
that seems like a less sensible default to me.

>
> While at it, also configure a wan interface if eth1 exists.
>
> Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
> ---
>  target/linux/malta/base-files/etc/uci-defaults/02-network |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/target/linux/malta/base-files/etc/uci-defaults/02-network
b/target/linux/malta/base-files/etc/uci-defaults/02-network
> index e90ecbe..1b22ec5 100644
> --- a/target/linux/malta/base-files/etc/uci-defaults/02-network
> +++ b/target/linux/malta/base-files/etc/uci-defaults/02-network
> @@ -3,4 +3,7 @@
>  . /lib/functions/uci-defaults.sh
>
>  ucidef_set_interface_loopback
> -ucidef_set_interface_raw "lan" "eth0" "dhcp"
> +ucidef_set_interface_lan "eth0"
> +if [ -d "/sys/class/net/eth1" ]; then
> +       ucidef_set_interface_wan "eth1"
> +fi
> --
> 1.7.10.4
Yousong Zhou Oct. 29, 2015, 2:32 a.m. UTC | #2
On 29 October 2015 at 00:19, Florian Fainelli <florian@openwrt.org> wrote:
> On Oct 28, 2015 5:56 AM, "Yousong Zhou" <yszhou4tech@gmail.com> wrote:
>>
>> This is almost the default config of OpenWrt targets (currently even
>> those sunxi boards with only one ethernet interface use static IP
>> address for its lan interface).
>
> And this is intend intended, because Malta is primarily used under qemu,
> from which you get your network to be NAT'd or bridged from/with the host.
> Your change would force an user to reconfigure the network on boot, and that
> seems like a less sensible default to me.
>

The current default is not that sensible anyway.  If I understand it
correctly, many packages in OpenWrt assume that lan is for the
"internal" part of the network map, e.g. by default, dnsmasq will
serve DHCP requests on lan interface, firewall will also allow
forwarding on lan interface.  A workaround can be making eth0 the
default wan interface.

When it comes to OpenWrt development with QEMU Malta, the benefits of
a better emulated dev/network environment can definitely compensate
for the efforts of setting up the environment needed only for the
first time.

                yousong

>>
>> While at it, also configure a wan interface if eth1 exists.
>>
>> Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
>> ---
>>  target/linux/malta/base-files/etc/uci-defaults/02-network |    5 ++++-
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/target/linux/malta/base-files/etc/uci-defaults/02-network
>> b/target/linux/malta/base-files/etc/uci-defaults/02-network
>> index e90ecbe..1b22ec5 100644
>> --- a/target/linux/malta/base-files/etc/uci-defaults/02-network
>> +++ b/target/linux/malta/base-files/etc/uci-defaults/02-network
>> @@ -3,4 +3,7 @@
>>  . /lib/functions/uci-defaults.sh
>>
>>  ucidef_set_interface_loopback
>> -ucidef_set_interface_raw "lan" "eth0" "dhcp"
>> +ucidef_set_interface_lan "eth0"
>> +if [ -d "/sys/class/net/eth1" ]; then
>> +       ucidef_set_interface_wan "eth1"
>> +fi
>> --
>> 1.7.10.4
Florian Fainelli Oct. 29, 2015, 2:20 p.m. UTC | #3
Le 28/10/2015 19:32, Yousong Zhou a écrit :
> On 29 October 2015 at 00:19, Florian Fainelli <florian@openwrt.org> wrote:
>> On Oct 28, 2015 5:56 AM, "Yousong Zhou" <yszhou4tech@gmail.com> wrote:
>>>
>>> This is almost the default config of OpenWrt targets (currently even
>>> those sunxi boards with only one ethernet interface use static IP
>>> address for its lan interface).
>>
>> And this is intend intended, because Malta is primarily used under qemu,
>> from which you get your network to be NAT'd or bridged from/with the host.
>> Your change would force an user to reconfigure the network on boot, and that
>> seems like a less sensible default to me.
>>
> 
> The current default is not that sensible anyway.  If I understand it
> correctly, many packages in OpenWrt assume that lan is for the
> "internal" part of the network map, e.g. by default, dnsmasq will
> serve DHCP requests on lan interface, firewall will also allow
> forwarding on lan interface.  A workaround can be making eth0 the
> default wan interface.

But then again, by making eth0 the default wan interface, this is
enforcing a specific model of the networking, and with QEMU this is a
lot more flexible than that.

Since there does not see to be a good answer, then let's go with your
changes and I will do my local changes if I am unhappy with these...
--
Florian
diff mbox

Patch

diff --git a/target/linux/malta/base-files/etc/uci-defaults/02-network b/target/linux/malta/base-files/etc/uci-defaults/02-network
index e90ecbe..1b22ec5 100644
--- a/target/linux/malta/base-files/etc/uci-defaults/02-network
+++ b/target/linux/malta/base-files/etc/uci-defaults/02-network
@@ -3,4 +3,7 @@ 
 . /lib/functions/uci-defaults.sh
 
 ucidef_set_interface_loopback
-ucidef_set_interface_raw "lan" "eth0" "dhcp"
+ucidef_set_interface_lan "eth0"
+if [ -d "/sys/class/net/eth1" ]; then
+	ucidef_set_interface_wan "eth1"
+fi