netlink_parse_rtattr((tb), (max), RTA_DATA(rta), RTA_PAYLOAD(rta))
static void netlink_vrf_change(struct nlmsghdr *h, struct rtattr *tb,
- const char *name)
+ uint32_t ns_id, const char *name)
{
struct ifinfomsg *ifi;
struct rtattr *linkinfo[IFLA_INFO_MAX + 1];
nl_table_id = *(uint32_t *)RTA_DATA(attr[IFLA_VRF_TABLE]);
if (h->nlmsg_type == RTM_NEWLINK) {
+ vrf_id_t exist_id;
+
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("RTM_NEWLINK for VRF %s(%u) table %u", name,
ifi->ifi_index, nl_table_id);
+ exist_id = vrf_lookup_by_table(nl_table_id, ns_id);
+ if (exist_id != VRF_DEFAULT) {
+ vrf = vrf_lookup_by_id(exist_id);
+
+ flog_err(
+ EC_ZEBRA_VRF_MISCONFIGURED,
+ "VRF %s id %u table id overlaps existing vrf %s, misconfiguration exiting",
+ name, ifi->ifi_index, vrf->name);
+ exit(-1);
+ }
/*
* vrf_get is implied creation if it does not exist
*/
/* If VRF, create the VRF structure itself. */
if (zif_type == ZEBRA_IF_VRF && !vrf_is_backend_netns()) {
- netlink_vrf_change(h, tb[IFLA_LINKINFO], name);
+ netlink_vrf_change(h, tb[IFLA_LINKINFO], ns_id, name);
vrf_id = (vrf_id_t)ifi->ifi_index;
}
/* If VRF, create or update the VRF structure itself. */
if (zif_type == ZEBRA_IF_VRF && !vrf_is_backend_netns()) {
- netlink_vrf_change(h, tb[IFLA_LINKINFO], name);
+ netlink_vrf_change(h, tb[IFLA_LINKINFO], ns_id, name);
vrf_id = (vrf_id_t)ifi->ifi_index;
}
.suggestion =
"See if the nexthop you are trying to add is already present in the fib."
},
+ {
+ .code = EC_ZEBRA_VRF_MISCONFIGURED,
+ .title = "Duplicate VRF table id detected",
+ .description = "Zebra has detected a situation where there are two vrf devices with the exact same tableid. This is considered a complete misconfiguration of VRF devices and breaks a fundamental assumption in FRR about how VRF's work",
+ .suggestion = "Use different table id's for the VRF's in question"
+ },
{
.code = END_FERR,
}