diff mbox series

[ovs-dev,v2,2/2] binding: fixed qos when no iface

Message ID 20230620135843.2273523-2-xsimonar@redhat.com
State Accepted
Headers show
Series [ovs-dev,v2,1/2] qos: fix potential double deletion of ovs idl row | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test fail github build: failed
ovsrobot/github-robot-_ovn-kubernetes fail github build: failed

Commit Message

Xavier Simonart June 20, 2023, 1:58 p.m. UTC
Before this patch, if iface did not exist when qos I+P was run the first time
a qos queue was still created and qos I+P was not applying qos to OVS.
qos was potentially applied later, if/when (for any reason) runtime_data had to be recomputed.

Fixes: 7d1d111ff213 ("controller: configure qos through ovs qos table and do not run tc directly")
Signed-off-by: Xavier Simonart <xsimonar@redhat.com>

---
v2: - handled Lorenzo's comments
    - updated test case to also test null network (as referenced by Lorenzo)
    - rebased on origin/main
---
 controller/binding.c | 26 ++++++++++++--------------
 tests/ovn.at         |  8 ++++++++
 2 files changed, 20 insertions(+), 14 deletions(-)

Comments

Ales Musil July 17, 2023, 9:13 a.m. UTC | #1
On Tue, Jun 20, 2023 at 3:59 PM Xavier Simonart <xsimonar@redhat.com> wrote:

