diff options
| author | Mitesh Kanjariya <mitesh@cumulusnetworks.com> | 2017-08-28 18:19:03 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-28 18:19:03 -0700 |
| commit | 09fdc88c8cb0cd4169ae97b652d82f6a174a4041 (patch) | |
| tree | ce312038b12ce5128d375fa075c52ce30cf64207 /lib/hook.c | |
| parent | 6b3ee3a0b013e580abbce83ae46e4ed2bcf5f7a7 (diff) | |
| parent | 126ee21d2ed9451aefab869c482bb28c6b4f6085 (diff) | |
Merge branch 'master' into dev-master
Diffstat (limited to 'lib/hook.c')
| -rw-r--r-- | lib/hook.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/hook.c b/lib/hook.c index 2c877cbf45..1468c4d329 100644 --- a/lib/hook.c +++ b/lib/hook.c @@ -26,17 +26,25 @@ DEFINE_MTYPE_STATIC(LIB, HOOK_ENTRY, "Hook entry") void _hook_register(struct hook *hook, void *funcptr, void *arg, bool has_arg, - struct frrmod_runtime *module, const char *funcname) + struct frrmod_runtime *module, const char *funcname, + int priority) { - struct hookent *he = XCALLOC(MTYPE_HOOK_ENTRY, sizeof(*he)); + struct hookent *he = XCALLOC(MTYPE_HOOK_ENTRY, sizeof(*he)), **pos; he->hookfn = funcptr; he->hookarg = arg; he->has_arg = has_arg; he->module = module; he->fnname = funcname; + he->priority = priority; - he->next = hook->entries; - hook->entries = he; + for (pos = &hook->entries; *pos; pos = &(*pos)->next) + if (hook->reverse + ? (*pos)->priority < priority + : (*pos)->priority >= priority) + break; + + he->next = *pos; + *pos = he; } void _hook_unregister(struct hook *hook, void *funcptr, void *arg, bool has_arg) |
