Skip to content

Commit

Permalink
ovn: l3ha, ovn-northd gateway chassis propagation
Browse files Browse the repository at this point in the history
The redirect-chassis option of logical router ports is now
translated to Gateway_Chassis entries for backwards compatibility.

Gateway_Chassis entries in nbdb are copied over to sbdb and
linked them to the Chassis entry.

Co-authored-by: Anil Venkata <vkommadi@redhat.com>
Signed-off-by: Miguel Angel Ajo <majopela@redhat.com>
Signed-off-by: Anil Venkata <vkommadi@redhat.com>
Signed-off-by: Russell Bryant <russell@ovn.org>
  • Loading branch information
2 people authored and russellb committed Jul 16, 2017
1 parent dc65a07 commit b86f476
Show file tree
Hide file tree
Showing 7 changed files with 446 additions and 9 deletions.
2 changes: 2 additions & 0 deletions ovn/lib/automake.mk
Expand Up @@ -5,6 +5,8 @@ ovn_lib_libovn_la_LDFLAGS = \
$(AM_LDFLAGS)
ovn_lib_libovn_la_SOURCES = \
ovn/lib/actions.c \
ovn/lib/chassis-index.c \
ovn/lib/chassis-index.h \
ovn/lib/expr.c \
ovn/lib/lex.c \
ovn/lib/ovn-dhcp.h \
Expand Down
77 changes: 77 additions & 0 deletions ovn/lib/chassis-index.c
@@ -0,0 +1,77 @@
/* Copyright (c) 2016, 2017 Red Hat, 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 "openvswitch/hmap.h"
#include "openvswitch/vlog.h"
#include "ovn/actions.h"
#include "ovn/lib/chassis-index.h"
#include "ovn/lib/ovn-sb-idl.h"

VLOG_DEFINE_THIS_MODULE(chassis_index);

struct chassis {
struct hmap_node name_node;
const struct sbrec_chassis *db;
};

const struct sbrec_chassis *
chassis_lookup_by_name(const struct chassis_index *chassis_index,
const char *name)
{
const struct chassis *chassis;
HMAP_FOR_EACH_WITH_HASH (chassis, name_node, hash_string(name, 0),
&chassis_index->by_name) {
if (!strcmp(chassis->db->name, name)) {
return chassis->db;
}
}
return NULL;
}

void
chassis_index_init(struct chassis_index *chassis_index,
struct ovsdb_idl *sb_idl)
{
hmap_init(&chassis_index->by_name);

const struct sbrec_chassis *chassis;
SBREC_CHASSIS_FOR_EACH (chassis, sb_idl) {
if (!chassis->name) {
continue;
}
struct chassis *c = xmalloc(sizeof *c);
hmap_insert(&chassis_index->by_name, &c->name_node,
hash_string(chassis->name, 0));
c->db = chassis;
}
}

void
chassis_index_destroy(struct chassis_index *chassis_index)
{
if (!chassis_index) {
return;
}

/* Destroy all of the "struct chassis"s. */
struct chassis *chassis, *next;
HMAP_FOR_EACH_SAFE (chassis, next, name_node, &chassis_index->by_name) {
hmap_remove(&chassis_index->by_name, &chassis->name_node);
free(chassis);
}

hmap_destroy(&chassis_index->by_name);
}
40 changes: 40 additions & 0 deletions ovn/lib/chassis-index.h
@@ -0,0 +1,40 @@
/* Copyright (c) 2017, Red Hat, 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_CHASSIS_INDEX_H
#define OVN_CHASSIS_INDEX_H 1

#include "openvswitch/hmap.h"

struct chassis_index {
struct hmap by_name;
};

struct ovsdb_idl;

/* Finds and returns the chassis with the given 'name', or NULL if no such
* chassis exists. */
const struct sbrec_chassis *
chassis_lookup_by_name(const struct chassis_index *chassis_index,
const char *name);

/* Initializes the chassis index out of the ovsdb_idl to SBDB */
void chassis_index_init(struct chassis_index *chassis_index,
struct ovsdb_idl *sb_idl);

/* Free a chassis index from memory */
void chassis_index_destroy(struct chassis_index *chassis_index);

#endif /* ovn/lib/chassis-index.h */

0 comments on commit b86f476

Please sign in to comment.