summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2018-05-29 11:17:10 +0200
committerPhilippe Guibert <philippe.guibert@6wind.com>2018-08-28 16:23:50 +0200
commitecbc5a37815987aebabae835366b1f2ea18fb3b2 (patch)
treef8badb4b6d2f02c2a5f6c9120a17c8a1741fd167
parentlib: autocomple vrf list authorises default vrf name (diff)
downloadfrr-ecbc5a37815987aebabae835366b1f2ea18fb3b2.tar.xz
frr-ecbc5a37815987aebabae835366b1f2ea18fb3b2.zip
*: add a vrf update hook to be informed of the vrf name
The Vrf aliases can be known with a specific hook. That hook will then, from zebra propagate the information to the relevant zapi clients. The registration hook function is the same for all daemons. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
-rw-r--r--bgpd/bgp_main.c3
-rw-r--r--eigrpd/eigrp_main.c2
-rw-r--r--isisd/isis_main.c2
-rw-r--r--ldpd/ldpd.c2
-rw-r--r--lib/vrf.c7
-rw-r--r--lib/vrf.h6
-rw-r--r--nhrpd/nhrp_main.c2
-rw-r--r--ospf6d/ospf6_main.c2
-rw-r--r--ospfd/ospfd.c2
-rw-r--r--pbrd/pbr_main.c2
-rw-r--r--pimd/pim_instance.c3
-rw-r--r--ripd/rip_main.c2
-rw-r--r--ripngd/ripng_main.c2
-rw-r--r--sharpd/sharp_main.c2
-rw-r--r--staticd/static_vrf.c2
-rw-r--r--tests/bgpd/test_capability.c2
-rw-r--r--tests/bgpd/test_mp_attr.c2
-rw-r--r--tests/bgpd/test_mpath.c2
-rw-r--r--tests/bgpd/test_packet.c2
-rw-r--r--tests/bgpd/test_peer_attr.c2
-rw-r--r--zebra/zebra_vrf.c15
21 files changed, 44 insertions, 22 deletions
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index 138788194..2308a32a2 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -332,7 +332,8 @@ static int bgp_vrf_disable(struct vrf *vrf)
static void bgp_vrf_init(void)
{
- vrf_init(bgp_vrf_new, bgp_vrf_enable, bgp_vrf_disable, bgp_vrf_delete);
+ vrf_init(bgp_vrf_new, bgp_vrf_enable, bgp_vrf_disable,
+ bgp_vrf_delete, NULL);
}
static void bgp_vrf_terminate(void)
diff --git a/eigrpd/eigrp_main.c b/eigrpd/eigrp_main.c
index 31101a52d..9e9c4649f 100644
--- a/eigrpd/eigrp_main.c
+++ b/eigrpd/eigrp_main.c
@@ -170,7 +170,7 @@ int main(int argc, char **argv, char **envp)
master = eigrp_om->master;
eigrp_error_init();
- vrf_init(NULL, NULL, NULL, NULL);
+ vrf_init(NULL, NULL, NULL, NULL, NULL);
/*EIGRPd init*/
eigrp_if_init();
diff --git a/isisd/isis_main.c b/isisd/isis_main.c
index 5b18ab0a2..3b4168adb 100644
--- a/isisd/isis_main.c
+++ b/isisd/isis_main.c
@@ -192,7 +192,7 @@ int main(int argc, char **argv, char **envp)
*/
isis_error_init();
access_list_init();
- vrf_init(NULL, NULL, NULL, NULL);
+ vrf_init(NULL, NULL, NULL, NULL, NULL);
prefix_list_init();
isis_init();
isis_circuit_init();
diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c
index e830263de..935e95959 100644
--- a/ldpd/ldpd.c
+++ b/ldpd/ldpd.c
@@ -330,7 +330,7 @@ main(int argc, char *argv[])
master = frr_init();
vty_config_lockless();
- vrf_init(NULL, NULL, NULL, NULL);
+ vrf_init(NULL, NULL, NULL, NULL, NULL);
access_list_init();
ldp_vty_init();
ldp_zebra_init(master);
diff --git a/lib/vrf.c b/lib/vrf.c
index b7c5e5e9a..0bb6a65bf 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -71,6 +71,7 @@ struct vrf_master {
int (*vrf_delete_hook)(struct vrf *);
int (*vrf_enable_hook)(struct vrf *);
int (*vrf_disable_hook)(struct vrf *);
+ int (*vrf_update_name_hook)(struct vrf *vrf);
} vrf_master = {
0,
};
@@ -461,7 +462,8 @@ static const struct cmd_variable_handler vrf_var_handlers[] = {
/* Initialize VRF module. */
void vrf_init(int (*create)(struct vrf *), int (*enable)(struct vrf *),
- int (*disable)(struct vrf *), int (*delete)(struct vrf *))
+ int (*disable)(struct vrf *), int (*delete)(struct vrf *),
+ int ((*update)(struct vrf *)))
{
struct vrf *default_vrf;
@@ -475,6 +477,7 @@ void vrf_init(int (*create)(struct vrf *), int (*enable)(struct vrf *),
vrf_master.vrf_enable_hook = enable;
vrf_master.vrf_disable_hook = disable;
vrf_master.vrf_delete_hook = delete;
+ vrf_master.vrf_update_name_hook = update;
/* The default VRF always exists. */
default_vrf = vrf_get(VRF_DEFAULT, VRF_DEFAULT_NAME);
@@ -897,6 +900,8 @@ void vrf_set_default_name(const char *default_name)
vrf_default_name, NS_NAMSIZ);
strlcpy(def_vrf->name, vrf_default_name, sizeof(def_vrf->name));
RB_INSERT(vrf_name_head, &vrfs_by_name, def_vrf);
+ if (vrf_master.vrf_update_name_hook)
+ (*vrf_master.vrf_update_name_hook)(def_vrf);
}
}
diff --git a/lib/vrf.h b/lib/vrf.h
index 7fb3f7ec8..c962ac4c6 100644
--- a/lib/vrf.h
+++ b/lib/vrf.h
@@ -199,8 +199,10 @@ extern int vrf_bitmap_check(vrf_bitmap_t, vrf_id_t);
* delete -> Called back when a vrf is being deleted from
* the system ( 2 and 3 ) above.
*/
-extern void vrf_init(int (*create)(struct vrf *), int (*enable)(struct vrf *),
- int (*disable)(struct vrf *), int (*delete)(struct vrf *));
+extern void vrf_init(int (*create)(struct vrf *vrf), int (*enable)(struct vrf *vrf),
+ int (*disable)(struct vrf *vrf), int (*delete)(struct vrf *vrf),
+ int ((*update)(struct vrf *vrf)));
+
/*
* Call vrf_terminate when the protocol is being shutdown
*/
diff --git a/nhrpd/nhrp_main.c b/nhrpd/nhrp_main.c
index e9f44e855..737e70103 100644
--- a/nhrpd/nhrp_main.c
+++ b/nhrpd/nhrp_main.c
@@ -130,7 +130,7 @@ int main(int argc, char **argv)
/* Library inits. */
master = frr_init();
nhrp_error_init();
- vrf_init(NULL, NULL, NULL, NULL);
+ vrf_init(NULL, NULL, NULL, NULL, NULL);
nhrp_interface_init();
resolver_init();
diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c
index 9580d87cf..eadc856ca 100644
--- a/ospf6d/ospf6_main.c
+++ b/ospf6d/ospf6_main.c
@@ -208,7 +208,7 @@ int main(int argc, char *argv[], char *envp[])
/* thread master */
master = frr_init();
- vrf_init(NULL, NULL, NULL, NULL);
+ vrf_init(NULL, NULL, NULL, NULL, NULL);
access_list_init();
prefix_list_init();
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c
index bfaedf2fe..62de94a47 100644
--- a/ospfd/ospfd.c
+++ b/ospfd/ospfd.c
@@ -2149,7 +2149,7 @@ static int ospf_vrf_disable(struct vrf *vrf)
void ospf_vrf_init(void)
{
vrf_init(ospf_vrf_new, ospf_vrf_enable, ospf_vrf_disable,
- ospf_vrf_delete);
+ ospf_vrf_delete, NULL);
}
void ospf_vrf_terminate(void)
diff --git a/pbrd/pbr_main.c b/pbrd/pbr_main.c
index ba0962108..f555ccc05 100644
--- a/pbrd/pbr_main.c
+++ b/pbrd/pbr_main.c
@@ -146,7 +146,7 @@ int main(int argc, char **argv, char **envp)
pbr_debug_init();
- vrf_init(NULL, NULL, NULL, NULL);
+ vrf_init(NULL, NULL, NULL, NULL, NULL);
nexthop_group_init(pbr_nhgroup_add_cb,
pbr_nhgroup_add_nexthop_cb,
pbr_nhgroup_del_nexthop_cb,
diff --git a/pimd/pim_instance.c b/pimd/pim_instance.c
index 8dc48cc00..bf8d05d1e 100644
--- a/pimd/pim_instance.c
+++ b/pimd/pim_instance.c
@@ -196,7 +196,8 @@ static int pim_vrf_config_write(struct vty *vty)
void pim_vrf_init(void)
{
- vrf_init(pim_vrf_new, pim_vrf_enable, pim_vrf_disable, pim_vrf_delete);
+ vrf_init(pim_vrf_new, pim_vrf_enable, pim_vrf_disable,
+ pim_vrf_delete, NULL);
vrf_cmd_init(pim_vrf_config_write, &pimd_privs);
}
diff --git a/ripd/rip_main.c b/ripd/rip_main.c
index e5a5c3e22..16087c234 100644
--- a/ripd/rip_main.c
+++ b/ripd/rip_main.c
@@ -170,7 +170,7 @@ int main(int argc, char **argv)
/* Library initialization. */
rip_error_init();
keychain_init();
- vrf_init(NULL, NULL, NULL, NULL);
+ vrf_init(NULL, NULL, NULL, NULL, NULL);
/* RIP related initialization. */
rip_init();
diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c
index e4501d6f8..bc81a956d 100644
--- a/ripngd/ripng_main.c
+++ b/ripngd/ripng_main.c
@@ -166,7 +166,7 @@ int main(int argc, char **argv)
master = frr_init();
/* Library inits. */
- vrf_init(NULL, NULL, NULL, NULL);
+ vrf_init(NULL, NULL, NULL, NULL, NULL);
/* RIPngd inits. */
ripng_init();
diff --git a/sharpd/sharp_main.c b/sharpd/sharp_main.c
index f0e6e3db4..65b1837f6 100644
--- a/sharpd/sharp_main.c
+++ b/sharpd/sharp_main.c
@@ -146,7 +146,7 @@ int main(int argc, char **argv, char **envp)
master = frr_init();
- vrf_init(NULL, NULL, NULL, NULL);
+ vrf_init(NULL, NULL, NULL, NULL, NULL);
access_list_init();
route_map_init();
diff --git a/staticd/static_vrf.c b/staticd/static_vrf.c
index 6946f2127..d33c1539c 100644
--- a/staticd/static_vrf.c
+++ b/staticd/static_vrf.c
@@ -190,7 +190,7 @@ int static_vrf_has_config(struct static_vrf *svrf)
void static_vrf_init(void)
{
vrf_init(static_vrf_new, static_vrf_enable,
- static_vrf_disable, static_vrf_delete);
+ static_vrf_disable, static_vrf_delete, NULL);
vrf_cmd_init(static_vrf_config_write, &static_privs);
}
diff --git a/tests/bgpd/test_capability.c b/tests/bgpd/test_capability.c
index fef7d39ff..83af5e9c6 100644
--- a/tests/bgpd/test_capability.c
+++ b/tests/bgpd/test_capability.c
@@ -913,7 +913,7 @@ int main(void)
qobj_init();
master = thread_master_create(NULL);
bgp_master_init(master);
- vrf_init(NULL, NULL, NULL, NULL);
+ vrf_init(NULL, NULL, NULL, NULL, NULL);
bgp_option_set(BGP_OPT_NO_LISTEN);
bgp_pthreads_init();
diff --git a/tests/bgpd/test_mp_attr.c b/tests/bgpd/test_mp_attr.c
index 8db1cb2ca..603b678cf 100644
--- a/tests/bgpd/test_mp_attr.c
+++ b/tests/bgpd/test_mp_attr.c
@@ -1079,7 +1079,7 @@ int main(void)
bgp_vty_init();
master = thread_master_create("test mp attr");
bgp_master_init(master);
- vrf_init(NULL, NULL, NULL, NULL);
+ vrf_init(NULL, NULL, NULL, NULL, NULL);
bgp_option_set(BGP_OPT_NO_LISTEN);
bgp_attr_init();
diff --git a/tests/bgpd/test_mpath.c b/tests/bgpd/test_mpath.c
index d8d2286bf..42f7d7675 100644
--- a/tests/bgpd/test_mpath.c
+++ b/tests/bgpd/test_mpath.c
@@ -379,7 +379,7 @@ static int global_test_init(void)
master = thread_master_create(NULL);
zclient = zclient_new_notify(master, &zclient_options_default);
bgp_master_init(master);
- vrf_init(NULL, NULL, NULL, NULL);
+ vrf_init(NULL, NULL, NULL, NULL, NULL);
bgp_option_set(BGP_OPT_NO_LISTEN);
if (fileno(stdout) >= 0)
diff --git a/tests/bgpd/test_packet.c b/tests/bgpd/test_packet.c
index c58a85eed..9719aceec 100644
--- a/tests/bgpd/test_packet.c
+++ b/tests/bgpd/test_packet.c
@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
bgp_attr_init();
master = thread_master_create(NULL);
bgp_master_init(master);
- vrf_init(NULL, NULL, NULL, NULL);
+ vrf_init(NULL, NULL, NULL, NULL, NULL);
bgp_option_set(BGP_OPT_NO_LISTEN);
if (bgp_get(&bgp, &asn, NULL, BGP_INSTANCE_TYPE_DEFAULT))
diff --git a/tests/bgpd/test_peer_attr.c b/tests/bgpd/test_peer_attr.c
index 16bd5d96d..452245ec1 100644
--- a/tests/bgpd/test_peer_attr.c
+++ b/tests/bgpd/test_peer_attr.c
@@ -1387,7 +1387,7 @@ static void bgp_startup(void)
master = thread_master_create(NULL);
bgp_master_init(master);
bgp_option_set(BGP_OPT_NO_LISTEN);
- vrf_init(NULL, NULL, NULL, NULL);
+ vrf_init(NULL, NULL, NULL, NULL, NULL);
bgp_init();
bgp_pthreads_run();
}
diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c
index 05ae418b5..be8f87924 100644
--- a/zebra/zebra_vrf.c
+++ b/zebra/zebra_vrf.c
@@ -282,6 +282,19 @@ static int zebra_vrf_delete(struct vrf *vrf)
return 0;
}
+static int zebra_vrf_update(struct vrf *vrf)
+{
+ struct zebra_vrf *zvrf = vrf->info;
+
+ assert(zvrf);
+ if (IS_ZEBRA_DEBUG_EVENT)
+ zlog_debug("VRF %s id %u, name updated", vrf->name,
+ zvrf_id(zvrf));
+ zebra_vrf_add_update(zvrf);
+ return 0;
+}
+
+
/* Return if this VRF has any FRR configuration or not.
* IMPORTANT: This function needs to be updated when additional configuration
* is added for a VRF.
@@ -491,7 +504,7 @@ static int vrf_config_write(struct vty *vty)
void zebra_vrf_init(void)
{
vrf_init(zebra_vrf_new, zebra_vrf_enable, zebra_vrf_disable,
- zebra_vrf_delete);
+ zebra_vrf_delete, zebra_vrf_update);
vrf_cmd_init(vrf_config_write, &zserv_privs);
}