Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3393,7 +3393,9 @@ network interface to the user, including:
Address Autoconfiguration) and Neighbor Discovery
- disabling Generic Receive Offload (GRO)

This might change in the future.
This might change in the future. If you do not want the driver to automatically
manage the interface (e.g. you are managing it externally), set
``manage_interface`` to ``False``.

Binds to:
iface:
Expand All @@ -3405,7 +3407,9 @@ Implements:
- None yet

Arguments:
- None
- manage_interface (bool, default=True): if ``True`` this driver will
setup/teardown the interface on activate/deactivate. Set this to ``False``
if you are managing the interface externally.

.. _conf-strategies:

Expand Down
19 changes: 15 additions & 4 deletions labgrid/driver/rawnetworkinterfacedriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,33 @@
@target_factory.reg_driver
@attr.s(eq=False)
class RawNetworkInterfaceDriver(Driver):
"""RawNetworkInterface - Manage a network interface and interact with it at a low level
Args:
manage_interface (bool, default=True): if True this driver will
setup/teardown the interface on activate/deactivate. Set this to False
if you are managing the interface externally.
"""

bindings = {
"iface": {"NetworkInterface", "RemoteNetworkInterface", "USBNetworkInterface"},
}
manage_interface = attr.ib(default=True, validator=attr.validators.instance_of(bool))

def __attrs_post_init__(self):
super().__attrs_post_init__()
self._record_handle = None
self._replay_handle = None

def on_activate(self):
self._set_interface("up")
self._wait_state("up")
if self.manage_inteface:
self._set_interface("up")
self._wait_state("up")

def on_deactivate(self):
self._set_interface("down")
self._wait_state("down")
if self.manage_interface:
self._set_interface("down")
self._wait_state("down")

def _wrap_command(self, args):
wrapper = ["sudo", "labgrid-raw-interface"]
Expand Down