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

Support Babeld without VLAN on ethernet interfaces inside br-lan #600

Closed
wants to merge 9 commits into from
1 change: 1 addition & 0 deletions packages/lime-docs/files/lime-example
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ config lime network
option bmx7_over_batman false
option bmx7_pref_gw none # Force bmx7 to use a specific gateway to Internet (hostname must be used as identifier)
option bmx7_wifi_rate_max 'auto'
option babeld_over_batman false # When Babeld is run without VLAN (babeld:0), it runs on the bridge which includes Batman-adv's bat0, keeping this false avoids to have Babeld metrics distorted by Batman-adv
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilario When someone would want to change from false to true ? If there is not known useful use case I prefer not to add more options.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you, and I'll remove this.
I added this originally just because the same was present for BMX6 over Batman-adv

option anygw_mac 'aa:aa:aa:%N1:%N2:aa' # Parametrizable with %Nn. Keep in mind that the ebtables rule will use a mask of ff:ff:ff:00:00:00 so br-lan will not forward anything coming in that matches the first 3 bytes of it's own anygw_mac (aa:aa:aa: by default)
# option autoap_enabled 0 # Requires lime-ap-watchping installed. If enabled AP SSID is changed to ERROR when network issues
# option autoap_hosts "8.8.8.8 141.1.1.1" # Requires lime-ap-watchping installed. Hosts used to check if the network is working fine
Expand Down
2 changes: 1 addition & 1 deletion packages/lime-proto-anygw/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ define Package/$(PKG_NAME)
URL:=http://libremesh.org
DEPENDS:=+dnsmasq-dhcpv6 @(!PACKAGE_dnsmasq) +ebtables +libuci-lua \
+lime-system +lua +kmod-ebtables +kmod-macvlan \
+shared-state +shared-state-dnsmasq_leases
+shared-state +shared-state-dnsmasq_leases +kmod-ebtables-ipv6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't you fixed this in another PR? here it seems unrelated

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That kernel module is needed both by anygw (see #599) and Babeld in case of no VLAN and presence of Batman.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gosh, now I noticed that this file was actually not pertaining to this PR, sorry.

PKGARCH:=all
endef

Expand Down
2 changes: 1 addition & 1 deletion packages/lime-proto-babeld/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 +PACKAGE_lime-proto-batadv:kmod-ebtables-ipv6
PKGARCH:=all
endef

Expand Down
49 changes: 43 additions & 6 deletions packages/lime-proto-babeld/files/usr/lib/lua/lime/proto/babeld.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,54 @@ function babeld.setup_interface(ifname, args)
local vlanProto = args[3] or "8021ad"
local nameSuffix = args[4] or "_babeld"

local addIPtoIf = true

--! If Babeld is without VLAN (vlanId is 0) it cannot run directly
--! on ethernet interfaces which are inside of a bridge (e.g. eth0 or eth0.1)
--! because they cannot have an IPv6 Link-Local, so Babeld has to run on
--! the bridge interface br-lan
--! If Babeld's Hello packets run over Batman-adv (whose bat0 is also
--! included in br-lan), the links will have a wrong quality metric,
--! so these hello on bat0 have to be filtered
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not that they have a wrong quality metric, it's that babeld will see all nodes as direct neighbours through batman

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mh... Isn't this the same? But ok, I'll change the text :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no it is not the same

if tonumber(vlanId) == 0 then
local hasBatman = false
local babeldOverBatman = config.get_bool("network", "babeld_over_batman")
local hasLan = false
for _,protoArgs in pairs(config.get("network", "protocols")) do
local proto = utils.split(protoArgs, network.protoParamsSeparator)[1]
if(proto == "lan") then hasLan = true
elseif(proto == "batadv") then hasBatman = true end
end

if hasLan and ifname:match("^eth%d") then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens with wan port? Or port manually configured with ground routing?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also consider to move this to configure method as it don't seems to need to be run for each interface, run it once seems enough

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens with wan port?

Woops... With this PR, WAN port is not anymore used by Babeld.
This was unintentional, sorry.
Anyway WAN port is used for connecting to non-LibreMesh networks, so Babeld is not needed there.
I am ok with fixing it if we want Babeld on WAN.
Rather than checking for lan protocol, I can check for the presence of the interface into the

config interface 'lan'
	list ifname 'bat0'
	list ifname 'eth0.1'

table.

Or port manually configured with ground routing?

Ports configured with specific configuration are not treated by the whole section.
Do you mean that even if ground routing ports have a specific configuration, they should trigger this fix anyway? Are them included into br-lan bridge?

Also consider to move this to configure method as it don't seems to need to be run for each interface, run it once seems enough

Sounds good!
Currently it runs more than once even if running once would be ok.
Running more than once is not detrimental but I agree that it is a waste.
If I put this into the configure, it would be executed even if no ethernet lan port is present, but I suppose this is ok, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also consider to move this to configure method as it don't seems to need to be run for each interface, run it once seems enough

If I put this into the configure, it would be executed even if no ethernet lan port is present, but I suppose this is ok, right?

Wait, the ebtables rule can be in the configuration part, but the ifname = "br-lan" stuff has to stay into the setup interface one...
This is a mess.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ports configured with specific configuration are not treated by the whole section.
Do you mean that even if ground routing ports have a specific configuration, they should trigger this fix anyway? Are them included into br-lan bridge?

It all depends on what kind of configuration they got, if they have babled specified as proto they get there too

Copy link
Member

@G10h4ck G10h4ck Sep 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a mess.

Networking is a complex problem, every apparently dumb change usually have unexpectedly complex implications to handle

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ports configured with specific configuration are not treated by the whole section.

I was wrong, interfaces with specific configuration are treated by this section.

Do you mean that even if ground routing ports have a specific configuration, they should trigger this fix anyway? Are them included into br-lan bridge?

The answer to my question was: no, interfaces configured via ground routing should not be touched by this fix and they will never be included in br-lan.

It all depends on what kind of configuration they got, if they have babled specified as proto they get there too

Interfaces managed by ground routing will never have VLAN ID 0, right? If this is correct, they will never trigger the fix and the problem is solved. Otherwise, how can I check if the interface is also configured for ground routing?

ifname = "br-lan"
addIPtoIf = false
if hasBatman and not babeldOverBatman then
ifname = "br-lan"
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
end

local owrtInterfaceName, linuxVlanIfName, owrtDeviceName =
network.createVlanIface(ifname, vlanId, nameSuffix, vlanProto)

local ipv4, _ = network.primary_address()

local uci = config.get_uci_cursor()

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()

uci:set("network", owrtInterfaceName, "ifname", "@"..owrtDeviceName)
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ config lime network
option bmx7_over_batman false
option bmx7_pref_gw none
option bmx7_wifi_rate_max 'auto'
option babeld_over_batman false
option anygw_mac "aa:aa:aa:%N1:%N2:aa"
option use_odhcpd false

Expand Down