summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Conole <aconole@redhat.com>2022-10-17 09:01:49 -0400
committerAaron Conole <aconole@redhat.com>2022-10-17 09:01:49 -0400
commit97800e452e2cea1fafb45058120128e902d8970e (patch)
tree0a5510cf14dad95fb01e8d0f120d86fb0ea1b174
parenta72c284ba19329cc530287f16b0f65bbed768ee5 (diff)
ovs-dpctl: allow setting version
Report: https://lists.linuxfoundation.org/pipermail/ovs-dev/2022-October/398485.html Create a DP as normal, then create it again with -V 0 and watch warning Signed-off-by: Aaron Conole <aconole@redhat.com>
-rw-r--r--ovs-dpctl.py28
1 files changed, 15 insertions, 13 deletions
diff --git a/ovs-dpctl.py b/ovs-dpctl.py
index fe8d147..b5c9b2a 100644
--- a/ovs-dpctl.py
+++ b/ovs-dpctl.py
@@ -1265,7 +1265,7 @@ def dump_flows_cb(msg, more):
return NL_OK
-def dpctl_mod_dp(args, add=True, setpid=False):
+def dpctl_mod_dp(args, add=True, setpid=False, hdrval=OVS_DATAPATH_VERSION):
global ovs_families, sk
dp = args[0]
@@ -1274,22 +1274,17 @@ def dpctl_mod_dp(args, add=True, setpid=False):
pr = "You don't have permission to {} a datapath."
print(pr.format("add" if add else "delete"))
return -1
- if add == if_exists(dp):
- pr = "You're trying to {} a datapath that {} exist{}."
- print(pr.format(
- "add" if add else "delete",
- "already" if add else "does not",
- "s" if add else ""
- ))
- return -1
cmd = OVS_DP_CMD_NEW if add else OVS_DP_CMD_DEL
msg_dpctl_cmd = nlmsg_alloc()
genlmsg_put(msg_dpctl_cmd, 0, NL_AUTO_SEQ,
ovs_families[OVS_DATAPATH_FAMILY], OVS_HDR_LEN,
- NLM_F_ACK, cmd, OVS_DATAPATH_VERSION)
+ NLM_F_ACK, cmd, hdrval)
userfeatures = OVS_DP_F_VPORT_PIDS
nla_put_u32(msg_dpctl_cmd, OVS_DP_ATTR_UPCALL_PID, 0)
nla_put_string(msg_dpctl_cmd, OVS_DP_ATTR_NAME, dp.encode('utf-8'))
+ if hdrval == OVS_DATAPATH_VERSION:
+ userfeatures = OVS_DP_F_VPORT_PIDS
+
if setpid:
userfeatures &= ~OVS_DP_F_VPORT_PIDS
userfeatures |= OVS_DP_F_DISPATCH_UPCALL_PER_CPU
@@ -1357,9 +1352,16 @@ def dpctl_mod_if(dp, iface, add=True, setPid=False):
def dpctl_add_dp(dp):
setpid = False
- if len(dp) > 1 and dp[1] == '-u':
- setpid = True
- return dpctl_mod_dp(dp, True, setpid)
+ dphdr = OVS_DATAPATH_VERSION
+ if len(dp) > 1:
+ for i in range(len(dp)):
+ if dp[i] == '-u':
+ setpid = True
+ elif dp[i] == '-V':
+ i += 1
+ dphdr = int(dp[i], 0)
+
+ return dpctl_mod_dp(dp, True, setpid, dphdr)
def dpctl_del_dp(dp):