mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 10:09:17 +00:00
zebra: nexthop groups vrf's are only a function of namespaces
Nexthop groups as a whole do not make sense to have a vrf'ness As that you can have a arbitrary number of nexthops that point to separate vrf's. Modify the code to make this distinction, by clearly delineating the line between the nhg and the nexthop a bit better. Nexthop groups having a vrf_id only make sense if you are using network namespaces to represent them. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
417f01b751
commit
88cafda739
@ -2364,6 +2364,9 @@ int netlink_nexthop_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
|
|||||||
|
|
||||||
nhm = NLMSG_DATA(h);
|
nhm = NLMSG_DATA(h);
|
||||||
|
|
||||||
|
if (ns_id)
|
||||||
|
vrf_id = ns_id;
|
||||||
|
|
||||||
if (startup && h->nlmsg_type != RTM_NEWNEXTHOP)
|
if (startup && h->nlmsg_type != RTM_NEWNEXTHOP)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -2443,7 +2446,7 @@ int netlink_nexthop_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
} else if (h->nlmsg_type == RTM_DELNEXTHOP)
|
} else if (h->nlmsg_type == RTM_DELNEXTHOP)
|
||||||
zebra_nhg_kernel_del(id);
|
zebra_nhg_kernel_del(id, vrf_id);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -317,15 +317,15 @@ zebra_nhg_connect_depends(struct nhg_hash_entry *nhe,
|
|||||||
struct interface *ifp = NULL;
|
struct interface *ifp = NULL;
|
||||||
|
|
||||||
ifp = if_lookup_by_index(nhe->nhg->nexthop->ifindex,
|
ifp = if_lookup_by_index(nhe->nhg->nexthop->ifindex,
|
||||||
nhe->vrf_id);
|
nhe->nhg->nexthop->vrf_id);
|
||||||
if (ifp)
|
if (ifp)
|
||||||
zebra_nhg_set_if(nhe, ifp);
|
zebra_nhg_set_if(nhe, ifp);
|
||||||
else
|
else
|
||||||
flog_err(
|
flog_err(
|
||||||
EC_ZEBRA_IF_LOOKUP_FAILED,
|
EC_ZEBRA_IF_LOOKUP_FAILED,
|
||||||
"Zebra failed to lookup an interface with ifindex=%d in vrf=%u for NHE id=%u",
|
"Zebra failed to lookup an interface with ifindex=%d in vrf=%u for NHE id=%u",
|
||||||
nhe->nhg->nexthop->ifindex, nhe->vrf_id,
|
nhe->nhg->nexthop->ifindex,
|
||||||
nhe->id);
|
nhe->nhg->nexthop->vrf_id, nhe->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -535,10 +535,10 @@ static bool zebra_nhg_find(struct nhg_hash_entry **nhe, uint32_t id,
|
|||||||
lookup.type = type ? type : ZEBRA_ROUTE_NHG;
|
lookup.type = type ? type : ZEBRA_ROUTE_NHG;
|
||||||
lookup.nhg = nhg;
|
lookup.nhg = nhg;
|
||||||
|
|
||||||
|
lookup.vrf_id = vrf_id;
|
||||||
if (lookup.nhg->nexthop->next) {
|
if (lookup.nhg->nexthop->next) {
|
||||||
/* Groups can have all vrfs and AF's in them */
|
/* Groups can have all vrfs and AF's in them */
|
||||||
lookup.afi = AFI_UNSPEC;
|
lookup.afi = AFI_UNSPEC;
|
||||||
lookup.vrf_id = VRF_DEFAULT;
|
|
||||||
} else {
|
} else {
|
||||||
switch (lookup.nhg->nexthop->type) {
|
switch (lookup.nhg->nexthop->type) {
|
||||||
case (NEXTHOP_TYPE_IFINDEX):
|
case (NEXTHOP_TYPE_IFINDEX):
|
||||||
@ -562,8 +562,6 @@ static bool zebra_nhg_find(struct nhg_hash_entry **nhe, uint32_t id,
|
|||||||
lookup.afi = AFI_IP6;
|
lookup.afi = AFI_IP6;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
lookup.vrf_id = vrf_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id)
|
if (id)
|
||||||
@ -622,10 +620,11 @@ zebra_nhg_find_nexthop(uint32_t id, struct nexthop *nh, afi_t afi, int type)
|
|||||||
{
|
{
|
||||||
struct nhg_hash_entry *nhe = NULL;
|
struct nhg_hash_entry *nhe = NULL;
|
||||||
struct nexthop_group nhg = {};
|
struct nexthop_group nhg = {};
|
||||||
|
vrf_id_t vrf_id = !vrf_is_backend_netns() ? VRF_DEFAULT : nh->vrf_id;
|
||||||
|
|
||||||
nexthop_group_add_sorted(&nhg, nh);
|
nexthop_group_add_sorted(&nhg, nh);
|
||||||
|
|
||||||
zebra_nhg_find(&nhe, id, &nhg, NULL, nh->vrf_id, afi, type);
|
zebra_nhg_find(&nhe, id, &nhg, NULL, vrf_id, afi, type);
|
||||||
|
|
||||||
return nhe;
|
return nhe;
|
||||||
}
|
}
|
||||||
@ -1062,11 +1061,11 @@ int zebra_nhg_kernel_find(uint32_t id, struct nexthop *nh, struct nh_grp *grp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Kernel-side, received delete message */
|
/* Kernel-side, received delete message */
|
||||||
int zebra_nhg_kernel_del(uint32_t id)
|
int zebra_nhg_kernel_del(uint32_t id, vrf_id_t vrf_id)
|
||||||
{
|
{
|
||||||
struct nhg_ctx *ctx = NULL;
|
struct nhg_ctx *ctx = NULL;
|
||||||
|
|
||||||
ctx = nhg_ctx_init(id, NULL, NULL, 0, 0, 0, 0);
|
ctx = nhg_ctx_init(id, NULL, NULL, vrf_id, 0, 0, 0);
|
||||||
|
|
||||||
nhg_ctx_set_op(ctx, NHG_CTX_OP_DEL);
|
nhg_ctx_set_op(ctx, NHG_CTX_OP_DEL);
|
||||||
|
|
||||||
@ -1183,6 +1182,14 @@ struct nhg_hash_entry *
|
|||||||
zebra_nhg_rib_find(uint32_t id, struct nexthop_group *nhg, afi_t rt_afi)
|
zebra_nhg_rib_find(uint32_t id, struct nexthop_group *nhg, afi_t rt_afi)
|
||||||
{
|
{
|
||||||
struct nhg_hash_entry *nhe = NULL;
|
struct nhg_hash_entry *nhe = NULL;
|
||||||
|
vrf_id_t vrf_id;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CLANG SA is complaining that nexthop may be NULL
|
||||||
|
* Make it happy but this is ridonc
|
||||||
|
*/
|
||||||
|
assert(nhg->nexthop);
|
||||||
|
vrf_id = !vrf_is_backend_netns() ? VRF_DEFAULT : nhg->nexthop->vrf_id;
|
||||||
|
|
||||||
if (!(nhg && nhg->nexthop)) {
|
if (!(nhg && nhg->nexthop)) {
|
||||||
flog_err(EC_ZEBRA_TABLE_LOOKUP_FAILED,
|
flog_err(EC_ZEBRA_TABLE_LOOKUP_FAILED,
|
||||||
@ -1190,7 +1197,7 @@ zebra_nhg_rib_find(uint32_t id, struct nexthop_group *nhg, afi_t rt_afi)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
zebra_nhg_find(&nhe, id, nhg, NULL, nhg->nexthop->vrf_id, rt_afi, 0);
|
zebra_nhg_find(&nhe, id, nhg, NULL, vrf_id, rt_afi, 0);
|
||||||
|
|
||||||
return nhe;
|
return nhe;
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ extern int zebra_nhg_kernel_find(uint32_t id, struct nexthop *nh,
|
|||||||
vrf_id_t vrf_id, afi_t afi, int type,
|
vrf_id_t vrf_id, afi_t afi, int type,
|
||||||
int startup);
|
int startup);
|
||||||
/* Del via kernel */
|
/* Del via kernel */
|
||||||
extern int zebra_nhg_kernel_del(uint32_t id);
|
extern int zebra_nhg_kernel_del(uint32_t id, vrf_id_t vrf_id);
|
||||||
|
|
||||||
/* Find via route creation */
|
/* Find via route creation */
|
||||||
extern struct nhg_hash_entry *
|
extern struct nhg_hash_entry *
|
||||||
|
@ -1373,6 +1373,11 @@ DEFPY (show_nexthop_group,
|
|||||||
else if (v6)
|
else if (v6)
|
||||||
afi = AFI_IP6;
|
afi = AFI_IP6;
|
||||||
|
|
||||||
|
if (vrf_is_backend_netns() && (vrf_name || vrf_all)) {
|
||||||
|
vty_out(vty, "VRF subcommand does not make any sense in l3mdev based vrf's");
|
||||||
|
return CMD_WARNING;
|
||||||
|
}
|
||||||
|
|
||||||
if (vrf_all) {
|
if (vrf_all) {
|
||||||
struct vrf *vrf;
|
struct vrf *vrf;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user