forked from openvswitch/ovs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ovn: l3ha, ovn-northd gateway chassis propagation
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 <[email protected]> Signed-off-by: Miguel Angel Ajo <[email protected]> Signed-off-by: Anil Venkata <[email protected]> Signed-off-by: Russell Bryant <[email protected]>
- Loading branch information
Showing
7 changed files
with
446 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 */ |
Oops, something went wrong.