gluon-core: create interfaces for each "port" in /etc/config/gluon
This commit enables (migration-safe) role assignment for individual "lan" and "wan" interfaces. This is helpful especially on devices with multiple "lan" or "wan" interfaces (as they appear for devices with DSA support). For interfaces in /lib/gluon/lan_ifname, we now create individual entries in /etc/config/gluon using the "/lan[0]", "/lan[1]", ... syntax (introduced in the last commit). Before this commit, all interfaces were referenced in a single interface "/lan" in /etc/config/gluon. The same is done for wan_ifname and single_ifname. Migration strategy: If new interfaces show up during gluon-reconfigure, the assigned roles of prior existing interfaces in the same category will be applied to the new interface.
This commit is contained in:
parent
2ab006190a
commit
3ab880352e
@ -52,14 +52,35 @@ local interfaces = {
|
||||
single = sysconfig.single_ifname,
|
||||
}
|
||||
|
||||
for iface in pairs(interfaces) do
|
||||
local section_name = 'iface_' .. iface
|
||||
for iface, ifnames in pairs(interfaces) do
|
||||
local default_roles = roles[iface]
|
||||
|
||||
-- migration from intermediate gluon master
|
||||
local section_name_old = 'iface_' .. iface
|
||||
if uci:get('gluon', section_name_old) then
|
||||
default_roles = uci:get('gluon', section_name_old, 'role')
|
||||
uci:delete('gluon', section_name_old)
|
||||
end
|
||||
|
||||
local interface_count = 1
|
||||
if type(ifnames) == 'table' then
|
||||
interface_count = #ifnames
|
||||
end
|
||||
|
||||
for i = 0, interface_count-1 do
|
||||
local section_name = 'iface_' .. iface .. '_' .. tostring(i)
|
||||
|
||||
if not uci:get('gluon', section_name) then
|
||||
uci:section('gluon', 'interface', section_name, {
|
||||
-- / prefix refers to sysconfig ifnames
|
||||
name = '/' .. iface,
|
||||
role = roles[iface],
|
||||
name = '/' .. iface .. '[' .. tostring(i) .. ']',
|
||||
role = default_roles,
|
||||
})
|
||||
else
|
||||
-- In case we have existing interfaces in that category, we want to
|
||||
-- use their roles as default for other new interfaces in that category.
|
||||
default_roles = uci:get('gluon', section_name, 'role')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user