lib, zebra: Rework vrf_add_update

The vrf_add_update function does not need to exist.
Move it's constituent parts into the appropriate
vrf_create/vrf_enable functionality as well as
move the zebra_vrf_add_update() function call
into zebra_vrf_enable()

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2016-04-13 10:06:36 -04:00
parent e74f14fc79
commit e2b1be648d
4 changed files with 18 additions and 38 deletions

View File

@ -231,20 +231,16 @@ vrf_is_enabled (struct vrf *vrf)
int
vrf_enable (struct vrf *vrf)
{
//Pending: see if VRF lib had a reason to leave it for default only
// /* Till now, only the default VRF can be enabled. */
// if (vrf->vrf_id == VRF_DEFAULT)
// {
if (debug_vrf)
zlog_debug ("VRF %u is enabled.", vrf->vrf_id);
if (vrf_master.vrf_enable_hook)
(*vrf_master.vrf_enable_hook) (vrf->vrf_id, vrf->name, &vrf->info);
if (!CHECK_FLAG (vrf->status, VRF_ACTIVE))
SET_FLAG (vrf->status, VRF_ACTIVE);
return 1;
// }
if (vrf_master.vrf_enable_hook)
(*vrf_master.vrf_enable_hook) (vrf->vrf_id, vrf->name, &vrf->info);
// return 0;
return 1;
}
/*

View File

@ -714,31 +714,6 @@ if_handle_vrf_change (struct interface *ifp, vrf_id_t vrf_id)
rib_update (ifp->vrf_id, RIB_UPDATE_IF_CHANGE);
}
/* Handle VRF addition */
void
vrf_add_update (struct vrf *vrfp)
{
zebra_vrf_add_update (vrf_info_lookup (vrfp->vrf_id));
if (! CHECK_FLAG (vrfp->status, VRF_ACTIVE))
{
SET_FLAG (vrfp->status, VRF_ACTIVE);
//Pending: Check if the equivalent of if_addr_wakeup (ifp) is needed here.
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug ("VRF %s id %u becomes active.",
vrfp->name, vrfp->vrf_id);
}
else
{
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug ("VRF %s id %u is added.",
vrfp->name, vrfp->vrf_id);
}
}
static void
ipv6_ll_address_to_mac (struct in6_addr *address, u_char *mac)
{

View File

@ -43,6 +43,7 @@
#include "zebra/rtadv.h"
#include "zebra/zebra_fpm.h"
#include "zebra/zebra_ptm.h"
#include "zebra/redistribute.h"
#define ZEBRA_PTM_SUPPORT
@ -276,6 +277,8 @@ zebra_vrf_enable (vrf_id_t vrf_id, const char *name, void **info)
assert (zvrf);
zebra_vrf_add_update (zvrf);
return 0;
}

View File

@ -556,6 +556,9 @@ netlink_vrf_change (struct nlmsghdr *h, struct rtattr *tb, const char *name)
zlog_debug ("RTM_NEWLINK for VRF %s(%u) table %u",
name, ifi->ifi_index, nl_table_id);
/*
* vrf_get is implied creation if it does not exist
*/
vrf = vrf_get((vrf_id_t)ifi->ifi_index, name); // It would create vrf
if (!vrf)
{
@ -570,11 +573,14 @@ netlink_vrf_change (struct nlmsghdr *h, struct rtattr *tb, const char *name)
return;
}
/*Pending: See if you want to optimize this code.. vrf, zvrf all have name */
zvrf = vrf->info;
/*
* This is the only place that we get the actual kernel table_id
* being used. We need it to set the table_id of the routes
* we are passing to the kernel.... And to throw some totally
* awesome parties. that too.
*/
zvrf = (struct zebra_vrf *)vrf->info;
zvrf->table_id = nl_table_id;
vrf_add_update(vrf);
}
else //h->nlmsg_type == RTM_DELLINK
{