Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bridge device section confusion #1061

Merged
merged 1 commit into from
Oct 22, 2023
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
21 changes: 16 additions & 5 deletions packages/lime-system/files/usr/lib/lua/lime/proto/lan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,21 @@ function lan.setup_interface(ifname, args)

local uci = config.get_uci_cursor()
local bridgedIfs = {}
-- here we bet that the first device section is the bridge one,
-- as it does not have a name for addressing it
local oldIfs = uci:get("network", "@device[0]", "ports") or {}
-- here we bet that there is a device section of type bridge named
-- br-lan
local bridge_section = nil
uci:foreach("network", "device",
function(s)
if bridge_section then return end
local dev_type = uci:get("network", s[".name"], "type")
local dev_name = uci:get("network", s[".name"], "name")
if not (dev_type == 'bridge') then return end
if not (dev_name == 'br-lan') then return end
bridge_section = s[".name"]
end
)
if not bridge_section then return end
local oldIfs = uci:get("network", bridge_section, "ports") or {}
-- it should be a table, it was a string in old OpenWrt releases
if type(oldIfs) == "string" then oldIfs = utils.split(oldIfs, " ") end
for _,iface in pairs(oldIfs) do
Expand All @@ -59,8 +71,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:set("network", bridge_section, "ports", bridgedIfs)
uci:save("network")
end

Expand Down
5 changes: 5 additions & 0 deletions packages/lime-system/tests/test_lime_network.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ describe('LiMe Network tests', function()
stub(utils, "getBoardAsTable", function () return BOARD end)
stub(network, "assert_interface_exists", function () return true end)

bridge_section = uci:add("network", "device")
uci:set("network", bridge_section, "type", "bridge")
uci:set("network", bridge_section, "name", "br-lan")
uci:commit("network")

network.configure()

assert.is.equal("1500", uci:get("network", "lan", "mtu"))
Expand Down
Loading