daemon: revert wlan mac learning change, due to undesired default behavior, there may be some cases where this behavior is desired, so the option to enable a promiscuous mode has been added and will be present in core-pygui
This commit is contained in:
parent
d1c2b1bdb9
commit
e7320a61a6
3 changed files with 23 additions and 6 deletions
|
@ -31,6 +31,9 @@ from core.nodes.network import WlanNode
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from core.emulator.session import Session
|
from core.emulator.session import Session
|
||||||
|
|
||||||
|
LEARNING_DISABLED: int = 0
|
||||||
|
LEARNING_ENABLED: int = 30000
|
||||||
|
|
||||||
|
|
||||||
def get_mobility_node(session: "Session", node_id: int) -> Union[WlanNode, EmaneNet]:
|
def get_mobility_node(session: "Session", node_id: int) -> Union[WlanNode, EmaneNet]:
|
||||||
try:
|
try:
|
||||||
|
@ -259,6 +262,12 @@ class BasicRangeModel(WirelessModel):
|
||||||
Configuration(
|
Configuration(
|
||||||
_id="error", _type=ConfigDataTypes.STRING, default="0", label="loss (%)"
|
_id="error", _type=ConfigDataTypes.STRING, default="0", label="loss (%)"
|
||||||
),
|
),
|
||||||
|
Configuration(
|
||||||
|
_id="promiscuous",
|
||||||
|
_type=ConfigDataTypes.BOOL,
|
||||||
|
default="0",
|
||||||
|
label="promiscuous mode",
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -282,6 +291,7 @@ class BasicRangeModel(WirelessModel):
|
||||||
self.delay: Optional[int] = None
|
self.delay: Optional[int] = None
|
||||||
self.loss: Optional[float] = None
|
self.loss: Optional[float] = None
|
||||||
self.jitter: Optional[int] = None
|
self.jitter: Optional[int] = None
|
||||||
|
self.promiscuous: bool = False
|
||||||
|
|
||||||
def _get_config(self, current_value: int, config: Dict[str, str], name: str) -> int:
|
def _get_config(self, current_value: int, config: Dict[str, str], name: str) -> int:
|
||||||
"""
|
"""
|
||||||
|
@ -444,6 +454,12 @@ class BasicRangeModel(WirelessModel):
|
||||||
self.delay = self._get_config(self.delay, config, "delay")
|
self.delay = self._get_config(self.delay, config, "delay")
|
||||||
self.loss = self._get_config(self.loss, config, "error")
|
self.loss = self._get_config(self.loss, config, "error")
|
||||||
self.jitter = self._get_config(self.jitter, config, "jitter")
|
self.jitter = self._get_config(self.jitter, config, "jitter")
|
||||||
|
promiscuous = config["promiscuous"] == "1"
|
||||||
|
if self.promiscuous and not promiscuous:
|
||||||
|
self.wlan.net_client.set_mac_learning(self.wlan.brname, LEARNING_ENABLED)
|
||||||
|
elif not self.promiscuous and promiscuous:
|
||||||
|
self.wlan.net_client.set_mac_learning(self.wlan.brname, LEARNING_DISABLED)
|
||||||
|
self.promiscuous = promiscuous
|
||||||
self.setlinkparams()
|
self.setlinkparams()
|
||||||
|
|
||||||
def create_link_data(
|
def create_link_data(
|
||||||
|
|
|
@ -286,14 +286,15 @@ class LinuxNetClient:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def disable_mac_learning(self, name: str) -> None:
|
def set_mac_learning(self, name: str, value: int) -> None:
|
||||||
"""
|
"""
|
||||||
Disable mac learning for a Linux bridge.
|
Set mac learning for a Linux bridge.
|
||||||
|
|
||||||
:param name: bridge name
|
:param name: bridge name
|
||||||
|
:param value: ageing time value
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
self.run(f"{IP} link set {name} type bridge ageing_time 0")
|
self.run(f"{IP} link set {name} type bridge ageing_time {value}")
|
||||||
|
|
||||||
|
|
||||||
class OvsNetClient(LinuxNetClient):
|
class OvsNetClient(LinuxNetClient):
|
||||||
|
|
|
@ -32,7 +32,8 @@ if TYPE_CHECKING:
|
||||||
|
|
||||||
WirelessModelType = Type[WirelessModel]
|
WirelessModelType = Type[WirelessModel]
|
||||||
|
|
||||||
ebtables_lock = threading.Lock()
|
LEARNING_DISABLED: int = 0
|
||||||
|
ebtables_lock: threading.Lock = threading.Lock()
|
||||||
|
|
||||||
|
|
||||||
class EbtablesQueue:
|
class EbtablesQueue:
|
||||||
|
@ -946,7 +947,7 @@ class HubNode(CoreNetwork):
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
super().startup()
|
super().startup()
|
||||||
self.net_client.disable_mac_learning(self.brname)
|
self.net_client.set_mac_learning(self.brname, LEARNING_DISABLED)
|
||||||
|
|
||||||
|
|
||||||
class WlanNode(CoreNetwork):
|
class WlanNode(CoreNetwork):
|
||||||
|
@ -989,7 +990,6 @@ class WlanNode(CoreNetwork):
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
super().startup()
|
super().startup()
|
||||||
self.net_client.disable_mac_learning(self.brname)
|
|
||||||
ebq.ebchange(self)
|
ebq.ebchange(self)
|
||||||
|
|
||||||
def attach(self, iface: CoreInterface) -> None:
|
def attach(self, iface: CoreInterface) -> None:
|
||||||
|
|
Loading…
Reference in a new issue