diff options
author | Renato Westphal <renato@openbsd.org> | 2018-03-08 23:04:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-08 23:04:08 +0100 |
commit | 1ffd1bcf86fde9c0642475ac3519767907fab721 (patch) | |
tree | 12e29b3977ced79c9dfab8bb642b2f5df941e8b6 | |
parent | Merge pull request #1842 from donaldsharp/zserv_buffer_size (diff) | |
parent | ospfd: Treat vrf interface as loopback type (diff) | |
download | frr-1ffd1bcf86fde9c0642475ac3519767907fab721.tar.xz frr-1ffd1bcf86fde9c0642475ac3519767907fab721.zip |
Merge pull request #1843 from chiragshah6/ospf_vrf_dev
zebra/ospfd: Treat vrf interface similar to loopback
-rw-r--r-- | lib/if.c | 6 | ||||
-rw-r--r-- | lib/if.h | 2 | ||||
-rw-r--r-- | ospfd/ospf_interface.c | 6 | ||||
-rw-r--r-- | zebra/connected.c | 3 | ||||
-rw-r--r-- | zebra/if_netlink.c | 10 |
5 files changed, 18 insertions, 9 deletions
@@ -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) { @@ -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 e19bfe7f5..0305305b8 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; diff --git a/zebra/connected.c b/zebra/connected.c index ad033db39..94b56c897 100644 --- a/zebra/connected.c +++ b/zebra/connected.c @@ -73,7 +73,8 @@ static void connected_announce(struct interface *ifp, struct connected *ifc) if (!ifc) return; - if (!if_is_loopback(ifp) && ifc->address->family == AF_INET) { + if (!if_is_loopback(ifp) && ifc->address->family == AF_INET && + !IS_ZEBRA_IF_VRF(ifp)) { if (ifc->address->prefixlen == 32) SET_FLAG(ifc->flags, ZEBRA_IFA_UNNUMBERED); else diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index 44f87f945..bb0a0e052 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -649,8 +649,6 @@ static int netlink_interface(struct sockaddr_nl *snl, struct nlmsghdr *h, ifp = if_get_by_name(name, vrf_id, 0); set_ifindex(ifp, ifi->ifi_index, zns); ifp->flags = ifi->ifi_flags & 0x0000fffff; - if (IS_ZEBRA_IF_VRF(ifp)) - SET_FLAG(ifp->status, ZEBRA_INTERFACE_VRF_LOOPBACK); ifp->mtu6 = ifp->mtu = *(uint32_t *)RTA_DATA(tb[IFLA_MTU]); ifp->metric = 0; ifp->speed = get_iflink_speed(ifp); @@ -661,6 +659,8 @@ static int netlink_interface(struct sockaddr_nl *snl, struct nlmsghdr *h, /* Set zebra interface type */ zebra_if_set_ziftype(ifp, zif_type, zif_slave_type); + if (IS_ZEBRA_IF_VRF(ifp)) + SET_FLAG(ifp->status, ZEBRA_INTERFACE_VRF_LOOPBACK); /* Update link. */ zebra_if_update_link(ifp, link_ifindex); @@ -1143,15 +1143,15 @@ int netlink_link_change(struct sockaddr_nl *snl, struct nlmsghdr *h, /* Update interface information. */ set_ifindex(ifp, ifi->ifi_index, zns); ifp->flags = ifi->ifi_flags & 0x0000fffff; - if (IS_ZEBRA_IF_VRF(ifp)) - SET_FLAG(ifp->status, - ZEBRA_INTERFACE_VRF_LOOPBACK); ifp->mtu6 = ifp->mtu = *(int *)RTA_DATA(tb[IFLA_MTU]); ifp->metric = 0; ifp->ptm_status = ZEBRA_PTM_STATUS_UNKNOWN; /* Set interface type */ zebra_if_set_ziftype(ifp, zif_type, zif_slave_type); + if (IS_ZEBRA_IF_VRF(ifp)) + SET_FLAG(ifp->status, + ZEBRA_INTERFACE_VRF_LOOPBACK); /* Update link. */ zebra_if_update_link(ifp, link_ifindex); |