-
Notifications
You must be signed in to change notification settings - Fork 96
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
Support Babeld without VLAN on ethernet interfaces inside br-lan, replaces #600 #631
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ define Package/$(PKG_NAME) | |
CATEGORY:=LiMe | ||
MAINTAINER:=Gioacchino Mazzurco <[email protected]> | ||
URL:=https://libremesh.org | ||
DEPENDS:=+babeld +lime-system | ||
DEPENDS:=+babeld +lime-system +kmod-ebtables-ipv6 | ||
PKGARCH:=all | ||
endef | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,18 @@ function babeld.configure(args) | |
|
||
uci:save("libremap") | ||
|
||
--! If Babeld's Hello packets run over Batman-adv (whose bat0 is also | ||
--! included in br-lan), all the Babeld nodes would appear as being direct | ||
--! neighbors, so these Hello packets on bat0 have to be filtered | ||
local babeldOverBatman = config.get_bool("network", "babeld_over_batman") | ||
if utils.is_installed("kmod-batman-adv") and not babeldOverBatman then | ||
fs.mkdir("/etc/firewall.lime.d") | ||
fs.writefile("/etc/firewall.lime.d/21-babeld-not-over-bat0-ebtables", | ||
"ebtables -t nat -A POSTROUTING -o bat0 -p ipv6".. | ||
" --ip6-proto udp --ip6-sport 6696 --ip6-dport 6696 -j DROP\n") | ||
else | ||
fs.remove("/etc/firewall.lime.d/21-babeld-not-over-bat0-ebtables") | ||
end | ||
end | ||
|
||
function babeld.setup_interface(ifname, args) | ||
|
@@ -99,25 +111,74 @@ function babeld.setup_interface(ifname, args) | |
|
||
utils.log("lime.proto.babeld.setup_interface(...)", ifname) | ||
|
||
local vlanId = args[2] or 17 | ||
local vlanId = tonumber(args[2]) or 17 | ||
local vlanProto = args[3] or "8021ad" | ||
local nameSuffix = args[4] or "_babeld" | ||
|
||
|
||
--! If Babeld is without VLAN (vlanId is 0) it should run directly on plain | ||
--! ethernet interfaces, but the ones which are inside of the LAN bridge | ||
--! (e.g. eth0 or eth0.1) cannot have an IPv6 Link-Local and Babeld needs it. | ||
--! So Babeld has to run on the bridge interface br-lan | ||
local isIntoLAN = false | ||
local addIPtoIf = true | ||
for _,v in pairs(args["deviceProtos"]) do | ||
if v == "lan" then | ||
isIntoLAN = true | ||
--! would be weird to add a static IP to the WAN interface | ||
elseif v == "wan" then | ||
addIPtoIf = false | ||
end | ||
end | ||
|
||
if ifname:match("^wlan") then | ||
--! currently (2019-10-12) mode-ap and mode-apname have an hardcoded | ||
--! "option network lan" so they are always in the br-lan bridge | ||
if ifname:match("^wlan.*ap$") or ifname:match("^wlan.*apname$") then | ||
isIntoLAN = true | ||
|
||
--! all the WLAN interfaces are ignored by proto-lan | ||
--! so they are not in the bridge even if proto-lan is present | ||
--! (except mode-ap and mode-apname as mentioned above) | ||
else | ||
isIntoLAN = false | ||
end | ||
end | ||
|
||
if vlanId == 0 and isIntoLAN then | ||
utils.log("Rather than "..ifname.. | ||
", adding br-lan into Babeld interfaces") | ||
ifname = "br-lan" | ||
--! br-lan has already an IPv4, no need to add it | ||
addIPtoIf = false | ||
end | ||
|
||
local owrtInterfaceName, linuxVlanIfName, owrtDeviceName = | ||
network.createVlanIface(ifname, vlanId, nameSuffix, vlanProto) | ||
|
||
local ipv4, _ = network.primary_address() | ||
|
||
local uci = config.get_uci_cursor() | ||
|
||
if(vlanId ~= 0 and ifname:match("^eth")) then | ||
uci:set("network", owrtDeviceName, "mtu", tostring(network.MTU_ETH_WITH_VLAN)) | ||
end | ||
|
||
uci:set("network", owrtInterfaceName, "proto", "static") | ||
uci:set("network", owrtInterfaceName, "ipaddr", ipv4:host():string()) | ||
uci:set("network", owrtInterfaceName, "netmask", "255.255.255.255") | ||
uci:save("network") | ||
if addIPtoIf then | ||
local ipv4, _ = network.primary_address() | ||
--! the "else" way should always work but it fails in a weird way | ||
--! with some wireless interfaces without VLAN | ||
--! (e.g. works with wlan0-mesh and fails with wlan1-mesh) | ||
--! so for these cases, the first way is used | ||
--! (which indeed fails for most of the other cases) | ||
if ifname:match("^wlan") and tonumber(vlanId) == 0 then | ||
uci:set("network", owrtInterfaceName, "ifname", "@"..owrtDeviceName) | ||
else | ||
uci:set("network", owrtInterfaceName, "ifname", linuxVlanIfName) | ||
end | ||
Comment on lines
+172
to
+176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @spiccinini @G10h4ck @nicopace @gmarcos87 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is not a new issue, we have workarounds for similar thing in other places of the code, it seems that when one uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did test it on 5 different routers (listed in the first comment in the PR), but more testing would also be nice to have :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I just added back the babeld_over_batman option, I just took the code for it from #600 so it should work (not tested now, but I tested some times ago in the previous PR). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @spiccinini could you test this on LibreRouter? Two scenarios should be tested: with VLAN and without VLAN. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I used the code from this PR (rebased to master). Maybe I did a mistake. I deleted both /etc/config wireless and network, regenerated them with generate_config, then lime-config and lime-apply, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not familiar with config_generate and I never trusted lime-apply... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I don't delete the config the vlan 17 still exists after lime-config There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow... Even after the reboot? So something is failing baaaad. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did more testing and for me it works. Can you confirm that it fails with LibreRouter or with your compilation procedure? |
||
uci:set("network", owrtInterfaceName, "proto", "static") | ||
uci:set("network", owrtInterfaceName, "ipaddr", ipv4:host():string()) | ||
uci:set("network", owrtInterfaceName, "netmask", "255.255.255.255") | ||
uci:save("network") | ||
end | ||
|
||
uci:set("babeld", owrtInterfaceName, "interface") | ||
uci:set("babeld", owrtInterfaceName, "ifname", linuxVlanIfName) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the first part of this function there is the following code:
As far as I understand for ap and apname it won't reach this part of the code. Is it ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, by default the AP and APname interfaces are not used for the backbone and the routing.
For using an AP interface for routing with Babeld, APbb should be used, as implemented in #554 and documented in lime-example here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok maybe I am not understanding. In which conditions the program will get into the if of line 137?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean this if, right?
lime-packages/packages/lime-proto-babeld/files/usr/lib/lua/lime/proto/babeld.lua
Line 137 in a8369d9
It gets hit when an AP or an APname is configured using interface-specific configuration (some documentation on the website here) and babeld is also selected in the interface-specific configuration.
An example of a case where configuring an AP with interface-specific configuration is here in #262 (5 GHz radio used just for mesh and 2.4 GHz radio used for AP+APname+mesh, which cannot currently be done with general configuration).
Something like: (the non-specified options in the wifi sections are taken from the generic wifi configuration, see db1c350. I don't know if more options should be specified for the net sections?)
(beware, I did not test this example)