Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ local uci
local COMPLETE_BOARD = {
["network"] = {
["lan"] = {
["ifname"] = "eth0",
["device"] = "br-lan",
["protocol"] = "static",
},
["wan"] = {
["ifname"] = "eth1",
["device"] = "wan",
["protocol"] = "dhcp",
},
}
Expand All @@ -39,7 +39,7 @@ describe('LiMe Network tests', function()

openwrt_wan.detect_hardware()
assert.are.same({'wan'}, config.get("lm_hwd_openwrt_wan", "protocols"))
assert.is.equal('eth1', config.get("lm_hwd_openwrt_wan", "linux_name"))
assert.is.equal('wan', config.get("lm_hwd_openwrt_wan", "linux_name"))
assert.is.equal('true', config.get("lm_hwd_openwrt_wan", "autogenerated"))
end)

Expand Down
2 changes: 1 addition & 1 deletion packages/lime-hwd-usbradio/src/usbradio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function usbradio.detect_hardware()
uci:set("wireless", radioName, "wifi-device")
uci:set("wireless", radioName, "type", "mac80211")
uci:set("wireless", radioName, "channel", "11") --TODO: working on all 802.11bgn devices; find a general way for working in different devices
uci:set("wireless", radioName, "hwmode", "11g") --TODO: working on all 802.11gn devices; find a general way for working in different devices
uci:set("wireless", radioName, "band", "2g") --TODO: working on all 802.11gn devices; find a general way for working in different devices
uci:set("wireless", radioName, "path", phyPath)
uci:set("wireless", radioName, "htmode", "HT20")
uci:set("wireless", radioName, "disabled", "0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function babeld.setup_interface(ifname, args)

local uci = config.get_uci_cursor()

if(vlanId ~= 0 and ifname:match("^eth")) then
if(vlanId ~= 0 and (ifname:match("^eth") or ifname:match("^lan"))) then
uci:set("network", owrtDeviceName, "mtu", tostring(network.MTU_ETH_WITH_VLAN))
end

Expand Down
17 changes: 10 additions & 7 deletions packages/lime-system/files/usr/lib/lua/lime/network.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function network.primary_interface()
local ifname = config.get("network", "primary_interface", "eth0")
if ifname == "auto" then
local board = utils.getBoardAsTable()
ifname = board['network']['lan']['ifname']
ifname = board['network']['lan']['device']
end
network.assert_interface_exists(ifname)
return ifname
Expand Down Expand Up @@ -213,6 +213,12 @@ function network.clean()
fs.writefile("/etc/config/6relayd", "")
end

function network._get_lower(dev)
local lower_if_path = utils.unsafe_shell("ls -d /sys/class/net/" .. dev .. "/lower*")
local lower_if_table = utils.split(lower_if_path, "_")
return lower_if_table[#lower_if_table]:gsub("\n", "")
end

function network.scandevices()
local devices = {}
local switch_vlan = {}
Expand All @@ -239,19 +245,16 @@ function network.scandevices()
end
--! With DSA, the LAN ports are not anymore eth0.1 but lan1, lan2...
if dev:match("^lan%d+$") then
local lower_if_path = utils.unsafe_shell("ls -d /sys/class/net/" .. dev .. "/lower*")
local lower_if_table = utils.split(lower_if_path, "_")
local lower_if = lower_if_table[#lower_if_table]:gsub("\n", "")
local lower_if = network._get_lower(dev)
devices[lower_if] = { nobridge = true }
devices[dev] = {}
utils.log( "network.scandevices.dev_parser found LAN port %s " ..
"and marking %s as nobridge", dev, lower_if )
end
--! With DSA, the WAN is named wan. Copying the code from the lan case.

if dev:match("^wan$") then
local lower_if_path = utils.unsafe_shell("ls -d /sys/class/net/" .. dev .. "/lower*")
local lower_if_table = utils.split(lower_if_path, "_")
local lower_if = lower_if_table[#lower_if_table]:gsub("\n", "")
local lower_if = network._get_lower(dev)
devices[lower_if] = { nobridge = true }
devices[dev] = {}
utils.log( "network.scandevices.dev_parser found WAN port %s " ..
Expand Down
1 change: 1 addition & 0 deletions packages/lime-system/files/usr/lib/lua/lime/proto/lan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function lan.setup_interface(ifname, args)
end
end
table.insert(bridgedIfs, ifname)
uci:set("network", "@device[0]", "device")
uci:set("network", "@device[0]", "ports", bridgedIfs)
uci:save("network")
end
Expand Down
12 changes: 6 additions & 6 deletions packages/lime-system/tests/test_lime_network.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ local BOARD = {
},
["network"] = {
["lan"] = {
["ifname"] = "lo",
["device"] = "lo",
["protocol"] = "static",
},
["wan"] = {
["ifname"] = "eth0",
["device"] = "wan",
["protocol"] = "dhcp",
},
}
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('LiMe Network tests', function()

assert.is.equal("1500", uci:get("network", "lan", "mtu"))
assert.is.equal("static", uci:get("network", "lan", "proto"))
assert.is.equal(ifname, uci:get("network", "lan", "ifname")[1])
assert.is.equal(ifname, uci:get("network", "@device[0]", "ports")[1])
network.get_mac:revert()
network.scandevices:revert()
end)
Expand All @@ -113,7 +113,7 @@ describe('LiMe Network tests', function()
assert.is.equal(tostring(vid), uci:get("network", "lm_net_eth99_fooproto_dev", "vid"))

-- the interface
assert.is.equal('eth99_15', uci:get("network", "lm_net_eth99_fooproto_if", "ifname"))
assert.is.equal('eth99_15', uci:get("network", "lm_net_eth99_fooproto_if", "device"))
assert.is.equal('1', uci:get("network", "lm_net_eth99_fooproto_if", "auto"))
assert.is.equal('none', uci:get("network", "lm_net_eth99_fooproto_if", "proto"))
end)
Expand All @@ -127,7 +127,7 @@ describe('LiMe Network tests', function()
assert.is_nil(uci:get("network", "lm_net_eth99_fooproto_dev", "name"))

-- the interface uses static protocol
assert.is.equal('eth99', uci:get("network", "lm_net_eth99_fooproto_if", "ifname"))
assert.is.equal('eth99', uci:get("network", "lm_net_eth99_fooproto_if", "device"))
assert.is.equal('1', uci:get("network", "lm_net_eth99_fooproto_if", "auto"))
assert.is.equal('static', uci:get("network", "lm_net_eth99_fooproto_if", "proto"))
end)
Expand All @@ -144,7 +144,7 @@ describe('LiMe Network tests', function()
assert.is.equal('@lm_net_wlan85', uci:get("network", "lm_net_wlan85_fooproto_dev", "ifname"))

-- the interface
assert.is.equal('wlan85_15', uci:get("network", "lm_net_wlan85_fooproto_if", "ifname"))
assert.is.equal('wlan85_15', uci:get("network", "lm_net_wlan85_fooproto_if", "device"))
assert.is.equal('1', uci:get("network", "lm_net_wlan85_fooproto_if", "auto"))
assert.is.equal('none', uci:get("network", "lm_net_wlan85_fooproto_if", "proto"))
end)
Expand Down
26 changes: 13 additions & 13 deletions packages/lime-system/tests/test_lime_wireless.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('LiMe Wireless tests #wireless', function()

it('test scandevices() one dev', function()
uci:set('wireless', 'radio0', 'wifi-device')
uci:set('wireless', 'radio0', 'hwmode', '11a')
uci:set('wireless', 'radio0', 'band', '5g')
uci:commit('wireless')
iwinfo.fake.load_from_uci(uci)

Expand All @@ -41,9 +41,9 @@ describe('LiMe Wireless tests #wireless', function()

it('test scandevices() two devs same band', function()
uci:set('wireless', 'radio0', 'wifi-device')
uci:set('wireless', 'radio0', 'hwmode', '11a')
uci:set('wireless', 'radio0', 'band', '5g')
uci:set('wireless', 'radio1', 'wifi-device')
uci:set('wireless', 'radio1', 'hwmode', '11a')
uci:set('wireless', 'radio1', 'band', '5g')

uci:commit('wireless')
iwinfo.fake.load_from_uci(uci)
Expand All @@ -58,9 +58,9 @@ describe('LiMe Wireless tests #wireless', function()

it('test scandevices() two devs same band inverted order', function()
uci:set('wireless', 'radio1', 'wifi-device')
uci:set('wireless', 'radio1', 'hwmode', '11a')
uci:set('wireless', 'radio1', 'band', '5g')
uci:set('wireless', 'radio0', 'wifi-device')
uci:set('wireless', 'radio0', 'hwmode', '11a')
uci:set('wireless', 'radio0', 'band', '5g')

uci:commit('wireless')
iwinfo.fake.load_from_uci(uci)
Expand All @@ -75,11 +75,11 @@ describe('LiMe Wireless tests #wireless', function()

it('test scandevices() tho devs 5ghz, 1 dev 2ghz', function()
uci:set('wireless', 'radio0', 'wifi-device')
uci:set('wireless', 'radio0', 'hwmode', '11g')
uci:set('wireless', 'radio0', 'band', '2g')
uci:set('wireless', 'radio1', 'wifi-device')
uci:set('wireless', 'radio1', 'hwmode', '11a')
uci:set('wireless', 'radio1', 'band', '5g')
uci:set('wireless', 'radio2', 'wifi-device')
uci:set('wireless', 'radio2', 'hwmode', '11a')
uci:set('wireless', 'radio2', 'band', '5g')

uci:commit('wireless')
iwinfo.fake.load_from_uci(uci)
Expand Down Expand Up @@ -123,7 +123,7 @@ describe('LiMe Wireless tests #wireless', function()

it('test configure() with distance', function()
uci:set('wireless', 'radio0', 'wifi-device')
uci:set('wireless', 'radio0', 'hwmode', '11a')
uci:set('wireless', 'radio0', 'band', '5g')
uci:commit('wireless')
iwinfo.fake.load_from_uci(uci)

Expand All @@ -148,7 +148,7 @@ describe('LiMe Wireless tests #wireless', function()
-- a specific radio config has precedence over the non specifc radio configs
-- specific radio distance_5ghz > specific radio distance > generic distance_5ghz > generic distance
uci:set('wireless', 'radio0', 'wifi-device')
uci:set('wireless', 'radio0', 'hwmode', '11a')
uci:set('wireless', 'radio0', 'band', '5g')
uci:commit('wireless')
iwinfo.fake.load_from_uci(uci)

Expand All @@ -168,9 +168,9 @@ describe('LiMe Wireless tests #wireless', function()

it('test configure() some options', function()
uci:set('wireless', 'radio0', 'wifi-device')
uci:set('wireless', 'radio0', 'hwmode', '11a')
uci:set('wireless', 'radio0', 'band', '5g')
uci:set('wireless', 'radio1', 'wifi-device')
uci:set('wireless', 'radio1', 'hwmode', '11a')
uci:set('wireless', 'radio1', 'band', '5g')
uci:commit('wireless')
iwinfo.fake.load_from_uci(uci)

Expand All @@ -192,7 +192,7 @@ describe('LiMe Wireless tests #wireless', function()

it('test configure() specific radio as client', function()
uci:set('wireless', 'radio0', 'wifi-device')
uci:set('wireless', 'radio0', 'hwmode', '11a')
uci:set('wireless', 'radio0', 'band', '5g')
uci:commit('wireless')
iwinfo.fake.load_from_uci(uci)

Expand Down
6 changes: 3 additions & 3 deletions packages/ubus-lime-utils/tests/test_hotspot_wwan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function config_uci_hotspot_radio()
uci:set('wireless', 'radio0', 'wifi-device')
uci:set('wireless', 'radio0', 'type', 'mac80211')
uci:set('wireless', 'radio0', 'channel', '4')
uci:set('wireless', 'radio0', 'hwmode', '11a')
uci:set('wireless', 'radio0', 'band', '5g')
uci:set('wireless', 'radio0', 'macaddr', '01:23:45:67:89:AB')
uci:set('wireless', 'radio0', 'disabled', '0')

Expand Down Expand Up @@ -92,7 +92,7 @@ describe('hotspot_wwan tests #hotspot_wwan', function()
uci:set('wireless', 'radio0', 'wifi-device')
uci:set('wireless', 'radio0', 'type', 'mac80211')
uci:set('wireless', 'radio0', 'channel', '4')
uci:set('wireless', 'radio0', 'hwmode', '11a')
uci:set('wireless', 'radio0', 'band', '5g')
uci:set('wireless', 'radio0', 'macaddr', '01:23:45:67:89:AB')
uci:set('wireless', 'radio0', 'disabled', '0')
uci:commit('wireless')
Expand All @@ -105,7 +105,7 @@ describe('hotspot_wwan tests #hotspot_wwan', function()
uci:set('wireless', 'radio0', 'wifi-device')
uci:set('wireless', 'radio0', 'type', 'mac80211')
uci:set('wireless', 'radio0', 'channel', '4')
uci:set('wireless', 'radio0', 'hwmode', '11a')
uci:set('wireless', 'radio0', 'band', '5g')
uci:set('wireless', 'radio0', 'macaddr', '01:23:45:67:89:AB')
uci:set('wireless', 'radio0', 'disabled', '0')

Expand Down
8 changes: 4 additions & 4 deletions packages/wifi-unstuck-wa/tests/uci_wireless
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
config wifi-device 'radio0'
option type 'mac80211'
option channel '11'
option hwmode '11g'
option band '2g'
option path 'platform/qca955x_wmac'
option htmode 'HT20'
option disabled '0'
Expand All @@ -10,7 +10,7 @@ config wifi-device 'radio0'

config wifi-device 'radio1'
option type 'mac80211'
option hwmode '11a'
option band '5g'
option path 'pci0000:00/0000:00:00.0'
option disabled '0'
option distance '1000'
Expand All @@ -20,7 +20,7 @@ config wifi-device 'radio1'

config wifi-device 'radio2'
option type 'mac80211'
option hwmode '11a'
option band '5g'
option path 'pci0000:01/0000:01:00.0'
option disabled '0'
option distance '1000'
Expand All @@ -30,7 +30,7 @@ config wifi-device 'radio2'

config wifi-device 'radio3'
option type 'mac80211'
option hwmode '11a'
option band '5g'
option path 'pci0000:02/0000:01:00.0'
option disabled '1'
option distance '1000'
Expand Down
43 changes: 4 additions & 39 deletions tests/devices/librerouter-v1/board.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,14 @@
},
"network" : {
"lan" : {
"ifname" : "eth1.2",
"ports" : [
"lan1"
],
"protocol" : "static"
},
"wan" : {
"ifname" : "eth0.1",
"device" : "wan",
"protocol" : "dhcp"
}
},
"switch" : {
"switch0" : {
"enable" : true,
"reset" : true,
"ports" : [
{
"num" : 0,
"device" : "eth0",
"need_tag" : false,
"want_untag" : false
},
{"num" : 5, "role" : "wan"},
{
"num" : 6,
"device" : "eth1",
"need_tag" : false,
"want_untag" : false
},
{"num" : 1, "role" : "lan"},
{"num" : 2, "role" : "lan"},
{"num" : 3, "role" : "lan"},
{"num" : 4, "role" : "lan"},
],
"roles" : [
{
"role" : "wan",
"ports" : "5 0t",
"device" : "eth0.1"
},
{
"role" : "lan",
"ports" : "1 2 3 4 6t",
"device" : "eth1.2"
}
]
}
}
}
27 changes: 8 additions & 19 deletions tests/devices/librerouter-v1/uci_config_network
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,25 @@ config interface 'loopback'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'

config device
option name 'br-lan'
option type 'bridge'
list ports 'lan1'

config globals 'globals'
option ula_prefix 'auto'

config interface 'lan'
option type 'bridge'
option ifname 'eth1.2'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'

config interface 'wan'
option ifname 'eth0.1'
option device 'wan'
option proto 'dhcp'

config interface 'wan6'
option ifname 'eth0.1'
option device 'wan'
option proto 'dhcpv6'

config switch
option name 'switch0'
option reset '1'
option enable_vlan '1'

config switch_vlan
option device 'switch0'
option vlan '1'
option ports '5 0t'

config switch_vlan
option device 'switch0'
option vlan '2'
option ports '1 2 3 4 6t'
Loading