From patchwork Tue Apr 9 13:49:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Ding X-Patchwork-Id: 1921408 X-Patchwork-Delegate: aconole@redhat.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=clrPJTKJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VDS550ZJ8z1yYH for ; Tue, 9 Apr 2024 23:50:00 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 2165460C2A; Tue, 9 Apr 2024 13:49:59 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 3QvL2trAzjYT; Tue, 9 Apr 2024 13:49:58 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=2605:bc80:3010:104::8cd3:938; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 1B0AA606F0 Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=clrPJTKJ Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 1B0AA606F0; Tue, 9 Apr 2024 13:49:58 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id E3D07C007C; Tue, 9 Apr 2024 13:49:57 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 26FEAC0037 for ; Tue, 9 Apr 2024 13:49:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 0E25260706 for ; Tue, 9 Apr 2024 13:49:57 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id W538yAiJ5YY8 for ; Tue, 9 Apr 2024 13:49:56 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::636; helo=mail-pl1-x636.google.com; envelope-from=danieldin186@gmail.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org 3FADB606F0 Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=gmail.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 3FADB606F0 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by smtp3.osuosl.org (Postfix) with ESMTPS id 3FADB606F0 for ; Tue, 9 Apr 2024 13:49:55 +0000 (UTC) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1e3cf5b171eso28634235ad.0 for ; Tue, 09 Apr 2024 06:49:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712670594; x=1713275394; darn=openvswitch.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=w1UVSbByxx14tq0t4jdp4eTIBChJHyyQl06/GoiIIVU=; b=clrPJTKJkvL5M+VtCOuieKtkWxic601t8qSFdw3VFS8vWsQlmLIenrKGB/6wBmpFFU YexR6Hp+F4UEq3guUQ2Fx4UR2l3Sbqhes7+6qF4PdInOSP6SjuF+8auIGOidYYNsC+rh mm2b6I328Um5ne5UFKVErAtLzbk2xeisz4Ux0HGQE6chF3qmvqMkvBMH8WBy2D5noqu1 dDK8EHaoOY1E0FdYNgwfpuebmrb+Qrk7MKWNlHj+zbABw24sv7HYqgbHoO2PzdRW3pB/ Ew8Kg/pDuqfFAIfp4NWp2lb0quJ5UeTTyqbzodQJvhT9Hm3LB9BnY5/R/scbvGlQRIaQ +7sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712670594; x=1713275394; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=w1UVSbByxx14tq0t4jdp4eTIBChJHyyQl06/GoiIIVU=; b=EQLdh39xsAphVRkMdWWg+Jh3vYS6aMP7Zbk65AzxEfJgEEFzwXcTzqehqYUHaUSiWR Wod/+ggcNota+eolbCwJaxtFjl4jGIHhgGq5BDCMdpNMMxZEQyh+nB649Tx05jy/1mhN wy6MjoeLDVQ/2pnG0OPHneOwoyHrF0DJy6RoxjQ06716hMlN51wU9EfogMx+LpnSpBLU wZC4iNSMPLPm++bAxKcIk9GQkJmHG+abL7NIFJgUBNaipnxtrcCzO4SWVE6XIw81KAhM XYUBEpSrD0ehkWDrqlZT0og3atTRD3fZTpjTpNUrh+r3lKFvaKADDrVa3TSMZYXArel5 BLdg== X-Gm-Message-State: AOJu0YzoxxA05qScNtJ2Htuyq2SK/NWZZI+yVquLp5SQAFaxqckdI1Lk wMBmTDMaz/V+EWRf8rueV/Y39glJUxJcTC9ERw8ZHMe/cVtgFgun/kBXrehhWOg= X-Google-Smtp-Source: AGHT+IHJXCNksM13v99bmNTYnjz2U6uhVkAiHH99aa0RfnoGTyxRHC80/tz3QykB4orsgkH1whgk1A== X-Received: by 2002:a17:902:f641:b0:1e3:e39a:2e49 with SMTP id m1-20020a170902f64100b001e3e39a2e49mr9984946plg.18.1712670594486; Tue, 09 Apr 2024 06:49:54 -0700 (PDT) Received: from ny.luscis.cn ([45.159.50.93]) by smtp.gmail.com with ESMTPSA id z17-20020a170903019100b001e452f47ba1sm3221663plg.173.2024.04.09.06.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 06:49:54 -0700 (PDT) From: Daniel Ding To: dev@openvswitch.org Date: Tue, 9 Apr 2024 21:49:47 +0800 Message-Id: <20240409134947.1892-1-danieldin186@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Cc: Daniel Ding Subject: [ovs-dev] [PATCH v2] ovs-tcpdump: Support vlan option. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" When I try filter geneve protocol with a vlan, the warning message occurs that tell me the kernel can't support this combination. $ ovs-tcpdump -i eth2 -nne vlan 10 and geneve Warning: Kernel filter failed: Invalid argument The fix is to make a convenience argument that sets the mirror port's select_vlan column, and also marks the port as native tagged with VLAN. Signed-off-by: Daniel Ding --- utilities/ovs-tcpdump.in | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/utilities/ovs-tcpdump.in b/utilities/ovs-tcpdump.in index eada803bb..f2fb2f04b 100755 --- a/utilities/ovs-tcpdump.in +++ b/utilities/ovs-tcpdump.in @@ -142,6 +142,8 @@ The following options are available: --mirror-to The name for the mirror port to use (optional) Default 'miINTERFACE' --span If specified, mirror all ports (optional) + --vlan If specified, mirror vlan traffic and pop + its tag (optional) """ % {'prog': sys.argv[0]}) sys.exit(0) @@ -319,7 +321,7 @@ class OVSDB(object): (mirror_name, txn.get_error())) self._txn = None - def make_port(self, port_name, bridge_name): + def make_port(self, port_name, bridge_name, vlan=None): iface_row = self.make_interface(port_name, False) txn = self._txn @@ -330,6 +332,10 @@ class OVSDB(object): port = txn.insert(self.get_table('Port')) port.name = port_name + if vlan is not None: + port.verify('tag') + port.tag = [vlan] + br.verify('ports') ports = getattr(br, 'ports', []) ports.append(port) @@ -354,7 +360,7 @@ class OVSDB(object): return result def bridge_mirror(self, intf_name, mirror_intf_name, br_name, - mirror_select_all=False): + mirror_select_all=False, mirrored_vlan=None): txn = self._start_txn() mirror = txn.insert(self.get_table('Mirror')) @@ -374,6 +380,12 @@ class OVSDB(object): src_port.append(mirrored_port) mirror.select_src_port = src_port + if mirrored_vlan: + mirror.verify('select_vlan') + select_vlan = getattr(mirror, 'select_vlan', []) + select_vlan.append(mirrored_vlan) + mirror.select_vlan = select_vlan + output_port = self._find_row_by_name('Port', mirror_intf_name) mirror.verify('output_port') @@ -440,6 +452,7 @@ def main(): db_sock = 'unix:%s' % os.path.join(rundir, "db.sock") interface = None tcpdargs = [] + vlan = None skip_next = False mirror_interface = None @@ -474,12 +487,25 @@ def main(): elif cur in ['--span']: mirror_select_all = True continue + elif cur in ['--vlan']: + vlan = nxt + skip_next = True + continue tcpdargs.append(cur) if interface is None: print("Error: must at least specify an interface with '-i' option") sys.exit(1) + if vlan: + try: + vlan = int(vlan) + if vlan < 0 or vlan > 4095: + raise ValueError("out of range") + except ValueError: + print("Error: vlan must be within <0-4095>") + sys.exit(1) + if not py_which(dump_cmd): print("Error: unable to execute '%s' (check PATH)" % dump_cmd) sys.exit(1) @@ -523,10 +549,11 @@ def main(): teardown(db_sock, interface, mirror_interface, tap_created) try: - ovsdb.make_port(mirror_interface, ovsdb.port_bridge(interface)) + ovsdb.make_port(mirror_interface, + ovsdb.port_bridge(interface), vlan) ovsdb.bridge_mirror(interface, mirror_interface, ovsdb.port_bridge(interface), - mirror_select_all) + mirror_select_all, vlan) except OVSDBException as oe: print("ERROR: Unable to properly setup the mirror: %s." % str(oe)) sys.exit(1)