mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-11 23:53:49 +00:00
lib: Ensure VRF is created with correct id
In function vrf_get(), an early call to vrf_get_by_name() may end up creating the Zebra VRF structure prior to the VRF id being set, resulting in various other misbehavior. Fix this with appropriate changes. Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com> Ticket: CM-10258 Reviewed By: CCR-4418 Testing Done: Manual
This commit is contained in:
parent
66e373aec0
commit
8087b296b4
20
lib/vrf.c
20
lib/vrf.c
@ -150,6 +150,7 @@ vrf_get (vrf_id_t vrf_id, const char *name)
|
||||
struct prefix p;
|
||||
struct route_node *rn;
|
||||
struct vrf *vrf = NULL;
|
||||
size_t namelen;
|
||||
|
||||
vrf_build_key (vrf_id, &p);
|
||||
rn = route_node_get (vrf_table, &p);
|
||||
@ -172,7 +173,7 @@ vrf_get (vrf_id_t vrf_id, const char *name)
|
||||
else
|
||||
{
|
||||
if (name)
|
||||
vrf = vrf_get_by_name(name);
|
||||
vrf = vrf_list_lookup_by_name(name);
|
||||
|
||||
if (vrf)
|
||||
{
|
||||
@ -182,10 +183,27 @@ vrf_get (vrf_id_t vrf_id, const char *name)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (name)
|
||||
{
|
||||
namelen = strlen (name);
|
||||
if (namelen > VRF_NAMSIZ)
|
||||
{
|
||||
zlog_err("Attempt to get/create VRF %u name %s - name too long",
|
||||
vrf_id, name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
vrf = XCALLOC (MTYPE_VRF, sizeof (struct vrf));
|
||||
if (debug_vrf)
|
||||
zlog_debug ("VRF(%u) %s is created.",
|
||||
vrf_id, (name) ? name : "(NULL)");
|
||||
if (name)
|
||||
{
|
||||
strncpy (vrf->name, name, namelen);
|
||||
vrf->name[namelen] = '\0';
|
||||
listnode_add_sort (vrf_list, vrf);
|
||||
}
|
||||
}
|
||||
vrf->vrf_id = vrf_id;
|
||||
rn->info = vrf;
|
||||
|
Loading…
Reference in New Issue
Block a user