AC_DEFINE_UNQUOTED([OSPFD_GR_STATE], ["$CFG_STATE%s/ospfd-gr.json"], [ospfd GR state information])
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])
AC_DEFINE_UNQUOTED([DAEMON_DB_DIR], ["$CFG_STATE"], [daemon database directory])
#define ISISD_VTY_PORT 2608
#define FABRICD_VTY_PORT 2618
+#define FABRICD_STATE_NAME "%s/fabricd.json", frr_libstatedir
+#define ISISD_STATE_NAME "%s/isisd.json", frr_libstatedir
+
+/* The typo was there before. Do not fix it! The point is to load mis-saved
+ * state files from older versions.
+ *
+ * Also fabricd was using the same file. Sigh.
+ */
+#define ISISD_COMPAT_STATE_NAME "%s/isid-restart.json", frr_runstatedir
+
/* isisd privileges */
zebra_capabilities_t _caps_p[] = {ZCAP_NET_RAW, ZCAP_BIND, ZCAP_SYS_ADMIN};
isis_config_finish(t_isis_cfg);
}
+/* actual paths filled in main() */
+static char state_path[512];
+static char state_compat_path[512];
+static char *state_paths[] = {
+ state_path,
+ state_compat_path,
+ NULL,
+};
+
/* clang-format off */
FRR_DAEMON_INFO(
#ifdef FABRICD
.yang_modules = isisd_yang_modules,
.n_yang_modules = array_size(isisd_yang_modules),
+
+ .state_paths = state_paths,
);
/* clang-format on */
}
}
+#ifdef FABRICD
+ snprintf(state_path, sizeof(state_path), FABRICD_STATE_NAME);
+#else
+ snprintf(state_path, sizeof(state_path), ISISD_STATE_NAME);
+#endif
+ snprintf(state_compat_path, sizeof(state_compat_path),
+ ISISD_COMPAT_STATE_NAME);
+
/* thread master */
isis_master_init(frr_init());
master = im->master;
}
}
-/*
- * Returns the path of the file (non-volatile memory) that contains restart
- * information.
- */
-char *isis_restart_filepath(void)
-{
- static char filepath[MAXPATHLEN];
- snprintf(filepath, sizeof(filepath), ISISD_RESTART, "");
- return filepath;
-}
-
/*
* Record in non-volatile memory the overload on startup time.
*/
void isis_restart_write_overload_time(struct isis_area *isis_area,
uint32_t overload_time)
{
- char *filepath;
const char *area_name;
json_object *json;
json_object *json_areas;
json_object *json_area;
- filepath = isis_restart_filepath();
+ json = frr_daemon_state_load();
area_name = isis_area->area_tag;
- json = json_object_from_file(filepath);
- if (json == NULL)
- json = json_object_new_object();
-
json_object_object_get_ex(json, "areas", &json_areas);
if (!json_areas) {
json_areas = json_object_new_object();
json_object_int_add(json_area, "overload_time",
isis_area->overload_on_startup_time);
- json_object_to_file_ext(filepath, json, JSON_C_TO_STRING_PRETTY);
- json_object_free(json);
+
+ frr_daemon_state_save(&json);
}
/*
*/
uint32_t isis_restart_read_overload_time(struct isis_area *isis_area)
{
- char *filepath;
const char *area_name;
json_object *json;
json_object *json_areas;
json_object *json_overload_time;
uint32_t overload_time = 0;
- filepath = isis_restart_filepath();
area_name = isis_area->area_tag;
- json = json_object_from_file(filepath);
- if (json == NULL)
- json = json_object_new_object();
+ json = frr_daemon_state_load();
json_object_object_get_ex(json, "areas", &json_areas);
if (!json_areas) {
json_object_object_del(json_areas, area_name);
- json_object_to_file_ext(filepath, json, JSON_C_TO_STRING_PRETTY);
- json_object_free(json);
+ frr_daemon_state_save(&json);
return overload_time;
}