mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-09 23:34:41 +01:00
Store session backup to persistent storage
This commit is contained in:
parent
5c94fa6b1a
commit
384c929c51
5 changed files with 29 additions and 2 deletions
|
|
@ -233,6 +233,19 @@ All backup session indexes are successive in the enumeration and starts with `BK
|
|||
|
||||
For each kind of backup session data, there are insert functions that call `build_xml_node_data` and load functions that calls `load_xml_node_data`.
|
||||
|
||||
### NOTE:
|
||||
This backup session feature has been limited to soft reboot and system upgrade, thus in case of power cycle or hard reboot, icwmp can not store the
|
||||
data in `/etc/icwmpd/icwmpd_backkup_session.xml`. Due to this limitation there is a chance that icwmp may send wrong event or not send an expected
|
||||
event in the first inform message after power up. For e.g: icwmp after power cycle may send `0 BOOTSTRAP` event even though it connects the same ACS.
|
||||
|
||||
So, to avoid this problem a compile time flag `PERSIST_BACKUP_SESSION_EVENTS` has been added, by enabling this flag icwmp will store the backup session
|
||||
information in flash (persistent storage) drive at every successful session end and after boot up icwmp loads the session information from flash drive
|
||||
if there exist any.
|
||||
|
||||
#### Precaution:
|
||||
This feature will increase the flash write operation, so user need to reconsider about enabling this flag. If flash has less write limit then it is
|
||||
better to disable this feature because after exceeding the write limit, flash could be corrupted.
|
||||
|
||||
## UCI and config mangement
|
||||
|
||||
- [UCI](./docs/api/uci/cwmp.md)
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ void bkp_session_save()
|
|||
fp = fopen(CWMP_BKP_FILE, "w");
|
||||
mxmlSaveFile(bkp_tree, fp, MXML_NO_CALLBACK);
|
||||
fclose(fp);
|
||||
sync();
|
||||
}
|
||||
|
||||
void bkp_session_create_file()
|
||||
|
|
|
|||
|
|
@ -23,6 +23,11 @@
|
|||
|
||||
#define CWMP_BACKUP_SESSION "<cwmp></cwmp>"
|
||||
#define CWMP_BKP_FILE "/var/run/icwmpd/icwmpd_backup_session.xml"
|
||||
|
||||
#ifdef PERSIST_BACKUP_SESSION_EVENTS
|
||||
#define CWMP_BKP_FILE_PERSISTENT "/etc/icwmpd/icwmpd_backup_session.xml"
|
||||
#endif
|
||||
|
||||
typedef enum backup_loading
|
||||
{
|
||||
ALL,
|
||||
|
|
|
|||
|
|
@ -469,7 +469,7 @@ int copy(const char *from, const char *to)
|
|||
if (fd_from < 0)
|
||||
return -1;
|
||||
|
||||
fd_to = open(to, O_WRONLY | O_CREAT | O_EXCL, 0666);
|
||||
fd_to = open(to, O_WRONLY | O_CREAT | O_EXCL | O_SYNC, 0666);
|
||||
if (fd_to < 0)
|
||||
goto out_error;
|
||||
|
||||
|
|
|
|||
|
|
@ -411,6 +411,16 @@ void start_cwmp_session(void)
|
|||
|
||||
cwmp_ctx.retry_count_session = 0;
|
||||
set_cwmp_session_status(SESSION_SUCCESS, 0);
|
||||
|
||||
#ifdef PERSIST_BACKUP_SESSION_EVENTS
|
||||
// session ended successfully so store next session events in persistent
|
||||
// storage to avoid loss of events over power cycle
|
||||
if (file_exists(CWMP_BKP_FILE)) {
|
||||
CWMP_LOG(DEBUG, "Copied events backup file to persistent storage");
|
||||
copy(CWMP_BKP_FILE, CWMP_BKP_FILE_PERSISTENT);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (cwmp_ctx.throttle_session_triggered == true) {
|
||||
cwmp_ctx.throttle_session_triggered = false;
|
||||
if (!cwmp_ctx.throttle_session) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue