Skip to content

Commit

Permalink
Devices/Device.py: add vf_trust method
Browse files Browse the repository at this point in the history
Allows configuration of vf device trust mode.

Signed-off-by: Jan Tluka <[email protected]>
  • Loading branch information
jtluka committed Sep 24, 2024
1 parent de79872 commit 2b4dfb9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lnst/Devices/Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -1167,13 +1167,20 @@ def alt_if_names(self):
return self._nl_msg.get_attr("IFLA_PROP_LIST").get_attrs("IFLA_ALT_IFNAME")
except:
return []

def keep_addrs_on_down(self):
exec_cmd(f"echo 1 > /proc/sys/net/ipv6/conf/{self.name}/keep_addr_on_down")

def remove_addrs_on_down(self):
exec_cmd(f"echo 0 > /proc/sys/net/ipv6/conf/{self.name}/keep_addr_on_down")

# TODO: implement through pyroute once supported
def vf_trust(self, vf_index: int, trusted: str):
if trusted not in ["on", "off"]:
raise DeviceConfigError(f"Incorrect value for vf trust: {trusted}")

exec_cmd(f"ip link set dev {self.name} vf {vf_index} trust {trusted}")

#TODO implement proper Route objects
#consider the same as with tc?
# def route_add(self, dest):
Expand Down

0 comments on commit 2b4dfb9

Please sign in to comment.