> Before this patch, if iface did not exist when qos I+P was run the first
> time
> a qos queue was still created and qos I+P was not applying qos to OVS.
> qos was potentially applied later, if/when (for any reason) runtime_data
> had to be recomputed.
>
> Fixes: 7d1d111ff213 ("controller: configure qos through ovs qos table and
> do not run tc directly")
> Signed-off-by: Xavier Simonart <xsimonar@redhat.com>
>
> ---
> v2: - handled Lorenzo's comments
>     - updated test case to also test null network (as referenced by
> Lorenzo)
>     - rebased on origin/main
> ---
>  controller/binding.c | 26 ++++++++++++--------------
>  tests/ovn.at         |  8 ++++++++
>  2 files changed, 20 insertions(+), 14 deletions(-)
>
> diff --git a/controller/binding.c b/controller/binding.c
> index 8069a2e0d..355b73070 100644
> --- a/controller/binding.c
> +++ b/controller/binding.c
> @@ -362,7 +362,7 @@ configure_qos(const struct sbrec_port_binding *pb,
>      struct qos_queue *q = find_qos_queue(b_ctx_out->qos_map, hash,
>                                           pb->logical_port);
>      if (!q || q->min_rate != min_rate || q->max_rate != max_rate ||
> -        q->burst != burst) {
> +        q->burst != burst || (network && strcmp(network, q->network))) {
>          struct shash bridge_mappings =
> SHASH_INITIALIZER(&bridge_mappings);
>          add_ovs_bridge_mappings(b_ctx_in->ovs_table,
> b_ctx_in->bridge_table,
>                                  &bridge_mappings);
> @@ -378,22 +378,20 @@ configure_qos(const struct sbrec_port_binding *pb,
>              add_ovs_qos_table_entry(b_ctx_in->ovs_idl_txn, port, min_rate,
>                                      max_rate, burst, queue_id,
>                                      pb->logical_port);
> +            if (!q) {
> +                q = xzalloc(sizeof *q);
> +                hmap_insert(b_ctx_out->qos_map, &q->node, hash);
> +                q->port = xstrdup(pb->logical_port);
> +                q->queue_id = queue_id;
> +            }
> +            free(q->network);
> +            q->network = network ? xstrdup(network) : NULL;
> +            q->min_rate = min_rate;
> +            q->max_rate = max_rate;
> +            q->burst = burst;
>          }
>          shash_destroy(&bridge_mappings);
>      }
> -
> -    if (!q) {
> -        q = xzalloc(sizeof *q);
> -        hmap_insert(b_ctx_out->qos_map, &q->node, hash);
> -        q->port = xstrdup(pb->logical_port);
> -        q->queue_id = queue_id;
> -    }
> -
> -    free(q->network);
> -    q->network = network ? xstrdup(network) : NULL;
> -    q->min_rate = min_rate;
> -    q->max_rate = max_rate;
> -    q->burst = burst;
>  }
>
>  static const struct ovsrec_queue *
> diff --git a/tests/ovn.at b/tests/ovn.at
> index 2c221a05c..8d69c35d9 100644
> --- a/tests/ovn.at
> +++ b/tests/ovn.at
> @@ -36235,6 +36235,7 @@ check ovn-nbctl ls-add ls1
>  check ovn-nbctl lsp-add ls1 public1
>  check ovn-nbctl lsp-set-addresses public1 unknown
>  check ovn-nbctl lsp-set-type public1 localnet
> +check ovn-nbctl lsp-set-options public1 network_name=phys
>
>  check ovn-nbctl lsp-add ls1 lsp5
>  check ovn-nbctl lsp-set-addresses lsp5 f0:00:00:00:00:05
> @@ -36244,6 +36245,12 @@ ovs-vsctl add-port br-int vif5 -- \
>      ofport-request=5
>  OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lsp5` = xup])
>
> +# Delete and add back public1
> +check ovn-nbctl --wait=hv lsp-del public1
> +check ovn-nbctl lsp-add ls1 public1
> +check ovn-nbctl lsp-set-addresses public1 unknown
> +check ovn-nbctl lsp-set-type public1 localnet
> +
>  check ovn-nbctl set Logical_Switch_Port public1
> options:qos_min_rate=6000000000
>  check ovn-nbctl set Logical_Switch_Port public1
> options:qos_max_rate=7000000000
>  check ovn-nbctl set Logical_Switch_Port public1
> options:qos_burst=8000000000
> @@ -36509,6 +36516,7 @@ check ovn-nbctl lsp-add ls2 public2
>  check ovn-nbctl lsp-set-addresses public2 unknown
>  check ovn-nbctl lsp-set-type public2 localnet
>  check ovn-nbctl --wait=sb set Logical_Switch_Port public2
> options:qos_min_rate=6000000000 options:qos_max_rate=7000000000
> options:qos_burst=8000000000 options:network_name=phys
> +check ovn-nbctl --wait=sb lsp-set-options public2 qos_min_rate=6000000000
> qos_max_rate=7000000000 qos_burst=8000000000
>
>  # Let's now send ovn controller to sleep, so it will receive both ofport
> notification and ls deletion simultaneously
>  sleep_controller hv-1
> --
> 2.31.1
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
>
Looks good to me, thanks.

Acked-by: Ales Musil <amusil@redhat.com>
Dumitru Ceara July 17, 2023, 1:51 p.m. UTC | #2
On 7/17/23 11:13, Ales Musil wrote:
> On Tue, Jun 20, 2023 at 3:59 PM Xavier Simonart <xsimonar@redhat.com> wrote:
> 
>> Before this patch, if iface did not exist when qos I+P was run the first
>> time
>> a qos queue was still created and qos I+P was not applying qos to OVS.
>> qos was potentially applied later, if/when (for any reason) runtime_data
>> had to be recomputed.
>>
>> Fixes: 7d1d111ff213 ("controller: configure qos through ovs qos table and
>> do not run tc directly")
>> Signed-off-by: Xavier Simonart <xsimonar@redhat.com>
>>
>> ---
>> v2: - handled Lorenzo's comments
>>     - updated test case to also test null network (as referenced by
>> Lorenzo)
>>     - rebased on origin/main
>> ---
>>  controller/binding.c | 26 ++++++++++++--------------
>>  tests/ovn.at         |  8 ++++++++
>>  2 files changed, 20 insertions(+), 14 deletions(-)
>>
>> diff --git a/controller/binding.c b/controller/binding.c
>> index 8069a2e0d..355b73070 100644
>> --- a/controller/binding.c
>> +++ b/controller/binding.c
>> @@ -362,7 +362,7 @@ configure_qos(const struct sbrec_port_binding *pb,
>>      struct qos_queue *q = find_qos_queue(b_ctx_out->qos_map, hash,
>>                                           pb->logical_port);
>>      if (!q || q->min_rate != min_rate || q->max_rate != max_rate ||
>> -        q->burst != burst) {
>> +        q->burst != burst || (network && strcmp(network, q->network))) {
>>          struct shash bridge_mappings =
>> SHASH_INITIALIZER(&bridge_mappings);
>>          add_ovs_bridge_mappings(b_ctx_in->ovs_table,
>> b_ctx_in->bridge_table,
>>                                  &bridge_mappings);
>> @@ -378,22 +378,20 @@ configure_qos(const struct sbrec_port_binding *pb,
>>              add_ovs_qos_table_entry(b_ctx_in->ovs_idl_txn, port, min_rate,
>>                                      max_rate, burst, queue_id,
>>                                      pb->logical_port);
>> +            if (!q) {
>> +                q = xzalloc(sizeof *q);
>> +                hmap_insert(b_ctx_out->qos_map, &q->node, hash);
>> +                q->port = xstrdup(pb->logical_port);
>> +                q->queue_id = queue_id;
>> +            }
>> +            free(q->network);
>> +            q->network = network ? xstrdup(network) : NULL;
>> +            q->min_rate = min_rate;
>> +            q->max_rate = max_rate;
>> +            q->burst = burst;
>>          }
>>          shash_destroy(&bridge_mappings);
>>      }
>> -
>> -    if (!q) {
>> -        q = xzalloc(sizeof *q);
>> -        hmap_insert(b_ctx_out->qos_map, &q->node, hash);
>> -        q->port = xstrdup(pb->logical_port);
>> -        q->queue_id = queue_id;
>> -    }
>> -
>> -    free(q->network);
>> -    q->network = network ? xstrdup(network) : NULL;
>> -    q->min_rate = min_rate;
>> -    q->max_rate = max_rate;
>> -    q->burst = burst;
>>  }
>>
>>  static const struct ovsrec_queue *
>> diff --git a/tests/ovn.at b/tests/ovn.at
>> index 2c221a05c..8d69c35d9 100644
>> --- a/tests/ovn.at
>> +++ b/tests/ovn.at
>> @@ -36235,6 +36235,7 @@ check ovn-nbctl ls-add ls1
>>  check ovn-nbctl lsp-add ls1 public1
>>  check ovn-nbctl lsp-set-addresses public1 unknown
>>  check ovn-nbctl lsp-set-type public1 localnet
>> +check ovn-nbctl lsp-set-options public1 network_name=phys
>>
>>  check ovn-nbctl lsp-add ls1 lsp5
>>  check ovn-nbctl lsp-set-addresses lsp5 f0:00:00:00:00:05
>> @@ -36244,6 +36245,12 @@ ovs-vsctl add-port br-int vif5 -- \
>>      ofport-request=5
>>  OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lsp5` = xup])
>>
>> +# Delete and add back public1
>> +check ovn-nbctl --wait=hv lsp-del public1
>> +check ovn-nbctl lsp-add ls1 public1
>> +check ovn-nbctl lsp-set-addresses public1 unknown
>> +check ovn-nbctl lsp-set-type public1 localnet
>> +
>>  check ovn-nbctl set Logical_Switch_Port public1
>> options:qos_min_rate=6000000000
>>  check ovn-nbctl set Logical_Switch_Port public1
>> options:qos_max_rate=7000000000
>>  check ovn-nbctl set Logical_Switch_Port public1
>> options:qos_burst=8000000000
>> @@ -36509,6 +36516,7 @@ check ovn-nbctl lsp-add ls2 public2
>>  check ovn-nbctl lsp-set-addresses public2 unknown
>>  check ovn-nbctl lsp-set-type public2 localnet
>>  check ovn-nbctl --wait=sb set Logical_Switch_Port public2
>> options:qos_min_rate=6000000000 options:qos_max_rate=7000000000
>> options:qos_burst=8000000000 options:network_name=phys
>> +check ovn-nbctl --wait=sb lsp-set-options public2 qos_min_rate=6000000000
>> qos_max_rate=7000000000 qos_burst=8000000000
>>
>>  # Let's now send ovn controller to sleep, so it will receive both ofport
>> notification and ls deletion simultaneously
>>  sleep_controller hv-1
>> --
>> 2.31.1
>>
>> _______________________________________________
>> dev mailing list
>> dev@openvswitch.org
>> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>>
>>
> Looks good to me, thanks.
> 
> Acked-by: Ales Musil <amusil@redhat.com>
> 

