diff options
Diffstat (limited to 'pimd/pim_iface.c')
| -rw-r--r-- | pimd/pim_iface.c | 121 |
1 files changed, 50 insertions, 71 deletions
diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index eb19cf4ddf..5afd5cd2fe 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -121,7 +121,7 @@ struct pim_interface *pim_if_new(struct interface *ifp, bool igmp, bool pim, pim_ifp = XCALLOC(MTYPE_PIM_INTERFACE, sizeof(*pim_ifp)); pim_ifp->options = 0; - pim_ifp->pim = pim_get_pim_instance(ifp->vrf_id); + pim_ifp->pim = ifp->vrf->info; pim_ifp->mroute_vif_index = -1; pim_ifp->igmp_version = IGMP_DEFAULT_VERSION; @@ -160,7 +160,7 @@ struct pim_interface *pim_if_new(struct interface *ifp, bool igmp, bool pim, pim_ifp->upstream_switch_list = NULL; pim_ifp->pim_generation_id = 0; - /* list of struct igmp_sock */ + /* list of struct gm_sock */ pim_igmp_if_init(pim_ifp, ifp); /* list of struct pim_neighbor */ @@ -289,7 +289,7 @@ static void pim_addr_change(struct interface *ifp) HoldTime should be sent immediately. -- FIXME See TODO T31 */ - pim_ifp->pim_ifstat_hello_sent = 0; /* reset hello counter */ + PIM_IF_FLAG_UNSET_HELLO_SENT(pim_ifp->flags); if (pim_ifp->pim_sock_fd < 0) return; pim_hello_restart_now(ifp); /* send hello and restart timer */ @@ -532,7 +532,7 @@ void pim_if_addr_add(struct connected *ifc) // return; if (PIM_IF_TEST_IGMP(pim_ifp->options)) { - struct igmp_sock *igmp; + struct gm_sock *igmp; /* lookup IGMP socket */ igmp = pim_igmp_sock_lookup_ifaddr(pim_ifp->igmp_socket_list, @@ -552,7 +552,7 @@ void pim_if_addr_add(struct connected *ifc) if (pim_ifp->igmp_join_list) { struct listnode *node; struct listnode *nextnode; - struct igmp_join *ij; + struct gm_join *ij; int join_fd; for (ALL_LIST_ELEMENTS(pim_ifp->igmp_join_list, node, @@ -583,7 +583,7 @@ void pim_if_addr_add(struct connected *ifc) } } /* igmp */ else { - struct igmp_sock *igmp; + struct gm_sock *igmp; /* lookup IGMP socket */ igmp = pim_igmp_sock_lookup_ifaddr(pim_ifp->igmp_socket_list, @@ -648,7 +648,7 @@ void pim_if_addr_add(struct connected *ifc) static void pim_if_addr_del_igmp(struct connected *ifc) { struct pim_interface *pim_ifp = ifc->ifp->info; - struct igmp_sock *igmp; + struct gm_sock *igmp; struct in_addr ifaddr; if (ifc->address->family != AF_INET) { @@ -785,12 +785,11 @@ void pim_if_addr_del_all(struct interface *ifp) struct connected *ifc; struct listnode *node; struct listnode *nextnode; - struct vrf *vrf = vrf_lookup_by_id(ifp->vrf_id); struct pim_instance *pim; - if (!vrf) + pim = ifp->vrf->info; + if (!pim) return; - pim = vrf->info; /* PIM/IGMP enabled ? */ if (!ifp->info) @@ -829,26 +828,6 @@ void pim_if_addr_del_all_igmp(struct interface *ifp) } } -void pim_if_addr_del_all_pim(struct interface *ifp) -{ - struct connected *ifc; - struct listnode *node; - struct listnode *nextnode; - - /* PIM/IGMP enabled ? */ - if (!ifp->info) - return; - - for (ALL_LIST_ELEMENTS(ifp->connected, node, nextnode, ifc)) { - struct prefix *p = ifc->address; - - if (p->family != AF_INET) - continue; - - pim_if_addr_del_pim(ifc); - } -} - struct in_addr pim_find_primary_addr(struct interface *ifp) { struct connected *ifc; @@ -857,10 +836,6 @@ struct in_addr pim_find_primary_addr(struct interface *ifp) int v4_addrs = 0; int v6_addrs = 0; struct pim_interface *pim_ifp = ifp->info; - struct vrf *vrf = vrf_lookup_by_id(ifp->vrf_id); - - if (!vrf) - return addr; if (pim_ifp && PIM_INADDR_ISNOT_ANY(pim_ifp->update_source)) { return pim_ifp->update_source; @@ -899,10 +874,11 @@ struct in_addr pim_find_primary_addr(struct interface *ifp) struct interface *lo_ifp; // DBS - Come back and check here - if (ifp->vrf_id == VRF_DEFAULT) - lo_ifp = if_lookup_by_name("lo", vrf->vrf_id); + if (ifp->vrf->vrf_id == VRF_DEFAULT) + lo_ifp = if_lookup_by_name("lo", ifp->vrf->vrf_id); else - lo_ifp = if_lookup_by_name(vrf->name, vrf->vrf_id); + lo_ifp = if_lookup_by_name(ifp->vrf->name, + ifp->vrf->vrf_id); if (lo_ifp && (lo_ifp != ifp)) return pim_find_primary_addr(lo_ifp); @@ -1183,17 +1159,17 @@ long pim_if_t_suppressed_msec(struct interface *ifp) return t_suppressed_msec; } -static void igmp_join_free(struct igmp_join *ij) +static void igmp_join_free(struct gm_join *ij) { XFREE(MTYPE_PIM_IGMP_JOIN, ij); } -static struct igmp_join *igmp_join_find(struct list *join_list, - struct in_addr group_addr, - struct in_addr source_addr) +static struct gm_join *igmp_join_find(struct list *join_list, + struct in_addr group_addr, + struct in_addr source_addr) { struct listnode *node; - struct igmp_join *ij; + struct gm_join *ij; assert(join_list); @@ -1235,12 +1211,12 @@ static int igmp_join_sock(const char *ifname, ifindex_t ifindex, return join_fd; } -static struct igmp_join *igmp_join_new(struct interface *ifp, - struct in_addr group_addr, - struct in_addr source_addr) +static struct gm_join *igmp_join_new(struct interface *ifp, + struct in_addr group_addr, + struct in_addr source_addr) { struct pim_interface *pim_ifp; - struct igmp_join *ij; + struct gm_join *ij; int join_fd; pim_ifp = ifp->info; @@ -1278,7 +1254,7 @@ ferr_r pim_if_igmp_join_add(struct interface *ifp, struct in_addr group_addr, struct in_addr source_addr) { struct pim_interface *pim_ifp; - struct igmp_join *ij; + struct gm_join *ij; pim_ifp = ifp->info; if (!pim_ifp) { @@ -1321,7 +1297,7 @@ int pim_if_igmp_join_del(struct interface *ifp, struct in_addr group_addr, struct in_addr source_addr) { struct pim_interface *pim_ifp; - struct igmp_join *ij; + struct gm_join *ij; pim_ifp = ifp->info; if (!pim_ifp) { @@ -1378,7 +1354,7 @@ static void pim_if_igmp_join_del_all(struct interface *ifp) struct pim_interface *pim_ifp; struct listnode *node; struct listnode *nextnode; - struct igmp_join *ij; + struct gm_join *ij; pim_ifp = ifp->info; if (!pim_ifp) { @@ -1482,7 +1458,8 @@ void pim_if_create_pimreg(struct pim_instance *pim) snprintf(pimreg_name, sizeof(pimreg_name), "pimreg%u", pim->vrf->data.l.table_id); - pim->regiface = if_create_name(pimreg_name, pim->vrf->vrf_id); + pim->regiface = if_get_by_name(pimreg_name, pim->vrf->vrf_id, + pim->vrf->name); pim->regiface->ifindex = PIM_OIF_PIM_REGISTER_VIF; pim_if_new(pim->regiface, false, false, true, @@ -1549,13 +1526,13 @@ int pim_ifp_create(struct interface *ifp) { struct pim_instance *pim; - pim = pim_get_pim_instance(ifp->vrf_id); + pim = ifp->vrf->info; if (PIM_DEBUG_ZEBRA) { zlog_debug( - "%s: %s index %d(%u) flags %ld metric %d mtu %d operative %d", - __func__, ifp->name, ifp->ifindex, ifp->vrf_id, - (long)ifp->flags, ifp->metric, ifp->mtu, - if_is_operative(ifp)); + "%s: %s index %d vrf %s(%u) flags %ld metric %d mtu %d operative %d", + __func__, ifp->name, ifp->ifindex, ifp->vrf->name, + ifp->vrf->vrf_id, (long)ifp->flags, ifp->metric, + ifp->mtu, if_is_operative(ifp)); } if (if_is_operative(ifp)) { @@ -1621,13 +1598,13 @@ int pim_ifp_up(struct interface *ifp) if (PIM_DEBUG_ZEBRA) { zlog_debug( - "%s: %s index %d(%u) flags %ld metric %d mtu %d operative %d", - __func__, ifp->name, ifp->ifindex, ifp->vrf_id, - (long)ifp->flags, ifp->metric, ifp->mtu, - if_is_operative(ifp)); + "%s: %s index %d vrf %s(%u) flags %ld metric %d mtu %d operative %d", + __func__, ifp->name, ifp->ifindex, ifp->vrf->name, + ifp->vrf->vrf_id, (long)ifp->flags, ifp->metric, + ifp->mtu, if_is_operative(ifp)); } - pim = pim_get_pim_instance(ifp->vrf_id); + pim = ifp->vrf->info; pim_ifp = ifp->info; /* @@ -1652,7 +1629,7 @@ int pim_ifp_up(struct interface *ifp) struct vrf *vrf; RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { if ((table_id == vrf->data.l.table_id) - && (ifp->vrf_id != vrf->vrf_id)) { + && (ifp->vrf->vrf_id != vrf->vrf_id)) { struct interface *master = if_lookup_by_name( vrf->name, vrf->vrf_id); @@ -1673,10 +1650,10 @@ int pim_ifp_down(struct interface *ifp) { if (PIM_DEBUG_ZEBRA) { zlog_debug( - "%s: %s index %d(%u) flags %ld metric %d mtu %d operative %d", - __func__, ifp->name, ifp->ifindex, ifp->vrf_id, - (long)ifp->flags, ifp->metric, ifp->mtu, - if_is_operative(ifp)); + "%s: %s index %d vrf %s(%u) flags %ld metric %d mtu %d operative %d", + __func__, ifp->name, ifp->ifindex, ifp->vrf->name, + ifp->vrf->vrf_id, (long)ifp->flags, ifp->metric, + ifp->mtu, if_is_operative(ifp)); } if (!if_is_operative(ifp)) { @@ -1697,8 +1674,10 @@ int pim_ifp_down(struct interface *ifp) } } - if (ifp->info) + if (ifp->info) { pim_if_del_vif(ifp); + pim_ifstat_reset(ifp); + } return 0; } @@ -1709,16 +1688,16 @@ int pim_ifp_destroy(struct interface *ifp) if (PIM_DEBUG_ZEBRA) { zlog_debug( - "%s: %s index %d(%u) flags %ld metric %d mtu %d operative %d", - __func__, ifp->name, ifp->ifindex, ifp->vrf_id, - (long)ifp->flags, ifp->metric, ifp->mtu, - if_is_operative(ifp)); + "%s: %s index %d vrf %s(%u) flags %ld metric %d mtu %d operative %d", + __func__, ifp->name, ifp->ifindex, ifp->vrf->name, + ifp->vrf->vrf_id, (long)ifp->flags, ifp->metric, + ifp->mtu, if_is_operative(ifp)); } if (!if_is_operative(ifp)) pim_if_addr_del_all(ifp); - pim = pim_get_pim_instance(ifp->vrf_id); + pim = ifp->vrf->info; if (pim && pim->vxlan.term_if == ifp) pim_vxlan_del_term_dev(pim); |
