Hi, Ilya Maximets.

Thank you for taking the time to review my patch, and I truly admire your 
dedication to the OVS community.

If duplicate controller parameters are set, OVS should establish multiple 
connections with the controller. If the controller does not perform relevant 
verification, it may send flows to the same OVS. It may cause some 
abnormalities.
Our operations colleagues configure OVS deployment through the command line. 
The frequency is relatively low, but this situation has occurred several times. 
All caused by misoperation

There are mainly the following reasons for implementing this function in the 
ovs-vsctl module:
1.fix this on the OVSDB side is indeed more comprehensive; however, 
fix this on the ovs-vsctl side eliminates the need for database 
access, making it faster and more lightweight in terms of overhead.
2.For more manual operations, the command line is often chosen for 
configuration, which leads to a higher probability of 
misoperations. Direct access to the OVSDB database is generally 
implemented through interface calls between functional modules, so the 
probability of duplicate parameters should be relatively low.


I understand that this implementation has its advantages, and at the very 
least, it has no negative effects. Additionally, sufficient testing has been 
conducted.
Is it possible to merge this patch first, and I will figure out how to fix 
this on the database side later?

Best regards, Lingfei Yao.




------------------ ???????? ------------------
??????:                                                                         
                                               "Ilya Maximets"                  
                                                                  
<i.maxim...@ovn.org&gt;;
????????:&nbsp;2025??8??27??(??????) ????4:18
??????:&nbsp;"??????????????"<543981...@qq.com&gt;;"dev"<d...@openvswitch.org&gt;;
????:&nbsp;"i.maximets"<i.maxim...@ovn.org&gt;;
????:&nbsp;Re: [ovs-dev] [PATCH v5] ovs-vsctl: Check controller parameters.



On 8/19/25 9:41 AM, yaolingfei via dev wrote:
&gt; Check the parameters when setting up the controller. The parameters will
&gt; only take effect when none of the following three parameters are
&gt; repeated; Otherwise, a prompt message will be returned
&gt; 1.ip address
&gt; 2.port no
&gt; 3.protocol type
&gt; 
&gt; v5: modified the subject summary
&gt; 
&gt; Signed-off-by: yaolingfei <543981...@qq.com&gt;
&gt; ---

Hi, yaolingfei.&nbsp; Thanks for the patch.

Could you, please, explain why this problem needs to be fixed?
Is it a common issue that users duplicate controllers on the command line?
Sounds a little unlikely.&nbsp; If it is, maybe we need to fix this on the
database side, e.g. by making the controller table indexed by the target.
If we just check on the command line level, users can still put duplicates
into the database.

Best regards, Ilya Maximets.


&gt;&nbsp; tests/ovs-vsctl.at&nbsp;&nbsp;&nbsp; |&nbsp; 4 ++++
&gt;&nbsp; utilities/ovs-vsctl.c | 26 +++++++++++++++++++++++++-
&gt;&nbsp; 2 files changed, 29 insertions(+), 1 deletion(-)
&gt; 
&gt; diff --git a/tests/ovs-vsctl.at b/tests/ovs-vsctl.at
&gt; index 59245fff8..76fe74414 100644
&gt; --- a/tests/ovs-vsctl.at
&gt; +++ b/tests/ovs-vsctl.at
&gt; @@ -492,6 +492,8 @@ AT_CHECK([RUN_OVS_VSCTL_TOGETHER(
&gt;&nbsp;&nbsp;&nbsp; [get-controller br0],
&gt;&nbsp; 
&gt;&nbsp;&nbsp;&nbsp; [--inactivity-probe=30000 set-controller br0 
tcp:1.2.3.4],
&gt; +&nbsp; [get-controller br0],
&gt; +&nbsp; [set-controller br0 tcp:8.9.10.11 tcp:8.9.10.11],
&gt;&nbsp;&nbsp;&nbsp; [get-controller br0])], [0], [
&gt;&nbsp; 
&gt;&nbsp; 
&gt; @@ -501,6 +503,8 @@ tcp:4.5.6.7
&gt;&nbsp; 
&gt;&nbsp; tcp:5.4.3.2\ntcp:8.9.10.11
&gt;&nbsp; 
&gt; +tcp:1.2.3.4
&gt; +Controller parameter is duplicated
&gt;&nbsp; tcp:1.2.3.4
&gt;&nbsp; ])
&gt;&nbsp; OVS_VSCTL_CLEANUP
&gt; diff --git a/utilities/ovs-vsctl.c b/utilities/ovs-vsctl.c
&gt; index d90db934b..f39952d72 100644
&gt; --- a/utilities/ovs-vsctl.c
&gt; +++ b/utilities/ovs-vsctl.c
&gt; @@ -2348,6 +2348,24 @@ insert_controllers(struct ctl_context *ctx, char 
*targets[], size_t n)
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return controllers;
&gt;&nbsp; }
&gt;&nbsp; 
&gt; +static int
&gt; +check_dup_controllers(char *targets[], size_t n)
&gt; +{
&gt; +&nbsp;&nbsp;&nbsp; size_t i;
&gt; +&nbsp;&nbsp;&nbsp; size_t j;
&gt; +
&gt; +&nbsp;&nbsp;&nbsp; /* check if the input parameters are duplicated */
&gt; +&nbsp;&nbsp;&nbsp; for (i = 0; i < n; i++) {
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (j = i + 1; j < n; j++) {
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if 
(!strcmp(targets[i], targets[j])) {
&gt; 
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 return 0;
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&gt; +&nbsp;&nbsp;&nbsp; }
&gt; +
&gt; +&nbsp;&nbsp;&nbsp; return 1;
&gt; +}
&gt; +
&gt;&nbsp; static void
&gt;&nbsp; cmd_set_controller(struct ctl_context *ctx)
&gt;&nbsp; {
&gt; @@ -2361,9 +2379,15 @@ cmd_set_controller(struct ctl_context *ctx)
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; br = find_real_bridge(vsctl_ctx, 
ctx-&gt;argv[1], true)-&gt;br_cfg;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; verify_controllers(br);
&gt;&nbsp; 
&gt; +&nbsp;&nbsp;&nbsp; n = ctx-&gt;argc - 2;
&gt; +&nbsp;&nbsp;&nbsp; if (!check_dup_controllers(&amp;ctx-&gt;argv[2], n)) {
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* controller parameters are 
duplicated */
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
ds_put_format(&amp;ctx-&gt;output, "Controller parameter is duplicated\n");
&gt; +&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;
&gt; +&nbsp;&nbsp;&nbsp; }
&gt; +
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delete_controllers(br-&gt;controller, 
br-&gt;n_controller);
&gt;&nbsp; 
&gt; -&nbsp;&nbsp;&nbsp; n = ctx-&gt;argc - 2;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; controllers = insert_controllers(ctx, 
&amp;ctx-&gt;argv[2], n);
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ovsrec_bridge_set_controller(br, 
controllers, n);
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; free(controllers);
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to