summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2020-02-10 10:49:44 -0500
committerGitHub <noreply@github.com>2020-02-10 10:49:44 -0500
commit283925de411b971fd3c6013ab4051f8311e3550a (patch)
tree1379cd4698ea4ba101efe046b4160eac615bfb1d
parentef985ef82222c30c0c3458ce0cb1ea86676b4737 (diff)
parent4348f9d2b9e9c876e51e3646e1e8604c3c76f154 (diff)
Merge pull request #5784 from donaldsharp/dc_73
[7.3] Double commit of nexthop cli changes to get this in.
-rw-r--r--doc/user/zebra.rst12
-rw-r--r--zebra/rt_netlink.c5
-rw-r--r--zebra/zebra_nhg.c26
-rw-r--r--zebra/zebra_nhg.h2
-rw-r--r--zebra/zebra_vty.c10
5 files changed, 38 insertions, 17 deletions
diff --git a/doc/user/zebra.rst b/doc/user/zebra.rst
index 23a062ab02..520080e83a 100644
--- a/doc/user/zebra.rst
+++ b/doc/user/zebra.rst
@@ -911,10 +911,14 @@ zebra Terminal Mode Commands
Reset statistics related to the zebra code that interacts with the
optional Forwarding Plane Manager (FPM) component.
-.. index:: show nexthop-group [ID] [vrf NAME] [ip|ipv6]
-.. clicmd:: show nexthop-group [ID] [vrf NAME] [ip|ipv6]
-
- Display nexthop groups created by zebra.
+.. index:: show nexthop-group rib [ID] [vrf NAME] [singleton [ip|ip6]]
+.. clicmd:: show nexthop-group rib [ID] [vrf NAME]
+
+ Display nexthop groups created by zebra. The [vrf NAME] option
+ is only meaningful if you have started zebra with the --vrfwnetns
+ option as that nexthop groups are per namespace in linux.
+ If you specify singleton you would like to see the singleton
+ nexthop groups that do have an afi.
Router-id
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 29a341abbd..2abcd6ef2a 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -2364,6 +2364,9 @@ int netlink_nexthop_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
nhm = NLMSG_DATA(h);
+ if (ns_id)
+ vrf_id = ns_id;
+
if (startup && h->nlmsg_type != RTM_NEWNEXTHOP)
return 0;
@@ -2443,7 +2446,7 @@ int netlink_nexthop_change(struct nlmsghdr *h, ns_id_t ns_id, int startup)
return -1;
} else if (h->nlmsg_type == RTM_DELNEXTHOP)
- zebra_nhg_kernel_del(id);
+ zebra_nhg_kernel_del(id, vrf_id);
return 0;
}
diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c
index 4d0e1db94b..cbeb73aed4 100644
--- a/zebra/zebra_nhg.c
+++ b/zebra/zebra_nhg.c
@@ -288,15 +288,15 @@ zebra_nhg_connect_depends(struct nhg_hash_entry *nhe,
struct interface *ifp = NULL;
ifp = if_lookup_by_index(nhe->nhg->nexthop->ifindex,
- nhe->vrf_id);
+ nhe->nhg->nexthop->vrf_id);
if (ifp)
zebra_nhg_set_if(nhe, ifp);
else
flog_err(
EC_ZEBRA_IF_LOOKUP_FAILED,
"Zebra failed to lookup an interface with ifindex=%d in vrf=%u for NHE id=%u",
- nhe->nhg->nexthop->ifindex, nhe->vrf_id,
- nhe->id);
+ nhe->nhg->nexthop->ifindex,
+ nhe->nhg->nexthop->vrf_id, nhe->id);
}
}
@@ -504,6 +504,7 @@ static bool zebra_nhg_find(struct nhg_hash_entry **nhe, uint32_t id,
lookup.type = type ? type : ZEBRA_ROUTE_NHG;
lookup.nhg = nhg;
+ lookup.vrf_id = vrf_id;
if (lookup.nhg->nexthop->next) {
/* Groups can have all vrfs and AF's in them */
lookup.afi = AFI_UNSPEC;
@@ -531,8 +532,6 @@ static bool zebra_nhg_find(struct nhg_hash_entry **nhe, uint32_t id,
lookup.afi = AFI_IP6;
break;
}
-
- lookup.vrf_id = vrf_id;
}
if (id)
@@ -591,10 +590,11 @@ zebra_nhg_find_nexthop(uint32_t id, struct nexthop *nh, afi_t afi, int type)
{
struct nhg_hash_entry *nhe = NULL;
struct nexthop_group nhg = {};
+ vrf_id_t vrf_id = !vrf_is_backend_netns() ? VRF_DEFAULT : nh->vrf_id;
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;
}
@@ -1031,11 +1031,11 @@ int zebra_nhg_kernel_find(uint32_t id, struct nexthop *nh, struct nh_grp *grp,
}
/* 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;
- 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);
@@ -1157,6 +1157,14 @@ struct nhg_hash_entry *
zebra_nhg_rib_find(uint32_t id, struct nexthop_group *nhg, afi_t rt_afi)
{
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)) {
flog_err(EC_ZEBRA_TABLE_LOOKUP_FAILED,
@@ -1164,7 +1172,7 @@ zebra_nhg_rib_find(uint32_t id, struct nexthop_group *nhg, afi_t rt_afi)
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;
}
diff --git a/zebra/zebra_nhg.h b/zebra/zebra_nhg.h
index 522ec1e9dd..c2e173e094 100644
--- a/zebra/zebra_nhg.h
+++ b/zebra/zebra_nhg.h
@@ -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,
int startup);
/* 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 */
extern struct nhg_hash_entry *
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index c8b96011dc..78001da170 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -1351,18 +1351,19 @@ DEFPY (show_interface_nexthop_group,
DEFPY (show_nexthop_group,
show_nexthop_group_cmd,
- "show nexthop-group rib <(0-4294967295)$id|[<ip$v4|ipv6$v6>] [vrf <NAME$vrf_name|all$vrf_all>]>",
+ "show nexthop-group rib <(0-4294967295)$id|[singleton <ip$v4|ipv6$v6>] [vrf <NAME$vrf_name|all$vrf_all>]>",
SHOW_STR
"Show Nexthop Groups\n"
"RIB information\n"
"Nexthop Group ID\n"
+ "Show Singleton Nexthop-Groups\n"
IP_STR
IP6_STR
VRF_FULL_CMD_HELP_STR)
{
struct zebra_vrf *zvrf = NULL;
- afi_t afi = 0;
+ afi_t afi = AFI_UNSPEC;
if (id)
return show_nexthop_group_id_cmd_helper(vty, id);
@@ -1372,6 +1373,11 @@ DEFPY (show_nexthop_group,
else if (v6)
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) {
struct vrf *vrf;