From 0c74bbe03e7e47af698e3f74a4eddec190193063 Mon Sep 17 00:00:00 2001 From: Chirag Shah Date: Tue, 6 Mar 2018 12:55:59 -0800 Subject: [PATCH] ospfd: Treat vrf interface as loopback type Ticket:CM-19914 Signed-off-by: Chirag Shah --- lib/if.c | 6 ++++++ lib/if.h | 2 ++ ospfd/ospf_interface.c | 6 +++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/if.c b/lib/if.c index c00418bac1..2541e6e45a 100644 --- a/lib/if.c +++ b/lib/if.c @@ -476,6 +476,12 @@ int if_is_loopback(struct interface *ifp) return (ifp->flags & (IFF_LOOPBACK | IFF_NOXMIT | IFF_VIRTUAL)); } +/* Check interface is VRF */ +int if_is_vrf(struct interface *ifp) +{ + return CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_VRF_LOOPBACK); +} + /* Does this interface support broadcast ? */ int if_is_broadcast(struct interface *ifp) { diff --git a/lib/if.h b/lib/if.h index 30d7b4e37f..7e23932a16 100644 --- a/lib/if.h +++ b/lib/if.h @@ -288,6 +288,7 @@ struct interface { QOBJ_FIELDS }; + RB_HEAD(if_name_head, interface); RB_PROTOTYPE(if_name_head, interface, name_entry, if_cmp_func); RB_HEAD(if_index_head, interface); @@ -491,6 +492,7 @@ extern int if_is_running(struct interface *); extern int if_is_operative(struct interface *); extern int if_is_no_ptm_operative(struct interface *); extern int if_is_loopback(struct interface *); +extern int if_is_vrf(struct interface *ifp); extern int if_is_broadcast(struct interface *); extern int if_is_pointopoint(struct interface *); extern int if_is_multicast(struct interface *); diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index e19bfe7f55..0305305b81 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -459,7 +459,7 @@ struct ospf_interface *ospf_if_lookup_recv_if(struct ospf *ospf, if (oi->type == OSPF_IFTYPE_VIRTUALLINK) continue; - if (if_is_loopback(oi->ifp)) + if (if_is_loopback(oi->ifp) || if_is_vrf(oi->ifp)) continue; if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED)) @@ -703,7 +703,7 @@ static int ospf_if_delete_hook(struct interface *ifp) int ospf_if_is_enable(struct ospf_interface *oi) { - if (!if_is_loopback(oi->ifp)) + if (!(if_is_loopback(oi->ifp) || if_is_vrf(oi->ifp))) if (if_is_up(oi->ifp)) return 1; @@ -1206,7 +1206,7 @@ u_char ospf_default_iftype(struct interface *ifp) { if (if_is_pointopoint(ifp)) return OSPF_IFTYPE_POINTOPOINT; - else if (if_is_loopback(ifp)) + else if (if_is_loopback(ifp) || if_is_vrf(ifp)) return OSPF_IFTYPE_LOOPBACK; else return OSPF_IFTYPE_BROADCAST; -- 2.39.5