From patchwork Fri Aug 2 04:04:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: LIU Yulong X-Patchwork-Id: 1968110 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (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 4WZsjw5t9lz1ybX for ; Fri, 2 Aug 2024 14:07:31 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 19A7F820FA; Fri, 2 Aug 2024 04:07:28 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id rdaFQtfdwmCV; Fri, 2 Aug 2024 04:07:27 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org EA415820E2 Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id EA415820E2; Fri, 2 Aug 2024 04:07:26 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B88ACC002B; Fri, 2 Aug 2024 04:07:26 +0000 (UTC) X-Original-To: ovs-dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3F622C002A for ; Fri, 2 Aug 2024 04:07:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 1929A4067B for ; Fri, 2 Aug 2024 04:07:25 +0000 (UTC) X-Virus-Scanned: amavis at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavis, port 10024) with ESMTP id 3CS1pPhiQTKn for ; Fri, 2 Aug 2024 04:07:24 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=43.154.197.177; helo=bg5.exmail.qq.com; envelope-from=i@liuyulong.me; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp4.osuosl.org E43CD40341 Authentication-Results: smtp4.osuosl.org; dmarc=none (p=none dis=none) header.from=liuyulong.me DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org E43CD40341 Received: from bg5.exmail.qq.com (bg5.exmail.qq.com [43.154.197.177]) by smtp4.osuosl.org (Postfix) with ESMTPS id E43CD40341 for ; Fri, 2 Aug 2024 04:07:22 +0000 (UTC) X-QQ-mid: bizesmtp85t1722571498t8z43pqd X-QQ-Originating-IP: I5lPtOC7ZbEVbACZPFdePFtx0hdXcyDOVpyxLrrD6LE= Received: from localhost.localdomain ( [114.247.186.97]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 02 Aug 2024 12:04:56 +0800 (CST) X-QQ-SSF: 0001000000000000000000000000000 X-QQ-GoodBg: 2 X-BIZMAIL-ID: 16687256340390985074 From: LIU Yulong To: ovs-dev@openvswitch.org Date: Fri, 2 Aug 2024 12:04:45 +0800 Message-Id: <20240802040445.1765-1-i@liuyulong.me> X-Mailer: git-send-email 2.28.0.windows.1 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:liuyulong.me:qybglogicsvrgz:qybglogicsvrgz7a-0 Subject: [ovs-dev] [PATCH] utilities: Add a GDB macro to dump ct conns. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Add a new GDB macro called ovs_dump_conntrack_conns, which can be used to dump all conn structure in a conntrack. For example (gdb) ovs_dump_conntrack_conns usage: ovs_dump_conntrack_conns (gdb) ovs_dump_conntrack_conns 0x558e658c9660 (struct conn *) 0x7f4094016960 (struct conn *) 0x7f4094045b30 (struct conn *) 0x7f409406fa80 Signed-off-by: LIU Yulong --- utilities/gdb/ovs_gdb.py | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/utilities/gdb/ovs_gdb.py b/utilities/gdb/ovs_gdb.py index 982395dd1..e7167f29e 100644 --- a/utilities/gdb/ovs_gdb.py +++ b/utilities/gdb/ovs_gdb.py @@ -37,6 +37,7 @@ # - ovs_dump_udpif_keys {|} {short} # - ovs_show_fdb {[] {dbg} {hash}} # - ovs_show_upcall {dbg} +# - ovs_dump_conntrack_conns # # Example: # $ gdb $(which ovs-vswitchd) $(pidof ovs-vswitchd) @@ -1549,6 +1550,45 @@ class CmdDumpPackets(gdb.Command): return packet +# +# Implements the GDB "ovs_dump_conntrack_conns" command +# +class CmdDumpDpConntrackConn(gdb.Command): + """Dump all connections in a conntrack set + Usage: + ovs_dump_conntrack_conns + + : Pointer to conntrack + + Example dumping all connections: + + (gdb) ovs_dump_ofpacts actions actions_len + (struct conn *) 0x7f4094016960 + (struct conn *) 0x7f4094045b30 + (struct conn *) 0x7f409406fa80 + (struct conn *) 0x7f4094081360 + """ + def __init__(self): + super(CmdDumpDpConntrackConn, self).__init__( + "ovs_dump_conntrack_conns", + gdb.COMMAND_DATA) + + @staticmethod + def display_single_conn(conn, indent=0): + indent = " " * indent + print("{}(struct conn *) {} ".format(indent, conn)) + + def invoke(self, arg, from_tty): + arg_list = gdb.string_to_argv(arg) + if len(arg_list) != 1: + print("usage: ovs_dump_conntrack_conns " + "") + return + ct = gdb.parse_and_eval(arg_list[0]).cast( + gdb.lookup_type('struct conntrack').pointer()) + for node in ForEachCMAP(ct["conns"], "struct conn", "cm_node"): + self.display_single_conn(node) + # # Initialize all GDB commands @@ -1571,3 +1611,4 @@ CmdDumpSmap() CmdDumpUdpifKeys() CmdShowFDB() CmdShowUpcall() +CmdDumpDpConntrackConn()