daemon: renamed network variables to not be named in a private way, since they were being used externally
This commit is contained in:
parent
30291a8438
commit
11d8bb0674
3 changed files with 26 additions and 26 deletions
|
@ -408,8 +408,8 @@ class BasicRangeModel(WirelessModel):
|
||||||
a = min(iface, iface2)
|
a = min(iface, iface2)
|
||||||
b = max(iface, iface2)
|
b = max(iface, iface2)
|
||||||
|
|
||||||
with self.wlan._linked_lock:
|
with self.wlan.linked_lock:
|
||||||
linked = self.wlan.linked(a, b)
|
linked = self.wlan.is_linked(a, b)
|
||||||
if d > self.range:
|
if d > self.range:
|
||||||
if linked:
|
if linked:
|
||||||
logger.debug("was linked, unlinking")
|
logger.debug("was linked, unlinking")
|
||||||
|
@ -508,10 +508,10 @@ class BasicRangeModel(WirelessModel):
|
||||||
:return: all link data
|
:return: all link data
|
||||||
"""
|
"""
|
||||||
all_links = []
|
all_links = []
|
||||||
with self.wlan._linked_lock:
|
with self.wlan.linked_lock:
|
||||||
for a in self.wlan._linked:
|
for a in self.wlan.linked:
|
||||||
for b in self.wlan._linked[a]:
|
for b in self.wlan.linked[a]:
|
||||||
if self.wlan._linked[a][b]:
|
if self.wlan.linked[a][b]:
|
||||||
all_links.append(self.create_link_data(a, b, flags))
|
all_links.append(self.create_link_data(a, b, flags))
|
||||||
return all_links
|
return all_links
|
||||||
|
|
||||||
|
|
|
@ -948,8 +948,8 @@ class CoreNetworkBase(NodeBase):
|
||||||
"""
|
"""
|
||||||
super().__init__(session, _id, name, server)
|
super().__init__(session, _id, name, server)
|
||||||
self.brname: Optional[str] = None
|
self.brname: Optional[str] = None
|
||||||
self._linked: Dict[CoreInterface, Dict[CoreInterface, bool]] = {}
|
self.linked: Dict[CoreInterface, Dict[CoreInterface, bool]] = {}
|
||||||
self._linked_lock: threading.Lock = threading.Lock()
|
self.linked_lock: threading.Lock = threading.Lock()
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def startup(self) -> None:
|
def startup(self) -> None:
|
||||||
|
@ -1018,8 +1018,8 @@ class CoreNetworkBase(NodeBase):
|
||||||
i = self.next_iface_id()
|
i = self.next_iface_id()
|
||||||
self.ifaces[i] = iface
|
self.ifaces[i] = iface
|
||||||
iface.net_id = i
|
iface.net_id = i
|
||||||
with self._linked_lock:
|
with self.linked_lock:
|
||||||
self._linked[iface] = {}
|
self.linked[iface] = {}
|
||||||
|
|
||||||
def detach(self, iface: CoreInterface) -> None:
|
def detach(self, iface: CoreInterface) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -1030,8 +1030,8 @@ class CoreNetworkBase(NodeBase):
|
||||||
"""
|
"""
|
||||||
del self.ifaces[iface.net_id]
|
del self.ifaces[iface.net_id]
|
||||||
iface.net_id = None
|
iface.net_id = None
|
||||||
with self._linked_lock:
|
with self.linked_lock:
|
||||||
del self._linked[iface]
|
del self.linked[iface]
|
||||||
|
|
||||||
def links(self, flags: MessageFlags = MessageFlags.NONE) -> List[LinkData]:
|
def links(self, flags: MessageFlags = MessageFlags.NONE) -> List[LinkData]:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -173,7 +173,7 @@ class NftablesQueue:
|
||||||
:param net: network to build commands for
|
:param net: network to build commands for
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
with net._linked_lock:
|
with net.linked_lock:
|
||||||
if net.has_nftables_chain:
|
if net.has_nftables_chain:
|
||||||
self.cmds.append(f"flush table bridge {net.brname}")
|
self.cmds.append(f"flush table bridge {net.brname}")
|
||||||
else:
|
else:
|
||||||
|
@ -190,7 +190,7 @@ class NftablesQueue:
|
||||||
f"ibriport != {net.brname} accept"
|
f"ibriport != {net.brname} accept"
|
||||||
)
|
)
|
||||||
# rebuild the chain
|
# rebuild the chain
|
||||||
for iface1, v in net._linked.items():
|
for iface1, v in net.linked.items():
|
||||||
for iface2, linked in v.items():
|
for iface2, linked in v.items():
|
||||||
policy = None
|
policy = None
|
||||||
if net.policy == NetworkPolicy.DROP and linked:
|
if net.policy == NetworkPolicy.DROP and linked:
|
||||||
|
@ -320,7 +320,7 @@ class CoreNetwork(CoreNetworkBase):
|
||||||
for iface in self.get_ifaces():
|
for iface in self.get_ifaces():
|
||||||
iface.shutdown()
|
iface.shutdown()
|
||||||
self.ifaces.clear()
|
self.ifaces.clear()
|
||||||
self._linked.clear()
|
self.linked.clear()
|
||||||
self.up = False
|
self.up = False
|
||||||
|
|
||||||
def attach(self, iface: CoreInterface) -> None:
|
def attach(self, iface: CoreInterface) -> None:
|
||||||
|
@ -345,7 +345,7 @@ class CoreNetwork(CoreNetworkBase):
|
||||||
iface.net_client.delete_iface(self.brname, iface.localname)
|
iface.net_client.delete_iface(self.brname, iface.localname)
|
||||||
super().detach(iface)
|
super().detach(iface)
|
||||||
|
|
||||||
def linked(self, iface1: CoreInterface, iface2: CoreInterface) -> bool:
|
def is_linked(self, iface1: CoreInterface, iface2: CoreInterface) -> bool:
|
||||||
"""
|
"""
|
||||||
Determine if the provided network interfaces are linked.
|
Determine if the provided network interfaces are linked.
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ class CoreNetwork(CoreNetworkBase):
|
||||||
if self.ifaces[iface2.net_id] != iface2:
|
if self.ifaces[iface2.net_id] != iface2:
|
||||||
raise ValueError(f"inconsistency for interface {iface2.name}")
|
raise ValueError(f"inconsistency for interface {iface2.name}")
|
||||||
try:
|
try:
|
||||||
linked = self._linked[iface1][iface2]
|
linked = self.linked[iface1][iface2]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
if self.policy == NetworkPolicy.ACCEPT:
|
if self.policy == NetworkPolicy.ACCEPT:
|
||||||
linked = True
|
linked = True
|
||||||
|
@ -367,7 +367,7 @@ class CoreNetwork(CoreNetworkBase):
|
||||||
linked = False
|
linked = False
|
||||||
else:
|
else:
|
||||||
raise Exception(f"unknown policy: {self.policy.value}")
|
raise Exception(f"unknown policy: {self.policy.value}")
|
||||||
self._linked[iface1][iface2] = linked
|
self.linked[iface1][iface2] = linked
|
||||||
return linked
|
return linked
|
||||||
|
|
||||||
def unlink(self, iface1: CoreInterface, iface2: CoreInterface) -> None:
|
def unlink(self, iface1: CoreInterface, iface2: CoreInterface) -> None:
|
||||||
|
@ -378,10 +378,10 @@ class CoreNetwork(CoreNetworkBase):
|
||||||
:param iface2: interface two
|
:param iface2: interface two
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
with self._linked_lock:
|
with self.linked_lock:
|
||||||
if not self.linked(iface1, iface2):
|
if not self.is_linked(iface1, iface2):
|
||||||
return
|
return
|
||||||
self._linked[iface1][iface2] = False
|
self.linked[iface1][iface2] = False
|
||||||
nft_queue.update(self)
|
nft_queue.update(self)
|
||||||
|
|
||||||
def link(self, iface1: CoreInterface, iface2: CoreInterface) -> None:
|
def link(self, iface1: CoreInterface, iface2: CoreInterface) -> None:
|
||||||
|
@ -393,10 +393,10 @@ class CoreNetwork(CoreNetworkBase):
|
||||||
:param iface2: interface two
|
:param iface2: interface two
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
with self._linked_lock:
|
with self.linked_lock:
|
||||||
if self.linked(iface1, iface2):
|
if self.is_linked(iface1, iface2):
|
||||||
return
|
return
|
||||||
self._linked[iface1][iface2] = True
|
self.linked[iface1][iface2] = True
|
||||||
nft_queue.update(self)
|
nft_queue.update(self)
|
||||||
|
|
||||||
def linkconfig(
|
def linkconfig(
|
||||||
|
@ -503,8 +503,8 @@ class CoreNetwork(CoreNetworkBase):
|
||||||
iface.net_client.set_iface_master(net.brname, iface.name)
|
iface.net_client.set_iface_master(net.brname, iface.name)
|
||||||
i = net.next_iface_id()
|
i = net.next_iface_id()
|
||||||
net.ifaces[i] = iface
|
net.ifaces[i] = iface
|
||||||
with net._linked_lock:
|
with net.linked_lock:
|
||||||
net._linked[iface] = {}
|
net.linked[iface] = {}
|
||||||
iface.net = self
|
iface.net = self
|
||||||
iface.othernet = net
|
iface.othernet = net
|
||||||
return iface
|
return iface
|
||||||
|
|
Loading…
Reference in a new issue