Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: fix a pile of directory and/or state retention related issues #15243

Merged
merged 19 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2740,8 +2740,6 @@ AC_DEFINE_UNQUOTED([LDPD_SOCKET], ["$CFG_STATE%s%s/ldpd.sock"], [ldpd control so
AC_DEFINE_UNQUOTED([ZEBRA_SERV_PATH], ["$CFG_STATE%s%s/zserv.api"], [zebra api socket])
AC_DEFINE_UNQUOTED([BFDD_CONTROL_SOCKET], ["$CFG_STATE%s%s/bfdd.sock"], [bfdd control socket])
AC_DEFINE_UNQUOTED([OSPFD_GR_STATE], ["$CFG_STATE%s/ospfd-gr.json"], [ospfd GR state information])
AC_DEFINE_UNQUOTED([MGMTD_FE_SERVER_PATH], ["$CFG_STATE/mgmtd_fe.sock"], [mgmtd frontend server socket])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a genuine bug fix for mgmtd ( and should be backported to 9.0 and 9.1 as well right? ) Should this be in it's own PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I'm still pondering if we shouldn't just backport this entire PR; saving state to /var/run is such a weird thing to do. But fixing that needs the entire other pile of commits too, which is a bit much…

… and because we have (historically) overloaded --localstatedir in this stupid way I can't really "undo" or split off that change for a backport, without that /var/lib is kinda "inaccessible" …

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Case in point: if you configure OSPFv3 with authentication trailers and then reboot your box… your sequence number is gone and all the other routers refuse you into the network due to replay protection 🤡

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(regardless, it's not going to be a clean backport ⇒ need manual backport PR anyways ⇒ can adjust/drop things if needed)

AC_DEFINE_UNQUOTED([MGMTD_BE_SERVER_PATH], ["$CFG_STATE/mgmtd_be.sock"], [mgmtd backend server socket])
AC_DEFINE_UNQUOTED([OSPF6D_GR_STATE], ["$CFG_STATE/ospf6d-gr.json"], [ospf6d GR state information])
AC_DEFINE_UNQUOTED([ISISD_RESTART], ["$CFG_STATE%s/isid-restart.json"], [isisd restart information])
AC_DEFINE_UNQUOTED([OSPF6_AUTH_SEQ_NUM_FILE], ["$CFG_STATE/ospf6d-at-seq-no.dat"], [ospf6d AT Sequence number information])
Expand Down
6 changes: 5 additions & 1 deletion lib/mgmt_be_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,7 @@ struct mgmt_be_client *mgmt_be_client_create(const char *client_name,
struct event_loop *event_loop)
{
struct mgmt_be_client *client;
char server_path[MAXPATHLEN];

if (__be_client)
return NULL;
Expand All @@ -1071,7 +1072,10 @@ struct mgmt_be_client *mgmt_be_client_create(const char *client_name,
if (cbs)
client->cbs = *cbs;
mgmt_be_txns_init(&client->txn_head);
msg_client_init(&client->client, event_loop, MGMTD_BE_SERVER_PATH,

snprintf(server_path, sizeof(server_path), MGMTD_BE_SOCK_NAME);

msg_client_init(&client->client, event_loop, server_path,
mgmt_be_client_notify_conenct,
mgmt_be_client_notify_disconenct,
mgmt_be_client_process_msg, MGMTD_BE_MAX_NUM_MSG_PROC,
Expand Down
3 changes: 3 additions & 0 deletions lib/mgmt_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

#include "yang.h"

#define MGMTD_FE_SOCK_NAME "%s/mgmtd_fe.sock", frr_runstatedir
#define MGMTD_BE_SOCK_NAME "%s/mgmtd_be.sock", frr_runstatedir

#define MGMTD_CLIENT_NAME_MAX_LEN 32

#define MGMTD_MAX_XPATH_LEN XPATH_MAXLEN
Expand Down
5 changes: 4 additions & 1 deletion lib/mgmt_fe_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,7 @@ struct mgmt_fe_client *mgmt_fe_client_create(const char *client_name,
struct event_loop *event_loop)
{
struct mgmt_fe_client *client;
char server_path[MAXPATHLEN];

if (__fe_client)
return NULL;
Expand All @@ -726,7 +727,9 @@ struct mgmt_fe_client *mgmt_fe_client_create(const char *client_name,

mgmt_sessions_init(&client->sessions);

msg_client_init(&client->client, event_loop, MGMTD_FE_SERVER_PATH,
snprintf(server_path, sizeof(server_path), MGMTD_FE_SOCK_NAME);

msg_client_init(&client->client, event_loop, server_path,
mgmt_fe_client_notify_connect,
mgmt_fe_client_notify_disconnect,
mgmt_fe_client_process_msg, MGMTD_FE_MAX_NUM_MSG_PROC,
Expand Down
9 changes: 6 additions & 3 deletions mgmtd/mgmt_be_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,15 +706,18 @@ extern void mgmt_be_adapter_unlock(struct mgmt_be_client_adapter **adapter)
*/
void mgmt_be_adapter_init(struct event_loop *tm)
{
char server_path[MAXPATHLEN];

assert(!mgmt_loop);
mgmt_loop = tm;

mgmt_be_adapters_init(&mgmt_be_adapters);
mgmt_be_xpath_map_init();

if (msg_server_init(&mgmt_be_server, MGMTD_BE_SERVER_PATH, tm,
mgmt_be_create_adapter, "backend",
&mgmt_debug_be)) {
snprintf(server_path, sizeof(server_path), MGMTD_BE_SOCK_NAME);

if (msg_server_init(&mgmt_be_server, server_path, tm,
mgmt_be_create_adapter, "backend", &mgmt_debug_be)) {
zlog_err("cannot initialize backend server");
exit(1);
}
Expand Down
9 changes: 6 additions & 3 deletions mgmtd/mgmt_fe_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,8 @@ extern void mgmt_fe_adapter_unlock(struct mgmt_fe_client_adapter **adapter)
*/
void mgmt_fe_adapter_init(struct event_loop *tm)
{
char server_path[MAXPATHLEN];

assert(!mgmt_loop);
mgmt_loop = tm;

Expand All @@ -1319,9 +1321,10 @@ void mgmt_fe_adapter_init(struct event_loop *tm)
hash_create(mgmt_fe_session_hash_key, mgmt_fe_session_hash_cmp,
"MGMT Frontend Sessions");

if (msg_server_init(&mgmt_fe_server, MGMTD_FE_SERVER_PATH, tm,
mgmt_fe_create_adapter, "frontend",
&mgmt_debug_fe)) {
snprintf(server_path, sizeof(server_path), MGMTD_FE_SOCK_NAME);

if (msg_server_init(&mgmt_fe_server, server_path, tm,
mgmt_fe_create_adapter, "frontend", &mgmt_debug_fe)) {
zlog_err("cannot initialize frontend server");
exit(1);
}
Expand Down