Closed arfett closed 11 years ago
The reason it was creating multiple lines was it was getting these lines from the network config which both have 'ifname' in them:
network.wan.ifname=eth0.1 network.wan._orig_ifname=eth0.1
I changed the fix so that it now greps out 'orig_ifname' so it doesn't matter what that option is set to it will still remove it giving $iface the proper value of 'wan'
Hi Arfett,
Thanks for the patch. I was struggling with almost the same. I did change that line on my own version, but didn't push it to git yet. I changed it in:
iface=$(uci show -P /var/state network | awk -F'=' '$2 == ("'$2'")' | grep device | awk -F'.' '{ print $2 }' | grep -v '@')
Could you paste me the results from "uci show -P /var/state network" on your router.
Thanks! Jeroen.
Met vriendelijke groet, Jeroen Louwes
Verstuurd vanaf mijn ENIAC
2013/7/9 arfett notifications@github.com
The reason it was creating multiple lines was it was getting these lines from the network config which both have 'ifname' in them:
network.wan.ifname=eth0.1 network.wan._orig_ifname=eth0.1
I changed the fix so that it now greps out 'orig_ifname' so it doesn't matter what that option is set to it will still remove it giving $iface the proper value of 'wan'
— Reply to this email directly or view it on GitHubhttps://github.com/Adze1502/mwan/pull/8#issuecomment-20653120 .
root@OpenWrt-F70:~# uci show -p /var/state network
network.loopback=interface
network.loopback.ifname=lo
network.loopback.proto=static
network.loopback.ipaddr=127.0.0.1
network.loopback.netmask=255.0.0.0
network.loopback.up=1
network.loopback.connect_time=29
network.loopback.device=lo
network.@alias[0]=alias
network.@alias[0].interface=loopback
network.@alias[0].proto=static
network.@alias[0].ipaddr=192.168.100.1
network.@alias[0].netmask=255.255.255.255
network.@alias[0].up=1
network.@alias[0].connect_time=30
network.@alias[0].ifname=lo
network.wan=interface
network.wan.ifname=eth0.1
network.wan._orig_ifname=eth0.1
network.wan._orig_bridge=false
network.wan.proto=static
network.wan.ipaddr=192.168.51.2
network.wan.netmask=255.255.255.0
network.wan.gateway=192.168.51.1
network.wan.metric=10
network.wan.macaddr=00:02:6B:0C:5F:6F
network.wan.dns=192.168.50.1
network.wan.up=1
network.wan.connect_time=20010
network.wan.device=eth0.1
network.lan=interface
network.lan.type=bridge
network.lan.proto=static
network.lan.netmask=255.255.255.0
network.lan.ipaddr=192.168.30.1
network.lan.macaddr=00:02:6B:0C:5F:6E
network.lan.up=1
network.lan.connect_time=23
network.lan.device=eth0.2
network.lan.ifname=br-lan
network.@switch[0]=switch
network.@switch[0].name=rt305x
network.@switch[0].reset=1
network.@switch[0].enable_vlan=1
network.@switch_vlan[0]=switch_vlan
network.@switch_vlan[0].device=rt305x
network.@switch_vlan[0].vlan=1
network.@switch_vlan[0].ports=0 6t
network.@switch_vlan[1]=switch_vlan
network.@switch_vlan[1].device=rt305x
network.@switch_vlan[1].vlan=2
network.@switch_vlan[1].ports=1 2 3 4 6t
network.wwan=interface
network.wwan.proto=dhcp
network.wwan.hostname=OpenWrt-F70
network.wwan.peerdns=0
network.wwan.dns=8.8.8.8 8.8.4.4
network.wwan.metric=20
network.wwan.up=1
network.wwan.connect_time=20017
network.wwan.ifname=wlan0
network.@route[0]=route
network.@route[0].interface=wan
network.@route[0].target=192.168.50.0
network.@route[0].netmask=255.255.255.0
network.@route[0].gateway=192.168.51.1
network.@route[1]=route
network.@route[1].interface=wwan
network.@route[1].target=216.146.38.70
network.@route[1].netmask=255.255.255.255
network.@route[1].gateway=192.168.0.1
As you can see my wwan has no device option. I think we should grep for ifname and grep remove orig_ifname.
Your patch doesn't work for me.. We have to think of something that will work for most/all situations:
root@mercurius:~# uci show -P /var/state network | awk -F'=' '$2 == ("'eth0.2'")' network.wan2.ifname=eth0.2 network.wan2.device=eth0.2 network.wan6.ifname=eth0.2
root@mercurius:~# uci show -P /var/state network | awk -F'=' '$2 == ("'eth0.2'")' | grep ifname | grep -v orig_ifname | awk -F'.' '{ print $2 }' | grep -v '@' wan2 wan6
Met vriendelijke groet, Jeroen Louwes
Verstuurd vanaf mijn ENIAC
2013/7/9 arfett notifications@github.com
As you can see my wwan has no device option. I think we should grep for ifname and grep remove orig_ifname.
— Reply to this email directly or view it on GitHubhttps://github.com/Adze1502/mwan/pull/8#issuecomment-20656927 .
What does your 'uci show -p /var/state network' look like? I ask because I can't create a scenario that would show two different wan names in that situation on my router I don't think. Are multiple interfaces showing the same ifname?
root@mercurius:~# cat /etc/config/network
config interface 'loopback' option ifname 'lo' option proto 'static' option ipaddr '127.0.0.1' option netmask '255.0.0.0'
config alias option interface 'loopback' option proto 'static' option ipaddr '192.168.1.1' option netmask '255.255.255.255' option ip6addr '2001:7b8:a00:1::1/64'
config interface 'lan' option ifname 'eth1' option type 'bridge' option proto 'static' option ipaddr '192.168.33.2' option netmask '255.255.255.0' option ip6addr '2001:7b8:a00:33:c63d:c7ff:fe86:a9a/64' option ip6assign '64'
config interface 'wan1' option ifname 'eth0.1' option proto 'static' option ipaddr '213.127.134.91' option netmask '255.255.255.248' option gateway '213.127.134.89' option dns '192.168.1.1 192.168.2.1' option metric '10'
config interface 'wan2' option ifname 'eth0.2' option proto 'static' option ipaddr '213.154.232.11' option netmask '255.255.255.248' option gateway '213.154.232.9' option dns '192.168.1.1 192.168.2.1' option metric '20' option accept_ra '1' option ipv6 '1'
config interface 'wan6' option ifname @wan2 option proto 'dhcpv6'
config interface 'vpn1' option proto 'none' option ifname 'tun0'
config interface 'vpn2' option proto 'none' option ifname 'tun1'
config switch option name 'rtl8366s' option reset '1' option enable_vlan '1' option blinkrate '2'
config switch_vlan option device 'rtl8366s' option vlan '1' option ports '3 5t'
config switch_vlan option device 'rtl8366s' option vlan '2' option ports '2 5t'
config switch_vlan option device 'rtl8366s' option vlan '3' option ports '1 5t'
config switch_vlan option device 'rtl8366s' option vlan '4' option ports '0 5t'
config switch_port option device 'rtl8366s' option port '1' option led '6'
config switch_port option device 'rtl8366s' option port '2' option led '9'
config switch_port option device 'rtl8366s' option port '5' option led '2'
Met vriendelijke groet, Jeroen Louwes
Verstuurd vanaf mijn ENIAC
2013/7/9 arfett notifications@github.com
what is in your network config that's making it show that?
On Tue, Jul 9, 2013 at 3:13 AM, Jeroen Louwes notifications@github.comwrote:
Your patch doesn't work for me.. We have to think of something that will work for most/all situations:
root@mercurius:~# uci show -P /var/state network | awk -F'=' '$2 == ("'eth0.2'")' network.wan2.ifname=eth0.2 network.wan2.device=eth0.2 network.wan6.ifname=eth0.2
root@mercurius:~# uci show -P /var/state network | awk -F'=' '$2 == ("'eth0.2'")' | grep ifname | grep -v orig_ifname | awk -F'.' '{ print $2 }' | grep -v '@' wan2 wan6
Met vriendelijke groet, Jeroen Louwes
Verstuurd vanaf mijn ENIAC
2013/7/9 arfett notifications@github.com
As you can see my wwan has no device option. I think we should grep for ifname and grep remove orig_ifname.
— Reply to this email directly or view it on GitHub< https://github.com/Adze1502/mwan/pull/8#issuecomment-20656927> .
— Reply to this email directly or view it on GitHub< https://github.com/Adze1502/mwan/pull/8#issuecomment-20664770> .
— Reply to this email directly or view it on GitHubhttps://github.com/Adze1502/mwan/pull/8#issuecomment-20668565 .
We may have to forgo the performance benefits of 'uci show -p' in this once instance and cat the network config file directly. Try this:
cat /etc/config/network | awk '/eth0.2/' RS= | grep 'config interface' | awk -F\' '{print $2}' | awk -F\' '{print $1}'
Although we may need to add a few more things to it to ensure it's from the interface section we want? It's 5:30 AM and I'm just now getting to sleep so I'll look into it further today.
Won't work, because ppp interfaces don't have a device statement in network config...
Met vriendelijke groet, Jeroen Louwes
Verstuurd vanaf mijn ENIAC
2013/7/9 arfett notifications@github.com
We may have to forgo the performance benefits of 'uci show -p' in this once instance and cat the network config file directly. Try this:
cat /etc/config/network | awk '/eth0.2/' RS= | grep 'config interface' | awk -F\' '{print $2}' | awk -F\' '{print $1}'
— Reply to this email directly or view it on GitHubhttps://github.com/Adze1502/mwan/pull/8#issuecomment-20670350 .
In my case I had two policies and when going through the second policy the variable $iface would equal "wan\nwan" rather than the desired "wan" and the proposed fix should remove the duplicate lines should they exist.