From nobody Sun Sep 27 03:45:53 2026 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 87656350A18 for ; Sat, 5 Sep 2026 10:40:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788604862; cv=none; b=jqeowczCenW5MAZQ/3tAbnjFdtDnh0p87BXPIy9HDbtFyP7Z5c3vVOPCuzl0ZhCL0yVY+Pc+6FjO9Q4ImowMpmNAJZmkuVir2F6vTYBvRzatj86pFijwBq3/D2PbxdOg+4l268jT4H7Vgb2KQE7xrDvplZ5a28eq/Ym/nlm4+KY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788604862; c=relaxed/simple; bh=q4WcbyMa/i4fUxy4deEUzzTp38R7Y7hGQZAweK9RUCI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tu2bGApr5z6ux6NmEdOcCVPYXZpANl8XGjegzPdOxcvR8ouuikOjVjXBUz6AYqPZeTkUrA14Lux0BAuP7A3ZN7LXKGm+A4EjlqaG8/9lC6hq3JwTLPpAQ3pCSi0eKxcV5iz1v5t6jNSFgWJNWqGRYnRpZxk1dEOUNUZtq9sIMbY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eJyT3FVv; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eJyT3FVv" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2db3305f94fso2891755ad.0 for ; Sat, 05 Sep 2026 03:40:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788604846; x=1789209646; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=1X0Shfhg72ovRFBKvp+vWJoJMhtuppXP8P05apr5Y58=; b=eJyT3FVvmGEW4S69XJ/gT1hQ/cjUYEqRFrBg29X8HVPPNRkW198YTeE/y0vBgihB79 oMY8JqHortc5lGZWIRK6bjhMNWNysAoyvYfi/0dFgMiT8aLB1RcpC6xq8C3tJgralgEM vrd99yG04oQIPeF/yKuTT0UVZ35F99pPaBJohPKnDQeBYU+OA6lbCT9cTXNEy5TCYRmS Sv1U9TYWdeF4a9RLj9LA0FmQTuAQ4HRpTGrZgnARii7Q+EYAJ+kUvXBGYfdpZ6y9L2g8 viaQWIhTtxUsiauRUk3tixoM5XJrnE7tG3TI3PcbJvpj/3gZSVwiSmgpYQiUGdB8sWZ8 oYZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788604846; x=1789209646; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=1X0Shfhg72ovRFBKvp+vWJoJMhtuppXP8P05apr5Y58=; b=m7toSYDsvTUh1BBL6F9m3x8oiHoHJ1uQAgTXivGrOHycg9NdUa0Pi7NSi/EvuRjR7K 3btqFS9tgGw+fstR67IdvP7S/iCQSJitpCN8NHT5DL+3yEdTdHVT8Iou20Hvaso6yJUp J2Pv5cWwAVtmvVu1iSI88UCA1Z+CEqK+z+NoAD7CTx55bbFd2U8kNTj3IdID/k9keNrr 7bn99TYKk5SatcBQE23FygbMuDPvUo05I8X/6V06v8LIFJLLbuVEIkA8qZrccWuJ0sj8 MpE5S7/M7avG9nPiSR43yNmj35zo3kKP02d/xbXBMUGaNq17maLIacPv99YPmzv8GefY ozcA== X-Forwarded-Encrypted: i=1; AKwUvByrAcPap9WbVvS7leWpswmt4nvMTm3XbJFaiqvawERtg7VRLj4BSYMd3aLXtysrFp72Rm7W0pJ6lUK8bKg=@vger.kernel.org X-Gm-Message-State: AFuF++lq0uK07cWxw82Y1bOJsh5aqh+2DAbOTTP/EaNELiNNT/+ZMXhD x2ub+SZfCA7ZWRML83gsfx9jNRG2NbKBediqoaS1v3GjJhO8z3TG+8WA X-Gm-Gg: AYBFou1bUO0iEb+FzcTiXQt5Wj66WY0kHRqIRPl+gEpXDj9G64JHgemMbRnSykLUziE NJOaT3olxgn/DfEXFuACfb4z4Zp4JgkJQd39HIB/EszM2M4CVVe+7I1V9GVLJPZXzRei71JuvTS NPVhjD9PglMqPJGKxTA91XcJ2CZVjg7FssgLkKKujxSkGRYegJh7PjK+rvm7QYv/5wYUPGC1hpg vqPksdEBlYZdZc23EX/zF9EEpz1GJ6oj4B+iu4BVqcjng1MfwvgeZ9Qcu1wwEk1AJWz302uSqmb 0JPZKPC/hMsC/SiFb3cdtQQ1J6lO1oB9eSEVpAprj7kjlVoWZwjlWHHRirVNPGWo7W1ZRwOLkic O9z7zLBS6OhJWB+cBD5zVy4asj36Lk3wLo+Swo1Tl7Rfse4UrwvjpmjCqwM7LCo3gK5/+Y6wKJ9 GZIktG3g3e8QrJV6CsZ0FyXpMfGiZq1WTtylSAKzMh+WnE+7ZLHQvvkw== X-Received: by 2002:a17:903:1b48:b0:2db:210f:c111 with SMTP id d9443c01a7336-2db210fc2cbmr95986585ad.2.1788604846114; Sat, 05 Sep 2026 03:40:46 -0700 (PDT) Received: from houminxi ([154.197.57.228]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3339b314cfcsm13559776eec.19.2026.09.05.03.40.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2026 03:40:45 -0700 (PDT) From: Minxi Hou To: netdev@vger.kernel.org Cc: aconole@redhat.com, davem@davemloft.net, dev@openvswitch.org, echaudro@redhat.com, edumazet@google.com, i.maximets@ovn.org, kuba@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, pabeni@redhat.com, shuah@kernel.org, horms@kernel.org, Minxi Hou Subject: [PATCH 1/4] selftests: openvswitch: convert %-formatting to f-strings Date: Sat, 5 Sep 2026 06:40:23 -0400 Message-ID: <20260905104026.3776396-2-houminxi@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260905104026.3776396-1-houminxi@gmail.com> References: <20260905104026.3776396-1-houminxi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Convert all 86 instances of %-formatting to f-strings to fix C0209 pylint warnings. No behavior change. Signed-off-by: Minxi Hou --- base-commit: 9eab111e765729e93087ff86a2ec9b2ae42d0fa5 .../selftests/net/openvswitch/ovs-dpctl.py | 267 ++++++++---------- 1 file changed, 120 insertions(+), 147 deletions(-) diff --git a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py b/tools/t= esting/selftests/net/openvswitch/ovs-dpctl.py index 1615843c225e..9cd0d8f0ab23 100644 --- a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py +++ b/tools/testing/selftests/net/openvswitch/ovs-dpctl.py @@ -65,7 +65,7 @@ OVS_FLOW_CMD_SET =3D 4 UINT32_MAX =3D 0xFFFFFFFF =20 def macstr(mac): - outstr =3D ":".join(["%02X" % i for i in mac]) + outstr =3D ":".join([f"{i:02X}" for i in mac]) return outstr =20 =20 @@ -146,7 +146,7 @@ def parse_flags(flag_str, flag_vals): if flag in flag_vals: if maskResult & flag_vals[flag]: raise KeyError( - "Flag %s set once, cannot be set in multiples" % flag + f"Flag {flag} set once, cannot be set in multiples" ) =20 if setFlag: @@ -154,7 +154,7 @@ def parse_flags(flag_str, flag_vals): =20 maskResult |=3D flag_vals[flag] else: - raise KeyError("Missing flag value: %s" % flag) + raise KeyError(f"Missing flag value: {flag}") =20 flag_str =3D flag_str[flag_len:] =20 @@ -211,7 +211,7 @@ def convert_ipv6(data): elif not mask: mask =3D 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff' elif mask.isdigit(): - mask =3D ipaddress.IPv6Network("::/" + mask).hostmask + mask =3D ipaddress.IPv6Network(f"::/{mask}").hostmask =20 return ipaddress.IPv6Address(ip).packed, ipaddress.IPv6Address(mask).p= acked =20 @@ -342,13 +342,13 @@ def parse_attrs(actstr, attr_desc): del attr_desc[i] =20 if not found: - raise ValueError("Unknown attribute: '%s'" % actstr) + raise ValueError(f"Unknown attribute: '{actstr}'") =20 actstr =3D actstr[strspn(actstr, ", ") :] =20 if actstr[0] !=3D ")": raise ValueError("Action string contains extra garbage or has " - "unbalanced parenthesis: '%s'" % actstr) + f"unbalanced parenthesis: '{actstr}'") =20 return attrs, actstr[1:] =20 @@ -413,14 +413,13 @@ class ovsactions(nla): ) =20 def dpstr(self, more=3DFalse): - args =3D "group=3D%d" % self.get_attr("OVS_PSAMPLE_ATTR_GROUP") + args =3D f"group=3D{int(self.get_attr('OVS_PSAMPLE_ATTR_GROUP'= ))}" =20 cookie =3D self.get_attr("OVS_PSAMPLE_ATTR_COOKIE") if cookie: - args +=3D ",cookie(%s)" % \ - "".join(format(x, "02x") for x in cookie) + args +=3D f",cookie({''.join((format(x, '02x') for x in co= okie))})" =20 - return "psample(%s)" % args + return f"psample({args})" =20 def parse(self, actstr): desc =3D ( @@ -451,15 +450,15 @@ class ovsactions(nla): def dpstr(self, more=3DFalse): args =3D [] =20 - args.append("sample=3D{:.2f}%".format( - 100 * self.get_attr("OVS_SAMPLE_ATTR_PROBABILITY") / - UINT32_MAX)) + prob =3D 100 * self.get_attr( + "OVS_SAMPLE_ATTR_PROBABILITY") / UINT32_MAX + args.append(f"sample=3D{prob:.2f}%") =20 actions =3D self.get_attr("OVS_SAMPLE_ATTR_ACTIONS") if actions: - args.append("actions(%s)" % actions.dpstr(more)) + args.append(f"actions({actions.dpstr(more)})") =20 - return "sample(%s)" % ",".join(args) + return f"sample({','.join(args)})" =20 def parse(self, actstr): def parse_nested_actions(actstr): @@ -528,26 +527,20 @@ class ovsactions(nla): "OVS_NAT_ATTR_IP_MAX" ): if self.get_attr("OVS_NAT_ATTR_IP_MIN"): - print_str +=3D "=3D%s," % str( - self.get_attr("OVS_NAT_ATTR_IP_MIN") - ) + print_str +=3D f"=3D{self.get_attr('OVS_NAT_ATTR_I= P_MIN')!s}," =20 if self.get_attr("OVS_NAT_ATTR_IP_MAX"): - print_str +=3D "-%s," % str( - self.get_attr("OVS_NAT_ATTR_IP_MAX") - ) + print_str +=3D f"-{self.get_attr('OVS_NAT_ATTR_IP_= MAX')!s}," else: print_str +=3D "," =20 if self.get_attr("OVS_NAT_ATTR_PROTO_MIN"): - print_str +=3D "proto_min=3D%d," % self.get_attr( - "OVS_NAT_ATTR_PROTO_MIN" - ) + val =3D self.get_attr("OVS_NAT_ATTR_PROTO_MIN") + print_str +=3D f"proto_min=3D{val}," =20 if self.get_attr("OVS_NAT_ATTR_PROTO_MAX"): - print_str +=3D "proto_max=3D%d," % self.get_attr( - "OVS_NAT_ATTR_PROTO_MAX" - ) + val =3D self.get_attr("OVS_NAT_ATTR_PROTO_MAX") + print_str +=3D f"proto_max=3D{val}," =20 if self.get_attr("OVS_NAT_ATTR_PERSISTENT"): print_str +=3D "persistent," @@ -564,22 +557,18 @@ class ovsactions(nla): if self.get_attr("OVS_CT_ATTR_COMMIT") is not None: print_str +=3D "commit," if self.get_attr("OVS_CT_ATTR_ZONE") is not None: - print_str +=3D "zone=3D%d," % self.get_attr("OVS_CT_ATTR_Z= ONE") + print_str +=3D f"zone=3D{int(self.get_attr('OVS_CT_ATTR_ZO= NE'))}," if self.get_attr("OVS_CT_ATTR_HELPER") is not None: - print_str +=3D "helper=3D%s," % self.get_attr("OVS_CT_ATTR= _HELPER") + print_str +=3D f"helper=3D{self.get_attr('OVS_CT_ATTR_HELP= ER')}," if self.get_attr("OVS_CT_ATTR_NAT") is not None: print_str +=3D self.get_attr("OVS_CT_ATTR_NAT").dpstr(more) print_str +=3D "," if self.get_attr("OVS_CT_ATTR_FORCE_COMMIT") is not None: print_str +=3D "force," if self.get_attr("OVS_CT_ATTR_EVENTMASK") is not None: - print_str +=3D "emask=3D0x%X," % self.get_attr( - "OVS_CT_ATTR_EVENTMASK" - ) + print_str +=3D f"emask=3D0x{self.get_attr('OVS_CT_ATTR_EVE= NTMASK'):X}," if self.get_attr("OVS_CT_ATTR_TIMEOUT") is not None: - print_str +=3D "timeout=3D%s" % self.get_attr( - "OVS_CT_ATTR_TIMEOUT" - ) + print_str +=3D f"timeout=3D{self.get_attr('OVS_CT_ATTR_TIM= EOUT')}" print_str +=3D ")" return print_str =20 @@ -596,17 +585,15 @@ class ovsactions(nla): def dpstr(self, more=3DFalse): print_str =3D "userspace(" if self.get_attr("OVS_USERSPACE_ATTR_PID") is not None: - print_str +=3D "pid=3D%d," % self.get_attr( - "OVS_USERSPACE_ATTR_PID" - ) + print_str +=3D f"pid=3D{int(self.get_attr('OVS_USERSPACE_A= TTR_PID'))}," if self.get_attr("OVS_USERSPACE_ATTR_USERDATA") is not None: print_str +=3D "userdata=3D" for f in self.get_attr("OVS_USERSPACE_ATTR_USERDATA"): - print_str +=3D "%x." % f + print_str +=3D f"{f:x}." if self.get_attr("OVS_USERSPACE_ATTR_EGRESS_TUN_PORT") is not = None: - print_str +=3D "egress_tun_port=3D%d" % self.get_attr( - "OVS_USERSPACE_ATTR_EGRESS_TUN_PORT" - ) + val =3D self.get_attr( + "OVS_USERSPACE_ATTR_EGRESS_TUN_PORT") + print_str +=3D f"egress_tun_port=3D{val}" print_str +=3D ")" return print_str =20 @@ -634,13 +621,13 @@ class ovsactions(nla): print_str +=3D "," =20 if field[0] =3D=3D "OVS_ACTION_ATTR_OUTPUT": - print_str +=3D "%d" % int(self.get_attr(field[0])) + print_str +=3D f"{int(self.get_attr(field[0]))}" elif field[0] =3D=3D "OVS_ACTION_ATTR_RECIRC": - print_str +=3D "recirc(0x%x)" % int(self.get_attr(field[0]= )) + print_str +=3D f"recirc(0x{int(self.get_attr(field[0])):x}= )" elif field[0] =3D=3D "OVS_ACTION_ATTR_TRUNC": - print_str +=3D "trunc(%d)" % int(self.get_attr(field[0])) + print_str +=3D f"trunc({int(self.get_attr(field[0]))})" elif field[0] =3D=3D "OVS_ACTION_ATTR_DROP": - print_str +=3D "drop(%d)" % int(self.get_attr(field[0])) + print_str +=3D f"drop({int(self.get_attr(field[0]))})" elif field[0] =3D=3D "OVS_ACTION_ATTR_CT_CLEAR": print_str +=3D "ct_clear" elif field[0] =3D=3D "OVS_ACTION_ATTR_POP_VLAN": @@ -658,8 +645,8 @@ class ovsactions(nla): tci =3D datum["vlan_tci"] vid =3D tci & 0x0FFF pcp =3D (tci >> 13) & 0x7 - print_str +=3D "push_vlan(vid=3D%d,pcp=3D%d" \ - ",tpid=3D0x%04x)" % (vid, pcp, tpid) + print_str +=3D (f"push_vlan(vid=3D{vid},pcp=3D{pcp}" + f",tpid=3D0x{tpid:04x})") elif field[0] =3D=3D "OVS_ACTION_ATTR_POP_ETH": print_str +=3D "pop_eth" elif field[0] =3D=3D "OVS_ACTION_ATTR_POP_NSH": @@ -767,32 +754,27 @@ class ovsactions(nla): for kv in actstr[:paren].split(","): if "=3D" not in kv: raise ValueError( - "push_vlan(): bad field '%s'" - % kv.strip()) + f"push_vlan(): bad field '{kv.strip()}'") k =3D kv[:kv.index("=3D")].strip() v =3D kv[kv.index("=3D") + 1:].strip() if k =3D=3D "vid": vid =3D int(v, 0) if vid < 0 or vid > 0xFFF: raise ValueError( - "push_vlan(): vid=3D%d out of " - "range (0-4095)" % vid) + f"push_vlan(): vid=3D{int(vid)} out of ran= ge (0-4095)") elif k =3D=3D "pcp": pcp =3D int(v, 0) if pcp < 0 or pcp > 7: raise ValueError( - "push_vlan(): pcp=3D%d out of " - "range (0-7)" % pcp) + f"push_vlan(): pcp=3D{int(pcp)} out of ran= ge (0-7)") elif k =3D=3D "tpid": tpid =3D int(v, 0) if tpid < 0 or tpid > 0xFFFF: raise ValueError( - "push_vlan(): tpid=3D0x%x out " - "of range (0-0xffff)" % tpid) + f"push_vlan(): tpid=3D0x{tpid:x} out of ra= nge (0-0xffff)") else: raise ValueError( - "push_vlan(): unknown key '%s'" - % k) + f"push_vlan(): unknown key '{k}'") tci =3D (vid & 0x0FFF) | ((pcp & 0x7) << 13) \ | 0x1000 pvact =3D self.push_vlan() @@ -833,7 +815,7 @@ class ovsactions(nla): actstr =3D k.parse(actstr, None) self["attrs"].append(("OVS_ACTION_ATTR_SET", k)) if not actstr.startswith(")"): - actstr =3D ")" + actstr + actstr =3D f"){actstr}" parsed =3D True elif parse_starts_block(actstr, "set_masked(", False): parencount +=3D 1 @@ -843,7 +825,7 @@ class ovsactions(nla): actstr =3D k.parse(actstr, m) self["attrs"].append(("OVS_ACTION_ATTR_SET_MASKED", [k, m]= )) if not actstr.startswith(")"): - actstr =3D ")" + actstr + actstr =3D f"){actstr}" parsed =3D True elif parse_starts_block(actstr, "ct(", False): parencount +=3D 1 @@ -974,7 +956,7 @@ class ovsactions(nla): parencount -=3D 1 actstr =3D actstr[strspn(actstr, " "):] if len(actstr) and actstr[0] !=3D ")": - raise ValueError("Action str: '%s' unbalanced" % actst= r) + raise ValueError(f"Action str: '{actstr}' unbalanced") actstr =3D actstr[1:] =20 if len(actstr) and actstr[0] =3D=3D ")": @@ -983,7 +965,7 @@ class ovsactions(nla): actstr =3D actstr[strspn(actstr, ", ") :] =20 if not parsed: - raise ValueError("Action str: '%s' not supported" % actstr) + raise ValueError(f"Action str: '{actstr}' not supported") =20 return (totallen - len(actstr)) =20 @@ -1108,20 +1090,20 @@ class ovskey(nla): return flowstr, k, m =20 def dpstr(self, masked=3DNone, more=3DFalse): - outstr =3D self.proto_str + "(" + outstr =3D f"{self.proto_str}(" first =3D False for f in self.fields_map: if first: outstr +=3D "," if masked is None: - outstr +=3D "%s=3D" % f[0] + outstr +=3D f"{f[0]}=3D" if isinstance(f[2], str): outstr +=3D f[2] % self[f[1]] else: outstr +=3D f[2](self[f[1]]) first =3D True elif more or f[3](masked[f[1]]) !=3D 0: - outstr +=3D "%s=3D" % f[0] + outstr +=3D f"{f[0]}=3D" if isinstance(f[2], str): outstr +=3D f[2] % self[f[1]] else: @@ -1702,23 +1684,23 @@ class ovskey(nla): for k in self["attrs"]: noprint =3D False if k[0] =3D=3D "OVS_TUNNEL_KEY_ATTR_ID": - print_str +=3D "tun_id=3D%d" % k[1] + print_str +=3D f"tun_id=3D{int(k[1])}" elif k[0] =3D=3D "OVS_TUNNEL_KEY_ATTR_IPV4_SRC": - print_str +=3D "src=3D%s" % k[1] + print_str +=3D f"src=3D{k[1]}" elif k[0] =3D=3D "OVS_TUNNEL_KEY_ATTR_IPV4_DST": - print_str +=3D "dst=3D%s" % k[1] + print_str +=3D f"dst=3D{k[1]}" elif k[0] =3D=3D "OVS_TUNNEL_KEY_ATTR_IPV6_SRC": - print_str +=3D "ipv6_src=3D%s" % k[1] + print_str +=3D f"ipv6_src=3D{k[1]}" elif k[0] =3D=3D "OVS_TUNNEL_KEY_ATTR_IPV6_DST": - print_str +=3D "ipv6_dst=3D%s" % k[1] + print_str +=3D f"ipv6_dst=3D{k[1]}" elif k[0] =3D=3D "OVS_TUNNEL_KEY_ATTR_TOS": - print_str +=3D "tos=3D%d" % k[1] + print_str +=3D f"tos=3D{int(k[1])}" elif k[0] =3D=3D "OVS_TUNNEL_KEY_ATTR_TTL": - print_str +=3D "ttl=3D%d" % k[1] + print_str +=3D f"ttl=3D{int(k[1])}" elif k[0] =3D=3D "OVS_TUNNEL_KEY_ATTR_TP_SRC": - print_str +=3D "tp_src=3D%d" % k[1] + print_str +=3D f"tp_src=3D{int(k[1])}" elif k[0] =3D=3D "OVS_TUNNEL_KEY_ATTR_TP_DST": - print_str +=3D "tp_dst=3D%d" % k[1] + print_str +=3D f"tp_dst=3D{int(k[1])}" elif k[0] =3D=3D "OVS_TUNNEL_KEY_ATTR_DONT_FRAGMENT": noprint =3D True flagsattrs.append("df") @@ -1733,7 +1715,7 @@ class ovskey(nla): print_str +=3D "," =20 if len(flagsattrs): - print_str +=3D "flags(" + "|".join(flagsattrs) + ")" + print_str +=3D f"flags({'|'.join(flagsattrs)})" print_str +=3D ")" return print_str =20 @@ -1756,8 +1738,8 @@ class ovskey(nla): pcp =3D (tci >> 13) & 0x7 cfi =3D (tci >> 12) & 0x1 if cfi: - return "vid=3D%d,pcp=3D%d,cfi=3D%d" % (vid, pcp, cfi) - return "tci=3D0x%04x" % tci + return f"vid=3D{int(vid)},pcp=3D{int(pcp)},cfi=3D{int(cfi)}" + return f"tci=3D0x{tci:04x}" =20 @staticmethod def _parse_vlan_from_flowstr(flowstr): @@ -1801,7 +1783,7 @@ class ovskey(nla): eq =3D flowstr.find('=3D') if eq =3D=3D -1: raise ValueError( - "vlan(): expected key=3Dvalue, got '%s'" % flowstr) + f"vlan(): expected key=3Dvalue, got '{flowstr}'") key =3D flowstr[:eq].strip() flowstr =3D flowstr[eq + 1:] =20 @@ -1815,13 +1797,12 @@ class ovskey(nla): flowstr =3D flowstr[end:] =20 if not val: - raise ValueError("vlan(): empty value for key '%s'" % key) + raise ValueError(f"vlan(): empty value for key '{key}'") try: v =3D int(val, 0) except ValueError as exc: raise ValueError( - "vlan(): invalid value '%s' for key '%s'" - % (val, key)) from exc + f"vlan(): invalid value '{val}' for key '{key}'") from= exc =20 if key =3D=3D 'tci': if has_tci: @@ -1829,7 +1810,7 @@ class ovskey(nla): if has_vid or has_pcp or has_cfi: raise ValueError(_tci_mix_err) if v > 0xFFFF or v < 0: - raise ValueError("vlan(): tci=3D0x%x out of range" % v) + raise ValueError(f"vlan(): tci=3D0x{v:x} out of range") tci =3D v mask =3D 0xFFFF has_tci =3D True @@ -1839,7 +1820,7 @@ class ovskey(nla): if has_vid: raise ValueError("vlan(): duplicate 'vid'") if v < 0 or v > 0xFFF: - raise ValueError("vlan(): vid=3D%d out of range (0-409= 5)" % v) + raise ValueError(f"vlan(): vid=3D{int(v)} out of range= (0-4095)") tci |=3D v mask |=3D 0x0FFF has_vid =3D True @@ -1849,7 +1830,7 @@ class ovskey(nla): if has_pcp: raise ValueError("vlan(): duplicate 'pcp'") if v < 0 or v > 7: - raise ValueError("vlan(): pcp=3D%d out of range (0-7)"= % v) + raise ValueError(f"vlan(): pcp=3D{int(v)} out of range= (0-7)") tci |=3D (v & 0x7) << 13 mask |=3D 0xE000 has_pcp =3D True @@ -1864,7 +1845,7 @@ class ovskey(nla): mask |=3D ovskey._VLAN_CFI_MASK has_cfi =3D True else: - raise ValueError("vlan(): unknown key '%s'" % key) + raise ValueError(f"vlan(): unknown key '{key}'") =20 flowstr =3D flowstr[1:] # skip ')' # Catch immediate '))' (user error). A ')' after ',' is consumed @@ -1900,7 +1881,7 @@ class ovskey(nla): depth -=3D 1 if depth < 0: raise ValueError( - "encap(): unmatched ')' at position %d" % i) + f"encap(): unmatched ')' at position {int(i)}") if depth =3D=3D 0: end =3D i break @@ -1923,8 +1904,7 @@ class ovskey(nla): remaining =3D inner_key.parse(inner_str, inner_mask) if remaining and re.search(r'[^\s,)]', remaining): raise ValueError( - "encap(): unrecognized trailing " - "content '%s'" % remaining.strip()) + f"encap(): unrecognized trailing content '{remaining.strip= ()}'") =20 return flowstr, inner_key, inner_mask =20 @@ -2005,7 +1985,7 @@ class ovskey(nla): lambda x: parse_flags(x, None), ), ): - fld =3D field[1] + "(" + fld =3D f"{field[1]}(" if not flowstr.startswith(fld): continue =20 @@ -2143,15 +2123,15 @@ class ovskey(nla): else: if m is None or field[3](m): val =3D fmt(v) if callable(fmt) else fmt % v - print_str +=3D field[1] + "(" + val + ")," + print_str +=3D f"{field[1]}({val})," elif more or m !=3D 0: if field[0] =3D=3D "OVS_KEY_ATTR_VLAN": - val =3D "tci=3D0x%04x/0x%04x" % (v, m) + val =3D f"tci=3D0x{v:04x}/0x{m:04x}" elif callable(fmt): - val =3D fmt(v) + "/" + fmt(m) + val =3D f"{fmt(v)}/{fmt(m)}" else: - val =3D (fmt % v) + "/" + (fmt % m) - print_str +=3D field[1] + "(" + val + ")," + val =3D f"{fmt % v}/{fmt % m}" + print_str +=3D f"{field[1]}({val})," =20 return print_str =20 @@ -2233,7 +2213,7 @@ class OvsPacket(GenericNetlinkSocket): elif msg["cmd"] =3D=3D OvsPacket.OVS_PACKET_CMD_EXECUT= E: up.execute(msg) else: - print("Unknown cmd: %d" % msg["cmd"]) + print(f"Unknown cmd: {int(msg['cmd'])}") except NetlinkError as ne: raise ne =20 @@ -2401,14 +2381,14 @@ class OvsVport(GenericNetlinkSocket): return "netdev" elif vport_type =3D=3D OvsVport.OVS_VPORT_TYPE_INTERNAL: return "internal" - raise ValueError("Unknown vport type:%d" % vport_type) + raise ValueError(f"Unknown vport type:{int(vport_type)}") =20 def str_to_type(vport_type): if vport_type in ["netdev", "gre", "vxlan", "geneve"]: return OvsVport.OVS_VPORT_TYPE_NETDEV elif vport_type =3D=3D "internal": return OvsVport.OVS_VPORT_TYPE_INTERNAL - raise ValueError("Unknown vport type: '%s'" % vport_type) + raise ValueError(f"Unknown vport type: '{vport_type}'") =20 def __init__(self, packet=3DOvsPacket()): GenericNetlinkSocket.__init__(self) @@ -2569,16 +2549,14 @@ class OvsFlow(GenericNetlinkSocket): ufid =3D self.get_attr("OVS_FLOW_ATTR_UFID") ufid_str =3D "" if ufid is not None: - ufid_str =3D ( - "ufid:{:08x}-{:04x}-{:04x}-{:04x}-{:04x}{:08x}".format( - ufid[0], - ufid[1] >> 16, - ufid[1] & 0xFFFF, - ufid[2] >> 16, - ufid[2] & 0, - ufid[3], - ) - ) + u0 =3D ufid[0] + u1h =3D ufid[1] >> 16 + u1l =3D ufid[1] & 0xFFFF + u2h =3D ufid[2] >> 16 + u2l =3D ufid[2] & 0 + u3 =3D ufid[3] + ufid_str =3D (f"ufid:{u0:08x}-{u1h:04x}-{u1l:04x}" + f"-{u2h:04x}-{u2l:04x}{u3:08x}") =20 key_field =3D self.get_attr("OVS_FLOW_ATTR_KEY") keymsg =3D None @@ -2598,7 +2576,7 @@ class OvsFlow(GenericNetlinkSocket): print_str =3D "" =20 if more: - print_str +=3D ufid_str + "," + print_str +=3D f"{ufid_str}," =20 if keymsg is not None: print_str +=3D keymsg.dpstr(maskmsg, more) @@ -2607,10 +2585,9 @@ class OvsFlow(GenericNetlinkSocket): if stats is None: print_str +=3D " packets:0, bytes:0," else: - print_str +=3D " packets:%d, bytes:%d," % ( - stats["packets"], - stats["bytes"], - ) + pkts =3D stats["packets"] + nbytes =3D stats["bytes"] + print_str +=3D f" packets:{pkts}, bytes:{nbytes}," =20 used =3D self.get_attr("OVS_FLOW_ATTR_USED") print_str +=3D " used:" @@ -2620,7 +2597,7 @@ class OvsFlow(GenericNetlinkSocket): used_time =3D int(used) cur_time_sec =3D time.clock_gettime(time.CLOCK_MONOTONIC) used_time =3D (cur_time_sec * 1000) - used_time - print_str +=3D "{}s,".format(used_time / 1000) + print_str +=3D f"{used_time / 1000}s," =20 print_str +=3D " actions:" if ( @@ -2808,7 +2785,7 @@ class OvsFlow(GenericNetlinkSocket): pktdata =3D packetmsg.get_attr("OVS_PACKET_ATTR_PACKET") pktpres =3D "yes" if pktdata is not None else "no" =20 - print("MISS upcall[%d/%s]: %s" % (seq, pktpres, keystr), flush=3DT= rue) + print(f"MISS upcall[{int(seq)}/{pktpres}]: {keystr}", flush=3DTrue) =20 def execute(self, packetmsg): print("userspace execute command", flush=3DTrue) @@ -2842,16 +2819,16 @@ class psample_sample(genlmsg): data =3D "" for (attr, value) in self["attrs"]: if attr =3D=3D "PSAMPLE_ATTR_SAMPLE_GROUP": - fields.append("group:%d" % value) + fields.append(f"group:{int(value)}") if attr =3D=3D "PSAMPLE_ATTR_SAMPLE_RATE": - fields.append("rate:%d" % value) + fields.append(f"rate:{int(value)}") if attr =3D=3D "PSAMPLE_ATTR_USER_COOKIE": value =3D "".join(format(x, "02x") for x in value) - fields.append("cookie:%s" % value) + fields.append(f"cookie:{value}") if attr =3D=3D "PSAMPLE_ATTR_DATA" and len(value) > 0: - data =3D "data:%s" % "".join(format(x, "02x") for x in val= ue) + data =3D f"data:{''.join((format(x, '02x') for x in value)= )}" =20 - return ("%s %s" % (",".join(fields), data)).strip() + return (f"{','.join(fields)} {data}").strip() =20 =20 class psample_msg(Marshal): @@ -2885,35 +2862,31 @@ def print_ovsdp_full(dp_lookup_rep, ifindex, ndb=3D= NDB(), vpl=3DOvsVport()): user_features =3D dp_lookup_rep.get_attr("OVS_DP_ATTR_USER_FEATURES") masks_cache_size =3D dp_lookup_rep.get_attr("OVS_DP_ATTR_MASKS_CACHE_S= IZE") =20 - print("%s:" % dp_name) - print( - " lookups: hit:%d missed:%d lost:%d" - % (base_stats["hit"], base_stats["missed"], base_stats["lost"]) - ) - print(" flows:%d" % base_stats["flows"]) + print(f"{dp_name}:") + hit =3D base_stats["hit"] + missed =3D base_stats["missed"] + lost =3D base_stats["lost"] + print(f" lookups: hit:{hit} missed:{missed} lost:{lost}") + print(f" flows:{int(base_stats['flows'])}") pkts =3D base_stats["hit"] + base_stats["missed"] avg =3D (megaflow_stats["mask_hit"] / pkts) if pkts !=3D 0 else 0.0 - print( - " masks: hit:%d total:%d hit/pkt:%f" - % (megaflow_stats["mask_hit"], megaflow_stats["masks"], avg) - ) + mhit =3D megaflow_stats["mask_hit"] + mtotal =3D megaflow_stats["masks"] + print(f" masks: hit:{mhit} total:{mtotal} hit/pkt:{avg:f}") print(" caches:") - print(" masks-cache: size:%d" % masks_cache_size) + print(f" masks-cache: size:{int(masks_cache_size)}") =20 if user_features is not None: - print(" features: 0x%X" % user_features) + print(f" features: 0x{user_features:X}") =20 # port print out for iface in ndb.interfaces: rep =3D vpl.info(iface.ifname, ifindex) if rep is not None: print( - " port %d: %s (%s)" - % ( - rep.get_attr("OVS_VPORT_ATTR_PORT_NO"), - rep.get_attr("OVS_VPORT_ATTR_NAME"), - OvsVport.type_to_str(rep.get_attr("OVS_VPORT_ATTR_TYPE= ")), - ) + f" port {int(rep.get_attr('OVS_VPORT_ATTR_PORT_NO'))}: " + f"{rep.get_attr('OVS_VPORT_ATTR_NAME')} " + f"({OvsVport.type_to_str(rep.get_attr('OVS_VPORT_ATTR_TYPE= '))})" ) =20 =20 @@ -3045,14 +3018,14 @@ def main(argv): if not found: msg =3D "No DP found" if args.showdp is not None: - msg +=3D ":'%s'" % args.showdp + msg +=3D f":'{args.showdp}'" print(msg) elif hasattr(args, "adddp"): rep =3D ovsdp.create(args.adddp, args.upcall, args.versioning, ovs= pk) if rep is None: - print("DP '%s' already exists" % args.adddp) + print(f"DP '{args.adddp}' already exists") else: - print("DP '%s' added" % args.adddp) + print(f"DP '{args.adddp}' added") if args.upcall: ovspk.upcall_handler(ovsflow) elif hasattr(args, "deldp"): @@ -3060,12 +3033,12 @@ def main(argv): elif hasattr(args, "addif"): rep =3D ovsdp.info(args.dpname, 0) if rep is None: - print("DP '%s' not found." % args.dpname) + print(f"DP '{args.dpname}' not found.") return 1 dpindex =3D rep["dpifindex"] rep =3D ovsvp.attach(rep["dpifindex"], args.addif, args.ptype, args.dport) - msg =3D "vport '%s'" % args.addif + msg =3D f"vport '{args.addif}'" if rep and rep["header"]["error"] is None: msg +=3D " added." else: @@ -3077,10 +3050,10 @@ def main(argv): elif hasattr(args, "delif"): rep =3D ovsdp.info(args.dpname, 0) if rep is None: - print("DP '%s' not found." % args.dpname) + print(f"DP '{args.dpname}' not found.") return 1 rep =3D ovsvp.detach(rep["dpifindex"], args.delif) - msg =3D "vport '%s'" % args.delif + msg =3D f"vport '{args.delif}'" if rep and rep["header"]["error"] is None: msg +=3D " removed." else: @@ -3091,7 +3064,7 @@ def main(argv): elif hasattr(args, "dumpdp"): rep =3D ovsdp.info(args.dumpdp, 0) if rep is None: - print("DP '%s' not found." % args.dumpdp) + print(f"DP '{args.dumpdp}' not found.") return 1 rep =3D ovsflow.dump(rep["dpifindex"]) for flow in rep: @@ -3099,7 +3072,7 @@ def main(argv): elif hasattr(args, "flbr"): rep =3D ovsdp.info(args.flbr, 0) if rep is None: - print("DP '%s' not found." % args.flbr) + print(f"DP '{args.flbr}' not found.") return 1 flow =3D OvsFlow.ovs_flow_msg() flow.parse(args.flow, args.acts, rep["dpifindex"]) @@ -3115,7 +3088,7 @@ def main(argv): elif hasattr(args, "flsbr"): rep =3D ovsdp.info(args.flsbr, 0) if rep is None: - print("DP '%s' not found." % args.flsbr) + print(f"DP '{args.flsbr}' not found.") ovsflow.del_flows(rep["dpifindex"]) =20 return 0 --=20 2.55.0 From nobody Sun Sep 27 03:45:53 2026 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 73583453A52 for ; Sat, 5 Sep 2026 10:41:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788604871; cv=none; b=EjK9LUm2K2pfuA3bFm2K4gqiLf9Us2LVZN4J2Io5MrV+toiGCuvYT8zNhXJwcYXl8L9ddrMU3Zyg6Yc+Y+J6ql6Lyk8c6Q/e9UMQvwRj2+vnC4Le9BzRdhYy5Q3vcElxv0BP/qRp/gHMIY6ObhgoGeCFgTh6F9fD4U5UE4Rdytc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788604871; c=relaxed/simple; bh=IKBCGIe+0rfZdqLtsEcEzIIMnR9trXnVBRpIA16kR3U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tqnosr0NGXelNQbdfhx9zRYm8s+ghI27RKiN/E/wK8xZIfdWLHoos3zAqqK2vMdyUO/Ta9bVE+ovXpZ05wJEtBCehDbkNRjIqSB6FH/vj4XN3ynO6gJLIHR3/LnNuHrFfRgXA5qLp4k+RN6WPU7/HUmYeZB3AMicCdQjPn9/wdA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DQSdh/0H; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DQSdh/0H" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2caced6038eso19529015ad.0 for ; Sat, 05 Sep 2026 03:40:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788604853; x=1789209653; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RVGO8QrL5Gygxi7WZN29yoHd/tJYxrEKp+l+Q17zcxs=; b=DQSdh/0Huf6oixM0pPsoS9P17MFu1jEGuPqe93SiOXExfBOuSaIhO3+EM9ka25YZCY oc1s551Px5kS4Fvqy3/h8kJ3rOsA9CkmfPfE+EK8vbz7AHyxS7mk/YofYzSumlfd0cUd PXYIHqQgGIYAt6cZjF99OK65JpFY14SeeBXJN4nABHtUWd4mz10JVXewZc09yAivcbo0 3MgjCMcUA3yGjORGO90E+7Bo+XKZxGsiwc4Bd6szSeXoYUMScwZjGMWRcAA8aYGRGxtY J/NWp+ejFM+qoi7mIUdT9xrlfeT8+L3wv2Yxs+LZHze8JZYcQ99qRI0O7tlrWxc6pEP+ yRFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788604853; x=1789209653; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=RVGO8QrL5Gygxi7WZN29yoHd/tJYxrEKp+l+Q17zcxs=; b=OYek54DEqrgl+tM3uXgy8ZsDBS/GzwApmAnnXzYvGjtfB1YXzJSvPMtNCzoJvr9XgD WiRXvu03ajQRyDwUk2NU4fVmrQiny/XRs8RiCX25hbJFMCbiRjmxi4Om1cborN1oZSbN jvdlogB2JzqaPS/m8uAc+bWNQ/nt6keSRYK2vAzmIwwxhrVo+wn+FyW12KDtP+77pD8I VqKm1RWaAaEFZHj/zH+4sWGeBHI5SuRyvPDAYkP4oktcPnx6U0uUXjCy7VgyZr33jGsl 9jdFNg1CQE5fyzvoxrjzhErsvI+eVdo8Xenh20utrO74CTCaIdq8y6OHOVMZ9nr/Xmuy BZ9g== X-Forwarded-Encrypted: i=1; AKwUvBxeonuSFH+gWaEFZA1UwpD3w+MK000N7EKf5//h7dqAvEcF11q9A0ylfQ1gdDGVjU96DMNMOgrQ1tLpDUs=@vger.kernel.org X-Gm-Message-State: AFuF++kiSwkwUIlnQ/U+4+tSc3U0n0cjh7WH5FB54tfExO51vc7NN99C aH8oYOUn3AIW5A4S8C96YTcliN8q+KpcuFTPAMVeaAI5FxuX5uZxY8+m X-Gm-Gg: AYBFou0DWW4QzW1uzcAXXL06l0fZhiFmE/1M0lQKIEN+7YXxflQsCrsqNMwk18p2e12 id57njs+XT5VWAt34yC4FVvYzCrhM0bvqxOmZDk3xwPfGQBPnH/jW69gzaFUJAL+7yhL8kpfI91 FNk1gpk1I74nGMlZyxlS62Tkg/hLguS+pZsg6gGGeEKNubnp8kDDVhkNmxrEwNsdzfh7StXvYKK dv8vQ6F0xzSJpcqfDa5mUgjJDLrkwGDjPUn8o71JyVMj4Wws+rcaxAmfXjsrdb7TWCMcDG3TRr2 3/8s9XpoDQSBBwW5O6mQgivS4fRBpGel9QwmIit7Vc3LEssYnalSRcu9ZPxRBC8j2M91jaugcnX sV6X3EFPT9FI7uBb5AWfLIlDxF9u3T7OO/nuscvIgkqTDNJ2nr0YX+sRTPDgY580WfYsFXYnALe GjNtI93Em5zp2LlRfUizEzv7Fe2NCVimNY5+Lf6tVt3jSQTrafaYcrsoo= X-Received: by 2002:a17:902:f707:b0:2cf:6e5d:23e9 with SMTP id d9443c01a7336-2dafb0b191cmr174136725ad.14.1788604853368; Sat, 05 Sep 2026 03:40:53 -0700 (PDT) Received: from houminxi ([154.197.57.228]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3339b314cfcsm13559776eec.19.2026.09.05.03.40.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2026 03:40:52 -0700 (PDT) From: Minxi Hou To: netdev@vger.kernel.org Cc: aconole@redhat.com, davem@davemloft.net, dev@openvswitch.org, echaudro@redhat.com, edumazet@google.com, i.maximets@ovn.org, kuba@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, pabeni@redhat.com, shuah@kernel.org, horms@kernel.org, Minxi Hou Subject: [PATCH 2/4] selftests: openvswitch: fix misc pylint warnings in ovs-dpctl.py Date: Sat, 5 Sep 2026 06:40:24 -0400 Message-ID: <20260905104026.3776396-3-houminxi@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260905104026.3776396-1-houminxi@gmail.com> References: <20260905104026.3776396-1-houminxi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Fix miscellaneous pylint warnings with no behavior change: - W0611: remove unused import struct - W0702: replace bare except with except Exception - C0325: remove superfluous parentheses after return (3) - R1705: remove unnecessary elif after return (3) - W0108: replace unnecessary lambda with int - R1714: merge comparisons with in operator - W0719: replace raise Exception with raise ValueError - C1802: use implicit boolean test instead of len() - C0121: use is None instead of =3D=3D None - R1719: simplify if-expression to bool test - R1703: simplify if/else to assignment expression - W0612: remove unused variables (keybits, maskbits, lst) - replace unused loop variable with underscore Signed-off-by: Minxi Hou --- base-commit: 9eab111e765729e93087ff86a2ec9b2ae42d0fa5 .../selftests/net/openvswitch/ovs-dpctl.py | 44 ++++++++----------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py b/tools/t= esting/selftests/net/openvswitch/ovs-dpctl.py index 9cd0d8f0ab23..6a02810fe4ea 100644 --- a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py +++ b/tools/testing/selftests/net/openvswitch/ovs-dpctl.py @@ -11,7 +11,6 @@ import logging import math import multiprocessing import re -import struct import sys import time import types @@ -125,10 +124,7 @@ def parse_flags(flag_str, flag_vals): maskResult =3D int(digits, 0) =20 while len(flag_str) > 0 and (flag_str[0] =3D=3D "+" or flag_str[0] =3D= =3D "-"): - if flag_str[0] =3D=3D "+": - setFlag =3D True - elif flag_str[0] =3D=3D "-": - setFlag =3D False + setFlag =3D flag_str[0] =3D=3D "+" =20 flag_str =3D flag_str[1:] =20 @@ -221,10 +217,9 @@ def convert_int(size): =20 if not value: return 0, 0 - elif not mask: + if not mask: return int(value, 0), pow(2, size) - 1 - else: - return int(value, 0), int(mask, 0) + return int(value, 0), int(mask, 0) =20 return convert_int_sized =20 @@ -705,11 +700,11 @@ class ovsactions(nla): parsed =3D True else: actstr =3D actstr[len("drop"): ] - return (totallen - len(actstr)) + return totallen - len(actstr) =20 elif parse_starts_block(actstr, r"^(\d+)", False, True): actstr, output =3D parse_extract_field( - actstr, None, r"(\d+)", lambda x: int(x), False, "0" + actstr, None, r"(\d+)", int, False, "0" ) self["attrs"].append(["OVS_ACTION_ATTR_OUTPUT", output]) parsed =3D True @@ -761,12 +756,12 @@ class ovsactions(nla): vid =3D int(v, 0) if vid < 0 or vid > 0xFFF: raise ValueError( - f"push_vlan(): vid=3D{int(vid)} out of ran= ge (0-4095)") + f"push_vlan(): vid=3D{vid} out of range (0= -4095)") elif k =3D=3D "pcp": pcp =3D int(v, 0) if pcp < 0 or pcp > 7: raise ValueError( - f"push_vlan(): pcp=3D{int(pcp)} out of ran= ge (0-7)") + f"push_vlan(): pcp=3D{pcp} out of range (0= -7)") elif k =3D=3D "tpid": tpid =3D int(v, 0) if tpid < 0 or tpid > 0xFFFF: @@ -804,7 +799,6 @@ class ovsactions(nla): subacts =3D ovsactions() actstr =3D actstr[len("clone("):] parsedLen =3D subacts.parse(actstr) - lst =3D [] self["attrs"].append(("OVS_ACTION_ATTR_CLONE", subacts)) actstr =3D actstr[parsedLen:] parsed =3D True @@ -960,14 +954,14 @@ class ovsactions(nla): actstr =3D actstr[1:] =20 if len(actstr) and actstr[0] =3D=3D ")": - return (totallen - len(actstr)) + return totallen - len(actstr) =20 actstr =3D actstr[strspn(actstr, ", ") :] =20 if not parsed: raise ValueError(f"Action str: '{actstr}' not supported") =20 - return (totallen - len(actstr)) + return totallen - len(actstr) =20 =20 # pyroute2 resolves nla_map types via getattr(self, name). @@ -1057,8 +1051,6 @@ class ovskey(nla): if flowstr.startswith("("): flowstr =3D flowstr[1:] =20 - keybits =3D b"" - maskbits =3D b"" for f in self.fields_map: if flowstr.startswith(f[1]): # the following assumes that the field looks @@ -1067,7 +1059,7 @@ class ovskey(nla): flowstr =3D flowstr[len(f[1]) + 1 :] splitchar =3D 0 for c in flowstr: - if c =3D=3D "," or c =3D=3D ")": + if c in (",", ")"): break splitchar +=3D 1 data =3D flowstr[:splitchar] @@ -1631,7 +1623,7 @@ class ovskey(nla): for prefix, regex, typ, attr_name, mask_val, default_val, v46_= flag in fields: flowstr, value =3D parse_extract_field(flowstr, prefix, re= gex, typ, False) if not attr_name: - raise Exception("Bad list value in tunnel fields") + raise ValueError("Bad list value in tunnel fields") =20 if value is None and attr_name in forced_include: value =3D default_val @@ -1714,7 +1706,7 @@ class ovskey(nla): if not noprint: print_str +=3D "," =20 - if len(flagsattrs): + if flagsattrs: print_str +=3D f"flags({'|'.join(flagsattrs)})" print_str +=3D ")" return print_str @@ -2304,7 +2296,7 @@ class OvsDatapath(GenericNetlinkSocket): =20 nproc =3D multiprocessing.cpu_count() procarray =3D [] - for i in range(1, nproc): + for _ in range(1, nproc): procarray +=3D [int(p.epid)] msg["attrs"].append(["OVS_DP_ATTR_UPCALL_PID", procarray]) msg["attrs"].append(["OVS_DP_ATTR_USER_FEATURES", dpfeatures]) @@ -2379,15 +2371,17 @@ class OvsVport(GenericNetlinkSocket): def type_to_str(vport_type): if vport_type =3D=3D OvsVport.OVS_VPORT_TYPE_NETDEV: return "netdev" - elif vport_type =3D=3D OvsVport.OVS_VPORT_TYPE_INTERNAL: + if vport_type =3D=3D OvsVport.OVS_VPORT_TYPE_INTERNAL: return "internal" + raise ValueError(f"Unknown vport type:{int(vport_type)}") =20 def str_to_type(vport_type): if vport_type in ["netdev", "gre", "vxlan", "geneve"]: return OvsVport.OVS_VPORT_TYPE_NETDEV - elif vport_type =3D=3D "internal": + if vport_type =3D=3D "internal": return OvsVport.OVS_VPORT_TYPE_INTERNAL + raise ValueError(f"Unknown vport type: '{vport_type}'") =20 def __init__(self, packet=3DOvsPacket()): @@ -2482,7 +2476,7 @@ class OvsVport(GenericNetlinkSocket): msg["dpifindex"] =3D dpindex msg["attrs"].append(["OVS_VPORT_ATTR_NAME", vport_ifname]) =20 - if p =3D=3D None: + if p is None: p =3D self.upcall_packet else: self.upcall_packet =3D p @@ -3068,7 +3062,7 @@ def main(argv): return 1 rep =3D ovsflow.dump(rep["dpifindex"]) for flow in rep: - print(flow.dpstr(True if args.verbose > 0 else False)) + print(flow.dpstr(args.verbose > 0)) elif hasattr(args, "flbr"): rep =3D ovsdp.info(args.flbr, 0) if rep is None: --=20 2.55.0 From nobody Sun Sep 27 03:45:53 2026 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85BCD3C13E3 for ; Sat, 5 Sep 2026 10:41:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788604877; cv=none; b=XN0XYM1hmyPZYtbILgumwQ5WVOaDbjMG6mirQBP5j+MlcjzmOqkxy3rPmW3ggVxbfLOxdf9J86mntalR7lxyL6iQf5HpbvuNFxC3hKIB/TXh83LWYdVrJ6gGMH3AtvZ/jRwUpx373EUq93ev+aH1cIqhETxvtXzYFkLwcD/69jI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788604877; c=relaxed/simple; bh=byvJ6cDoECFPiIABGqWhpSuk/JBAwpvNeR95VdYydJ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LCXPPTeCGGXLDIjGwgoleU2FdGO62B0LCzapY1wytQPLin+qvbNlUlPHl7QMl291dBranoPv8TKVtdsBiLeOqKiDZ/olQtpuHFK1vNYVh2LW3sxkyGKDjMAMomF1ROGwL4JHTWomI2jrMEQt3gN09TBAscVUJb/kJBLaLkcPPrM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=E+Cm+yRh; arc=none smtp.client-ip=209.85.210.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E+Cm+yRh" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-86265451beeso622969b3a.0 for ; Sat, 05 Sep 2026 03:41:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788604861; x=1789209661; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=CiII+16dre11TT4H5s+rrA0Inivb15OxMDlBCk8aoaM=; b=E+Cm+yRhnehBIH/yrpCzF39n58kn//TIEVYaSrSH3AVbuNvUGl/5jRaXgxMePImWx3 L9Omcg8MGslA4//knuwku8ZAIrLCr37WwhmVVRRy2oLBDvWcpOAN+HwXT1HYXgpFNHf7 cRbBudd+PpxTeerWZRmjkFgjhwlGhcs+Tmx9tKOWjwudxGd4oodSjjHuilatFW/MVFFp bdq6KMh3Ayq/8F3sOh3CJoO3/5PzgO95PE/hcNzZNslRmKk8cOfiSQh+OvNx4aSSQ6IX S56/8Ku6Rn3yIqQZM5V6lo6vKLvV5Xuwb/A6L/AiGVQDy+TldLzYDIDfSXO/jOSGSzHc hD9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788604861; x=1789209661; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=CiII+16dre11TT4H5s+rrA0Inivb15OxMDlBCk8aoaM=; b=o9NJ1p5JUZf1LHGdXNhDbCpDuQ8KrSxglDhPu/d2F1Gpmh7+Jx+TonclA2fkrT4IXo NlDyYWvUOqHXq+RcBaD7ihHgXDJCwHPlsOfCFYDSf5uQbcDKkWmaWV79WitXYD/hMATr uv5jwODM0RH/mb2YkkTkP7WVvpRDrLDJ/UXbQKwAY3GTaSRvx5lwKeBOwpeoPvDjL4G7 SVHgJlG8xDHO5Xc6uqNWXmtFbntd7JfMy5mAamJufpNa+myYNkQEvu1ZhogwxtYJcN97 E9GLRJ01DxXBRkbeZenDdb3kLTxRV6JgTwGpw83asJJEkBsEkPh5WfE+aZiTolATWR19 AH2w== X-Forwarded-Encrypted: i=1; AKwUvBy2qvhRtUoGxR3mljdvctCJ0OesDlIJ0R4X3s1GKsehQQVEs6AEhfsYno/yjtJdmIaKdzddMiNbYRZqwPE=@vger.kernel.org X-Gm-Message-State: AFuF++nE34yslFvJmwI81OSTQ80RY6XXXZgquiQA0DVtK3B+qs0FecHT Cc9zUYrbTqKd9Ahtidn8A34ZE/xBPzzVTGHwgBTWegGuf1aUG6l0ZVZg X-Gm-Gg: AYBFou12ySkxtg2kMIufc7OZ0hEWcvOjTbu0CRj03uO2LmFkOU8gW1buajiOT9ecBTk Cw0/JOvKl/pCDvkrY5UT9VNjfylgCmWvvWDQDddsdyVaW+3twdddxWiqH551W0QbDUVXYC9O42i 1wGIreURU+2+WhlJJJyepLaBtZs990cicEzmzyMBzAhLlYBqjArLcfgVR7qOQje7pnYi8XkgKjx w6FwjuB99GdNkzZE/mY9A9AwhMh72MEj6TLELvtThOC0d5rDz8SFFPE/hag/0nDNLpAxjkMPEp3 v3P/7LmVw4Bv0Zk4Mn+kz5e7L/U/yWyQzNLwyeu8nki8BHeFuP375wXirZFb/9jJAfvQOFPnv98 9x4kKFxRH6jZO7jI4A4xPCEXvY2DQJl//Xe8dXmOb+IpyM5Ix1rgGziOBQ7S47B28lIsjW8kcif u1BB7AbR+Wrv9swdp2aqXsN8BJ/RvhuC06vjphv5S8t1yzIY3M2RUOc2rbMm1NL9Hj X-Received: by 2002:a05:6a20:bea6:b0:3bf:7e2a:e874 with SMTP id adf61e73a8af0-3da39b5c429mr18372372637.1.1788604860453; Sat, 05 Sep 2026 03:41:00 -0700 (PDT) Received: from houminxi ([154.197.57.228]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3339b314cfcsm13559776eec.19.2026.09.05.03.40.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2026 03:40:59 -0700 (PDT) From: Minxi Hou To: netdev@vger.kernel.org Cc: aconole@redhat.com, davem@davemloft.net, dev@openvswitch.org, echaudro@redhat.com, edumazet@google.com, i.maximets@ovn.org, kuba@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, pabeni@redhat.com, shuah@kernel.org, horms@kernel.org, Minxi Hou Subject: [PATCH 3/4] selftests: openvswitch: add missing docstrings in ovs-dpctl.py Date: Sat, 5 Sep 2026 06:40:25 -0400 Message-ID: <20260905104026.3776396-4-houminxi@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260905104026.3776396-1-houminxi@gmail.com> References: <20260905104026.3776396-1-houminxi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add one-line docstrings to all module, class, and method definitions to fix C0114, C0115, and C0116 pylint warnings (88 instances). Signed-off-by: Minxi Hou --- base-commit: 9eab111e765729e93087ff86a2ec9b2ae42d0fa5 .../selftests/net/openvswitch/ovs-dpctl.py | 110 ++++++++++++++++-- 1 file changed, 100 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py b/tools/t= esting/selftests/net/openvswitch/ovs-dpctl.py index 6a02810fe4ea..5b29aeb4b50e 100644 --- a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py +++ b/tools/testing/selftests/net/openvswitch/ovs-dpctl.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0 +"""OVS datapath control utility for kernel selftests.""" =20 # Controls the openvswitch module. Part of the kselftest suite, but # can be used for some diagnostic purpose as well. @@ -64,11 +65,13 @@ OVS_FLOW_CMD_SET =3D 4 UINT32_MAX =3D 0xFFFFFFFF =20 def macstr(mac): + """Format MAC address bytes as colon-separated hex string.""" outstr =3D ":".join([f"{i:02X}" for i in mac]) return outstr =20 =20 def strcspn(str1, str2): + """Return index of first char in str1 that is in str2.""" tot =3D 0 for char in str1: if str2.find(char) !=3D -1: @@ -78,6 +81,7 @@ def strcspn(str1, str2): =20 =20 def strspn(str1, str2): + """Return index of first char in str1 that is not in str2.""" tot =3D 0 for char in str1: if str2.find(char) =3D=3D -1: @@ -87,6 +91,7 @@ def strspn(str1, str2): =20 =20 def intparse(statestr, defmask=3D"0xffffffff"): + """Parse an integer with optional mask from a state string.""" totalparse =3D strspn(statestr, "0123456789abcdefABCDEFx/") # scan until "/" count =3D strspn(statestr, "x0123456789abcdefABCDEF") @@ -107,6 +112,7 @@ def intparse(statestr, defmask=3D"0xffffffff"): =20 =20 def parse_flags(flag_str, flag_vals): + """Parse flag string into bitmask and mask values.""" bitResult =3D 0 maskResult =3D 0 =20 @@ -158,6 +164,7 @@ def parse_flags(flag_str, flag_vals): =20 =20 def parse_ct_state(statestr): + """Parse conntrack state flags string.""" ct_flags =3D { "new": 1 << 0, "est": 1 << 1, @@ -173,6 +180,7 @@ def parse_ct_state(statestr): =20 =20 def convert_mac(data): + """Convert MAC address string with optional mask to bytes.""" def to_bytes(mac): mac_split =3D mac.split(":") ret =3D bytearray([int(i, 16) for i in mac_split]) @@ -188,6 +196,7 @@ def convert_mac(data): return to_bytes(mac_str), to_bytes(mask_str) =20 def convert_ipv4(data): + """Convert IPv4 address string with optional mask to integers.""" ip, _, mask =3D data.partition('/') =20 if not ip: @@ -200,6 +209,7 @@ def convert_ipv4(data): return int(ipaddress.IPv4Address(ip)), int(ipaddress.IPv4Address(mask)) =20 def convert_ipv6(data): + """Convert IPv6 address string with optional mask to packed bytes.""" ip, _, mask =3D data.partition('/') =20 if not ip: @@ -212,6 +222,7 @@ def convert_ipv6(data): return ipaddress.IPv6Address(ip).packed, ipaddress.IPv6Address(mask).p= acked =20 def convert_int(size): + """Return a converter for integer fields of the given bit size.""" def convert_int_sized(data): value, _, mask =3D data.partition('/') =20 @@ -224,6 +235,7 @@ def convert_int(size): return convert_int_sized =20 def parse_starts_block(block_str, scanstr, returnskipped, scanregex=3DFals= e): + """Check if block_str starts with scanstr, optionally skip it.""" if scanregex: m =3D re.search(scanstr, block_str) if m is None: @@ -250,6 +262,7 @@ def parse_starts_block(block_str, scanstr, returnskippe= d, scanregex=3DFalse): def parse_extract_field( block_str, fieldstr, scanfmt, convert, masked=3DFalse, defval=3DNone ): + """Extract a field value from block_str using regex scanfmt.""" if fieldstr and not block_str.startswith(fieldstr): return block_str, defval =20 @@ -349,6 +362,7 @@ def parse_attrs(actstr, attr_desc): =20 =20 class ovs_dp_msg(genlmsg): + """OVS datapath generic netlink message.""" # include the OVS version # We need a custom header rather than just being able to rely on # genlmsg because fields ends up not expressing everything correctly @@ -357,6 +371,7 @@ class ovs_dp_msg(genlmsg): =20 =20 class ovsactions(nla): + """OVS datapath actions netlink attribute.""" nla_flags =3D NLA_F_NESTED =20 nla_map =3D ( @@ -372,7 +387,7 @@ class ovsactions(nla): ("OVS_ACTION_ATTR_PUSH_MPLS", "none"), ("OVS_ACTION_ATTR_POP_MPLS", "flag"), ("OVS_ACTION_ATTR_SET_MASKED", "ovskey"), - ("OVS_ACTION_ATTR_CT", "ctact"), + ("OVS_ACTION_ATTR_CT", "CtAct"), ("OVS_ACTION_ATTR_TRUNC", "uint32"), ("OVS_ACTION_ATTR_PUSH_ETH", "none"), ("OVS_ACTION_ATTR_POP_ETH", "flag"), @@ -399,6 +414,7 @@ class ovsactions(nla): ) =20 class psample(nla): + """Packet sampling action attributes.""" nla_flags =3D NLA_F_NESTED =20 nla_map =3D ( @@ -408,6 +424,7 @@ class ovsactions(nla): ) =20 def dpstr(self, more=3DFalse): + """Format psample attributes as dpctl string.""" args =3D f"group=3D{int(self.get_attr('OVS_PSAMPLE_ATTR_GROUP'= ))}" =20 cookie =3D self.get_attr("OVS_PSAMPLE_ATTR_COOKIE") @@ -417,6 +434,7 @@ class ovsactions(nla): return f"psample({args})" =20 def parse(self, actstr): + """Parse psample attributes from dpctl string.""" desc =3D ( ("group", "OVS_PSAMPLE_ATTR_GROUP", int), ("cookie", "OVS_PSAMPLE_ATTR_COOKIE", @@ -431,9 +449,11 @@ class ovsactions(nla): return actstr =20 class push_vlan(nla): + """Push VLAN action fields (tpid + tci).""" fields =3D (("vlan_tpid", "!H"), ("vlan_tci", "!H")) =20 class sample(nla): + """sample action attributes.""" nla_flags =3D NLA_F_NESTED =20 nla_map =3D ( @@ -443,6 +463,7 @@ class ovsactions(nla): ) =20 def dpstr(self, more=3DFalse): + """Format sample attributes as dpctl string.""" args =3D [] =20 prob =3D 100 * self.get_attr( @@ -456,10 +477,11 @@ class ovsactions(nla): return f"sample({','.join(args)})" =20 def parse(self, actstr): + """Parse sample attributes from dpctl string.""" def parse_nested_actions(actstr): subacts =3D ovsactions() - parsed_len =3D subacts.parse(actstr) - return subacts, actstr[parsed_len :] + parsedLen =3D subacts.parse(actstr) + return subacts, actstr[parsedLen :] =20 def percent_to_rate(percent): percent =3D float(percent.strip('%')) @@ -476,7 +498,8 @@ class ovsactions(nla): =20 return actstr =20 - class ctact(nla): + class CtAct(nla): + """Conntrack action attributes.""" nla_flags =3D NLA_F_NESTED =20 nla_map =3D ( @@ -493,6 +516,7 @@ class ovsactions(nla): ) =20 class natattr(nla): + """NAT sub-action attributes.""" nla_flags =3D NLA_F_NESTED =20 nla_map =3D ( @@ -509,6 +533,7 @@ class ovsactions(nla): ) =20 def dpstr(self, more=3DFalse): + """Format NAT attributes as dpctl string.""" print_str =3D "nat(" =20 if self.get_attr("OVS_NAT_ATTR_SRC"): @@ -547,6 +572,7 @@ class ovsactions(nla): return print_str =20 def dpstr(self, more=3DFalse): + """Format conntrack attributes as dpctl string.""" print_str =3D "ct(" =20 if self.get_attr("OVS_CT_ATTR_COMMIT") is not None: @@ -568,6 +594,7 @@ class ovsactions(nla): return print_str =20 class userspace(nla): + """userspace action attributes.""" nla_flags =3D NLA_F_NESTED =20 nla_map =3D ( @@ -578,6 +605,7 @@ class ovsactions(nla): ) =20 def dpstr(self, more=3DFalse): + """Format userspace attributes as dpctl string.""" print_str =3D "userspace(" if self.get_attr("OVS_USERSPACE_ATTR_PID") is not None: print_str +=3D f"pid=3D{int(self.get_attr('OVS_USERSPACE_A= TTR_PID'))}," @@ -593,6 +621,7 @@ class ovsactions(nla): return print_str =20 def parse(self, actstr): + """Parse userspace attributes from dpctl string.""" attrs_desc =3D ( ("pid", "OVS_USERSPACE_ATTR_PID", int), ("userdata", "OVS_USERSPACE_ATTR_USERDATA", @@ -607,6 +636,7 @@ class ovsactions(nla): return actstr =20 def dpstr(self, more=3DFalse): + """Format all actions as dpctl string.""" print_str =3D "" =20 for field in self["attrs"]: @@ -669,12 +699,13 @@ class ovsactions(nla): else: try: print_str +=3D datum.dpstr(more) - except: - print_str +=3D "{ATTR: %s not decoded}" % field[0] + except Exception: + print_str +=3D f"{{ATTR: {field[0]} not decoded}}" =20 return print_str =20 def parse(self, actstr): + """Parse actions from dpctl string.""" totallen =3D len(actstr) while len(actstr) !=3D 0: parsed =3D False @@ -784,7 +815,7 @@ class ovsactions(nla): parencount +=3D 2 subacts =3D ovsactions() actstr =3D actstr[len("dec_ttl(le_1("):] - parsed_len =3D subacts.parse(actstr) + parsedLen =3D subacts.parse(actstr) decttl =3D ovsactions.dec_ttl() decttl["attrs"].append( ("OVS_DEC_TTL_ATTR_ACTION", subacts) @@ -792,7 +823,7 @@ class ovsactions(nla): self["attrs"].append( ("OVS_ACTION_ATTR_DEC_TTL", decttl) ) - actstr =3D actstr[parsed_len:] + actstr =3D actstr[parsedLen:] parsed =3D True elif parse_starts_block(actstr, "clone(", False): parencount +=3D 1 @@ -824,7 +855,7 @@ class ovsactions(nla): elif parse_starts_block(actstr, "ct(", False): parencount +=3D 1 actstr =3D actstr[len("ct(") :] - ctact =3D ovsactions.ctact() + ctact =3D ovsactions.CtAct() =20 for scan in ( ("commit", "OVS_CT_ATTR_COMMIT", None), @@ -851,7 +882,7 @@ class ovsactions(nla): # sub-action and this lets it sit anywhere in the ct()= action if actstr.startswith("nat"): actstr =3D actstr[3:] - natact =3D ovsactions.ctact.natattr() + natact =3D ovsactions.CtAct.natattr() =20 if actstr.startswith("("): parencount +=3D 1 @@ -971,6 +1002,7 @@ ovsactions.dec_ttl.actions =3D ovsactions =20 =20 class ovskey(nla): + """OVS flow key netlink attribute.""" nla_flags =3D NLA_F_NESTED nla_map =3D ( ("OVS_KEY_ATTR_UNSPEC", "none"), @@ -1009,6 +1041,7 @@ class ovskey(nla): ) =20 class ovs_key_proto(nla): + """Protocol key fields (ethertype).""" fields =3D ( ("src", "!H"), ("dst", "!H"), @@ -1041,6 +1074,7 @@ class ovskey(nla): ) =20 def parse(self, flowstr, typeInst): + """Parse protocol key from dpctl string.""" if not flowstr.startswith(self.proto_str): return None, None =20 @@ -1082,6 +1116,7 @@ class ovskey(nla): return flowstr, k, m =20 def dpstr(self, masked=3DNone, more=3DFalse): + """Format protocol key as dpctl string.""" outstr =3D f"{self.proto_str}(" first =3D False for f in self.fields_map: @@ -1110,6 +1145,7 @@ class ovskey(nla): return outstr =20 class ethaddr(ovs_key_proto): + """Ethernet address key fields.""" fields =3D ( ("src", "!6s"), ("dst", "!6s"), @@ -1151,6 +1187,7 @@ class ovskey(nla): ) =20 class ovs_key_ipv4(ovs_key_proto): + """IPv4 key fields.""" fields =3D ( ("src", "!I"), ("dst", "!I"), @@ -1204,6 +1241,7 @@ class ovskey(nla): ) =20 class ovs_key_ipv6(ovs_key_proto): + """IPv6 key fields.""" fields =3D ( ("src", "!16s"), ("dst", "!16s"), @@ -1260,6 +1298,7 @@ class ovskey(nla): ) =20 class ovs_key_tcp(ovs_key_proto): + """TCP key fields (src/dst port).""" def __init__( self, data=3DNone, @@ -1279,6 +1318,7 @@ class ovskey(nla): ) =20 class ovs_key_udp(ovs_key_proto): + """UDP key fields (src/dst port).""" def __init__( self, data=3DNone, @@ -1298,6 +1338,7 @@ class ovskey(nla): ) =20 class ovs_key_sctp(ovs_key_proto): + """SCTP key fields (src/dst port).""" def __init__( self, data=3DNone, @@ -1317,6 +1358,7 @@ class ovskey(nla): ) =20 class ovs_key_icmp(ovs_key_proto): + """ICMP key fields (type/code).""" fields =3D ( ("type", "B"), ("code", "B"), @@ -1348,6 +1390,7 @@ class ovskey(nla): ) =20 class ovs_key_icmpv6(ovs_key_icmp): + """ICMPv6 key fields (type/code).""" def __init__( self, data=3DNone, @@ -1367,6 +1410,7 @@ class ovskey(nla): ) =20 class ovs_key_arp(ovs_key_proto): + """ARP key fields.""" fields =3D ( ("sip", "!I"), ("tip", "!I"), @@ -1427,6 +1471,7 @@ class ovskey(nla): ) =20 class ovs_key_nd(ovs_key_proto): + """Neighbor discovery key fields.""" fields =3D ( ("target", "!16s"), ("sll", "!6s"), @@ -1463,6 +1508,7 @@ class ovskey(nla): ) =20 class ovs_key_ct_tuple_ipv4(ovs_key_proto): + """Conntrack original tuple key (IPv4).""" fields =3D ( ("src", "!I"), ("dst", "!I"), @@ -1510,6 +1556,7 @@ class ovskey(nla): ) =20 class ovs_key_ct_tuple_ipv6(nla): + """Conntrack original tuple key (IPv6).""" fields =3D ( ("src", "!16s"), ("dst", "!16s"), @@ -1555,6 +1602,7 @@ class ovskey(nla): ) =20 class ovs_key_tunnel(nla): + """Tunnel key fields.""" nla_flags =3D NLA_F_NESTED =20 nla_map =3D ( @@ -1578,6 +1626,7 @@ class ovskey(nla): ) =20 def parse(self, flowstr, mask=3DNone): + """Parse tunnel key from dpctl string.""" if not flowstr.startswith("tunnel("): return None, None =20 @@ -1670,6 +1719,7 @@ class ovskey(nla): return flowstr, k, mask =20 def dpstr(self, mask=3DNone, more=3DFalse): + """Format tunnel key as dpctl string.""" print_str =3D "tunnel(" =20 flagsattrs =3D [] @@ -1712,6 +1762,7 @@ class ovskey(nla): return print_str =20 class ovs_key_mpls(nla): + """MPLS key fields.""" fields =3D (("lse", ">I"),) =20 # 802.1Q CFI (Canonical Format Indicator) bit, always set for Ethernet @@ -1901,6 +1952,7 @@ class ovskey(nla): return flowstr, inner_key, inner_mask =20 def parse(self, flowstr, mask=3DNone): + """Parse flow key from dpctl string.""" for field in ( ("OVS_KEY_ATTR_PRIORITY", "skb_priority", intparse), ("OVS_KEY_ATTR_SKB_MARK", "skb_mark", intparse), @@ -1997,6 +2049,7 @@ class ovskey(nla): return flowstr =20 def dpstr(self, mask=3DNone, more=3DFalse): + """Format flow key as dpctl string.""" print_str =3D "" =20 for field in ( @@ -2166,11 +2219,13 @@ class encap_ovskey(ovskey): =20 =20 class OvsPacket(GenericNetlinkSocket): + """OVS packet command message.""" OVS_PACKET_CMD_MISS =3D 1 # Flow table miss OVS_PACKET_CMD_ACTION =3D 2 # USERSPACE action OVS_PACKET_CMD_EXECUTE =3D 3 # Apply actions to packet =20 class ovs_packet_msg(ovs_dp_msg): + """OVS packet message header.""" nla_map =3D ( ("OVS_PACKET_ATTR_UNSPEC", "none"), ("OVS_PACKET_ATTR_PACKET", "array(uint8)"), @@ -2191,6 +2246,7 @@ class OvsPacket(GenericNetlinkSocket): self.bind(OVS_PACKET_FAMILY, OvsPacket.ovs_packet_msg) =20 def upcall_handler(self, up=3DNone): + """Execute a packet on the datapath.""" print("listening on upcall packet handler:", self.epid) while True: try: @@ -2211,6 +2267,7 @@ class OvsPacket(GenericNetlinkSocket): =20 =20 class OvsDatapath(GenericNetlinkSocket): + """OVS datapath management.""" OVS_DP_F_VPORT_PIDS =3D 1 << 1 OVS_DP_F_DISPATCH_UPCALL_PER_CPU =3D 1 << 3 =20 @@ -2232,6 +2289,7 @@ class OvsDatapath(GenericNetlinkSocket): ) =20 class dpstats(nla): + """Datapath info message.""" fields =3D ( ("hit", "=3DQ"), ("missed", "=3DQ"), @@ -2240,6 +2298,7 @@ class OvsDatapath(GenericNetlinkSocket): ) =20 class megaflowstats(nla): + """Datapath statistics.""" fields =3D ( ("mask_hit", "=3DQ"), ("masks", "=3DI"), @@ -2253,6 +2312,7 @@ class OvsDatapath(GenericNetlinkSocket): self.bind(OVS_DATAPATH_FAMILY, OvsDatapath.dp_cmd_msg) =20 def info(self, dpname, ifindex=3D0): + """Create a new datapath.""" msg =3D OvsDatapath.dp_cmd_msg() msg["cmd"] =3D OVS_DP_CMD_GET msg["version"] =3D OVS_DATAPATH_VERSION @@ -2276,6 +2336,7 @@ class OvsDatapath(GenericNetlinkSocket): def create( self, dpname, shouldUpcall=3DFalse, versionStr=3DNone, p=3DOvsPack= et() ): + """Destroy a datapath.""" msg =3D OvsDatapath.dp_cmd_msg() msg["cmd"] =3D OVS_DP_CMD_NEW if versionStr is None: @@ -2317,6 +2378,7 @@ class OvsDatapath(GenericNetlinkSocket): return reply =20 def destroy(self, dpname): + """Look up a datapath by name.""" msg =3D OvsDatapath.dp_cmd_msg() msg["cmd"] =3D OVS_DP_CMD_DEL msg["version"] =3D OVS_DATAPATH_VERSION @@ -2339,10 +2401,12 @@ class OvsDatapath(GenericNetlinkSocket): =20 =20 class OvsVport(GenericNetlinkSocket): + """OVS virtual port management.""" OVS_VPORT_TYPE_NETDEV =3D 1 OVS_VPORT_TYPE_INTERNAL =3D 2 =20 class ovs_vport_msg(ovs_dp_msg): + """Vport info message.""" nla_map =3D ( ("OVS_VPORT_ATTR_UNSPEC", "none"), ("OVS_VPORT_ATTR_PORT_NO", "uint32"), @@ -2356,7 +2420,9 @@ class OvsVport(GenericNetlinkSocket): ("OVS_VPORT_ATTR_NETNSID", "uint32"), ) =20 + class vportstats(nla): + """Tunnel options attributes.""" fields =3D ( ("rx_packets", "=3DQ"), ("tx_packets", "=3DQ"), @@ -2368,7 +2434,9 @@ class OvsVport(GenericNetlinkSocket): ("tx_dropped", "=3DQ"), ) =20 + @staticmethod def type_to_str(vport_type): + """Convert vport type integer to string.""" if vport_type =3D=3D OvsVport.OVS_VPORT_TYPE_NETDEV: return "netdev" if vport_type =3D=3D OvsVport.OVS_VPORT_TYPE_INTERNAL: @@ -2376,7 +2444,9 @@ class OvsVport(GenericNetlinkSocket): =20 raise ValueError(f"Unknown vport type:{int(vport_type)}") =20 + @staticmethod def str_to_type(vport_type): + """Convert vport type string to integer.""" if vport_type in ["netdev", "gre", "vxlan", "geneve"]: return OvsVport.OVS_VPORT_TYPE_NETDEV if vport_type =3D=3D "internal": @@ -2390,6 +2460,7 @@ class OvsVport(GenericNetlinkSocket): self.upcall_packet =3D packet =20 def info(self, vport_name, dpifindex=3D0, portno=3DNone): + """Create a new vport.""" msg =3D OvsVport.ovs_vport_msg() =20 msg["cmd"] =3D OVS_VPORT_CMD_GET @@ -2415,6 +2486,7 @@ class OvsVport(GenericNetlinkSocket): return reply =20 def attach(self, dpindex, vport_ifname, ptype, dport): + """Get info about a vport.""" msg =3D OvsVport.ovs_vport_msg() =20 msg["cmd"] =3D OVS_VPORT_CMD_NEW @@ -2468,6 +2540,7 @@ class OvsVport(GenericNetlinkSocket): return reply =20 def reset_upcall(self, dpindex, vport_ifname, p=3DNone): + """Attach a vport to a datapath.""" msg =3D OvsVport.ovs_vport_msg() =20 msg["cmd"] =3D OVS_VPORT_CMD_SET @@ -2493,6 +2566,7 @@ class OvsVport(GenericNetlinkSocket): return reply =20 def detach(self, dpindex, vport_ifname): + """Reset a vport.""" msg =3D OvsVport.ovs_vport_msg() =20 msg["cmd"] =3D OVS_VPORT_CMD_DEL @@ -2514,11 +2588,14 @@ class OvsVport(GenericNetlinkSocket): return reply =20 def upcall_handler(self, handler=3DNone): + """Remove a vport from a datapath.""" self.upcall_packet.upcall_handler(handler) =20 =20 class OvsFlow(GenericNetlinkSocket): + """OVS flow table management.""" class ovs_flow_msg(ovs_dp_msg): + """Flow info message.""" nla_map =3D ( ("OVS_FLOW_ATTR_UNSPEC", "none"), ("OVS_FLOW_ATTR_KEY", "ovskey"), @@ -2534,12 +2611,14 @@ class OvsFlow(GenericNetlinkSocket): ) =20 class flowstats(nla): + """Flow key/mask/actions message.""" fields =3D ( ("packets", "=3DQ"), ("bytes", "=3DQ"), ) =20 def dpstr(self, more=3DFalse): + """Format flow as dpctl string.""" ufid =3D self.get_attr("OVS_FLOW_ATTR_UFID") ufid_str =3D "" if ufid is not None: @@ -2606,6 +2685,7 @@ class OvsFlow(GenericNetlinkSocket): return print_str =20 def parse(self, flowstr, actstr, dpidx=3D0): + """Parse flow from dpctl string.""" OVS_UFID_F_OMIT_KEY =3D 1 << 0 OVS_UFID_F_OMIT_MASK =3D 1 << 1 OVS_UFID_F_OMIT_ACTIONS =3D 1 << 2 @@ -2770,6 +2850,7 @@ class OvsFlow(GenericNetlinkSocket): return rep =20 def miss(self, packetmsg): + """Dump all flows for a datapath.""" seq =3D packetmsg["header"]["sequence_number"] keystr =3D "(none)" key_field =3D packetmsg.get_attr("OVS_PACKET_ATTR_KEY") @@ -2782,13 +2863,16 @@ class OvsFlow(GenericNetlinkSocket): print(f"MISS upcall[{int(seq)}/{pktpres}]: {keystr}", flush=3DTrue) =20 def execute(self, packetmsg): + """Delete a flow from a datapath.""" print("userspace execute command", flush=3DTrue) =20 def action(self, packetmsg): + """Add a flow to a datapath.""" print("userspace action command", flush=3DTrue) =20 =20 class psample_sample(genlmsg): + """psample generic netlink event handler.""" nla_map =3D ( ("PSAMPLE_ATTR_IIFINDEX", "none"), ("PSAMPLE_ATTR_OIFINDEX", "none"), @@ -2809,6 +2893,7 @@ class psample_sample(genlmsg): ) =20 def dpstr(self): + """Start receiving psample events.""" fields =3D [] data =3D "" for (attr, value) in self["attrs"]: @@ -2826,6 +2911,7 @@ class psample_sample(genlmsg): =20 =20 class psample_msg(Marshal): + """psample generic netlink message.""" PSAMPLE_CMD_SAMPLE =3D 0 PSAMPLE_CMD_GET_GROUP =3D 1 PSAMPLE_CMD_NEW_GROUP =3D 2 @@ -2835,11 +2921,13 @@ class psample_msg(Marshal): =20 =20 class PsampleEvent(EventSocket): + """psample event listener.""" genl_family =3D "psample" mcast_groups =3D ["packets"] marshal_class =3D psample_msg =20 def read_samples(self): + """Set the psample group to listen on.""" print("listening for psample events", flush=3DTrue) while True: try: @@ -2850,6 +2938,7 @@ class PsampleEvent(EventSocket): =20 =20 def print_ovsdp_full(dp_lookup_rep, ifindex, ndb=3DNDB(), vpl=3DOvsVport()= ): + """Print full OVS datapath information.""" dp_name =3D dp_lookup_rep.get_attr("OVS_DP_ATTR_NAME") base_stats =3D dp_lookup_rep.get_attr("OVS_DP_ATTR_STATS") megaflow_stats =3D dp_lookup_rep.get_attr("OVS_DP_ATTR_MEGAFLOW_STATS") @@ -2885,6 +2974,7 @@ def print_ovsdp_full(dp_lookup_rep, ifindex, ndb=3DND= B(), vpl=3DOvsVport()): =20 =20 def main(argv): + """Entry point for ovs-dpctl utility.""" nlmsg_atoms.encap_ovskey =3D encap_ovskey nlmsg_atoms.ovskey =3D ovskey nlmsg_atoms.ovsactions =3D ovsactions --=20 2.55.0 From nobody Sun Sep 27 03:45:53 2026 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF6E64503E6 for ; Sat, 5 Sep 2026 10:41:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788604875; cv=none; b=JjXW/TLhVBOoRXH7qyTaP4WdinP8Axa6FAg9NbHBOK3oy+Glq6qbrqB42Yv/Fob3hyayDjQ1xluMnCyneZGfYkE1xne43kbmq6xTJ51VDNei7wRhrCtknx4RXZCrodxu4VxuHBfo3k31+bNpMbD6LD8XoNAkUu7JAzoVA1neRdo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788604875; c=relaxed/simple; bh=3H7DWsjdB2t1XmW+qQclm6nGtSHSe5mjsU+kx9BBsDA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o8vWVO0rM3nNKBU560btUgPgtoTEWU4ArWN+c+KL/FUnpFUCcQ6NULLX8upLQPqW7eUkC3Uaqcs4Iloduy+BytZXeeMtFpMb0Jd+j7lTOA6GHd/ikyqArfUEH/QAloXbveFj6bpbWawr0YgZmojuYoB3lc3/oxgCQRQaMHUhK0o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ox+SKv45; arc=none smtp.client-ip=209.85.215.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ox+SKv45" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-c9aea40d799so1089929a12.0 for ; Sat, 05 Sep 2026 03:41:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788604867; x=1789209667; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=9d1us5ou1/R6dn+w5YFLXgBK3EMQL/jKg3S7fI7Edk4=; b=Ox+SKv45BlaCEgLEb11cuz3fFHPGcjrNp5+W59jn0QCLx7ScN0xBi8gARYNmidb9iM YSIfySIz3j8o9LU6RWKcKs3/YcIYecNaE4l0Cb09pykqNr92+mUEQOpUpZg5ynlQZuM2 lILrZbOqaiKyIUsyPx3OJ8Ynq9S8LcfwjQUrprSadJjI+m3nSNPEO7tHOAFTHYeLzuCI t1aSYao4Md0PGLXYGXaVSN88rheZJDNtQh6PT1YhzKU2x3B3gxMoy9me7jmSskVquWn5 BRsvb1avRdwlV1RMXMbCsB34cv7F4ETuhDFVXeFSyRDGhclxkZAZn5/udKBzxEQb8/fc WkMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788604867; x=1789209667; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=9d1us5ou1/R6dn+w5YFLXgBK3EMQL/jKg3S7fI7Edk4=; b=kkkhX4coaPCfZjH31K4EulWRc9FJheTy5Dovk9AIUotsLeze/3PO/12hJ/kGZ7EVSb 6GOK9utJQxSE+yts9CrNy2V/nCFI2YlcS2zBMkjpFkJwTwhOg2Xj5mQ9QtV4zKIi8s/s 3DxLGrw6XM2Cu8HYilFcVanyWMnknZsdcpqfWP4J67gXTWMdQmy3uDHwG453NQl1Py38 vVHTVlTaLVRDm57FFV0zvdvdS/FrhKvIMigZwY2jacQN7FKcp6O7yhxU6ExPsu8L7uhZ z4nW08BxCdkT9jTZFux/BSWTPLYT2Y7YdBd/HFytyLzW8rm44UKPYBPjbrV1Rt5ULXD3 ZILQ== X-Forwarded-Encrypted: i=1; AKwUvBwJ6NlG3tMzP/0/Z2v1HgIZEjzZoCevEQKrVqnA1dKJpBWg9NyQide36bU7B85qB9Jvl7p9pqQnn1BB/e0=@vger.kernel.org X-Gm-Message-State: AFuF++kp5sjNUhmhI8QdyQ50e4QfbbGu6Mfs8RKbBBwWpX1zC0UTZzAh RmS5vf4nzFG5ivDqQ3uqmPOKTwIJ2BJkofuL6reT0ghdJp590u4Gg0E5 X-Gm-Gg: AYBFou32VUX7wyM46NpSUPqWcXXC59KVjm1qUYhIf5GIdpAAgde5jwqoWLicsDCc0Mp bhF/pidGZL3epZL0M9mWvc/za2LvdGvwufHN7k8X7dTSxekllVOIQMEhrgivmfe6Uv7gCTzUdtW owvTP78s77LGK2S1YFXxWmt14q8N76jVeAP8JgTQpKJ2F+CXdudr/LyxpxjqA6mD5Hw8HJOq88P U1Oh7oI3MOmZ1Drk1JoXGvdQm0MzqoYCIHXkV3V0zbuYISh6bUpnpLuehQBFdQQ2KByFxdlNGv3 +9iKlldK+j115ngn92MTWYIjhbxt41WWTMsgJppPb332QqOQmKjRrwjSHQdPjX4YwqoppIy4CgV gwPapD5XFLiEN20qI06hYdXqiQ4KsUewKdLmTDwfRMI1ffzPyz7x9Wv9bmXJomoCVc4PwS4A3jt zJEDHzegrNlo1MnV5HkN+GnbFubM5V3fZ/BYbC772BD1pvR8KzsVQzNQ== X-Received: by 2002:a17:90b:2b8b:b0:398:c0ad:711c with SMTP id 98e67ed59e1d1-39b26272f0fmr18850197a91.15.1788604866501; Sat, 05 Sep 2026 03:41:06 -0700 (PDT) Received: from houminxi ([154.197.57.228]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3339b314cfcsm13559776eec.19.2026.09.05.03.41.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Sep 2026 03:41:05 -0700 (PDT) From: Minxi Hou To: netdev@vger.kernel.org Cc: aconole@redhat.com, davem@davemloft.net, dev@openvswitch.org, echaudro@redhat.com, edumazet@google.com, i.maximets@ovn.org, kuba@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, pabeni@redhat.com, shuah@kernel.org, horms@kernel.org, Minxi Hou Subject: [PATCH 4/4] selftests: openvswitch: suppress pylint complexity warnings Date: Sat, 5 Sep 2026 06:40:26 -0400 Message-ID: <20260905104026.3776396-5-houminxi@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260905104026.3776396-1-houminxi@gmail.com> References: <20260905104026.3776396-1-houminxi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add file-level pylint:disable comments for warnings caused by pyroute2 framework constraints that cannot be fixed without restructuring the netlink attribute hierarchy. After this patch, pylint reports 9.93/10 with 10 remaining C0301 line-too-long warnings (81-89 columns) on f-string constructions that match the surrounding style. Signed-off-by: Minxi Hou --- base-commit: 9eab111e765729e93087ff86a2ec9b2ae42d0fa5 tools/testing/selftests/net/openvswitch/ovs-dpctl.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py b/tools/t= esting/selftests/net/openvswitch/ovs-dpctl.py index 5b29aeb4b50e..5948471ffe63 100644 --- a/tools/testing/selftests/net/openvswitch/ovs-dpctl.py +++ b/tools/testing/selftests/net/openvswitch/ovs-dpctl.py @@ -1,6 +1,14 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0 """OVS datapath control utility for kernel selftests.""" +# pylint: disable=3Dinvalid-name,too-many-lines +# pylint: disable=3Dtoo-many-ancestors,too-many-arguments +# pylint: disable=3Dtoo-many-positional-arguments,too-many-branches +# pylint: disable=3Dtoo-many-locals,too-many-statements +# pylint: disable=3Dtoo-many-return-statements,too-many-nested-blocks +# pylint: disable=3Dunused-argument,broad-exception-caught +# pylint: disable=3Dno-member,not-callable +# pylint: disable=3Dnon-parent-init-called,super-init-not-called =20 # Controls the openvswitch module. Part of the kselftest suite, but # can be used for some diagnostic purpose as well. --=20 2.55.0