mirror of
https://github.com/kernelkit/infix.git
synced 2026-08-05 23:23:02 +02:00
board/common: set DHCP and ZeroConf routes using Frr/staticd
This patch changes the way Infix DHCP and ZerocConf clients set their routes in the system. Instead of setting them directly in the kernel we ask FRR staticd to set them for us. The reason for this change is to be able to override routes from these protocols with locally set static routes. The routes are now set with a distance of 5 and 254, respectively, while static routes by default have a distance of 1. In contrast, kernel routes are always treated by Frr as distance 0, i.e., they are preferred over static routes. Finally, this patch drops the use of Linux legacy interface aliases, or colon interfaces, in an effort to reduce confusion for end users. This may give some odd results if using older tools like ifconfig, so we recommend using 'show interfaces' or 'ipb a' instead. Fixes #640 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
#define XPATH_BASE_ "/ietf-routing:routing/control-plane-protocols/control-plane-protocol"
|
||||
#define XPATH_OSPF_ XPATH_BASE_ "/ietf-ospf:ospf"
|
||||
#define STATICD_CONF "/etc/frr/staticd.conf"
|
||||
#define STATICD_CONF "/etc/frr/static.d/confd.conf"
|
||||
#define STATICD_CONF_NEXT STATICD_CONF "+"
|
||||
#define STATICD_CONF_PREV STATICD_CONF "-"
|
||||
#define OSPFD_CONF "/etc/frr/ospfd.conf"
|
||||
@@ -245,7 +245,7 @@ static int change_control_plane_protocols(sr_session_ctx_t *session, uint32_t su
|
||||
const char *xpath, sr_event_t event, unsigned request_id, void *priv)
|
||||
{
|
||||
int staticd_enabled = 0, ospfd_enabled = 0, bfdd_enabled = 0;
|
||||
bool ospfd_running, staticd_running, bfdd_running;
|
||||
bool ospfd_running, bfdd_running;
|
||||
struct lyd_node *cplane, *tmp;
|
||||
bool restart_zebra = false;
|
||||
int rc = SR_ERR_OK;
|
||||
@@ -260,7 +260,7 @@ static int change_control_plane_protocols(sr_session_ctx_t *session, uint32_t su
|
||||
ERROR("Failed to open %s", STATICD_CONF_NEXT);
|
||||
return SR_ERR_INTERNAL;
|
||||
}
|
||||
fputs(FRR_STATIC_CONFIG, fp);
|
||||
fputs("! Generated by Infix confd\n", fp);
|
||||
break;
|
||||
|
||||
case SR_EV_ABORT: /* User abort, or other plugin failed */
|
||||
@@ -272,18 +272,8 @@ static int change_control_plane_protocols(sr_session_ctx_t *session, uint32_t su
|
||||
staticd_enabled = fexist(STATICD_CONF_NEXT);
|
||||
ospfd_enabled = fexist(OSPFD_CONF_NEXT);
|
||||
bfdd_enabled = fexist(BFDD_CONF_NEXT);
|
||||
staticd_running = !systemf("initctl -bfq status staticd");
|
||||
ospfd_running = !systemf("initctl -bfq status ospfd");
|
||||
bfdd_running = !systemf("initctl -bfq status bfdd");
|
||||
if (staticd_running && !staticd_enabled) {
|
||||
if (systemf("initctl -bfq disable staticd")) {
|
||||
ERROR("Failed to disable static routing daemon");
|
||||
rc = SR_ERR_INTERNAL;
|
||||
goto err_abandon;
|
||||
}
|
||||
/* Remove all generated files */
|
||||
(void)remove(STATICD_CONF);
|
||||
}
|
||||
|
||||
if (bfdd_running && !bfdd_enabled) {
|
||||
if (systemf("initctl -bfq disable bfdd")) {
|
||||
@@ -337,15 +327,10 @@ static int change_control_plane_protocols(sr_session_ctx_t *session, uint32_t su
|
||||
(void)remove(STATICD_CONF_PREV);
|
||||
(void)rename(STATICD_CONF, STATICD_CONF_PREV);
|
||||
(void)rename(STATICD_CONF_NEXT, STATICD_CONF);
|
||||
if (!staticd_running) {
|
||||
if (systemf("initctl -bfq enable staticd")) {
|
||||
ERROR("Failed to enable static routing daemon");
|
||||
rc = SR_ERR_INTERNAL;
|
||||
goto err_abandon;
|
||||
}
|
||||
} else {
|
||||
restart_zebra = true;
|
||||
} else {
|
||||
if (!remove(STATICD_CONF))
|
||||
restart_zebra = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (restart_zebra) {
|
||||
|
||||
Reference in New Issue
Block a user