diff options
| author | Renato Westphal <renato@openbsd.org> | 2018-02-27 10:20:53 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-27 10:20:53 -0300 |
| commit | 7bcf94689d94e897eecbac4ebf504380f391f75d (patch) | |
| tree | 14bba4e1a2eb53ddcbff272b0f4211c7b43d3833 /lib/if.c | |
| parent | f9159fbc1057dfe4ca73635637c1a080d5b3d499 (diff) | |
| parent | b7b816df6bd8b110aedb0f047fa8e3105ce86d1d (diff) | |
Merge pull request #1711 from pguibert6WIND/issue_385_step5
Netns Support / VRF/NS/ogical router rework, along with BGP & OSPF support for multiple VRF with NETNS backend
Diffstat (limited to 'lib/if.c')
| -rw-r--r-- | lib/if.c | 46 |
1 files changed, 26 insertions, 20 deletions
@@ -384,29 +384,35 @@ struct interface *if_get_by_name(const char *name, vrf_id_t vrf_id, int vty) { struct interface *ifp; + ifp = if_lookup_by_name(name, vrf_id); + if (ifp) + return ifp; + /* Not Found on same VRF. If the interface command + * was entered in vty without a VRF (passed as VRF_DEFAULT), + * accept the ifp we found. If a vrf was entered and there is + * a mismatch, reject it if from vty. + */ ifp = if_lookup_by_name_all_vrf(name); - if (ifp) { - if (ifp->vrf_id == vrf_id) - return ifp; - - /* Found a match on a different VRF. If the interface command - * was entered in vty without a VRF (passed as VRF_DEFAULT), - * accept the ifp we found. If a vrf was entered and there is - * a mismatch, reject it if from vty. If it came from the kernel - * or by way of zclient, believe it and update the ifp - * accordingly. - */ - if (vty) { - if (vrf_id == VRF_DEFAULT) - return ifp; - return NULL; - } else { - if_update_to_new_vrf(ifp, vrf_id); + if (!ifp) + return if_create(name, vrf_id); + if (vty) { + if (vrf_id == VRF_DEFAULT) return ifp; - } + return NULL; } - - return if_create(name, vrf_id); + /* if vrf backend uses NETNS, then + * this should not be considered as an update + * then create the new interface + */ + if (ifp->vrf_id != vrf_id && + vrf_is_mapped_on_netns(vrf_id)) + return if_create(name, vrf_id); + /* If it came from the kernel + * or by way of zclient, believe it and update + * the ifp accordingly. + */ + if_update_to_new_vrf(ifp, vrf_id); + return ifp; } void if_set_index(struct interface *ifp, ifindex_t ifindex) |
