forked from ovn-org/ovn
-
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.
controller: Announce routes via route-exchange.
This engine node takes the routes from the "route" engine node and ensures they are written to the linux side. It is separate from the "route" engine node as it will also be used to learn routes in the future. Signed-off-by: Felix Huettner <felix.huettner@stackit.cloud> Signed-off-by: 0-day Robot <robot@bytheb.org>
- Loading branch information
1 parent
f77cb93
commit a21916f
Showing
8 changed files
with
668 additions
and
4 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
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,42 @@ | ||
/* | ||
* 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 <stdbool.h> | ||
|
||
#include "openvswitch/compiler.h" | ||
#include "route-exchange.h" | ||
|
||
bool | ||
route_exchange_relevant_port(const struct sbrec_port_binding *pb OVS_UNUSED) | ||
{ | ||
return false; | ||
} | ||
|
||
void | ||
route_exchange_run(struct route_exchange_ctx_in *r_ctx_in OVS_UNUSED, | ||
struct route_exchange_ctx_out *r_ctx_out OVS_UNUSED) | ||
{ | ||
} | ||
|
||
void | ||
route_exchange_cleanup(void) | ||
{ | ||
} | ||
|
||
void | ||
route_exchange_destroy(void) | ||
{ | ||
} |
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,102 @@ | ||
/* | ||
* 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 <errno.h> | ||
#include <net/if.h> | ||
|
||
#include "openvswitch/vlog.h" | ||
|
||
#include "lib/ovn-sb-idl.h" | ||
|
||
#include "binding.h" | ||
#include "ha-chassis.h" | ||
#include "local_data.h" | ||
#include "route.h" | ||
#include "route-exchange.h" | ||
#include "route-exchange-netlink.h" | ||
|
||
|
||
VLOG_DEFINE_THIS_MODULE(route_exchange); | ||
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); | ||
|
||
static struct sset _maintained_vrfs = SSET_INITIALIZER(&_maintained_vrfs); | ||
|
||
void | ||
route_exchange_run(struct route_exchange_ctx_in *r_ctx_in, | ||
struct route_exchange_ctx_out *r_ctx_out OVS_UNUSED) | ||
{ | ||
struct sset old_maintained_vrfs = SSET_INITIALIZER(&old_maintained_vrfs); | ||
sset_swap(&_maintained_vrfs, &old_maintained_vrfs); | ||
|
||
const struct advertise_datapath_entry *ad; | ||
HMAP_FOR_EACH (ad, node, r_ctx_in->announce_routes) { | ||
struct hmap received_routes | ||
= HMAP_INITIALIZER(&received_routes); | ||
char vrf_name[IFNAMSIZ + 1]; | ||
snprintf(vrf_name, sizeof vrf_name, "ovnvrf%"PRIi64, | ||
ad->key); | ||
|
||
if (ad->maintain_vrf) { | ||
int error = re_nl_create_vrf(vrf_name, ad->key); | ||
if (error && error != EEXIST) { | ||
VLOG_WARN_RL(&rl, | ||
"Unable to create VRF %s for datapath " | ||
"%"PRId64": %s.", | ||
vrf_name, ad->key, | ||
ovs_strerror(error)); | ||
continue; | ||
} | ||
sset_add(&_maintained_vrfs, vrf_name); | ||
} else { | ||
/* a previous maintain-vrf flag was removed. We should therfor | ||
* also not delete it even if we created it previously. */ | ||
sset_find_and_delete(&_maintained_vrfs, vrf_name); | ||
sset_find_and_delete(&old_maintained_vrfs, vrf_name); | ||
} | ||
|
||
re_nl_sync_routes(ad->key, &ad->routes); | ||
} | ||
|
||
/* Remove VRFs previously maintained by us not found in the above loop. */ | ||
const char *vrf_name; | ||
SSET_FOR_EACH_SAFE (vrf_name, &old_maintained_vrfs) { | ||
if (!sset_find(&_maintained_vrfs, vrf_name)) { | ||
re_nl_delete_vrf(vrf_name); | ||
} | ||
sset_delete(&old_maintained_vrfs, SSET_NODE_FROM_NAME(vrf_name)); | ||
} | ||
sset_destroy(&old_maintained_vrfs); | ||
} | ||
|
||
void | ||
route_exchange_cleanup(void) | ||
{ | ||
const char *vrf_name; | ||
SSET_FOR_EACH_SAFE (vrf_name, &_maintained_vrfs) { | ||
re_nl_delete_vrf(vrf_name); | ||
} | ||
} | ||
|
||
void | ||
route_exchange_destroy(void) | ||
{ | ||
const char *vrf_name; | ||
SSET_FOR_EACH_SAFE (vrf_name, &_maintained_vrfs) { | ||
sset_delete(&_maintained_vrfs, SSET_NODE_FROM_NAME(vrf_name)); | ||
} | ||
|
||
sset_destroy(&_maintained_vrfs); | ||
} |
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,33 @@ | ||
/* | ||
* 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 ROUTE_EXCHANGE_H | ||
#define ROUTE_EXCHANGE_H 1 | ||
|
||
#include <stdbool.h> | ||
|
||
struct route_exchange_ctx_in { | ||
/* Contains struct advertise_datapath_entry */ | ||
struct hmap *announce_routes; | ||
}; | ||
|
||
struct route_exchange_ctx_out { | ||
}; | ||
|
||
void route_exchange_run(struct route_exchange_ctx_in *, | ||
struct route_exchange_ctx_out *); | ||
void route_exchange_cleanup(void); | ||
void route_exchange_destroy(void); | ||
|
||
#endif /* ROUTE_EXCHANGE_H */ |
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
Oops, something went wrong.