On 12 Aug 2024, at 18:14, Mike Pattrick wrote:
> Hello! > > Thank you for this contribution! There were two flake8 warnings that > need to be fixed before it can be accepted, detailed below. In addition when you send out a v3, please also make sure the revision is represented in the subject line. Thanks, Eelco > Cheers, > M > > > On Thu, Aug 8, 2024 at 10:17 PM LIU Yulong <[email protected]> wrote: >> >> 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 <struct conntrack *> {short} >> >> (gdb) ovs_dump_conntrack_conns 0x5606339c25e0 >> (struct conn *) 0x7f32c000a8c0: expiration = 26162886419, mark = 0, dl_type >> = 8, zone = 3, nw_proto = 6 '\006' >> (struct conn *) 0x7f32c00489d0: expiration = 26162900867, mark = 0, dl_type >> = 8, zone = 3, nw_proto = 1 '\001' >> (struct conn *) 0x7f32c0153bb0: expiration = 26249266420, mark = 0, dl_type >> = 8, zone = 3, nw_proto = 6 '\006' >> >> (gdb) ovs_dump_conntrack_conns 0x5606339c25e0 short >> (struct conn *) 0x7f32c000a8c0 >> (struct conn *) 0x7f32c00489d0 >> (struct conn *) 0x7f32c0153bb0 >> >> Signed-off-by: LIU Yulong <[email protected]> >> --- >> >> v1: initial version >> v2: address comments from reviewers >> print details of struct conn >> add short param >> >> --- >> utilities/gdb/ovs_gdb.py | 56 ++++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 56 insertions(+) >> >> diff --git a/utilities/gdb/ovs_gdb.py b/utilities/gdb/ovs_gdb.py >> index 982395dd1..0964a31eb 100644 >> --- a/utilities/gdb/ovs_gdb.py >> +++ b/utilities/gdb/ovs_gdb.py >> @@ -37,6 +37,7 @@ >> # - ovs_dump_udpif_keys {<udpif_name>|<udpif_address>} {short} >> # - ovs_show_fdb {[<bridge_name>] {dbg} {hash}} >> # - ovs_show_upcall {dbg} >> +# - ovs_dump_conntrack_conns <struct conntrack *> {short} >> # >> # Example: >> # $ gdb $(which ovs-vswitchd) $(pidof ovs-vswitchd) >> @@ -1549,6 +1550,60 @@ class CmdDumpPackets(gdb.Command): >> >> return packet >> > Flake8 reports: > > utilities/gdb/ovs_gdb.py:1556:1: E302 expected 2 blank lines, found 1 > >> +# >> +# Implements the GDB "ovs_dump_conntrack_conns" command >> +# >> +class CmdDumpDpConntrackConn(gdb.Command): >> + """Dump all connections in a conntrack set >> + Usage: >> + ovs_dump_conntrack_conns <struct conntrack *> {short} >> + >> + <struct conntrack *> : Pointer to conntrack >> + short : Only dump conn structure addresses, >> + no content details >> + >> + Example dumping all <struct conn> connections: >> + >> + (gdb) ovs_dump_conntrack_conns 0x5606339c25e0 >> + (struct conn *) 0x7f32c000a8c0: expiration = ... nw_proto = 1 >> + (struct conn *) 0x7f32c00489d0: expiration = ... nw_proto = 6 >> + (struct conn *) 0x7f32c0153bb0: expiration = ... nw_proto = 17 >> + >> + (gdb) ovs_dump_conntrack_conns 0x5606339c25e0 short >> + (struct conn *) 0x7f32c000a8c0 >> + (struct conn *) 0x7f32c00489d0 >> + (struct conn *) 0x7f32c0153bb0 >> + """ >> + def __init__(self): >> + super(CmdDumpDpConntrackConn, self).__init__( >> + "ovs_dump_conntrack_conns", >> + gdb.COMMAND_DATA) >> + >> + @staticmethod >> + def display_single_conn(conn, indent=0, short=False): >> + indent = " " * indent >> + if short: >> + print("{}(struct conn *) {}".format(indent, conn)) >> + else: >> + print("{}(struct conn *) {}: expiration = {}, mark = {}, " >> + "dl_type = {}, zone = {}, nw_proto = {}".format( >> + indent, conn, conn['expiration'], >> + conn['mark'], conn['key']['dl_type'], >> + conn['key']['zone'], >> + conn['key']['nw_proto'])) >> + >> + def invoke(self, arg, from_tty): >> + arg_list = gdb.string_to_argv(arg) >> + if len(arg_list) == 0: >> + print("usage: ovs_dump_conntrack_conns <struct conntrack *> >> {short}") > > Flake8 reports: > utilities/gdb/ovs_gdb.py:1598:80: E501 line too long (81 > 79 characters) > > >> + 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, short="short" in arg_list[1:]) >> + >> >> # >> # Initialize all GDB commands >> @@ -1571,3 +1626,4 @@ CmdDumpSmap() >> CmdDumpUdpifKeys() >> CmdShowFDB() >> CmdShowUpcall() >> +CmdDumpDpConntrackConn() >> -- >> 2.28.0.windows.1 >> >> _______________________________________________ >> dev mailing list >> [email protected] >> https://mail.openvswitch.org/mailman/listinfo/ovs-dev >> > > _______________________________________________ > dev mailing list > [email protected] > https://mail.openvswitch.org/mailman/listinfo/ovs-dev _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
