Skip to content

Commit c4d03e9

Browse files
committed
added client isolation package
1 parent e5edeb8 commit c4d03e9

File tree

6 files changed

+104
-0
lines changed

6 files changed

+104
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
include $(TOPDIR)/rules.mk
2+
3+
PKG_NAME:=gluon-client-isolation
4+
5+
include ../gluon.mk
6+
7+
define Package/gluon-client-isolation
8+
TITLE:=Support for client isolation over batman-adv
9+
DEPENDS:=+gluon-core +gluon-ebtables gluon-mesh-batman-adv
10+
endef
11+
12+
define Package/gluon-client-isolation/description
13+
This package provides client isolation in a batman-adv
14+
bridged layer 2 network.
15+
16+
To use it, mesh.isolate must be set in the site or
17+
domain configuration.
18+
19+
When it is set to wireless, wireless clients are isolated from
20+
other wireless clients, wireless to wired, wired to wireless
21+
and wire to wired traffic is not affected in this mode.
22+
23+
When it is set to all, wired traffic is also isolated.
24+
25+
To isolate the clients connected to the same wireless interface,
26+
it sets the isolate option in the wireless configuration for
27+
the client and owe wifi interfaces.
28+
29+
To extend the isolation the ap_isolation and isolation_mark
30+
options are set for the gluon_bat0 network interface.
31+
32+
A new filter chain ISOLATED is added to ebtables, through which
33+
all traffic of br-client is routed.
34+
Depending the value of mesh.isolate, the traffic is marked when
35+
it arrives from the interfaces to isolate and batman-adv
36+
restores the mark for isolated traffic from other nodes.
37+
The marked traffic will not be forwarded to isolated interfaces.
38+
endef
39+
40+
$(eval $(call BuildPackageGluon,gluon-client-isolation))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
chain('ISOLATED', 'ACCEPT')
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
local isolate = require('gluon.site').mesh.isolate("none")
2+
3+
if isolate == "all" then
4+
for _,dev in ipairs({ 'eth0', 'eth1', 'client0', 'client1', 'owe0', 'owe1' }) do
5+
rule('ISOLATED -i ' .. dev .. ' -j mark --mark-or 0x10 --mark-target CONTINUE')
6+
end
7+
end
8+
if isolate == "wireless" then
9+
for _,dev in ipairs({ 'client0', 'client1', 'owe0', 'owe1' }) do
10+
rule('ISOLATED -i ' .. dev .. ' -j mark --mark-or 0x10 --mark-target CONTINUE')
11+
end
12+
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
local isolate = require('gluon.site').mesh.isolate("none")
2+
3+
if isolate == "all" then
4+
for _,dev in ipairs({ 'eth0', 'eth1', 'client0', 'client1', 'owe0', 'owe1' }) do
5+
rule('ISOLATED -o ' .. dev .. ' --mark 0x10/0x10 -j DROP')
6+
end
7+
end
8+
if isolate == "wireless" then
9+
for _,dev in ipairs({ 'client0', 'client1', 'owe0', 'owe1' }) do
10+
rule('ISOLATED -o ' .. dev .. ' --mark 0x10/0x10 -j DROP')
11+
end
12+
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rule('FORWARD --logical-in br-client -j ISOLATED')
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/lua
2+
3+
local site = require 'gluon.site'
4+
local wireless = require 'gluon.wireless'
5+
6+
local isolate = site.mesh.isolate("none")
7+
8+
local uci = require('simple-uci').cursor()
9+
10+
wireless.foreach_radio(uci, function(radio)
11+
local radio_name = radio['.name']
12+
vif = 'client_' .. radio_name
13+
if uci:get('wireless', vif) then
14+
uci:delete('wireless', vif, 'isolate')
15+
if isolate == "all" or isolate == "wireless" then
16+
uci:set('wireless', vif, 'isolate', '1')
17+
end
18+
end
19+
vif = 'owe_' .. radio_name
20+
if uci:get('wireless', vif) then
21+
uci:delete('wireless', vif, 'isolate')
22+
if isolate == "all" or isolate == "wireless" then
23+
uci:set('wireless', vif, 'isolate', '1')
24+
end
25+
end
26+
end)
27+
28+
uci:save('wireless')
29+
30+
uci:delete('network', 'gluon_bat0', 'ap_isolation')
31+
uci:delete('network', 'gluon_bat0', 'isolation_mark')
32+
33+
if isolate == "all" or isolate == "wireless" then
34+
uci:set('network', 'gluon_bat0', 'ap_isolation', '1')
35+
uci:set('network', 'gluon_bat0', 'isolation_mark', '0x10/0x10')
36+
end
37+
38+
uci:save('network')

0 commit comments

Comments
 (0)