summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2016-10-30 22:50:26 +0100
committerRenato Westphal <renato@opensourcerouting.org>2016-11-28 19:18:35 +0100
commit661512bf053ecc3d441bb8938dcd4541ae7ffc33 (patch)
tree01233125543e939ed1e5bd23c050509755c5db50 /lib
parentlib/zebra: put vrf_get() on a diet (diff)
downloadfrr-661512bf053ecc3d441bb8938dcd4541ae7ffc33.tar.xz
frr-661512bf053ecc3d441bb8938dcd4541ae7ffc33.zip
zebra/lib: remove redundant fields from zebra_vrf
There's no need to duplicate the 'vrf_id' and 'name' fields from the 'vrf' structure into the 'zebra_vrf' structure. Instead of that, add a back pointer in 'zebra_vrf' that should point to the associated 'vrf' structure. Additionally, modify the vrf callbacks to pass the whole vrf structure as a parameter. This allow us to make further simplifications in the code. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/vrf.c18
-rw-r--r--lib/vrf.h2
2 files changed, 10 insertions, 10 deletions
diff --git a/lib/vrf.c b/lib/vrf.c
index aa1bfeeab..39d8a89a7 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -53,10 +53,10 @@ int debug_vrf = 0;
/* Holding VRF hooks */
struct vrf_master
{
- int (*vrf_new_hook) (vrf_id_t, const char *, void **);
- int (*vrf_delete_hook) (vrf_id_t, const char *, void **);
- int (*vrf_enable_hook) (vrf_id_t, const char *, void **);
- int (*vrf_disable_hook) (vrf_id_t, const char *, void **);
+ int (*vrf_new_hook) (struct vrf *);
+ int (*vrf_delete_hook) (struct vrf *);
+ int (*vrf_enable_hook) (struct vrf *);
+ int (*vrf_disable_hook) (struct vrf *);
} vrf_master = {0,};
static int vrf_is_enabled (struct vrf *vrf);
@@ -143,7 +143,7 @@ vrf_get (vrf_id_t vrf_id, const char *name)
}
if (new && vrf_master.vrf_new_hook)
- (*vrf_master.vrf_new_hook) (vrf_id, name, &vrf->info);
+ (*vrf_master.vrf_new_hook) (vrf);
return vrf;
}
@@ -159,7 +159,7 @@ vrf_delete (struct vrf *vrf)
vrf_disable (vrf);
if (vrf_master.vrf_delete_hook)
- (*vrf_master.vrf_delete_hook) (vrf->vrf_id, vrf->name, &vrf->info);
+ (*vrf_master.vrf_delete_hook) (vrf);
QOBJ_UNREG (vrf);
if_terminate (&vrf->iflist);
@@ -209,7 +209,7 @@ vrf_enable (struct vrf *vrf)
SET_FLAG (vrf->status, VRF_ACTIVE);
if (vrf_master.vrf_enable_hook)
- (*vrf_master.vrf_enable_hook) (vrf->vrf_id, vrf->name, &vrf->info);
+ (*vrf_master.vrf_enable_hook) (vrf);
return 1;
}
@@ -234,13 +234,13 @@ vrf_disable (struct vrf *vrf)
//Pending: see why this statement.
if (vrf_master.vrf_disable_hook)
- (*vrf_master.vrf_disable_hook) (vrf->vrf_id, vrf->name, &vrf->info);
+ (*vrf_master.vrf_disable_hook) (vrf);
}
/* Add a VRF hook. Please add hooks before calling vrf_init(). */
void
-vrf_add_hook (int type, int (*func)(vrf_id_t, const char *, void **))
+vrf_add_hook (int type, int (*func)(struct vrf *))
{
if (debug_vrf)
zlog_debug ("%s: Add Hook %d to function %p", __PRETTY_FUNCTION__,
diff --git a/lib/vrf.h b/lib/vrf.h
index feaf76896..c9e81bf66 100644
--- a/lib/vrf.h
+++ b/lib/vrf.h
@@ -108,7 +108,7 @@ extern struct vrf_name_head vrfs_by_name;
* - param 2: the address of the user data pointer (the user data
* can be stored in or freed from there)
*/
-extern void vrf_add_hook (int, int (*)(vrf_id_t, const char *, void **));
+extern void vrf_add_hook (int, int (*)(struct vrf *));
extern struct vrf *vrf_lookup_by_id (vrf_id_t);
extern struct vrf *vrf_lookup_by_name (const char *);