[ovs-dev] [PATCH ovn v8] ovn-sbctl.c Add logical flows count numbers
From: Alexey Roytman For big scale deployments, when number of logical flows can be 2M+, sometimes users just need to know the total number of logical flows and numbers of logical flows per table/per datapath. New command output Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: ingress table=0 (ls_in_port_sec_l2 ) lflows=2 table=1 (ls_in_port_sec_ip ) lflows=1 table=2 (ls_in_port_sec_nd ) lflows=1 table=3 (ls_in_lookup_fdb ) lflows=1 table=4 (ls_in_put_fdb ) lflows=1 table=5 (ls_in_pre_acl ) lflows=2 table=6 (ls_in_pre_lb ) lflows=3 table=7 (ls_in_pre_stateful ) lflows=2 table=8 (ls_in_acl_hint ) lflows=1 table=9 (ls_in_acl ) lflows=2 table=10(ls_in_qos_mark ) lflows=1 table=11(ls_in_qos_meter) lflows=1 table=12(ls_in_lb ) lflows=1 table=13(ls_in_stateful ) lflows=8 table=14(ls_in_pre_hairpin ) lflows=1 table=15(ls_in_nat_hairpin ) lflows=1 table=16(ls_in_hairpin ) lflows=1 table=17(ls_in_arp_rsp ) lflows=1 table=18(ls_in_dhcp_options ) lflows=1 table=19(ls_in_dhcp_response) lflows=1 table=20(ls_in_dns_lookup ) lflows=1 table=21(ls_in_dns_response ) lflows=1 table=22(ls_in_external_port) lflows=1 table=23(ls_in_l2_lkup ) lflows=3 table=24(ls_in_l2_unknown ) lflows=2 Total number of logical flows in the datapath "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: ingress = 41 Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: egress table=0 (ls_out_pre_lb ) lflows=3 table=1 (ls_out_pre_acl ) lflows=2 table=2 (ls_out_pre_stateful) lflows=2 table=3 (ls_out_lb ) lflows=1 table=4 (ls_out_acl_hint) lflows=1 table=5 (ls_out_acl ) lflows=2 table=6 (ls_out_qos_mark) lflows=1 table=7 (ls_out_qos_meter ) lflows=1 table=8 (ls_out_stateful) lflows=3 table=9 (ls_out_port_sec_ip ) lflows=1 table=10(ls_out_port_sec_l2 ) lflows=1 Total number of logical flows in the datapath "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: egress = 18 Total number of logical flows = 59 Signed-off-by: Alexey Roytman --- V6 -> V7 * Addressed commit b6f0e51d8b52cf2381503c3c1c5c2a0d6bd7afa6 and Matk's comments v5 -> v6 * Addressed Ben's comments about replacemen the --count flag of lflow-list/dump-flows by a a "count-flows" command. v3 -> v4 * Addressed review comments from Mark --- tests/ovn-sbctl.at| 69 - utilities/ovn-sbctl.8.xml | 3 ++ utilities/ovn-sbctl.c | 106 +++--- 3 files changed, 169 insertions(+), 9 deletions(-) diff --git a/tests/ovn-sbctl.at b/tests/ovn-sbctl.at index f49134381..16f5dabcc 100644 --- a/tests/ovn-sbctl.at +++ b/tests/ovn-sbctl.at @@ -175,4 +175,71 @@ inactivity_probe: 3 OVN_SBCTL_TEST([ovn_sbctl_invalid_0x_flow], [invalid 0x flow], [ check ovn-sbctl lflow-list 0x12345678 -]) \ No newline at end of file +]) + +dnl - + +OVN_SBCTL_TEST([ovn_sbctl_count_flows], [ovn-sbctl - count-flows], [ + +count_entries() { +ovn-sbctl --column=_uuid list Logical_Flow | sed -r '/^\s*$/d' | wc -l +} + +count_pipeline() { +ovn-sbctl --column=pipeline list Logical_Flow | grep $1 | sed -r '/^\s*$/d' | wc -l +} + +# we start with empty Logical_Flow table +# validate that the table is indeed empty +AT_CHECK([count_entries], [0], [dnl +0 +]) + +AT_CHECK([ovn-sbctl count-flows], [0], [dnl +Total number of logical flows = 0 +]) + +# create some logical flows +check ovn-nbctl ls-add count-test + +OVS_WAIT_UNTIL([total_lflows=`count_entries`; test $total_lflows -ne 0]) + +total_lflows=`count_entries` +egress_lflows=`count_pipeline egress` +ingress_lflows=`count_pipeline ingress` + +AT_CHECK_UNQUOTED([ovn-sbctl count-flows | grep "flows =" | awk 'NF>1{print $NF}'], [0], [dnl +$total_lflows +]) +AT_CHECK_UNQUOTED([ovn-sbctl count-flows | grep Total | grep egress | awk 'NF>1{print $NF}'], [0], [dnl +$egress_lflows +]) +AT_CHECK_UNQUOTED([ovn-sbctl count-flows | grep Total | grep ingress | awk 'NF>1{print $NF}'], [0], [dnl +$ingress_lflows +]) + +# add another datapath +check ovn-nbctl ls-add count-test2 + +# check total logical flows in 2 datapathes +AT_CHECK_UNQUOTED([ovn-sbctl count-flows | grep "flows =" | awk 'NF>1{print $NF}'], [0], [dnl +$(($total_lflows * 2)) +]) +# check total logical flows in a specific datapath +AT_CHECK_UNQUOTED([ovn-sbctl count-flows count-test | grep "flows =" | awk 'NF>1{print $NF}'], [0], [dnl +$total_lflows +]) + +AT_CHECK_UNQUOTED([ovn-sbctl count-flows count-test | grep Total | grep egress | awk 'NF>1{print $NF}'], [0], [dnl +$egress_lflows +]) +AT_CHECK_UNQUOTED([ovn-sbctl count-flows count-test | grep Tot
[ovs-dev] [PATCH ovn v7] ovn-sbctl.c Add logical flows count numbers
From: Alexey Roytman For big scale deployments, when number of logical flows can be 2M+, sometimes users just need to know the total number of logical flows and numbers of logical flows per table/per datapath. New command output Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: ingress table=0 (ls_in_port_sec_l2 ) lflows=2 table=1 (ls_in_port_sec_ip ) lflows=1 table=2 (ls_in_port_sec_nd ) lflows=1 table=3 (ls_in_lookup_fdb ) lflows=1 table=4 (ls_in_put_fdb ) lflows=1 table=5 (ls_in_pre_acl ) lflows=2 table=6 (ls_in_pre_lb ) lflows=3 table=7 (ls_in_pre_stateful ) lflows=2 table=8 (ls_in_acl_hint ) lflows=1 table=9 (ls_in_acl ) lflows=2 table=10(ls_in_qos_mark ) lflows=1 table=11(ls_in_qos_meter) lflows=1 table=12(ls_in_lb ) lflows=1 table=13(ls_in_stateful ) lflows=8 table=14(ls_in_pre_hairpin ) lflows=1 table=15(ls_in_nat_hairpin ) lflows=1 table=16(ls_in_hairpin ) lflows=1 table=17(ls_in_arp_rsp ) lflows=1 table=18(ls_in_dhcp_options ) lflows=1 table=19(ls_in_dhcp_response) lflows=1 table=20(ls_in_dns_lookup ) lflows=1 table=21(ls_in_dns_response ) lflows=1 table=22(ls_in_external_port) lflows=1 table=23(ls_in_l2_lkup ) lflows=3 table=24(ls_in_l2_unknown ) lflows=2 Total number of logical flows in the datapath "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: ingress = 41 Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: egress table=0 (ls_out_pre_lb ) lflows=3 table=1 (ls_out_pre_acl ) lflows=2 table=2 (ls_out_pre_stateful) lflows=2 table=3 (ls_out_lb ) lflows=1 table=4 (ls_out_acl_hint) lflows=1 table=5 (ls_out_acl ) lflows=2 table=6 (ls_out_qos_mark) lflows=1 table=7 (ls_out_qos_meter ) lflows=1 table=8 (ls_out_stateful) lflows=3 table=9 (ls_out_port_sec_ip ) lflows=1 table=10(ls_out_port_sec_l2 ) lflows=1 Total number of logical flows in the datapath "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: egress = 18 Total number of logical flows = 59 Signed-off-by: Alexey Roytman fix comments Signed-off-by: Alexey Roytman --- V6 -> V7 * Addressed commit b6f0e51d8b52cf2381503c3c1c5c2a0d6bd7afa6 and Matk's comments v5 -> v6 * Addressed Ben's comments about replacemen the --count flag of lflow-list/dump-flows by a a "count-flows" command. v3 -> v4 * Addressed review comments from Mark --- tests/ovn-sbctl.at| 69 +++- utilities/ovn-sbctl.8.xml | 3 ++ utilities/ovn-sbctl.c | 108 ++ 3 files changed, 170 insertions(+), 10 deletions(-) diff --git a/tests/ovn-sbctl.at b/tests/ovn-sbctl.at index f49134381..16f5dabcc 100644 --- a/tests/ovn-sbctl.at +++ b/tests/ovn-sbctl.at @@ -175,4 +175,71 @@ inactivity_probe: 3 OVN_SBCTL_TEST([ovn_sbctl_invalid_0x_flow], [invalid 0x flow], [ check ovn-sbctl lflow-list 0x12345678 -]) \ No newline at end of file +]) + +dnl - + +OVN_SBCTL_TEST([ovn_sbctl_count_flows], [ovn-sbctl - count-flows], [ + +count_entries() { +ovn-sbctl --column=_uuid list Logical_Flow | sed -r '/^\s*$/d' | wc -l +} + +count_pipeline() { +ovn-sbctl --column=pipeline list Logical_Flow | grep $1 | sed -r '/^\s*$/d' | wc -l +} + +# we start with empty Logical_Flow table +# validate that the table is indeed empty +AT_CHECK([count_entries], [0], [dnl +0 +]) + +AT_CHECK([ovn-sbctl count-flows], [0], [dnl +Total number of logical flows = 0 +]) + +# create some logical flows +check ovn-nbctl ls-add count-test + +OVS_WAIT_UNTIL([total_lflows=`count_entries`; test $total_lflows -ne 0]) + +total_lflows=`count_entries` +egress_lflows=`count_pipeline egress` +ingress_lflows=`count_pipeline ingress` + +AT_CHECK_UNQUOTED([ovn-sbctl count-flows | grep "flows =" | awk 'NF>1{print $NF}'], [0], [dnl +$total_lflows +]) +AT_CHECK_UNQUOTED([ovn-sbctl count-flows | grep Total | grep egress | awk 'NF>1{print $NF}'], [0], [dnl +$egress_lflows +]) +AT_CHECK_UNQUOTED([ovn-sbctl count-flows | grep Total | grep ingress | awk 'NF>1{print $NF}'], [0], [dnl +$ingress_lflows +]) + +# add another datapath +check ovn-nbctl ls-add count-test2 + +# check total logical flows in 2 datapathes +AT_CHECK_UNQUOTED([ovn-sbctl count-flows | grep "flows =" | awk 'NF>1{print $NF}'], [0], [dnl +$(($total_lflows * 2)) +]) +# check total logical flows in a specific datapath +AT_CHECK_UNQUOTED([ovn-sbctl count-flows count-test | grep "flows =" | awk 'NF>1{print $NF}'], [0], [dnl +$total_lflows +]) + +AT_CHECK_UNQUOTED([ovn-sbctl count-flows count-test | grep Total | grep egress | awk 'NF>1{print $NF}'], [0], [dnl +$egress_lflows +]) +AT_CH
[ovs-dev] [PATCH v1] ovsdb-server.7.rst Fix response result of monitor_cond_change
From: Alexey Roytman The original version said that "monitor_cond_change" request response should contain '"result": null'. However, if response message has form like {"id":13, "result":null} or {"id":13} the ovsdb client (ovn-controller) returns the folling misleading message and closes connection. 2021-06-07T14:32:30.116Z|00026|jsonrpc|WARN|tcp:172.18.0.4:6642: received bad JSON-RPC message: request must have "method" 2021-06-07T14:32:30.116Z|00027|reconnect|WARN|tcp:172.18.0.4:6642: connection dropped (Protocol error) Signed-off-by: Alexey Roytman --- Documentation/ref/ovsdb-server.7.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/ref/ovsdb-server.7.rst b/Documentation/ref/ovsdb-server.7.rst index 04414350a..e1dca6dca 100644 --- a/Documentation/ref/ovsdb-server.7.rst +++ b/Documentation/ref/ovsdb-server.7.rst @@ -304,7 +304,7 @@ monitoring session. The response object has the following members:: -"result": null +"result": {} "error": null "id": same "id" as request -- 2.25.1 ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Re: [ovs-dev] [PATCH ovn v6] ovn-sbctl.c Add logical flows count numbers
Hi Aaron, These are not operators, but command names. Could you suggest please how to prevent these warnings. ? Thanks Alexey. On Sat, May 29, 2021 at 8:01 PM 0-day Robot wrote: > Bleep bloop. Greetings Alexey Roytman, I am a robot and I have tried out > your patch. > Thanks for your contribution. > > I encountered some error that I wasn't expecting. See the details below. > > > checkpatch: > WARNING: Line lacks whitespace around operator > #146 FILE: utilities/ovn-sbctl.c:108: > lflow-list [DATAPATH] [LFLOW...] list logical flows for DATAPATH\n\ > > WARNING: Line lacks whitespace around operator > #147 FILE: utilities/ovn-sbctl.c:109: > dump-flows [DATAPATH] [LFLOW...] alias for lflow-list\n\ > > WARNING: Line lacks whitespace around operator > #148 FILE: utilities/ovn-sbctl.c:110: > count-flows [DATAPATH]count logical flows for DATAPATH\n\ > > Lines checked: 350, Warnings: 3, Errors: 0 > > > Please check this out. If you feel there has been an error, please email > acon...@redhat.com > > Thanks, > 0-day Robot > ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev
[ovs-dev] [PATCH ovn v6] ovn-sbctl.c Add logical flows count numbers
From: Alexey Roytman For big scale deployments, when number of logical flows can be 2M+, sometimes users just need to know the total number of logical flows and numbers of logical flows per table/per datapath. New command output ovn-sbctl count-flows Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) pipeline: ingress table=0 (ls_in_port_sec_l2 ) lflows=2 table=1 (ls_in_port_sec_ip ) lflows=1 table=2 (ls_in_port_sec_nd ) lflows=1 table=3 (ls_in_lookup_fdb ) lflows=1 table=4 (ls_in_put_fdb ) lflows=1 table=5 (ls_in_pre_acl ) lflows=2 table=6 (ls_in_pre_lb ) lflows=3 table=7 (ls_in_pre_stateful ) lflows=2 table=8 (ls_in_acl_hint ) lflows=1 table=9 (ls_in_acl ) lflows=2 table=10(ls_in_qos_mark ) lflows=1 table=11(ls_in_qos_meter) lflows=1 table=12(ls_in_lb ) lflows=1 table=13(ls_in_stateful ) lflows=8 table=14(ls_in_pre_hairpin ) lflows=1 table=15(ls_in_nat_hairpin ) lflows=1 table=16(ls_in_hairpin ) lflows=1 table=17(ls_in_arp_rsp ) lflows=1 table=18(ls_in_dhcp_options ) lflows=1 table=19(ls_in_dhcp_response) lflows=1 table=20(ls_in_dns_lookup ) lflows=1 table=21(ls_in_dns_response ) lflows=1 table=22(ls_in_external_port) lflows=1 table=23(ls_in_l2_lkup ) lflows=3 table=24(ls_in_l2_unknown ) lflows=2 Total number of logical flows in the datapath "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) pipeline: ingress = 41 Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) pipeline: egress table=0 (ls_out_pre_lb ) lflows=3 table=1 (ls_out_pre_acl ) lflows=2 table=2 (ls_out_pre_stateful) lflows=2 table=3 (ls_out_lb ) lflows=1 table=4 (ls_out_acl_hint) lflows=1 table=5 (ls_out_acl ) lflows=2 table=6 (ls_out_qos_mark) lflows=1 table=7 (ls_out_qos_meter ) lflows=1 table=8 (ls_out_stateful) lflows=3 table=9 (ls_out_port_sec_ip ) lflows=1 table=10(ls_out_port_sec_l2 ) lflows=1 Total number of logical flows in the datapath "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) pipeline: egress = 18 Total number of logical flows = 59 Signed-off-by: Alexey Roytman --- v5 -> v6 * Addressed Ben's comments about replacemen the --count flag of lflow-list/dump-flows by a a "count-flows" command. v3 -> v4 * Addressed review comments from Mark NOTE: In the current ovn-sbctl (and probably ovn-nbctl) implementation, some of the methods do not work, when the utility is running in the daemon mode (there is no output). All printf methods should be replaced by "ds_put_*" methods. I can work on that in a separate path. Meantime, I added to temporary functions "print_datapath_name_new" and "print_datapath_prompt_new" just for finishing this task. tests/ovn-sbctl.at| 45 ++- utilities/ovn-sbctl.8.xml | 4 + utilities/ovn-sbctl.c | 153 +++--- 3 files changed, 190 insertions(+), 12 deletions(-) diff --git a/tests/ovn-sbctl.at b/tests/ovn-sbctl.at index f49134381..ff727281e 100644 --- a/tests/ovn-sbctl.at +++ b/tests/ovn-sbctl.at @@ -175,4 +175,47 @@ inactivity_probe: 3 OVN_SBCTL_TEST([ovn_sbctl_invalid_0x_flow], [invalid 0x flow], [ check ovn-sbctl lflow-list 0x12345678 -]) \ No newline at end of file +]) + +dnl - + +OVN_SBCTL_TEST([ovn_sbctl_count_flows], [ovn-sbctl - count-flows], [ + +count_entries() { +ovn-sbctl --column=_uuid list Logical_Flow | sed -r '/^\s*$/d' | wc -l +} + +count_pipeline() { +ovn-sbctl --column=pipeline list Logical_Flow | grep $1 | sed -r '/^\s*$/d' | wc -l +} + +# we start with empty Logical_Flow table +# validate that the table is indeed empty +AT_CHECK([count_entries], [0], [dnl +0 +]) + +AT_CHECK([ovn-sbctl count-flows], [0], [stdout], [stderr]) + +AT_CHECK([ovn-sbctl count-flows], [0], [dnl +Total number of logical flows = 0 +]) + +# create some logical flows +check ovn-nbctl ls-add count-test + +OVS_WAIT_UNTIL([total_lflows=`count_entries`; test $total_lflows -ne 0]) + +egress_lflows=`count_pipeline egress` +ingress_lflows=`count_pipeline ingress` + +AT_CHECK_UNQUOTED([ovn-sbctl count-flows | grep "flows =" | awk 'NF>1{print $NF}'], [0], [dnl +$total_lflows +]) +AT_CHECK_UNQUOTED([ovn-sbctl count-flows | grep Total | grep egress | awk 'NF>1{print $NF}'], [0], [dnl +$egress_lflows +]) +AT_CHECK_UNQUOTED([ovn-sbctl count-flows | grep Total | grep ingress | awk 'NF>1{print $NF}'], [0], [dnl +$ingress_lflows +]) +]) diff --git a/utilities/ovn-sbctl.8.xml b/utilities/ovn-sbctl.8.xml index 4e6b21c47..ad16f5fa3 100644 --- a/utilities/ovn-sbctl.8.xml +++ b/utilities/ovn-sbctl.8.xml @@ -416,10 +416,14 @@ chassis. The --ovs and --stats can also be used in conjunction with --vflows.
Re: [ovs-dev] [PATCH ovn v5] ovn-sbctl.c Add logical flows count numbers
OK, will make it a separate command. On Mon, May 24, 2021 at 8:44 PM Ben Pfaff wrote: > On Sat, May 22, 2021 at 10:56:13PM +0300, Alexey Roytman wrote: > > From: Alexey Roytman > > > > For big scale deployments, when number of logical flows can be 2M+, > > sometimes users just need to know the total number of logical flows > > and numbers of logical flows per table/per datapath. > > > > New command output > > Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) pipeline: ingress > > table=0 (ls_in_port_sec_l2 ) lflows=2 > > table=1 (ls_in_port_sec_ip ) lflows=1 > > If adding "--count" to "dump-flows" makes it no longer list flows, I > think it would be better to make it a "count-flows" command. We have > precedent for adding statistics to a command (rather than dropping the > full output) by adding -s or --stats. > ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Re: [ovs-dev] [PATCH ovn v3] ovn-sbctl: Add logical flows count numbers
Hi Mark, Thanks for the comments. With a delay, but I've fixed the patch. Mistakenly, I used a slightly different email subject, so please see the fixes in the [ovs-dev] [PATCH ovn v5] ovn-sbctl.c Add logical flows count numbers <https://www.mail-archive.com/ovs-dev@openvswitch.org/msg55127.html> thread. Thanks Alexey. On Mon, May 10, 2021 at 11:42 PM Mark Michelson wrote: > Hi Alexey, > > In general, the C side of things looks good. I recommend that you run > ./utilities/checkpatch.py against the resulting patch, though. > checkpatch.py recently had a bug fixed in it so that it correctly > catches lines that are in excess of 80 characters now. You'll find that > there are several violations in this patch. > > See below for comments about the added test. > > On 4/13/21 11:18 AM, Alexey Roytman wrote: > > From: Alexey Roytman > > > > For big scale deployments, when number of logical flows can be 2M+, > > sometimes users just need to know the total number of logical flows > > and numbers of logical flows per table/per datapath. > > > > New command output > > Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: ingress > >table=0 (ls_in_port_sec_l2 ) lflows=2 > >table=1 (ls_in_port_sec_ip ) lflows=1 > >table=2 (ls_in_port_sec_nd ) lflows=1 > >table=3 (ls_in_lookup_fdb ) lflows=1 > >table=4 (ls_in_put_fdb ) lflows=1 > >table=5 (ls_in_pre_acl ) lflows=2 > >table=6 (ls_in_pre_lb ) lflows=3 > >table=7 (ls_in_pre_stateful ) lflows=2 > >table=8 (ls_in_acl_hint ) lflows=1 > >table=9 (ls_in_acl ) lflows=2 > >table=10(ls_in_qos_mark ) lflows=1 > >table=11(ls_in_qos_meter) lflows=1 > >table=12(ls_in_lb ) lflows=1 > >table=13(ls_in_stateful ) lflows=8 > >table=14(ls_in_pre_hairpin ) lflows=1 > >table=15(ls_in_nat_hairpin ) lflows=1 > >table=16(ls_in_hairpin ) lflows=1 > >table=17(ls_in_arp_rsp ) lflows=1 > >table=18(ls_in_dhcp_options ) lflows=1 > >table=19(ls_in_dhcp_response) lflows=1 > >table=20(ls_in_dns_lookup ) lflows=1 > >table=21(ls_in_dns_response ) lflows=1 > >table=22(ls_in_external_port) lflows=1 > >table=23(ls_in_l2_lkup ) lflows=3 > >table=24(ls_in_l2_unknown ) lflows=2 > > Total number of logical flows in the datapath = 41 > > > > Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: egress > >table=0 (ls_out_pre_lb ) lflows=3 > >table=1 (ls_out_pre_acl ) lflows=2 > >table=2 (ls_out_pre_stateful) lflows=2 > >table=3 (ls_out_lb ) lflows=1 > >table=4 (ls_out_acl_hint) lflows=1 > >table=5 (ls_out_acl ) lflows=2 > >table=6 (ls_out_qos_mark ) lflows=1 > >table=7 (ls_out_qos_meter ) lflows=1 > >table=8 (ls_out_stateful) lflows=3 > >table=9 (ls_out_port_sec_ip ) lflows=1 > >table=10(ls_out_port_sec_l2 ) lflows=1 > > Total number of logical flows in the datapath = 18 > > > > Total number of logical flows = 59 > > > > Signed-off-by: Alexey Roytman > > --- > > tests/ovn-sbctl.at | 29 > > utilities/ovn-sbctl.8.in | 5 +++ > > utilities/ovn-sbctl.c| 72 > > 3 files changed, 99 insertions(+), 7 deletions(-) > > > > diff --git a/tests/ovn-sbctl.at b/tests/ovn-sbctl.at > > index 2712cc154..b15b15964 100644 > > --- a/tests/ovn-sbctl.at > > +++ b/tests/ovn-sbctl.at > > @@ -148,3 +148,32 @@ inactivity_probe: 3 > > > > OVN_SBCTL_TEST_STOP > > AT_CLEANUP > > + > > +dnl > - > > + > > +AT_SETUP([ovn-sbctl --count lflow-list/dump-flows]) > > +OVN_SBCTL_TEST_START > > + > > +AT_CHECK([ovn-nbctl ls-add count-test]) > > You can use the "check" function here as a shortcut since you are not > checking any output: > > check ovn-nbctl ls-add count-test > > > +AT_CHECK([ovn-sbctl --count lflow-list | cat < > +import sys > > + > > +lflows=0 > > +dp_flows=0 > > +total_flows=0 > > + > > +for line in sys.stdin: > > +x = line.rsplit("=", 1) > > +if "table=" in line: > > + lflows += int(x[1]) > > +elif "flows in the datapath" in line: > > + dp_flows += int(x[1]) > > +elif "Total number of logical flows =" in line: > &
[ovs-dev] [PATCH ovn v5] ovn-sbctl.c Add logical flows count numbers
From: Alexey Roytman For big scale deployments, when number of logical flows can be 2M+, sometimes users just need to know the total number of logical flows and numbers of logical flows per table/per datapath. New command output Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) pipeline: ingress table=0 (ls_in_port_sec_l2 ) lflows=2 table=1 (ls_in_port_sec_ip ) lflows=1 table=2 (ls_in_port_sec_nd ) lflows=1 table=3 (ls_in_lookup_fdb ) lflows=1 table=4 (ls_in_put_fdb ) lflows=1 table=5 (ls_in_pre_acl ) lflows=2 table=6 (ls_in_pre_lb ) lflows=3 table=7 (ls_in_pre_stateful ) lflows=2 table=8 (ls_in_acl_hint ) lflows=1 table=9 (ls_in_acl ) lflows=2 table=10(ls_in_qos_mark ) lflows=1 table=11(ls_in_qos_meter) lflows=1 table=12(ls_in_lb ) lflows=1 table=13(ls_in_stateful ) lflows=8 table=14(ls_in_pre_hairpin ) lflows=1 table=15(ls_in_nat_hairpin ) lflows=1 table=16(ls_in_hairpin ) lflows=1 table=17(ls_in_arp_rsp ) lflows=1 table=18(ls_in_dhcp_options ) lflows=1 table=19(ls_in_dhcp_response) lflows=1 table=20(ls_in_dns_lookup ) lflows=1 table=21(ls_in_dns_response ) lflows=1 table=22(ls_in_external_port) lflows=1 table=23(ls_in_l2_lkup ) lflows=3 table=24(ls_in_l2_unknown ) lflows=2 Total number of logical flows in the datapath "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) pipeline: ingress = 41 Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) pipeline: egress table=0 (ls_out_pre_lb ) lflows=3 table=1 (ls_out_pre_acl ) lflows=2 table=2 (ls_out_pre_stateful) lflows=2 table=3 (ls_out_lb ) lflows=1 table=4 (ls_out_acl_hint) lflows=1 table=5 (ls_out_acl ) lflows=2 table=6 (ls_out_qos_mark) lflows=1 table=7 (ls_out_qos_meter ) lflows=1 table=8 (ls_out_stateful) lflows=3 table=9 (ls_out_port_sec_ip ) lflows=1 table=10(ls_out_port_sec_l2 ) lflows=1 Total number of logical flows in the datapath "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) pipeline: egress = 18 Total number of logical flows = 59 Signed-off-by: Alexey Roytman --- v3 -> v4 * Addressed review comments from Mark tests/ovn-sbctl.at| 44 +++- utilities/ovn-sbctl.8.xml | 13 + utilities/ovn-sbctl.c | 102 ++ 3 files changed, 149 insertions(+), 10 deletions(-) diff --git a/tests/ovn-sbctl.at b/tests/ovn-sbctl.at index f49134381..34ee452e5 100644 --- a/tests/ovn-sbctl.at +++ b/tests/ovn-sbctl.at @@ -175,4 +175,46 @@ inactivity_probe: 3 OVN_SBCTL_TEST([ovn_sbctl_invalid_0x_flow], [invalid 0x flow], [ check ovn-sbctl lflow-list 0x12345678 -]) \ No newline at end of file +]) + +dnl - + +AT_SETUP([ovn-sbctl --count lflow-list/dump-flows]) +OVN_SBCTL_TEST_START + +count_entries() { +ovn-sbctl --column=_uuid list Logical_Flow | sed -r '/^\s*$/d' | wc -l +} + +count_pipeline() { +ovn-sbctl --column=pipeline list Logical_Flow | grep $1 | sed -r '/^\s*$/d' | wc -l +} + +# we start with empty Logical_Flow table +# validate that the table is indeed empty +AT_CHECK([count_entries], [0], [dnl +0 +]) + +AT_CHECK([ovn-sbctl --count lflow-list], [0], [dnl +Total number of logical flows = 0 +]) + +# create some logical flows +check ovn-nbctl ls-add count-test +total_lflows=`count_entries` +egress_lflows=`count_pipeline egress` +ingress_lflows=`count_pipeline ingress` + +AT_CHECK_UNQUOTED([ovn-sbctl --count lflow-list | grep "flows =" | awk 'NF>1{print $NF}'], [0], [dnl +$total_lflows +]) +AT_CHECK_UNQUOTED([ovn-sbctl --count lflow-list | grep Total | grep egress | awk 'NF>1{print $NF}'], [0], [dnl +$egress_lflows +]) +AT_CHECK_UNQUOTED([ovn-sbctl --count lflow-list | grep Total | grep ingress | awk 'NF>1{print $NF}'], [0], [dnl +$ingress_lflows +]) + +OVN_SBCTL_TEST_STOP +AT_CLEANUP diff --git a/utilities/ovn-sbctl.8.xml b/utilities/ovn-sbctl.8.xml index 4e6b21c47..8892a55e8 100644 --- a/utilities/ovn-sbctl.8.xml +++ b/utilities/ovn-sbctl.8.xml @@ -416,10 +416,23 @@ chassis. The --ovs and --stats can also be used in conjunction with --vflows. + + + --count lflow-list + [logical-datapath] prints numbers of logical flows per + table and per datapath. + + [--uuid] dump-flows [logical-datapath] Alias for lflow-list. + + --count dump-flow + [logical-datapath] + Alias for --count lflow-list + [logical-datapath] + Remote Connectivity Commands diff --git a/utilities/ovn-sbctl.c b/utilities/ovn-sbctl.c index 53f10cdd8..8bdc0838a 100644 --- a/utilities/ovn-sbctl.c +++ b/utilities/ovn-sbctl.c @@ -898,11 +898,92 @@ sbctl_lflow_add(struct sbctl_lflow **lflows, if (*n_f
[ovs-dev] [PATCH ovn v4] ovn-sbctl.c Add logical flows count numbers
From: Alexey Roytman For big scale deployments, when number of logical flows can be 2M+, sometimes users just need to know the total number of logical flows and numbers of logical flows per table/per datapath. New command output Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) pipeline: ingress table=0 (ls_in_port_sec_l2 ) lflows=2 table=1 (ls_in_port_sec_ip ) lflows=1 table=2 (ls_in_port_sec_nd ) lflows=1 table=3 (ls_in_lookup_fdb ) lflows=1 table=4 (ls_in_put_fdb ) lflows=1 table=5 (ls_in_pre_acl ) lflows=2 table=6 (ls_in_pre_lb ) lflows=3 table=7 (ls_in_pre_stateful ) lflows=2 table=8 (ls_in_acl_hint ) lflows=1 table=9 (ls_in_acl ) lflows=2 table=10(ls_in_qos_mark ) lflows=1 table=11(ls_in_qos_meter) lflows=1 table=12(ls_in_lb ) lflows=1 table=13(ls_in_stateful ) lflows=8 table=14(ls_in_pre_hairpin ) lflows=1 table=15(ls_in_nat_hairpin ) lflows=1 table=16(ls_in_hairpin ) lflows=1 table=17(ls_in_arp_rsp ) lflows=1 table=18(ls_in_dhcp_options ) lflows=1 table=19(ls_in_dhcp_response) lflows=1 table=20(ls_in_dns_lookup ) lflows=1 table=21(ls_in_dns_response ) lflows=1 table=22(ls_in_external_port) lflows=1 table=23(ls_in_l2_lkup ) lflows=3 table=24(ls_in_l2_unknown ) lflows=2 Total number of logical flows in the datapath "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) pipeline: ingress = 41 Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) pipeline: egress table=0 (ls_out_pre_lb ) lflows=3 table=1 (ls_out_pre_acl ) lflows=2 table=2 (ls_out_pre_stateful) lflows=2 table=3 (ls_out_lb ) lflows=1 table=4 (ls_out_acl_hint) lflows=1 table=5 (ls_out_acl ) lflows=2 table=6 (ls_out_qos_mark) lflows=1 table=7 (ls_out_qos_meter ) lflows=1 table=8 (ls_out_stateful) lflows=3 table=9 (ls_out_port_sec_ip ) lflows=1 table=10(ls_out_port_sec_l2 ) lflows=1 Total number of logical flows in the datapath "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) pipeline: egress = 18 Total number of logical flows = 59 Signed-off-by: Alexey Roytman --- v3 -> v4 * Addressed review comments from Mark tests/ovn-sbctl.at| 44 - utilities/ovn-sbctl.8.xml | 10 utilities/ovn-sbctl.c | 100 ++ 3 files changed, 144 insertions(+), 10 deletions(-) diff --git a/tests/ovn-sbctl.at b/tests/ovn-sbctl.at index f49134381..34ee452e5 100644 --- a/tests/ovn-sbctl.at +++ b/tests/ovn-sbctl.at @@ -175,4 +175,46 @@ inactivity_probe: 3 OVN_SBCTL_TEST([ovn_sbctl_invalid_0x_flow], [invalid 0x flow], [ check ovn-sbctl lflow-list 0x12345678 -]) \ No newline at end of file +]) + +dnl - + +AT_SETUP([ovn-sbctl --count lflow-list/dump-flows]) +OVN_SBCTL_TEST_START + +count_entries() { +ovn-sbctl --column=_uuid list Logical_Flow | sed -r '/^\s*$/d' | wc -l +} + +count_pipeline() { +ovn-sbctl --column=pipeline list Logical_Flow | grep $1 | sed -r '/^\s*$/d' | wc -l +} + +# we start with empty Logical_Flow table +# validate that the table is indeed empty +AT_CHECK([count_entries], [0], [dnl +0 +]) + +AT_CHECK([ovn-sbctl --count lflow-list], [0], [dnl +Total number of logical flows = 0 +]) + +# create some logical flows +check ovn-nbctl ls-add count-test +total_lflows=`count_entries` +egress_lflows=`count_pipeline egress` +ingress_lflows=`count_pipeline ingress` + +AT_CHECK_UNQUOTED([ovn-sbctl --count lflow-list | grep "flows =" | awk 'NF>1{print $NF}'], [0], [dnl +$total_lflows +]) +AT_CHECK_UNQUOTED([ovn-sbctl --count lflow-list | grep Total | grep egress | awk 'NF>1{print $NF}'], [0], [dnl +$egress_lflows +]) +AT_CHECK_UNQUOTED([ovn-sbctl --count lflow-list | grep Total | grep ingress | awk 'NF>1{print $NF}'], [0], [dnl +$ingress_lflows +]) + +OVN_SBCTL_TEST_STOP +AT_CLEANUP diff --git a/utilities/ovn-sbctl.8.xml b/utilities/ovn-sbctl.8.xml index 4e6b21c47..2030bcda9 100644 --- a/utilities/ovn-sbctl.8.xml +++ b/utilities/ovn-sbctl.8.xml @@ -416,10 +416,20 @@ chassis. The --ovs and --stats can also be used in conjunction with --vflows. + + + --count lflow-list [logical-datapath] + prints numbers of logical flows per table and per datapath. + + [--uuid] dump-flows [logical-datapath] Alias for lflow-list. + + --count dump-flow [logical-datapath] + Alias for --count lflow-list [logical-datapath] + Remote Connectivity Commands diff --git a/utilities/ovn-sbctl.c b/utilities/ovn-sbctl.c index 53f10cdd8..ca9d21d52 100644 --- a/utilities/ovn-sbctl.c +++ b/utilities/ovn-sbctl.c @@ -898,11 +898,92 @@ sbctl_lflow_add(struct sbctl_lflow **lflows, if (*n_flows == *n
[ovs-dev] [PATCH v3 ovn] ovn-sbctl: Prevent core dump from ovn-sbctl lflow-list [datpath] 0xflow
From: Alexey Roytman When ovn-sbctl lflow-list gets lflow argument with 0x prefix, e.g. 0x8131c8a8, it prints correct output, but fails with coredump. For example: ovn-sbctl --uuid lflow-list sw1 0x8131c8a8 Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: egress uuid=0x8131c8a8, table=10(ls_out_port_sec_l2 ), priority=100 , match=(eth.mcast), action=(output;) free(): invalid pointer [2]616553 abort (core dumped) ovn-sbctl --uuid dump-flows sw1 0x8131c8a8 This patch fixes it. Signed-off-by: Alexey Roytman --- utilities/ovn-sbctl.c | 28 +--- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/utilities/ovn-sbctl.c b/utilities/ovn-sbctl.c index e3aa7a68e..99c112358 100644 --- a/utilities/ovn-sbctl.c +++ b/utilities/ovn-sbctl.c @@ -764,23 +764,28 @@ sbctl_lflow_cmp(const void *a_, const void *b_) return cmp ? cmp : strcmp(a->actions, b->actions); } -static char * +static bool +is_uuid_with_prefix(const char *uuid) +{ + return uuid[0] == '0' && (uuid[1] == 'x' || uuid[1] == 'X'); +} + +static bool parse_partial_uuid(char *s) { /* Accept a full or partial UUID. */ if (uuid_is_partial_string(s)) { -return s; +return true; } /* Accept a full or partial UUID prefixed by 0x, since "ovs-ofctl * dump-flows" prints cookies prefixed by 0x. */ -if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X') -&& uuid_is_partial_string(s + 2)) { -return s + 2; +if (is_uuid_with_prefix(s) && uuid_is_partial_string(s + 2)) { +return true; } /* Not a (partial) UUID. */ -return NULL; +return false; } static const char * @@ -799,8 +804,11 @@ is_partial_uuid_match(const struct uuid *uuid, const char *match) * from UUIDs, and cookie values are printed without leading zeros because * they're just numbers. */ const char *s1 = strip_leading_zero(uuid_s); -const char *s2 = strip_leading_zero(match); - +const char *s2 = match; +if (is_uuid_with_prefix(s2)) { +s2 = s2 + 2; +} +s2 = strip_leading_zero(s2); return !strncmp(s1, s2, strlen(s2)); } @@ -1134,12 +1142,10 @@ cmd_lflow_list(struct ctl_context *ctx) } for (size_t i = 1; i < ctx->argc; i++) { -char *s = parse_partial_uuid(ctx->argv[i]); -if (!s) { +if (!parse_partial_uuid(ctx->argv[i])) { ctl_fatal("%s is not a UUID or the beginning of a UUID", ctx->argv[i]); } -ctx->argv[i] = s; } struct vconn *vconn = sbctl_open_vconn(&ctx->options); -- 2.25.1 ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev
[ovs-dev] [PATCH v2 ovn] ovn-sbctl: Prevent core dump from ovn-sbctl lflow-list [datpath] 0xflow
From: Alexey Roytman When ovn-sbctl lflow-list gets lflow argument with 0x prefix, e.g. 0x8131c8a8, it prints correct output, but fails with coredump. For example: ovn-sbctl --uuid lflow-list sw1 0x8131c8a8 Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: egress uuid=0x8131c8a8, table=10(ls_out_port_sec_l2 ), priority=100 , match=(eth.mcast), action=(output;) free(): invalid pointer [2]616553 abort (core dumped) ovn-sbctl --uuid dump-flows sw1 0x8131c8a8 This patch fixes it. Signed-off-by: Alexey Roytman --- utilities/ovn-sbctl.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/utilities/ovn-sbctl.c b/utilities/ovn-sbctl.c index e3aa7a68e..099d31f08 100644 --- a/utilities/ovn-sbctl.c +++ b/utilities/ovn-sbctl.c @@ -764,6 +764,12 @@ sbctl_lflow_cmp(const void *a_, const void *b_) return cmp ? cmp : strcmp(a->actions, b->actions); } +static bool +is_uuid_with_prefix(const char *uuid) +{ + return uuid[0] == '0' && (uuid[1] == 'x' || uuid[1] == 'X'); +} + static char * parse_partial_uuid(char *s) { @@ -774,8 +780,7 @@ parse_partial_uuid(char *s) /* Accept a full or partial UUID prefixed by 0x, since "ovs-ofctl * dump-flows" prints cookies prefixed by 0x. */ -if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X') -&& uuid_is_partial_string(s + 2)) { +if (is_uuid_with_prefix(s) && uuid_is_partial_string(s + 2)) { return s + 2; } @@ -799,8 +804,11 @@ is_partial_uuid_match(const struct uuid *uuid, const char *match) * from UUIDs, and cookie values are printed without leading zeros because * they're just numbers. */ const char *s1 = strip_leading_zero(uuid_s); -const char *s2 = strip_leading_zero(match); - +const char *s2 = match; +if (is_uuid_with_prefix(s2)) { +s2 = s2 + 2; +} +s2 = strip_leading_zero(s2); return !strncmp(s1, s2, strlen(s2)); } @@ -1139,7 +1147,6 @@ cmd_lflow_list(struct ctl_context *ctx) ctl_fatal("%s is not a UUID or the beginning of a UUID", ctx->argv[i]); } -ctx->argv[i] = s; } struct vconn *vconn = sbctl_open_vconn(&ctx->options); -- 2.25.1 ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev
[ovs-dev] [PATCH ovn] ovn-sbctl: Prevent core dump from ovn-sbctl lflow-list [datpath] 0xflow
From: Alexey Roytman When ovn-sbctl lflow-list gets lflow argument with 0x prefix, e.g. 0x8131c8a8, it prints correct output, but fails with coredump. For example: ovn-sbctl --uuid lflow-list sw1 0x8131c8a8 Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: egress uuid=0x8131c8a8, table=10(ls_out_port_sec_l2 ), priority=100 , match=(eth.mcast), action=(output;) free(): invalid pointer [2]616553 abort (core dumped) ovn-sbctl --uuid dump-flows sw1 0x8131c8a8 This patch fixes it. Signed-off-by: Alexey Roytman --- utilities/ovn-sbctl.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/utilities/ovn-sbctl.c b/utilities/ovn-sbctl.c index e3aa7a68e..9de9bd774 100644 --- a/utilities/ovn-sbctl.c +++ b/utilities/ovn-sbctl.c @@ -764,6 +764,12 @@ sbctl_lflow_cmp(const void *a_, const void *b_) return cmp ? cmp : strcmp(a->actions, b->actions); } +static bool +is_uuid_with_prefix(const char *uuid) +{ + return uuid[0] == '0' && (uuid[1] == 'x' || uuid[1] == 'X'); +} + static char * parse_partial_uuid(char *s) { @@ -774,8 +780,7 @@ parse_partial_uuid(char *s) /* Accept a full or partial UUID prefixed by 0x, since "ovs-ofctl * dump-flows" prints cookies prefixed by 0x. */ -if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X') -&& uuid_is_partial_string(s + 2)) { +if (is_uuid_with_prefix(s) && uuid_is_partial_string(s + 2)) { return s + 2; } @@ -799,8 +804,11 @@ is_partial_uuid_match(const struct uuid *uuid, const char *match) * from UUIDs, and cookie values are printed without leading zeros because * they're just numbers. */ const char *s1 = strip_leading_zero(uuid_s); -const char *s2 = strip_leading_zero(match); - +const char *s2 = match; +if (is_uuid_with_prefix(s2)) { +s2 = s2 + 2; +} +s2 = strip_leading_zero(s2); return !strncmp(s1, s2, strlen(s2)); } @@ -1139,7 +1147,6 @@ cmd_lflow_list(struct ctl_context *ctx) ctl_fatal("%s is not a UUID or the beginning of a UUID", ctx->argv[i]); } -ctx->argv[i] = s; } struct vconn *vconn = sbctl_open_vconn(&ctx->options); -- 2.25.1 ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev
[ovs-dev] [PATCHi ovn] ovn-sbctl: Prevent core dump from ovn-sbctl lflow-list [datpath] 0xflow
From: Alexey Roytman When ovn-sbctl lflow-list gets lflow argument with 0x prefix, e.g. 0x8131c8a8, it prints correct output, but fails with coredump. For example: ovn-sbctl --uuid lflow-list sw1 0x8131c8a8 Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: egress uuid=0x8131c8a8, table=10(ls_out_port_sec_l2 ), priority=100 , match=(eth.mcast), action=(output;) free(): invalid pointer [2]616553 abort (core dumped) ovn-sbctl --uuid dump-flows sw1 0x8131c8a8 This patch fixes it. Signed-off-by: Alexey Roytman --- utilities/ovn-sbctl.c | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/utilities/ovn-sbctl.c b/utilities/ovn-sbctl.c index e3aa7a68e..9de9bd774 100644 --- a/utilities/ovn-sbctl.c +++ b/utilities/ovn-sbctl.c @@ -764,6 +764,12 @@ sbctl_lflow_cmp(const void *a_, const void *b_) return cmp ? cmp : strcmp(a->actions, b->actions); } +static bool +is_uuid_with_prefix(const char *uuid) +{ + return uuid[0] == '0' && (uuid[1] == 'x' || uuid[1] == 'X'); +} + static char * parse_partial_uuid(char *s) { @@ -774,8 +780,7 @@ parse_partial_uuid(char *s) /* Accept a full or partial UUID prefixed by 0x, since "ovs-ofctl * dump-flows" prints cookies prefixed by 0x. */ -if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X') -&& uuid_is_partial_string(s + 2)) { +if (is_uuid_with_prefix(s) && uuid_is_partial_string(s + 2)) { return s + 2; } @@ -799,8 +804,11 @@ is_partial_uuid_match(const struct uuid *uuid, const char *match) * from UUIDs, and cookie values are printed without leading zeros because * they're just numbers. */ const char *s1 = strip_leading_zero(uuid_s); -const char *s2 = strip_leading_zero(match); - +const char *s2 = match; +if (is_uuid_with_prefix(s2)) { +s2 = s2 + 2; +} +s2 = strip_leading_zero(s2); return !strncmp(s1, s2, strlen(s2)); } @@ -1139,7 +1147,6 @@ cmd_lflow_list(struct ctl_context *ctx) ctl_fatal("%s is not a UUID or the beginning of a UUID", ctx->argv[i]); } -ctx->argv[i] = s; } struct vconn *vconn = sbctl_open_vconn(&ctx->options); -- 2.25.1 ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev
[ovs-dev] [PATCH ovn v3] ovn-sbctl: Add logical flows count numbers
From: Alexey Roytman For big scale deployments, when number of logical flows can be 2M+, sometimes users just need to know the total number of logical flows and numbers of logical flows per table/per datapath. New command output Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: ingress table=0 (ls_in_port_sec_l2 ) lflows=2 table=1 (ls_in_port_sec_ip ) lflows=1 table=2 (ls_in_port_sec_nd ) lflows=1 table=3 (ls_in_lookup_fdb ) lflows=1 table=4 (ls_in_put_fdb ) lflows=1 table=5 (ls_in_pre_acl ) lflows=2 table=6 (ls_in_pre_lb ) lflows=3 table=7 (ls_in_pre_stateful ) lflows=2 table=8 (ls_in_acl_hint ) lflows=1 table=9 (ls_in_acl ) lflows=2 table=10(ls_in_qos_mark ) lflows=1 table=11(ls_in_qos_meter) lflows=1 table=12(ls_in_lb ) lflows=1 table=13(ls_in_stateful ) lflows=8 table=14(ls_in_pre_hairpin ) lflows=1 table=15(ls_in_nat_hairpin ) lflows=1 table=16(ls_in_hairpin ) lflows=1 table=17(ls_in_arp_rsp ) lflows=1 table=18(ls_in_dhcp_options ) lflows=1 table=19(ls_in_dhcp_response) lflows=1 table=20(ls_in_dns_lookup ) lflows=1 table=21(ls_in_dns_response ) lflows=1 table=22(ls_in_external_port) lflows=1 table=23(ls_in_l2_lkup ) lflows=3 table=24(ls_in_l2_unknown ) lflows=2 Total number of logical flows in the datapath = 41 Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: egress table=0 (ls_out_pre_lb ) lflows=3 table=1 (ls_out_pre_acl ) lflows=2 table=2 (ls_out_pre_stateful) lflows=2 table=3 (ls_out_lb ) lflows=1 table=4 (ls_out_acl_hint) lflows=1 table=5 (ls_out_acl ) lflows=2 table=6 (ls_out_qos_mark) lflows=1 table=7 (ls_out_qos_meter ) lflows=1 table=8 (ls_out_stateful) lflows=3 table=9 (ls_out_port_sec_ip ) lflows=1 table=10(ls_out_port_sec_l2 ) lflows=1 Total number of logical flows in the datapath = 18 Total number of logical flows = 59 Signed-off-by: Alexey Roytman --- tests/ovn-sbctl.at | 29 utilities/ovn-sbctl.8.in | 5 +++ utilities/ovn-sbctl.c| 72 3 files changed, 99 insertions(+), 7 deletions(-) diff --git a/tests/ovn-sbctl.at b/tests/ovn-sbctl.at index 2712cc154..b15b15964 100644 --- a/tests/ovn-sbctl.at +++ b/tests/ovn-sbctl.at @@ -148,3 +148,32 @@ inactivity_probe: 3 OVN_SBCTL_TEST_STOP AT_CLEANUP + +dnl - + +AT_SETUP([ovn-sbctl --count lflow-list/dump-flows]) +OVN_SBCTL_TEST_START + +AT_CHECK([ovn-nbctl ls-add count-test]) +AT_CHECK([ovn-sbctl --count lflow-list | cat <dp != curr->dp +|| strcmp(prev->lflow->pipeline, curr->lflow->pipeline)) { +new_datapath = true; +} + +if (prev && (prev->lflow->table_id != curr->lflow->table_id || new_datapath)) { +print_lflows_count(prev->lflow->table_id, smap_get_def(&prev->lflow->external_ids, "stage-name", ""), table_lflows); +table_lflows = 1; +if (new_datapath) { +printf("Total number of logical flows in the datapath = %ld\n\n", dp_lflows); +dp_lflows = 1; +} else { +dp_lflows++; +} +} else { +dp_lflows++; +table_lflows++; +} + +if (new_datapath) { +print_datapath_prompt(curr->dp, &curr->dp->header_.uuid, curr->lflow->pipeline); +} +prev = curr; +} +if (n_flows > 0) { +print_lflows_count(prev->lflow->table_id, smap_get_def(&prev->lflow->external_ids, "stage-name", ""), table_lflows); +printf("Total number of logical flows in the datapath = %ld\n\n", dp_lflows); +} +printf("Total number of logical flows = %ld\n", n_flows); +} + static void cmd_lflow_list(struct ctl_context *ctx) { @@ -1176,6 +1233,10 @@ cmd_lflow_list(struct ctl_context *ctx) qsort(lflows, n_flows, sizeof *lflows, sbctl_lflow_cmp); } +if (shash_find(&ctx->options, "--count") != NULL) { +print_lflow_counters(n_flows, lflows); +goto cleanup; +} bool print_uuid = shash_find(&ctx->options, "--uuid") != NULL; const struct sbctl_lflow *curr, *prev = NULL; @@ -1207,11 +1268,7 @@ cmd_lflow_list(struct ctl_context *ctx) if (!prev || prev->dp != curr->dp || strcmp(prev->lflow->pipeline, curr->lflow->pipeline)) { -printf("Datapath: "); -print_datapath_name(curr->dp); -printf(" ("UUID_FMT") Pipeline: %s\n", - UUID_ARGS(&c
Re: [ovs-dev] [PATCH v2 ovn] ovn-sbctl: Add logical flows count numbers
Oops, sorry, will fix it and send another patch. I'd like to add a unittest for the feature, but don't know the right place to do it. Can you point me? Thanks Alexey. On Mon, Apr 12, 2021 at 7:38 PM Ben Pfaff wrote: > On Mon, Apr 12, 2021 at 01:36:11PM +0300, Alexey Roytman wrote: > > From: Alexey Roytman > > > > For big scale deployments, when number of logical flows can be 2M+, > > sometimes users just need to know the total number of logical flows > > and numbers of logical flows per table/per datapath. > > This isn't really a review but when I glanced at this I noticed that > "lflow" was misspelled "lfow" in some places. > ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev
[ovs-dev] [PATCH v2 ovn] ovn-sbctl: Add logical flows count numbers
From: Alexey Roytman For big scale deployments, when number of logical flows can be 2M+, sometimes users just need to know the total number of logical flows and numbers of logical flows per table/per datapath. New command output: ovn-sbctl --count lflow-list sw1 Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: ingress table=0 (ls_in_port_sec_l2 ) lflows=2 table=1 (ls_in_port_sec_ip ) lflows=1 table=2 (ls_in_port_sec_nd ) lflows=1 table=3 (ls_in_lookup_fdb ) lflows=1 table=4 (ls_in_put_fdb ) lflows=1 table=5 (ls_in_pre_acl ) lflows=2 table=6 (ls_in_pre_lb ) lflows=3 table=7 (ls_in_pre_stateful ) lflows=2 table=8 (ls_in_acl_hint ) lflows=1 table=9 (ls_in_acl ) lflows=2 table=10(ls_in_qos_mark ) lflows=1 table=11(ls_in_qos_meter) lflows=1 table=12(ls_in_lb ) lflows=1 table=13(ls_in_stateful ) lflows=8 table=14(ls_in_pre_hairpin ) lflows=1 table=15(ls_in_nat_hairpin ) lflows=1 table=16(ls_in_hairpin ) lflows=1 table=17(ls_in_arp_rsp ) lflows=1 table=18(ls_in_dhcp_options ) lflows=1 table=19(ls_in_dhcp_response) lflows=1 table=20(ls_in_dns_lookup ) lflows=1 table=21(ls_in_dns_response ) lflows=1 table=22(ls_in_external_port) lflows=1 table=23(ls_in_l2_lkup ) lflows=3 table=24(ls_in_l2_unknown ) lflows=2 Total number of logical flows in the datapath = 41 Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: egress table=0 (ls_out_pre_lb ) lflows=3 table=1 (ls_out_pre_acl ) lflows=2 table=2 (ls_out_pre_stateful) lflows=2 table=3 (ls_out_lb ) lflows=1 table=4 (ls_out_acl_hint) lflows=1 table=5 (ls_out_acl ) lflows=2 table=6 (ls_out_qos_mark) lflows=1 table=7 (ls_out_qos_meter ) lflows=1 table=8 (ls_out_stateful) lflows=3 table=9 (ls_out_port_sec_ip ) lflows=1 table=10(ls_out_port_sec_l2 ) lflows=1 Total number of logical flows in the datapath = 18 Total number of logical flows = 59 Signed-off-by: Alexey Roytman --- utilities/ovn-sbctl.8.in | 5 +++ utilities/ovn-sbctl.c| 72 2 files changed, 70 insertions(+), 7 deletions(-) diff --git a/utilities/ovn-sbctl.8.in b/utilities/ovn-sbctl.8.in index 153e72e6c..6de4ab968 100644 --- a/utilities/ovn-sbctl.8.in +++ b/utilities/ovn-sbctl.8.in @@ -207,6 +207,11 @@ conjunction with \fB\-\-vflows\fR. .IP "[\fB\-\-uuid\fR] \fBdump\-flows\fR [\fIlogical-datapath\fR]" Alias for \fBlflow\-list\fB. . +.IP "[\fB\-\-count\fR] \fBlflow\-list\fR [\fIlogical-datapath\fR]" +and +.IP "[\fB\-\-count\fR] \fBdump\-flows\fR [\fIlogical-datapath\fR]" +Print numbers of logical flows per table and per datapath. +. .SS "Remote Connectivity Commands" . These commands manipulate the \fBconnections\fR column in the \fBSB_Global\fR diff --git a/utilities/ovn-sbctl.c b/utilities/ovn-sbctl.c index e3aa7a68e..a931e8300 100644 --- a/utilities/ovn-sbctl.c +++ b/utilities/ovn-sbctl.c @@ -1114,6 +1114,63 @@ sbctl_lflow_add(struct sbctl_lflow **lflows, (*n_flows)++; } +static void +print_datapath_prompt(const struct sbrec_datapath_binding *dp, + const struct uuid *uuid, + char *pipeline) { +printf("Datapath: "); +print_datapath_name(dp); +printf(" ("UUID_FMT") Pipeline: %s\n", UUID_ARGS(uuid), pipeline); +} + +static void +print_lflows_count(int64_t table_id, const char *name, long count) { +printf(" table=%-2"PRId64"(%-19s) lflows=%ld\n", \ + table_id, name, count); +} + +static void +print_lfow_counters(size_t n_flows, struct sbctl_lflow *lflows) +{ +const struct sbctl_lflow *curr, *prev = NULL; +long table_lflows = 0; +long dp_lflows = 0; + +for (size_t i = 0; i < n_flows; i++) { + bool new_datapath = false; + curr = &lflows[i]; + if (!prev +|| prev->dp != curr->dp +|| strcmp(prev->lflow->pipeline, curr->lflow->pipeline)) { +new_datapath = true; +} + +if (prev && (prev->lflow->table_id != curr->lflow->table_id || new_datapath)) { +print_lflows_count(prev->lflow->table_id, smap_get_def(&prev->lflow->external_ids, "stage-name", ""), table_lflows); +table_lflows = 1; +if (new_datapath) { +printf("Total number of logical flows in the datapath = %ld\n\n", dp_lflows); +dp_lflows = 1; +} else { +dp_lflows++; +} +} else { +dp_lflows++; +table_lflows++; +} + +if (new_datapath) { +print_datapath_prompt(curr->dp, &curr->dp->header_.uuid, curr->lflow->pipeline); +} +
[ovs-dev] [PATCH ovn] ovn-sbctl: Add logical flows count numbers
From: Alexey Roytman For big scale deployments, when number of logical flows can be 2M+, sometimes users just need to know the total number of logical flows and numbers of logical flows per table/per datapath. New command output Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: ingress table=0 (ls_in_port_sec_l2 ) lflows=2 table=1 (ls_in_port_sec_ip ) lflows=1 table=2 (ls_in_port_sec_nd ) lflows=1 table=3 (ls_in_lookup_fdb ) lflows=1 table=4 (ls_in_put_fdb ) lflows=1 table=5 (ls_in_pre_acl ) lflows=2 table=6 (ls_in_pre_lb ) lflows=3 table=7 (ls_in_pre_stateful ) lflows=2 table=8 (ls_in_acl_hint ) lflows=1 table=9 (ls_in_acl ) lflows=2 table=10(ls_in_qos_mark ) lflows=1 table=11(ls_in_qos_meter) lflows=1 table=12(ls_in_lb ) lflows=1 table=13(ls_in_stateful ) lflows=8 table=14(ls_in_pre_hairpin ) lflows=1 table=15(ls_in_nat_hairpin ) lflows=1 table=16(ls_in_hairpin ) lflows=1 table=17(ls_in_arp_rsp ) lflows=1 table=18(ls_in_dhcp_options ) lflows=1 table=19(ls_in_dhcp_response) lflows=1 table=20(ls_in_dns_lookup ) lflows=1 table=21(ls_in_dns_response ) lflows=1 table=22(ls_in_external_port) lflows=1 table=23(ls_in_l2_lkup ) lflows=3 table=24(ls_in_l2_unknown ) lflows=2 Total number of logical flows in the datapath = 41 Datapath: "sw1" (4b1e53d8-9f0f-4768-b4a6-6cbc58a4bfda) Pipeline: egress table=0 (ls_out_pre_lb ) lflows=3 table=1 (ls_out_pre_acl ) lflows=2 table=2 (ls_out_pre_stateful) lflows=2 table=3 (ls_out_lb ) lflows=1 table=4 (ls_out_acl_hint) lflows=1 table=5 (ls_out_acl ) lflows=2 table=6 (ls_out_qos_mark) lflows=1 table=7 (ls_out_qos_meter ) lflows=1 table=8 (ls_out_stateful) lflows=3 table=9 (ls_out_port_sec_ip ) lflows=1 table=10(ls_out_port_sec_l2 ) lflows=1 Total number of logical flows in the datapath = 18 Total number of logical flows = 59 Signed-off-by: Alexey Roytman --- utilities/ovn-sbctl.8.in | 5 +++ utilities/ovn-sbctl.c| 72 2 files changed, 70 insertions(+), 7 deletions(-) diff --git a/utilities/ovn-sbctl.8.in b/utilities/ovn-sbctl.8.in index 153e72e6c..46e01140b 100644 --- a/utilities/ovn-sbctl.8.in +++ b/utilities/ovn-sbctl.8.in @@ -207,6 +207,11 @@ conjunction with \fB\-\-vflows\fR. .IP "[\fB\-\-uuid\fR] \fBdump\-flows\fR [\fIlogical-datapath\fR]" Alias for \fBlflow\-list\fB. . +.IP "[\fB\-\-count\fR] \fBlflow\-list\fR [\fIlogical-datapath\fR]" +and +.IP "[\fB\-\-count\fR] \fBdump\-flows\fR [\fIlogical-datapath\fR]" +Print numbers of logical flows per table and per datapath. +. .SS "Remote Connectivity Commands" . These commands manipulate the \fBconnections\fR column in the \fBSB_Global\fR diff --git a/utilities/ovn-sbctl.c b/utilities/ovn-sbctl.c index e3aa7a68e..ca9047a42 100644 --- a/utilities/ovn-sbctl.c +++ b/utilities/ovn-sbctl.c @@ -1114,6 +1114,63 @@ sbctl_lflow_add(struct sbctl_lflow **lflows, (*n_flows)++; } +static void +print_datapath_prompt(const struct sbrec_datapath_binding *dp, + const struct uuid *uuid, + char *pipeline) { +printf("Datapath: "); +print_datapath_name(dp); +printf(" ("UUID_FMT") Pipeline: %s\n", UUID_ARGS(uuid), pipeline); +} + +static void +print_lflows_count(int64_t table_id, const char *name, long count) { +printf(" table=%-2"PRId64"(%-19s) lflows=%ld\n", \ + table_id, name, count); +} + +static void +print_lfow_counters(size_t n_flows, struct sbctl_lflow *lflows) +{ +const struct sbctl_lflow *curr, *prev = NULL; +long table_lflows = 0; +long dp_lflows = 0; + +for (size_t i = 0; i < n_flows; i++) { + bool new_datapath = false; + curr = &lflows[i]; + if (!prev +|| prev->dp != curr->dp +|| strcmp(prev->lflow->pipeline, curr->lflow->pipeline)) { +new_datapath = true; +} + +if ( prev && (prev->lflow->table_id != curr->lflow->table_id || new_datapath )) { +print_lflows_count(prev->lflow->table_id, smap_get_def(&prev->lflow->external_ids, "stage-name", ""), table_lflows); +table_lflows = 1; +if ( new_datapath ) { +printf("Total number of logical flows in the datapath = %ld\n\n", dp_lflows); +dp_lflows = 1; +} else { +dp_lflows++; +} +} else { +dp_lflows++; +table_lflows++; +} + +if ( new_datapath ) { +print_datapath_prompt(curr->dp, &curr->dp->header_.uuid, curr->lflow->pipeline); +} +prev = curr; +} +
[ovs-dev] [PATCH ovn] northd: Fix "Destination unknown" table number in man pages.
From: Alexey Roytman The actual number of the "Destination unknown" table, is 24 and is not 23 as mentioned. Signed-off-by: Alexey Roytman --- northd/ovn-northd.8.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/northd/ovn-northd.8.xml b/northd/ovn-northd.8.xml index a62f5c057..e42a2249e 100644 --- a/northd/ovn-northd.8.xml +++ b/northd/ovn-northd.8.xml @@ -1619,7 +1619,7 @@ output; -Ingress Table 23 Destination unknown +Ingress Table 24 Destination unknown This table handles the packets whose destination was not found or -- 2.25.1 ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev
[ovs-dev] [PATCH v2 2/2] tests/ovs-vsctl.at: Add test to the arguments validation
From: Alexey Roytman Signed-off-by: Alexey Roytman --- tests/ovs-vsctl.at | 5 + 1 file changed, 5 insertions(+) diff --git a/tests/ovs-vsctl.at b/tests/ovs-vsctl.at index d2cb41403..6fbe6da49 100644 --- a/tests/ovs-vsctl.at +++ b/tests/ovs-vsctl.at @@ -1483,6 +1483,11 @@ AT_CHECK([RUN_OVS_VSCTL( qos : [] ]]) +AT_CHECK([RUN_OVS_VSCTL( + [ destroy Qos])], [0],[], [stderr]) +AT_CHECK([sed "s/^.*|WARN|//" < stderr], [0], +[[either --all or records argument should be specified +]]) AT_CHECK([RUN_OVS_VSCTL( [--all destroy Qos])]) AT_CHECK([RUN_OVS_VSCTL( -- 2.25.1 ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev
[ovs-dev] [PATCH v2 1/2] lib/db-ctl-base.c: Check that --all option or records argument provided
From: Alexey Roytman Signed-off-by: Alexey Roytman --- lib/db-ctl-base.c | 5 + 1 file changed, 5 insertions(+) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index e95c77da2..77cc76a9f 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -1823,6 +1823,11 @@ cmd_destroy(struct ctl_context *ctx) return; } +if (!delete_all && ctx->argc == 2) { +VLOG_WARN("either --all or records argument should be specified"); +return; +} + if (delete_all) { const struct ovsdb_idl_row *row; const struct ovsdb_idl_row *next_row; -- 2.25.1 ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev
[ovs-dev] [PATCH v2 0/2] OVSDB CLI destroy command, check that --all or records argument provided
From: Alexey Roytman OVSDB CLI utilities (ovs-vsctl, ovn-nbctl and ovn-sbctl) allow destroying the entire table or some records from the given table. However, either the --all option or the deleted records should be provided. These patches add the test. Changes since v1: - replace ctl_error by VLOG_WARN - add test Alexey Roytman (2): Add a check that either the --all option or records argument provided to the destroy command Add test to the destroy command arguments validation lib/db-ctl-base.c | 5 + tests/ovs-vsctl.at | 5 + 2 files changed, 10 insertions(+) -- 2.25.1 ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev
[ovs-dev] [PATCH ovs]: lib/db-ctl-base.c: Check that --all or records argument provided
From: Alexey Roytman ovn-nbctl and ovn-sbctl CLI utilities allow destroying the entire table or some records from the given table. However, either the --all option or the deleted records should be provided. This patch adds the test. Signed-off-by: Alexey Roytman --- lib/db-ctl-base.c | 5 + 1 file changed, 5 insertions(+) diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index e95c77da2..81ade7abc 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -1823,6 +1823,11 @@ cmd_destroy(struct ctl_context *ctx) return; } +if (!delete_all && ctx->argc == 2) { +ctl_error(ctx, "either --all or records argument should be specified"); +return; +} + if (delete_all) { const struct ovsdb_idl_row *row; const struct ovsdb_idl_row *next_row; -- 2.25.1 ___ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev