[ovs-dev] [PATCH] ovn-controller: if 'ovn-bridge-mappings' unconfigured, return directly.

Russell Bryant russell at ovn.org
Tue Aug 2 15:26:29 UTC 2016


On Mon, Aug 1, 2016 at 1:30 PM, Russell Bryant <russell at ovn.org> wrote:

>
>
> On Mon, Aug 1, 2016 at 12:09 PM, Russell Bryant <russell at ovn.org> wrote:
>
>>
>>
>> On Mon, Aug 1, 2016 at 12:00 PM, Ben Pfaff <blp at ovn.org> wrote:
>>
>>> On Mon, Aug 01, 2016 at 02:55:26AM -0700, nickcooper-zhangtonghao wrote:
>>> > If the chassis doesn't configure the
>>> 'external-ids:ovn-bridge-mappings' in
>>> > the OVSDB, the 'add_bridge_mappings' should return directly.
>>> >
>>> > Signed-off-by: nickcooper-zhangtonghao
>>> <nickcooper-zhangtonghao at opencloud.tech>
>>>
>>> What's the benefit?
>>
>>
>> I was looking at this earlier before I got on some calls.
>>
>> There doesn't appear to be any bug here, but this patch does skip some
>> unnecessary code.  The most notable improvement seems to be skipping a loop
>> over all Port_Binding records in every call to patch_run.
>>
>
> Acked-by: Russell Bryant <russell at ovn.org>
>

I went ahead and applied this to master with a minor addition to the commit
message and a change to also return on an empty string.  I also dropped the
new comment, as I think the code is obvious enough.  The final patch is
here:

commit c13fb2b804e9fb2c9524ed6f54d84324e2d219dc
Author: nickcooper-zhangtonghao <nickcooper-zhangtonghao at opencloud.tech>
Date:   Mon Aug 1 02:55:26 2016 -0700

    ovn-controller: if 'ovn-bridge-mappings' unconfigured, return directly.

    If the chassis doesn't configure the 'external-ids:ovn-bridge-mappings'
in
    the OVSDB, the 'add_bridge_mappings' should return directly to skip some
    unnecessary code.

    Signed-off-by: nickcooper-zhangtonghao
<nickcooper-zhangtonghao at opencloud.tech>
    Signed-off-by: Russell Bryant <russell at ovn.org>

diff --git a/ovn/controller/patch.c b/ovn/controller/patch.c
index 012e6ba..62d68d9 100644
--- a/ovn/controller/patch.c
+++ b/ovn/controller/patch.c
@@ -151,8 +151,8 @@ add_bridge_mappings(struct controller_ctx *ctx,
     cfg = ovsrec_open_vswitch_first(ctx->ovs_idl);
     if (cfg) {
         mappings_cfg = smap_get(&cfg->external_ids, "ovn-bridge-mappings");
-        if (!mappings_cfg) {
-            mappings_cfg = "";
+        if (!mappings_cfg || !mappings_cfg[0]) {
+            return;
         }
     }



More information about the dev mailing list