Merge pull request #311 from coreemu/feature/init-ebtables-for-wlan-only
feature/init-ebtables-for-wlan-only,
This commit is contained in:
commit
ea6ecc751d
1 changed files with 19 additions and 16 deletions
|
@ -181,7 +181,7 @@ class EbtablesQueue:
|
||||||
|
|
||||||
def ebchange(self, wlan):
|
def ebchange(self, wlan):
|
||||||
"""
|
"""
|
||||||
Flag a change to the given WLAN"s _linked dict, so the ebtables
|
Flag a change to the given WLAN's _linked dict, so the ebtables
|
||||||
chain will be rebuilt at the next interval.
|
chain will be rebuilt at the next interval.
|
||||||
|
|
||||||
:return: nothing
|
:return: nothing
|
||||||
|
@ -197,8 +197,17 @@ class EbtablesQueue:
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
with wlan._linked_lock:
|
with wlan._linked_lock:
|
||||||
|
if wlan.has_ebtables_chain:
|
||||||
# flush the chain
|
# flush the chain
|
||||||
self.cmds.append(f"-F {wlan.brname}")
|
self.cmds.append(f"-F {wlan.brname}")
|
||||||
|
else:
|
||||||
|
wlan.has_ebtables_chain = True
|
||||||
|
self.cmds.extend(
|
||||||
|
[
|
||||||
|
f"-N {wlan.brname} -P {wlan.policy}",
|
||||||
|
f"-A FORWARD --logical-in {wlan.brname} -j {wlan.brname}",
|
||||||
|
]
|
||||||
|
)
|
||||||
# rebuild the chain
|
# rebuild the chain
|
||||||
for netif1, v in wlan._linked.items():
|
for netif1, v in wlan._linked.items():
|
||||||
for netif2, linked in v.items():
|
for netif2, linked in v.items():
|
||||||
|
@ -297,14 +306,7 @@ class CoreNetwork(CoreNetworkBase):
|
||||||
:raises CoreCommandError: when there is a command exception
|
:raises CoreCommandError: when there is a command exception
|
||||||
"""
|
"""
|
||||||
self.net_client.create_bridge(self.brname)
|
self.net_client.create_bridge(self.brname)
|
||||||
|
self.has_ebtables_chain = False
|
||||||
# create a new ebtables chain for this bridge
|
|
||||||
cmds = [
|
|
||||||
f"{EBTABLES_BIN} -N {self.brname} -P {self.policy}",
|
|
||||||
f"{EBTABLES_BIN} -A FORWARD --logical-in {self.brname} -j {self.brname}",
|
|
||||||
]
|
|
||||||
ebtablescmds(self.host_cmd, cmds)
|
|
||||||
|
|
||||||
self.up = True
|
self.up = True
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
|
@ -320,6 +322,7 @@ class CoreNetwork(CoreNetworkBase):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.net_client.delete_bridge(self.brname)
|
self.net_client.delete_bridge(self.brname)
|
||||||
|
if self.has_ebtables_chain:
|
||||||
cmds = [
|
cmds = [
|
||||||
f"{EBTABLES_BIN} -D FORWARD --logical-in {self.brname} -j {self.brname}",
|
f"{EBTABLES_BIN} -D FORWARD --logical-in {self.brname} -j {self.brname}",
|
||||||
f"{EBTABLES_BIN} -X {self.brname}",
|
f"{EBTABLES_BIN} -X {self.brname}",
|
||||||
|
|
Loading…
Reference in a new issue