146#define CFG_FL_TARGET bit0
147#define CFG_FL_DIRTY bit1
148#define CFG_FL_FORCE_DEADNODES bit2
149#define CFG_FL_FORCE_TOP_DEFAULTS bit3
150#define CFG_FL_EXTERN_NVSTORE bit4
152#define CFG_INITIAL_TXID (ncx_transaction_id_t)0
155#define CFG_NUM_STATIC 3
157#define CFG_GET_FORCE_DEADNODES(C) ((C)->flags & CFG_FL_FORCE_DEADNODES)
159#define CFG_SET_FORCE_DEADNODES(C) (C)->flags |= CFG_FL_FORCE_DEADNODES
161#define CFG_GET_FORCE_TOP_DEFAULTS(C) ((C)->flags & CFG_FL_FORCE_TOP_DEFAULTS)
163#define CFG_SET_FORCE_TOP_DEFAULTS(C) (C)->flags |= CFG_FL_FORCE_TOP_DEFAULTS
166#define CFG_SET_EXTERN_NVSTORE(C) (C)->flags |= CFG_FL_EXTERN_NVSTORE
168#define CFG_IS_EXTERN_NVSTORE(C) ((C)->flags & CFG_FL_EXTERN_NVSTORE)
175#define CFG_RWLOCK_READ_ACCESS FALSE
176#define CFG_RWLOCK_WRITE_ACCESS TRUE
177#define READ_ACCESS CFG_RWLOCK_READ_ACCESS
178#define WRITE_ACCESS CFG_RWLOCK_WRITE_ACCESS
180#define CFG_GET_ROOT(C) ((C)->root)
182#define CFG_GET_ID(C) ((C)->cfg_id)
184#define CFG_IN_CC_ROLLBACK(C) (C)->in_cc_rollback
186#define CFG_DEFER_LOAD(C) ((C)->defer_load)
198typedef enum cfg_state_t_ {
209typedef enum cfg_source_t_ {
221typedef enum cfg_location_t_ {
229typedef struct cfg_template_t_ {
356extern boolean wrlock_pending;
596extern const xmlChar *
802 const xmlChar **locktime);
887 boolean skip_reload);
973extern const xmlChar *
1131extern const xmlChar *
dlq provides general double-linked list and queue support:
boolean cfg_candidate_is_wrlocked(void)
Check if the candidate datastore is currently pthreads write-locked.
Definition: cfg.c:3469
void cfg_set_defer_load(boolean val)
Set the config defer load flag to the config.
Definition: cfg.c:3619
void cfg_update_stamps(cfg_template_t *source, cfg_template_t *dest)
Update the last-modified and last-txid stamps.
Definition: cfg.c:2967
const xmlChar * cfg_get_startup_filespec(void)
Get the filespec string for the XML file to save the running database.
Definition: cfg.c:3428
cfg_template_t * cfg_new_template(const xmlChar *name, ncx_cfg_t cfg_id)
Malloc and initialize a cfg_template_t struct.
Definition: cfg.c:1336
status_t cfg_ok_to_unlock2(const cfg_template_t *cfg, ses_id_t sesid, boolean lockall)
Check if the specified config can be unlocked right now by the specified session ID; for global lock ...
Definition: cfg.c:2166
status_t cfg_get_global_lock_info(const cfg_template_t *cfg, ses_id_t *sesid, const xmlChar **locktime)
Get the current global lock info.
Definition: cfg.c:2476
cfg_template_t * cfg_get_config(const xmlChar *cfgname)
Get the config struct from its name.
Definition: cfg.c:1452
boolean cfg_is_partial_locked(const cfg_template_t *cfg)
Check if the specified config has any active partial locks.
Definition: cfg.c:2443
status_t cfg_fill_candidate_from_running(ses_id_t sesid)
Fill the <candidate> config with the config contents of the <running> config.
Definition: cfg.c:1562
status_t cfg_add_partial_lock(cfg_template_t *cfg, plock_cb_t *plcb)
Add a partial lock the specified config.
Definition: cfg.c:3118
status_t cfg_lock2(cfg_template_t *cfg, ses_id_t locked_by, cfg_source_t lock_src, boolean lockall)
Lock the specified config (with lockall)
Definition: cfg.c:2549
void cfg_cleanup(void)
Cleanup the config manager.
Definition: cfg.c:1250
status_t cfg_rwlock_acquire_lock_pair(thd_tcb_t *tcb, cfg_template_t *cfg1, boolean wrlock1, cfg_template_t *cfg2, boolean wrlock2)
Acquire multiple (2) locks in predetermined, repeatable in order to help prevent deadlock.
Definition: cfg.c:829
status_t cfg_setup_running(void)
Setup the running config root if load_running_config did not add anything.
Definition: cfg.c:3371
cfg_location_t
classify the config location
Definition: cfg.h:221
void cfg_ypinit(void)
Initialize the config manager.
Definition: cfg.c:1196
void cfg_release_partial_locks(ses_id_t sesid)
Release any configuration locks held by the specified session.
Definition: cfg.c:2778
status_t cfg_rwlock_acquire_single_wrlock(thd_tcb_t *tcb, cfg_template_t *cfg)
Acquire a single RWLOCK for write access.
Definition: cfg.c:963
void cfg_set_dirty_flag(cfg_template_t *cfg)
Mark the config as 'changed'.
Definition: cfg.c:1967
plock_cb_t * cfg_find_partial_lock(cfg_template_t *cfg, plock_id_t lockid)
Find a partial lock in the specified config.
Definition: cfg.c:3153
status_t cfg_unlock2(cfg_template_t *cfg, ses_id_t locked_by, boolean lockall)
Unlock the specified config (2nd rev)
Definition: cfg.c:2671
status_t cfg_ok_to_unlock(const cfg_template_t *cfg, ses_id_t sesid)
Check if the specified config can be unlocked right now by the specified session ID; for global lock ...
Definition: cfg.c:2146
cfg_state_t
current configuration state
Definition: cfg.h:198
boolean cfg_running_is_wrlocked(void)
Check if the running datastore is currently pthreads write-locked.
Definition: cfg.c:3449
plock_cb_t * cfg_first_partial_lock(cfg_template_t *cfg)
Get the first partial lock in the specified config.
Definition: cfg.c:3189
void cfg_clear_running_dirty_flag(void)
Clear the running dirty flag when it is saved to NV-storage or loaded into running from startup.
Definition: cfg.c:2010
status_t cfg_rwlock_wrlock(thd_tcb_t *tcb, cfg_template_t *cfg)
Take out a write lock associated with a cfg (datastore) RWLOCK structure.
Definition: cfg.c:368
time_t cfg_get_lock_itime(ncx_cfg_t cfg_id)
Get the lock_itime field.
Definition: cfg.c:3556
boolean cfg_get_dirty_flag(const cfg_template_t *cfg)
Get the config dirty flag value.
Definition: cfg.c:2052
void cfg_clear_candidate_dirty_flag(void)
Clear the candidate dirty flag when it is saved to NV-storage or loaded into running from startup.
Definition: cfg.c:2030
status_t cfg_fill_candidate_from_startup(ses_id_t sesid)
Fill the <candidate> config with the config contents of the <startup> config.
Definition: cfg.c:1740
status_t cfg_ok_to_partial_lock(const cfg_template_t *cfg)
Check if the specified config can be locked right now for partial lock only.
Definition: cfg.c:3289
status_t cfg_rwlock_init_req_locks(thd_tcb_t *tcb)
Initialize TCB multiple lock structure.
Definition: cfg.c:627
void cfg_clean_roots(void)
Cleanup the cfg->root nodes before all the objects are freed.
Definition: cfg.c:1224
status_t cfg_lock(cfg_template_t *cfg, ses_id_t locked_by, cfg_source_t lock_src)
Lock the specified config.
Definition: cfg.c:2522
status_t cfg_ok_to_lock(const cfg_template_t *cfg)
Check if the specified config can be locked right now for global lock only.
Definition: cfg.c:2081
void cfg_free_template(cfg_template_t *cfg)
Clean and free the cfg_template_t struct.
Definition: cfg.c:1375
status_t cfg_ok_to_read(const cfg_template_t *cfg)
Check if the specified config can be read right now.
Definition: cfg.c:2231
const xmlChar * cfg_get_last_ch_time(cfg_template_t *cfg)
Get the last-modified timestamp.
Definition: cfg.c:2992
const xmlChar * cfg_get_config_name(ncx_cfg_t cfgid)
Get the config name from its ID.
Definition: cfg.c:1475
status_t cfg_rwlock_acquire_locks(thd_tcb_t *tcb)
Acquire multiple locks in order to help prevent deadlock.
Definition: cfg.c:705
void cfg_get_lock_list(ses_id_t sesid, val_value_t *retval)
Get a list of all the locks held by a session.
Definition: cfg.c:2832
status_t cfg_ok_to_write(const cfg_template_t *cfg, ses_id_t sesid)
Check if the specified config can be written right now by the specified session ID.
Definition: cfg.c:2289
void cfg_delete_partial_lock(cfg_template_t *cfg, plock_id_t lockid)
Remove a partial lock from the specified config.
Definition: cfg.c:3238
void cfg_release_locks(ses_id_t sesid)
Release any configuration locks held by the specified session.
Definition: cfg.c:2720
status_t cfg_init_static_db(ncx_cfg_t cfg_id)
Initialize the specified static configuration slot.
Definition: cfg.c:1280
cfg_template_t * cfg_get_config_id(ncx_cfg_t cfgid)
Get the config struct from its ID.
Definition: cfg.c:1512
void cfg_register_reload_candidate_cb(cfg_reload_candidate_cb_t cbfn)
Register a callback function to be called anytime the.
Definition: cfg.c:3413
void cfg_set_state(ncx_cfg_t cfg_id, cfg_state_t new_state)
Change the state of the specified static config.
Definition: cfg.c:1398
status_t cfg_rwlock_release_all_locks(thd_tcb_t *tcb)
Release all RWLOCKs recorded in TCB lock state structure.
Definition: cfg.c:662
status_t cfg_rwlock_acquire_single_rdlock(thd_tcb_t *tcb, cfg_template_t *cfg)
Acquire a single RWLOCK for read access.
Definition: cfg.c:942
ncx_transaction_id_t cfg_get_last_txid(cfg_template_t *cfg)
Get the last good transaction ID.
Definition: cfg.c:3014
status_t cfg_lock_hold_timeout(ncx_cfg_t cfg_id)
Force a cfg lock to be undone due to max-lock-hold-time.
Definition: cfg.c:3583
cfg_state_t cfg_get_state(ncx_cfg_t cfg_id)
Get the state of the specified static config.
Definition: cfg.c:1426
void cfg_update_last_ch_time(cfg_template_t *cfg, time_t *timestamp)
Update the last-modified timestamp.
Definition: cfg.c:2913
void cfg_update_last_txid(cfg_template_t *cfg, ncx_transaction_id_t txid)
Update the last good transaction ID.
Definition: cfg.c:2946
status_t cfg_rwlock_acquire_single_lock(thd_tcb_t *tcb, cfg_template_t *cfg, boolean wrlock)
Acquire a single RWLOCK.
Definition: cfg.c:870
void(* cfg_reload_candidate_cb_t)(void)
support for server callback anytime the candidate config is reloaded from the running config <discard...
Definition: cfg.h:345
status_t cfg_unlock(cfg_template_t *cfg, ses_id_t locked_by)
Unlock the specified config.
Definition: cfg.c:2649
status_t cfg_fill_candidate_from_inline(ses_id_t sesid, val_value_t *newroot)
Fill the <candidate> config with the config contents of the <config> inline XML node.
Definition: cfg.c:1882
void cfg_apply_load_root(cfg_template_t *cfg, val_value_t *newroot)
Apply the AGT_CB_APPLY function for the OP_EDITOP_LOAD operation.
Definition: cfg.c:2880
plock_cb_t * cfg_next_partial_lock(plock_cb_t *curplockcb)
Get the next partial lock in the specified config.
Definition: cfg.c:3214
void cfg_clear_dirty_flag(cfg_template_t *cfg)
Clear the cfg dirty flag upon request.
Definition: cfg.c:1991
void cfg_set_target(ncx_cfg_t cfg_id)
Set the CFG_FL_TARGET flag in the specified config.
Definition: cfg.c:1533
cfg_source_t
classify the config source
Definition: cfg.h:209
status_t cfg_rwlock_rdlock(thd_tcb_t *tcb, cfg_template_t *cfg)
Take out the read lock associated with a cfg (datastore) RWLOCK structure May be called recursively.
Definition: cfg.c:251
val_value_t * cfg_get_root(ncx_cfg_t cfgid)
Get the config root for the specified config.
Definition: cfg.c:3346
status_t cfg_sprintf_etag(cfg_template_t *cfg, xmlChar *buff, int32 buffsize)
Write the Entity Tag for the datastore to the specified buffer.
Definition: cfg.c:3040
boolean cfg_is_global_locked(const cfg_template_t *cfg)
Check if the specified config has ab active global lock.
Definition: cfg.c:2415
status_t cfg_rwlock_unlock(thd_tcb_t *tcb, cfg_template_t *cfg)
Release a lock associated with a cfg (datastore) RWLOCK structure.
Definition: cfg.c:526
cfg_template_t * cfg_new_fake_candidate(const xmlChar *name, ncx_cfg_t cfg_id)
Malloc and initialize a new fake Candidate cfg_template_t struct.
Definition: cfg.c:3497
status_t cfg_unlock_ex(cfg_template_t *cfg, ses_id_t locked_by, boolean skip_reload)
Unlock the specified config.
Definition: cfg.c:2698
status_t cfg_sprintf_etag_id(ncx_transaction_id_t id, xmlChar *buff, int32 buffsize)
Write the Entity Tag for the datastore to the specified buffer Use the last_id instead of the cfg tem...
Definition: cfg.c:3068
@ CFG_ST_INIT
init in progress
Definition: cfg.h:200
@ CFG_ST_NONE
not set
Definition: cfg.h:199
@ CFG_ST_CLEANUP
cleanup in progress
Definition: cfg.h:204
@ CFG_ST_PLOCK
partial lock active
Definition: cfg.h:202
@ CFG_ST_READY
ready and no locks
Definition: cfg.h:201
@ CFG_ST_FLOCK
full lock active
Definition: cfg.h:203
uint32 plock_id_t
matches lock-id-type in YANG module
Definition: plock_cb.h:78
status_t
global error return code
Definition: status_enum.h:210
uint32 ses_id_t
Session ID.
Definition: ses.h:335
#define TSTAMP_MIN_SIZE
normal minimum buffer size for a tstamp buffer
Definition: tstamp.h:71
ncx_cfg_t
hardwire the 3 standard configs
Definition: ncxtypes.h:548
uint64 ncx_transaction_id_t
transaction is scoped to single session write operation on a config
Definition: ncxtypes.h:728
YANG module utility functions.
RFC 57517 partial lock support.
NETCONF Session Common definitions module.
Global error messages for status code enumerations.
struct representing 1 configuration database
Definition: cfg.h:229
boolean defer_load
TRUE if load is deferred due to sil-sa bundles.
Definition: cfg.h:337
boolean fake_candidate
TRUE if this is YANG-PATCH request fake candidate template.
Definition: cfg.h:327
xmlChar * name
datastore name string
Definition: cfg.h:251
boolean rw_wrlocked
PTHREADS=1 only: TRUE if currently write-locked.
Definition: cfg.h:313
cfg_location_t cfg_loc
config location: Enumeration identifying the configuration source location.
Definition: cfg.h:236
boolean locked_by_lockall
Flag indicating the global lock is from lock-all not lock.
Definition: cfg.h:276
pthread_rwlock_t rwlock
PTHREADS=1 only: rwlock data.
Definition: cfg.h:301
ses_id_t rw_wrlocked_by
PTHREADS=1 only: Single write lock holder, if any.
Definition: cfg.h:304
boolean rwlock_initialized
RWLOCK for this config - used by multiple reader/writer threads according to RWLOCK rules: basically,...
Definition: cfg.h:298
boolean wrlock_pending
TRUE if the wrlock is active and set.
Definition: cfg.h:319
ses_id_t locked_by
Session ID that owns the global configuration lock, if the database is currently locked.
Definition: cfg.h:273
dlq_hdr_t load_errQ
Queue of rpc_err_rec_t structures that represent any <rpc-error> records that were generated when the...
Definition: cfg.h:288
ncx_transaction_id_t cur_txid
current edit transaction ID
Definition: cfg.h:245
time_t lock_itime
time_t timestamp for max-lock-hold-time enforcement
Definition: cfg.h:259
xmlChar * src_url
source URL: URL for use with 'cfg_loc' to identify the configuration source.
Definition: cfg.h:256
uint32 flags
Internal configuration flags.
Definition: cfg.h:268
ses_id_t rw_rdlocked_by
Most recent read lock holder only, used for debugging if the background thread locks the cfg for fill...
Definition: cfg.h:310
boolean rw_rdlocked
PTHREADS=1 only: TRUE if currently read-locked.
Definition: cfg.h:316
ncx_transaction_id_t last_txid
last edit transaction ID
Definition: cfg.h:242
cfg_state_t cfg_state
config state: Current internal configuration state.
Definition: cfg.h:239
boolean in_cc_rollback
YPW-2036: flag to allow rollback transaction to indicate if the transaction is due to a confirmed-com...
Definition: cfg.h:334
ncx_cfg_t cfg_id
config ID: Internal configuration ID assigned to this configuration.
Definition: cfg.h:231
time_t last_modified
last modified timestamp
Definition: cfg.h:248
val_value_t * root
datastore root value.
Definition: cfg.h:324
struct representing 1 configuration database
Definition: plock_cb.h:81
Thread control block (TCB)
Definition: thd.h:175
one value to match one type
Definition: val.h:912
Thread support (for now limited to netconfd)
Value Node Basic Support.