Message ID | 20240802040445.1765-1-i@liuyulong.me |
---|---|
State | Changes Requested |
Headers | show |
Series | [ovs-dev] utilities: Add a GDB macro to dump ct conns. | expand |
Context | Check | Description |
---|---|---|
ovsrobot/apply-robot | success | apply and check: success |
ovsrobot/github-robot-_Build_and_Test | fail | github build: failed |
ovsrobot/intel-ovs-compilation | fail | test: fail |
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 <i@liuyulong.me> > --- > 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 > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Thank you Eelco for reviewing the patch. I will upload patch v2 with the new {short} param and printing attributes of struct conn. LIU Yulong i@liuyulong.me From: Eelco Chaudron Date: 2024-08-07 21:52 To: LIU Yulong CC: ovs-dev Subject: Re: [ovs-dev] [PATCH] utilities: Add a GDB macro to dump ct conns. 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 <i@liuyulong.me> > --- > 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 > dev@openvswitch.org > https://mail.openvswitch.org/mailman/listinfo/ovs-dev
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 + (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 *>") + 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()
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 *> (gdb) ovs_dump_conntrack_conns 0x558e658c9660 (struct conn *) 0x7f4094016960 (struct conn *) 0x7f4094045b30 (struct conn *) 0x7f409406fa80 Signed-off-by: LIU Yulong <i@liuyulong.me> --- utilities/gdb/ovs_gdb.py | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)