Support changing the VLAN tag on WAN

This commit is contained in:
Tim Wilkinson 2022-04-16 16:32:23 -07:00 committed by Joe AE6XE
parent d707ca89ac
commit 7b77f111ce
4 changed files with 43 additions and 11 deletions

View File

@ -90,7 +90,7 @@ local dtdmac = mac_to_ip(aredn.hardware.get_interface_mac(lanintf:match("^(%S+)"
local deleteme = {} local deleteme = {}
local cfg = { local cfg = {
lan_intf = lanintf, lan_intf = lanintf,
wan_intf = "dummy", wan_intf = aredn.hardware.get_board().network.wan.ifname,
dtdlink_intf = aredn.hardware.get_bridge_iface_names('dtdlink') dtdlink_intf = aredn.hardware.get_bridge_iface_names('dtdlink')
} }

View File

@ -55,14 +55,6 @@ done < $configfile
meshif="$(uci -q get network.wifi.ifname)" meshif="$(uci -q get network.wifi.ifname)"
meshphy="phy${meshif#wlan}" meshphy="phy${meshif#wlan}"
# set physical wan interface in network
wan_intf=`cat /etc/board.json|jsonfilter -e '@.network.wan.ifname'`
uci -c ${dropdir} -q batch > /dev/null <<-EOF
set network.wan.ifname="$wan_intf"
EOF
uci -c ${dropdir} -q commit network
rm -f "${dropdir}/wireless" rm -f "${dropdir}/wireless"
touch "${dropdir}/wireless" touch "${dropdir}/wireless"

View File

@ -196,7 +196,8 @@ local settings = {
key = "aredn.@tunnel[0].wanonly", key = "aredn.@tunnel[0].wanonly",
type = "boolean", type = "boolean",
desc = "Prevents tunnel traffic from being routed over the mesh network itself.", desc = "Prevents tunnel traffic from being routed over the mesh network itself.",
default = "1" default = "1",
needreboot= true
}, },
{ {
key = "aredn.@meshstatus[0].lowmem", key = "aredn.@meshstatus[0].lowmem",
@ -210,6 +211,14 @@ local settings = {
desc = "When low memory is detected, limit the number of routes shown on the mesh status page", desc = "When low memory is detected, limit the number of routes shown on the mesh status page",
default = "1000" default = "1000"
}, },
{
key = "network.wan.ifname",
type = "string",
desc = "Specify WAN interface VLAN #. MUST be entered as ethX.YY where X is the interface (usually '0') and YY is the VLAN # to use.",
default = "",
postcallback = "postChangeWANVLAN()",
needreboot = true
},
{ {
key = "aredn.olsr.restart", key = "aredn.olsr.restart",
type = "none", type = "none",
@ -234,7 +243,8 @@ local settings = {
key = "aredn.@alerts[0].pollrate", key = "aredn.@alerts[0].pollrate",
type = "string", type = "string",
desc = "Specifies how many hours to wait between polling for new AREDN Alerts.", desc = "Specifies how many hours to wait between polling for new AREDN Alerts.",
default = "12" default = "12",
needreboot = true
}, },
{ {
key = "aredn.aam.purge", key = "aredn.aam.purge",
@ -446,6 +456,28 @@ function adjustTunnelInterfaceCount()
end end
end end
function postChangeWANVLAN()
local lines = {}
for line in io.lines("/etc/config.mesh/_setup")
do
if not line:match("^wan_intf = ") then
lines[#lines + 1] = line
end
end
if newval ~= "" then
lines[#lines + 1] = "wan_intf = " .. newval
end
local f = io.open("/etc/config.mesh/_setup", "w")
if f then
for _, line in ipairs(lines)
do
f:write(line .. "\n")
end
f:close()
end
os.execute("/usr/local/bin/node-setup -a mesh")
end
-- read_postdata -- read_postdata
local parms = {} local parms = {}
if os.getenv("REQUEST_METHOD") == "POST" then if os.getenv("REQUEST_METHOD") == "POST" then
@ -496,6 +528,9 @@ do
if setting.postcallback then if setting.postcallback then
loadstring(setting.postcallback)() loadstring(setting.postcallback)()
end end
if setting.needreboot then
io.open("/tmp/reboot-required", "w"):close()
end
break break
end end
end end
@ -605,6 +640,10 @@ html.print("</td></tr>")
html.print("<tr><td align=center><a href='/help.html#advancedconfig' target='_blank'>Help</a>&nbsp;&nbsp;<input type=submit name=button_reboot value=Reboot style='font-weight:bold' title='Immediately reboot this node'>&nbsp;&nbsp;<input type=submit name=button_firstboot value='Reset to Firstboot' onclick=\"return confirm('All config settings and add-on packages will be lost back to first boot state. Continue?')\" title='Reset this node to the initial/firstboot status and reboot.'></td></tr>") html.print("<tr><td align=center><a href='/help.html#advancedconfig' target='_blank'>Help</a>&nbsp;&nbsp;<input type=submit name=button_reboot value=Reboot style='font-weight:bold' title='Immediately reboot this node'>&nbsp;&nbsp;<input type=submit name=button_firstboot value='Reset to Firstboot' onclick=\"return confirm('All config settings and add-on packages will be lost back to first boot state. Continue?')\" title='Reset this node to the initial/firstboot status and reboot.'></td></tr>")
if nixio.fs.stat("/tmp/reboot-required") then
html.print("<tr><td align=center><h3>Reboot is required for changes to take effect</h3></td></tr>")
end
for _, m in ipairs(msgs) for _, m in ipairs(msgs)
do do
html.print("<tr><td align='center'><strong>" .. m .. "</strong></td></tr>") html.print("<tr><td align='center'><strong>" .. m .. "</strong></td></tr>")

View File

@ -1310,6 +1310,7 @@ html.print("</select></td><td align=left>NTP Server</td><td><input type=text nam
hidden[#hidden + 1] = "<input type=hidden name=reload value=1>" hidden[#hidden + 1] = "<input type=hidden name=reload value=1>"
hidden[#hidden + 1] = "<input type=hidden name=dtdlink_ip value='" .. dtdlink_ip .. "'>" hidden[#hidden + 1] = "<input type=hidden name=dtdlink_ip value='" .. dtdlink_ip .. "'>"
hidden[#hidden + 1] = "<input type=hidden name=wan_intf value='" .. (wan_intf or "") .. "'>"
for _,hid in ipairs(hidden) for _,hid in ipairs(hidden)
do do