/* helper function called by if_netlink_change * to delete interfaces in case the interface moved * to an other netns */ static void if_netlink_check_ifp_instance_consistency(uint16_t cmd, struct interface *ifp, ns_id_t ns_id) { struct interface *other_ifp; /* * look if interface name is also found on other netns * - only if vrf backend is netns * - do not concern lo interface * - then remove previous one * - for new link case, check found interface is not active */ if (!vrf_is_backend_netns() || !strcmp(ifp->name, "lo")) return; other_ifp = if_lookup_by_name_not_ns(ns_id, ifp->name); if (!other_ifp) return; /* because previous interface may be inactive, * interface is moved back to default vrf * then one may find the same pointer; ignore */ if (other_ifp == ifp) return; if ((cmd == RTM_NEWLINK) && (CHECK_FLAG(other_ifp->status, ZEBRA_INTERFACE_ACTIVE))) return; if (IS_ZEBRA_DEBUG_KERNEL && cmd == RTM_NEWLINK) { zlog_debug("RTM_NEWLINK %s(%u, VRF %u) replaces %s(%u, VRF %u)\n", ifp->name, ifp->ifindex, ifp->vrf_id, other_ifp->name, other_ifp->ifindex, other_ifp->vrf_id); } else if (IS_ZEBRA_DEBUG_KERNEL && cmd == RTM_DELLINK) { zlog_debug("RTM_DELLINK %s(%u, VRF %u) is replaced by %s(%u, VRF %u)\n", ifp->name, ifp->ifindex, ifp->vrf_id, other_ifp->name, other_ifp->ifindex, other_ifp->vrf_id); } /* the found interface replaces the current one * remove it */ if (cmd == RTM_DELLINK) if_delete(ifp); else if_delete(other_ifp); /* the found interface is replaced by the current one * suppress it */ }
/* Interface adding function */ int ifan_read (struct if_announcemsghdr *ifan) { struct interface *ifp; ifp = if_lookup_by_index (ifan->ifan_index); if (ifp == NULL && ifan->ifan_what == IFAN_ARRIVAL) { /* Create Interface */ ifp = if_get_by_name (ifan->ifan_name); ifp->ifindex = ifan->ifan_index; if_add_update (ifp); } else if (ifp != NULL && ifan->ifan_what == IFAN_DEPARTURE) { if_delete_update (ifp); if_delete (ifp); } if_get_flags (ifp); if_get_mtu (ifp); if_get_metric (ifp); if (IS_ZEBRA_DEBUG_KERNEL) zlog_info ("interface %s index %d", ifp->name, ifp->ifindex); return 0; }
int isis_zebra_if_del (int command, struct zclient *zclient, zebra_size_t length) { struct interface *ifp; struct stream *s; s = zclient->ibuf; ifp = zebra_interface_state_read (s); if (!ifp) return 0; if (if_is_operative (ifp)) zlog_warn ("Zebra: got delete of %s, but interface is still up", ifp->name); zlog_debug ("Zebra I/F delete: %s index %d flags %ld metric %d mtu %d", ifp->name, ifp->ifindex, ifp->flags, ifp->metric, ifp->mtu); if_delete (ifp); isis_csm_state_change (IF_DOWN_FROM_Z, circuit_scan_by_ifp (ifp), ifp); return 0; }
static void ospf_vl_if_delete(struct ospf_vl_data *vl_data) { struct interface *ifp = vl_data->vl_oi->ifp; vl_data->vl_oi->address->u.prefix4.s_addr = 0; vl_data->vl_oi->address->prefixlen = 0; ospf_if_free(vl_data->vl_oi); if_delete(ifp); vlink_count--; }