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