mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 13:33:15 +00:00
lib, zebra: Refactor vrf creation a bit more
Create the idea of a VRF_UNKNOWN, this is for a vrf where we don't yet have the vrf_id for it yet. Refactor the vrf_create code out of existence. We had two code paths vrf_create and vrf_get. We should use vrf_get to create the new vrf since XXX_get() creates the data structures now. Signed-off-by: Donald Sharp Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
This commit is contained in:
parent
88227bbe36
commit
58255d3440
2
lib/if.c
2
lib/if.c
@ -848,7 +848,7 @@ DEFUN (vrf,
|
|||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
vrfp = vrf_get_by_name (argv[0]);
|
vrfp = vrf_get (VRF_UNKNOWN, argv[0]);
|
||||||
|
|
||||||
vty->index = vrfp;
|
vty->index = vrfp;
|
||||||
vty->node = VRF_NODE;
|
vty->node = VRF_NODE;
|
||||||
|
37
lib/vrf.c
37
lib/vrf.c
@ -70,43 +70,6 @@ vrf_list_lookup_by_name (const char *name)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create new vrf structure. */
|
|
||||||
struct vrf *
|
|
||||||
vrf_create (const char *name)
|
|
||||||
{
|
|
||||||
struct vrf *vrfp;
|
|
||||||
|
|
||||||
vrfp = XCALLOC (MTYPE_VRF, sizeof (struct vrf));
|
|
||||||
|
|
||||||
assert (name);
|
|
||||||
|
|
||||||
zlog_debug ("Vrf_create: %s", name);
|
|
||||||
strncpy (vrfp->name, name, VRF_NAMSIZ);
|
|
||||||
vrfp->name[VRF_NAMSIZ] = '\0';
|
|
||||||
|
|
||||||
if (vrf_list_lookup_by_name (vrfp->name) == NULL)
|
|
||||||
listnode_add_sort (vrf_list, vrfp);
|
|
||||||
else
|
|
||||||
zlog_err("vrf_create(%s): corruption detected -- vrf with this "
|
|
||||||
"name exists already with vrf-id %u!", vrfp->name, vrfp->vrf_id);
|
|
||||||
|
|
||||||
UNSET_FLAG(vrfp->status, VRF_ACTIVE);
|
|
||||||
|
|
||||||
if (vrf_master.vrf_new_hook)
|
|
||||||
(*vrf_master.vrf_new_hook) (0, name, &vrfp->info);
|
|
||||||
|
|
||||||
return vrfp;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct vrf *
|
|
||||||
vrf_get_by_name (const char *name)
|
|
||||||
{
|
|
||||||
struct vrf *vrfp;
|
|
||||||
|
|
||||||
return ((vrfp = vrf_list_lookup_by_name (name)) != NULL) ? vrfp :
|
|
||||||
vrf_create (name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Build the table key */
|
/* Build the table key */
|
||||||
static void
|
static void
|
||||||
vrf_build_key (vrf_id_t vrf_id, struct prefix *p)
|
vrf_build_key (vrf_id_t vrf_id, struct prefix *p)
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
/* The default VRF ID */
|
/* The default VRF ID */
|
||||||
#define VRF_DEFAULT 0
|
#define VRF_DEFAULT 0
|
||||||
|
#define VRF_UNKNOWN UINT16_MAX
|
||||||
|
|
||||||
/* Pending: May need to refine this. */
|
/* Pending: May need to refine this. */
|
||||||
#ifndef IFLA_VRF_MAX
|
#ifndef IFLA_VRF_MAX
|
||||||
@ -109,9 +110,7 @@ typedef void * vrf_iter_t;
|
|||||||
extern struct vrf *vrf_lookup (vrf_id_t);
|
extern struct vrf *vrf_lookup (vrf_id_t);
|
||||||
extern struct vrf *vrf_lookup_by_name (const char *);
|
extern struct vrf *vrf_lookup_by_name (const char *);
|
||||||
extern struct vrf *vrf_list_lookup_by_name (const char *);
|
extern struct vrf *vrf_list_lookup_by_name (const char *);
|
||||||
extern struct vrf *vrf_get_by_name (const char *);
|
|
||||||
extern struct vrf *vrf_get (vrf_id_t, const char *);
|
extern struct vrf *vrf_get (vrf_id_t, const char *);
|
||||||
extern struct vrf *vrf_create (const char *);
|
|
||||||
extern void vrf_delete (struct vrf *);
|
extern void vrf_delete (struct vrf *);
|
||||||
extern int vrf_enable (struct vrf *);
|
extern int vrf_enable (struct vrf *);
|
||||||
extern vrf_id_t vrf_name_to_id (const char *);
|
extern vrf_id_t vrf_name_to_id (const char *);
|
||||||
|
@ -757,7 +757,7 @@ vrf_delete_update (struct vrf *vrfp)
|
|||||||
while processing the deletion. Each client daemon is responsible
|
while processing the deletion. Each client daemon is responsible
|
||||||
for setting vrf-id to IFINDEX_INTERNAL after processing the
|
for setting vrf-id to IFINDEX_INTERNAL after processing the
|
||||||
interface deletion message. */
|
interface deletion message. */
|
||||||
vrfp->vrf_id = 0;
|
vrfp->vrf_id = VRF_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1284,7 +1284,7 @@ rib_process (struct route_node *rn)
|
|||||||
char buf[INET6_ADDRSTRLEN];
|
char buf[INET6_ADDRSTRLEN];
|
||||||
rib_dest_t *dest;
|
rib_dest_t *dest;
|
||||||
struct zebra_vrf *zvrf = NULL;
|
struct zebra_vrf *zvrf = NULL;
|
||||||
vrf_id_t vrf_id = 0;
|
vrf_id_t vrf_id = VRF_UNKNOWN;
|
||||||
|
|
||||||
assert (rn);
|
assert (rn);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user