Thanks, Xavier and Ales!

I applied this to main and backported it to 23.06.

Regards,
Dumitru
diff mbox series

Patch

diff --git a/controller/binding.c b/controller/binding.c
index 8069a2e0d..355b73070 100644
--- a/controller/binding.c
+++ b/controller/binding.c
@@ -362,7 +362,7 @@  configure_qos(const struct sbrec_port_binding *pb,
     struct qos_queue *q = find_qos_queue(b_ctx_out->qos_map, hash,
                                          pb->logical_port);
     if (!q || q->min_rate != min_rate || q->max_rate != max_rate ||
-        q->burst != burst) {
+        q->burst != burst || (network && strcmp(network, q->network))) {
         struct shash bridge_mappings = SHASH_INITIALIZER(&bridge_mappings);
         add_ovs_bridge_mappings(b_ctx_in->ovs_table, b_ctx_in->bridge_table,
                                 &bridge_mappings);
@@ -378,22 +378,20 @@  configure_qos(const struct sbrec_port_binding *pb,
             add_ovs_qos_table_entry(b_ctx_in->ovs_idl_txn, port, min_rate,
                                     max_rate, burst, queue_id,
                                     pb->logical_port);
+            if (!q) {
+                q = xzalloc(sizeof *q);
+                hmap_insert(b_ctx_out->qos_map, &q->node, hash);
+                q->port = xstrdup(pb->logical_port);
+                q->queue_id = queue_id;
+            }
+            free(q->network);
+            q->network = network ? xstrdup(network) : NULL;
+            q->min_rate = min_rate;
+            q->max_rate = max_rate;
+            q->burst = burst;
         }
         shash_destroy(&bridge_mappings);
     }
-
-    if (!q) {
-        q = xzalloc(sizeof *q);
-        hmap_insert(b_ctx_out->qos_map, &q->node, hash);
-        q->port = xstrdup(pb->logical_port);
-        q->queue_id = queue_id;
-    }
-
-    free(q->network);
-    q->network = network ? xstrdup(network) : NULL;
-    q->min_rate = min_rate;
-    q->max_rate = max_rate;
-    q->burst = burst;
 }
 
 static const struct ovsrec_queue *
