diff options
Diffstat (limited to 'zebra/if_netlink.c')
| -rw-r--r-- | zebra/if_netlink.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index 65a0add57e..429bb968a5 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -275,7 +275,7 @@ static void netlink_determine_zebra_iftype(const char *kind, 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]; @@ -314,6 +314,21 @@ static void netlink_vrf_change(struct nlmsghdr *h, struct rtattr *tb, zlog_debug("RTM_NEWLINK for VRF %s(%u) table %u", name, ifi->ifi_index, nl_table_id); + if (!vrf_lookup_by_id((vrf_id_t)ifi->ifi_index)) { + vrf_id_t exist_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 */ @@ -664,7 +679,7 @@ static int netlink_interface(struct nlmsghdr *h, ns_id_t ns_id, int startup) /* 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; } @@ -764,7 +779,7 @@ static int netlink_request_intf_addr(struct nlsock *netlink_cmd, int family, if (filter_mask) addattr32(&req.n, sizeof(req), IFLA_EXT_MASK, filter_mask); - return netlink_request(netlink_cmd, &req.n); + return netlink_request(netlink_cmd, &req); } /* Interface lookup by netlink socket. */ @@ -1226,7 +1241,7 @@ int netlink_link_change(struct nlmsghdr *h, ns_id_t ns_id, int startup) /* 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; } |
