On 2 Aug 2024, at 6:04, LIU Yulong 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 > Thanks for the patch, I did not test it, but I have some small comments inline. > (gdb) ovs_dump_conntrack_conns > usage: ovs_dump_conntrack_conns <struct conntrack *> > > (gdb) ovs_dump_conntrack_conns 0x558e658c9660 Single space between ovs_dump_conntrack_conns and the address. > (struct conn *) 0x7f4094016960 > (struct conn *) 0x7f4094045b30 > (struct conn *) 0x7f409406fa80 > > Signed-off-by: LIU Yulong <[email protected]> > --- > 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 {<udpif_name>|<udpif_address>} {short} > # - ovs_show_fdb {[<bridge_name>] {dbg} {hash}} > # - ovs_show_upcall {dbg} > +# - ovs_dump_conntrack_conns <struct conntrack *> > # > # 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 <struct conntrack *> > + > + <struct conntrack *> : Pointer to conntrack > + > + Example dumping all <struct conn> connections: > + > + (gdb) ovs_dump_ofpacts actions actions_len You forgot to replace the example with a real example for this command. > + (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 " > + "<struct conntrack *>") This print() will fit on one line. > + return Add a newline here. > + ct = gdb.parse_and_eval(arg_list[0]).cast( > + gdb.lookup_type('struct conntrack').pointer()) Add a newline here. > + for node in ForEachCMAP(ct["conns"], "struct conn", "cm_node"): As we do not use the indent, and it’s a simple function, I would just replace this with the below for now: print("(struct conn *) {} ".format(node)) Or are you planning to display some structure details? If so, you can do that in this patch, and add a “short” option to only dump the address. > + self.display_single_conn(node) > + > > # > # Initialize all GDB commands > @@ -1571,3 +1611,4 @@ CmdDumpSmap() > CmdDumpUdpifKeys() > CmdShowFDB() > CmdShowUpcall() > +CmdDumpDpConntrackConn() > -- > 2.27.0 > > _______________________________________________ > 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
