summaryrefslogtreecommitdiff
path: root/lib/if.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2018-03-01 11:10:01 -0500
committerQuentin Young <qlyoung@cumulusnetworks.com>2018-03-01 11:10:01 -0500
commita975744835bb87e3cf62701e13248d66f1dac1df (patch)
treebca5ab1f29594688c43e0c36c9eb2f0c5c8e66c6 /lib/if.c
parent351c56649bfd8487676704a10995d736d1d893cc (diff)
parentc98f4d81aa5d4113ceea58ce6db4bebab5c99735 (diff)
Merge branch 'master' into docuser
* New manpage: mtracebis.rst * Makefile.am includes mtracebis.rst * configure.ac lines removed * Debian packaging files updated * Fixed up manpage |seealso-programs| in the process * Centos7 build package list updated to include systemd-devel * New paragraph on netns vrf support in zebra manpage Conflicts: configure.ac debianpkg/backports/ubuntu14.04/debian/frr.install debianpkg/frr.install doc/Makefile.am doc/developer/Building_FRR_on_CentOS7.rst doc/zebra.8.in Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/if.c')
-rw-r--r--lib/if.c52
1 files changed, 30 insertions, 22 deletions
diff --git a/lib/if.c b/lib/if.c
index 7866ddb8c4..3a83de46ae 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -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)
+ if (!ifp)
+ return if_create(name, vrf_id);
+ if (vty) {
+ if (vrf_id == VRF_DEFAULT)
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);
- 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)
@@ -1064,7 +1070,7 @@ ifaddr_ipv4_lookup (struct in_addr *addr, ifindex_t ifindex)
rn = route_node_lookup (ifaddr_ipv4_table, (struct prefix *) &p);
if (! rn)
return NULL;
-
+
ifp = rn->info;
route_unlock_node (rn);
return ifp;
@@ -1078,7 +1084,9 @@ void if_terminate(struct vrf *vrf)
{
struct interface *ifp;
- while ((ifp = RB_ROOT(if_name_head, &vrf->ifaces_by_name)) != NULL) {
+ while (!RB_EMPTY(if_name_head, &vrf->ifaces_by_name)) {
+ ifp = RB_ROOT(if_name_head, &vrf->ifaces_by_name);
+
if (ifp->node) {
ifp->node->info = NULL;
route_unlock_node(ifp->node);