diff --git a/tests/ovn.at b/tests/ovn.at
index 2c221a05c..8d69c35d9 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -36235,6 +36235,7 @@  check ovn-nbctl ls-add ls1
 check ovn-nbctl lsp-add ls1 public1
 check ovn-nbctl lsp-set-addresses public1 unknown
 check ovn-nbctl lsp-set-type public1 localnet
+check ovn-nbctl lsp-set-options public1 network_name=phys
 
 check ovn-nbctl lsp-add ls1 lsp5
 check ovn-nbctl lsp-set-addresses lsp5 f0:00:00:00:00:05
@@ -36244,6 +36245,12 @@  ovs-vsctl add-port br-int vif5 -- \
     ofport-request=5
 OVS_WAIT_UNTIL([test x`ovn-nbctl lsp-get-up lsp5` = xup])
 
+# Delete and add back public1
+check ovn-nbctl --wait=hv lsp-del public1
+check ovn-nbctl lsp-add ls1 public1
+check ovn-nbctl lsp-set-addresses public1 unknown
+check ovn-nbctl lsp-set-type public1 localnet
+
 check ovn-nbctl set Logical_Switch_Port public1 options:qos_min_rate=6000000000
 check ovn-nbctl set Logical_Switch_Port public1 options:qos_max_rate=7000000000
 check ovn-nbctl set Logical_Switch_Port public1 options:qos_burst=8000000000
@@ -36509,6 +36516,7 @@  check ovn-nbctl lsp-add ls2 public2
 check ovn-nbctl lsp-set-addresses public2 unknown
 check ovn-nbctl lsp-set-type public2 localnet
 check ovn-nbctl --wait=sb set Logical_Switch_Port public2 options:qos_min_rate=6000000000 options:qos_max_rate=7000000000 options:qos_burst=8000000000 options:network_name=phys
+check ovn-nbctl --wait=sb lsp-set-options public2 qos_min_rate=6000000000 qos_max_rate=7000000000 qos_burst=8000000000
 
 # Let's now send ovn controller to sleep, so it will receive both ofport notification and ls deletion simultaneously
 sleep_controller hv-1