[ovs-dev] [PATCH V8 1/3] ovn-controller-vtep: Add vtep module.

Russell Bryant rbryant at redhat.com
Mon Aug 24 14:58:29 UTC 2015


On 08/23/2015 02:06 PM, Alex Wang wrote:
> This commit adds the vtep module to ovn-controller-vtep.  The
> module will scan through the Port_Binding table in OVN-SB database,
> and update the vtep logcial switches tunnel keys.
> 
> Signed-off-by: Alex Wang <alexw at nicira.com>

Two incredibly minor tweaks inline.

Acked-by: Russell Bryant <rbryant at redhat.com>

> diff --git a/ovn/controller-vtep/vtep.c b/ovn/controller-vtep/vtep.c
> new file mode 100644
> index 0000000..c7b43c0
> --- /dev/null
> +++ b/ovn/controller-vtep/vtep.c
> @@ -0,0 +1,168 @@
> +/* Copyright (c) 2015 Nicira, Inc.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at:
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +#include <config.h>
> +
> +#include "vtep.h"
> +
> +#include "lib/hash.h"
> +#include "lib/hmap.h"
> +#include "lib/smap.h"
> +#include "lib/sset.h"
> +#include "lib/util.h"
> +#include "ovn-controller-vtep.h"
> +#include "openvswitch/vlog.h"
> +#include "ovn/lib/ovn-sb-idl.h"
> +#include "vtep/vtep-idl.h"
> +
> +VLOG_DEFINE_THIS_MODULE(vtep);
> +
> +/*
> + * Scans through the Binding table in ovnsb and updates the vtep logical
> + * switch tunnel keys.
> + *
> + */
> +
> +/* Updates the vtep Logical_Switch table entries' tunnel keys based
> + * on the port bindings. */
> +static void
> +vtep_lswitch_run(struct controller_vtep_ctx *ctx)
> +{
> +    struct shash vtep_lswitches = SHASH_INITIALIZER(&vtep_lswitches);
> +    struct sset vtep_pswitches = SSET_INITIALIZER(&vtep_pswitches);
> +    struct sset used_ls = SSET_INITIALIZER(&used_ls);
> +    const struct vteprec_physical_switch *pswitch;
> +    const struct sbrec_port_binding *port_binding_rec;
> +    const struct vteprec_logical_switch *vtep_ls;
> +
> +    /* Registers all vtep physical switch names in the vtep database. */
> +    VTEPREC_PHYSICAL_SWITCH_FOR_EACH (pswitch, ctx->vtep_idl) {
> +        sset_add(&vtep_pswitches, pswitch->name);
> +    }
> +
> +    /* Stores all logical switches to 'vtep_lswitches' with name as key. */
> +    VTEPREC_LOGICAL_SWITCH_FOR_EACH (vtep_ls, ctx->vtep_idl) {
> +        shash_add(&vtep_lswitches, vtep_ls->name, vtep_ls);
> +    }
> +
> +    ovsdb_idl_txn_add_comment(ctx->vtep_idl_txn,
> +                              "ovn-controller-vtep: update logical switch "
> +                              "tunnel keys");
> +    /* Collects the logical switch bindings from port binding entries.
> +     * Since the binding module has already guaranteed that each vtep
> +     * logical switch is bound only to one ovn-sb logical datapath,
> +     * we can just iterate and assign tunnel key to vtep logical switch. */
> +    SBREC_PORT_BINDING_FOR_EACH(port_binding_rec, ctx->ovnsb_idl) {
> +        if (strcmp(port_binding_rec->type, "vtep")
> +            || !port_binding_rec->chassis) {
> +            continue;
> +        }
> +        const char *pswitch_name = smap_get(&port_binding_rec->options,
> +                                            "vtep-physical-switch");
> +        const char *lswitch_name = smap_get(&port_binding_rec->options,
> +                                            "vtep-logical-switch");
> +
> +        /* If 'port_binding_rec->chassis' exists then 'lswitch_name'
> +         * must also exist. */

This comment should reflect that both pswitch_name and lswitch_name must
exist.


> diff --git a/ovn/controller-vtep/vtep.h b/ovn/controller-vtep/vtep.h
> new file mode 100644
> index 0000000..ae6c79b
> --- /dev/null
> +++ b/ovn/controller-vtep/vtep.h
> @@ -0,0 +1,27 @@
> +/* Copyright (c) 2015 Nicira, Inc.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at:
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +
> +#ifndef OVN_VTEP_H
> +#define OVN_VTEP_H 1
> +
> +#include <stdbool.h>
> +
> +struct controller_vtep_ctx;
> +
> +void vtep_run(struct controller_vtep_ctx *);
> +bool vtep_cleanup(struct controller_vtep_ctx *);
> +
> +#endif /* ovn/controller-gw/vtep.h */

s/controller-gw/controller-vtep/


-- 
Russell Bryant



More information about the dev mailing list