Lines Matching refs:ifp
155 static void addrconf_join_anycast(struct inet6_ifaddr *ifp);
156 static void addrconf_leave_anycast(struct inet6_ifaddr *ifp);
168 static void addrconf_dad_start(struct inet6_ifaddr *ifp);
170 static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id,
312 static void addrconf_del_dad_work(struct inet6_ifaddr *ifp) in addrconf_del_dad_work() argument
314 if (cancel_delayed_work(&ifp->dad_work)) in addrconf_del_dad_work()
315 __in6_ifa_put(ifp); in addrconf_del_dad_work()
326 static void addrconf_mod_dad_work(struct inet6_ifaddr *ifp, in addrconf_mod_dad_work() argument
329 in6_ifa_hold(ifp); in addrconf_mod_dad_work()
330 if (mod_delayed_work(addrconf_wq, &ifp->dad_work, delay)) in addrconf_mod_dad_work()
331 in6_ifa_put(ifp); in addrconf_mod_dad_work()
968 void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp) in inet6_ifa_finish_destroy() argument
970 WARN_ON(!hlist_unhashed(&ifp->addr_lst)); in inet6_ifa_finish_destroy()
976 in6_dev_put(ifp->idev); in inet6_ifa_finish_destroy()
978 if (cancel_delayed_work(&ifp->dad_work)) in inet6_ifa_finish_destroy()
980 ifp); in inet6_ifa_finish_destroy()
982 if (ifp->state != INET6_IFADDR_STATE_DEAD) { in inet6_ifa_finish_destroy()
983 pr_warn("Freeing alive inet6 address %p\n", ifp); in inet6_ifa_finish_destroy()
987 kfree_rcu(ifp, rcu); in inet6_ifa_finish_destroy()
991 ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp) in ipv6_link_dev_addr() argument
994 int ifp_scope = ipv6_addr_src_scope(&ifp->addr); in ipv6_link_dev_addr()
1007 list_add_tail_rcu(&ifp->if_list, p); in ipv6_link_dev_addr()
1020 struct inet6_ifaddr *ifp; in ipv6_chk_same_addr() local
1022 hlist_for_each_entry(ifp, &net->ipv6.inet6_addr_lst[hash], addr_lst) { in ipv6_chk_same_addr()
1023 if (ipv6_addr_equal(&ifp->addr, addr)) { in ipv6_chk_same_addr()
1024 if (!dev || ifp->idev->dev == dev) in ipv6_chk_same_addr()
1206 check_cleanup_prefix_route(struct inet6_ifaddr *ifp, unsigned long *expires) in check_cleanup_prefix_route() argument
1209 struct inet6_dev *idev = ifp->idev; in check_cleanup_prefix_route()
1216 if (ifa == ifp) in check_cleanup_prefix_route()
1218 if (ifa->prefix_len != ifp->prefix_len || in check_cleanup_prefix_route()
1219 !ipv6_prefix_equal(&ifa->addr, &ifp->addr, in check_cleanup_prefix_route()
1220 ifp->prefix_len)) in check_cleanup_prefix_route()
1244 cleanup_prefix_route(struct inet6_ifaddr *ifp, unsigned long expires, in cleanup_prefix_route() argument
1249 f6i = addrconf_get_prefix_route(del_peer ? &ifp->peer_addr : &ifp->addr, in cleanup_prefix_route()
1250 ifp->prefix_len, in cleanup_prefix_route()
1251 ifp->idev->dev, 0, RTF_DEFAULT, true); in cleanup_prefix_route()
1254 ip6_del_rt(dev_net(ifp->idev->dev), f6i, false); in cleanup_prefix_route()
1266 static void ipv6_del_addr(struct inet6_ifaddr *ifp) in ipv6_del_addr() argument
1269 struct net *net = dev_net(ifp->idev->dev); in ipv6_del_addr()
1275 spin_lock_bh(&ifp->lock); in ipv6_del_addr()
1276 state = ifp->state; in ipv6_del_addr()
1277 ifp->state = INET6_IFADDR_STATE_DEAD; in ipv6_del_addr()
1278 spin_unlock_bh(&ifp->lock); in ipv6_del_addr()
1284 hlist_del_init_rcu(&ifp->addr_lst); in ipv6_del_addr()
1287 write_lock_bh(&ifp->idev->lock); in ipv6_del_addr()
1289 if (ifp->flags&IFA_F_TEMPORARY) { in ipv6_del_addr()
1290 list_del(&ifp->tmp_list); in ipv6_del_addr()
1291 if (ifp->ifpub) { in ipv6_del_addr()
1292 in6_ifa_put(ifp->ifpub); in ipv6_del_addr()
1293 ifp->ifpub = NULL; in ipv6_del_addr()
1295 __in6_ifa_put(ifp); in ipv6_del_addr()
1298 if (ifp->flags & IFA_F_PERMANENT && !(ifp->flags & IFA_F_NOPREFIXROUTE)) in ipv6_del_addr()
1299 action = check_cleanup_prefix_route(ifp, &expires); in ipv6_del_addr()
1301 list_del_rcu(&ifp->if_list); in ipv6_del_addr()
1302 __in6_ifa_put(ifp); in ipv6_del_addr()
1304 write_unlock_bh(&ifp->idev->lock); in ipv6_del_addr()
1306 addrconf_del_dad_work(ifp); in ipv6_del_addr()
1308 ipv6_ifa_notify(RTM_DELADDR, ifp); in ipv6_del_addr()
1310 inet6addr_notifier_call_chain(NETDEV_DOWN, ifp); in ipv6_del_addr()
1313 cleanup_prefix_route(ifp, expires, in ipv6_del_addr()
1318 rt6_remove_prefsrc(ifp); in ipv6_del_addr()
1320 in6_ifa_put(ifp); in ipv6_del_addr()
1323 static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, bool block) in ipv6_create_tempaddr() argument
1325 struct inet6_dev *idev = ifp->idev; in ipv6_create_tempaddr()
1347 spin_lock_bh(&ifp->lock); in ipv6_create_tempaddr()
1348 if (ifp->regen_count++ >= idev->cnf.regen_max_retry) { in ipv6_create_tempaddr()
1350 spin_unlock_bh(&ifp->lock); in ipv6_create_tempaddr()
1358 in6_ifa_hold(ifp); in ipv6_create_tempaddr()
1359 memcpy(addr.s6_addr, ifp->addr.s6_addr, 8); in ipv6_create_tempaddr()
1362 age = (now - ifp->tstamp) / HZ; in ipv6_create_tempaddr()
1387 cfg.valid_lft = min_t(__u32, ifp->valid_lft, in ipv6_create_tempaddr()
1390 cfg.preferred_lft = min_t(__u32, ifp->prefered_lft, cfg.preferred_lft); in ipv6_create_tempaddr()
1392 cfg.plen = ifp->prefix_len; in ipv6_create_tempaddr()
1393 tmp_tstamp = ifp->tstamp; in ipv6_create_tempaddr()
1394 spin_unlock_bh(&ifp->lock); in ipv6_create_tempaddr()
1407 in6_ifa_put(ifp); in ipv6_create_tempaddr()
1415 if (ifp->flags & IFA_F_OPTIMISTIC) in ipv6_create_tempaddr()
1423 in6_ifa_put(ifp); in ipv6_create_tempaddr()
1431 ift->ifpub = ifp; in ipv6_create_tempaddr()
1850 struct inet6_ifaddr *ifp; in __ipv6_get_lladdr() local
1853 list_for_each_entry_reverse(ifp, &idev->addr_list, if_list) { in __ipv6_get_lladdr()
1854 if (ifp->scope > IFA_LINK) in __ipv6_get_lladdr()
1856 if (ifp->scope == IFA_LINK && in __ipv6_get_lladdr()
1857 !(ifp->flags & banned_flags)) { in __ipv6_get_lladdr()
1858 *addr = ifp->addr; in __ipv6_get_lladdr()
1885 const struct inet6_ifaddr *ifp; in ipv6_count_addresses() local
1889 list_for_each_entry_rcu(ifp, &idev->addr_list, if_list) in ipv6_count_addresses()
1919 struct inet6_ifaddr *ifp; in __ipv6_chk_addr_and_flags() local
1928 hlist_for_each_entry_rcu(ifp, &net->ipv6.inet6_addr_lst[hash], addr_lst) { in __ipv6_chk_addr_and_flags()
1929 ndev = ifp->idev->dev; in __ipv6_chk_addr_and_flags()
1937 ifp_flags = (ifp->flags&IFA_F_OPTIMISTIC) in __ipv6_chk_addr_and_flags()
1938 ? (ifp->flags&~IFA_F_TENTATIVE) in __ipv6_chk_addr_and_flags()
1939 : ifp->flags; in __ipv6_chk_addr_and_flags()
1940 if (ipv6_addr_equal(&ifp->addr, addr) && in __ipv6_chk_addr_and_flags()
1943 !(ifp->scope&(IFA_LINK|IFA_HOST) || strict))) { in __ipv6_chk_addr_and_flags()
2030 struct inet6_ifaddr *ifp, *result = NULL; in ipv6_get_ifaddr() local
2033 hlist_for_each_entry_rcu(ifp, &net->ipv6.inet6_addr_lst[hash], addr_lst) { in ipv6_get_ifaddr()
2034 if (ipv6_addr_equal(&ifp->addr, addr)) { in ipv6_get_ifaddr()
2035 if (!dev || ifp->idev->dev == dev || in ipv6_get_ifaddr()
2036 !(ifp->scope&(IFA_LINK|IFA_HOST) || strict)) { in ipv6_get_ifaddr()
2037 result = ifp; in ipv6_get_ifaddr()
2038 in6_ifa_hold(ifp); in ipv6_get_ifaddr()
2050 static void addrconf_dad_stop(struct inet6_ifaddr *ifp, int dad_failed) in addrconf_dad_stop() argument
2053 ifp->flags |= IFA_F_DADFAILED; in addrconf_dad_stop()
2055 if (ifp->flags&IFA_F_TEMPORARY) { in addrconf_dad_stop()
2057 spin_lock_bh(&ifp->lock); in addrconf_dad_stop()
2058 ifpub = ifp->ifpub; in addrconf_dad_stop()
2061 spin_unlock_bh(&ifp->lock); in addrconf_dad_stop()
2065 spin_unlock_bh(&ifp->lock); in addrconf_dad_stop()
2067 ipv6_del_addr(ifp); in addrconf_dad_stop()
2068 } else if (ifp->flags&IFA_F_PERMANENT || !dad_failed) { in addrconf_dad_stop()
2069 spin_lock_bh(&ifp->lock); in addrconf_dad_stop()
2070 addrconf_del_dad_work(ifp); in addrconf_dad_stop()
2071 ifp->flags |= IFA_F_TENTATIVE; in addrconf_dad_stop()
2073 ifp->flags &= ~IFA_F_OPTIMISTIC; in addrconf_dad_stop()
2074 spin_unlock_bh(&ifp->lock); in addrconf_dad_stop()
2076 ipv6_ifa_notify(0, ifp); in addrconf_dad_stop()
2077 in6_ifa_put(ifp); in addrconf_dad_stop()
2079 ipv6_del_addr(ifp); in addrconf_dad_stop()
2083 static int addrconf_dad_end(struct inet6_ifaddr *ifp) in addrconf_dad_end() argument
2087 spin_lock_bh(&ifp->lock); in addrconf_dad_end()
2088 if (ifp->state == INET6_IFADDR_STATE_DAD) { in addrconf_dad_end()
2089 ifp->state = INET6_IFADDR_STATE_POSTDAD; in addrconf_dad_end()
2092 spin_unlock_bh(&ifp->lock); in addrconf_dad_end()
2097 void addrconf_dad_failure(struct sk_buff *skb, struct inet6_ifaddr *ifp) in addrconf_dad_failure() argument
2099 struct inet6_dev *idev = ifp->idev; in addrconf_dad_failure()
2102 if (addrconf_dad_end(ifp)) { in addrconf_dad_failure()
2103 in6_ifa_put(ifp); in addrconf_dad_failure()
2108 ifp->idev->dev->name, &ifp->addr, eth_hdr(skb)->h_source); in addrconf_dad_failure()
2110 spin_lock_bh(&ifp->lock); in addrconf_dad_failure()
2112 if (ifp->flags & IFA_F_STABLE_PRIVACY) { in addrconf_dad_failure()
2115 int retries = ifp->stable_privacy_retry + 1; in addrconf_dad_failure()
2118 .plen = ifp->prefix_len, in addrconf_dad_failure()
2119 .ifa_flags = ifp->flags, in addrconf_dad_failure()
2120 .valid_lft = ifp->valid_lft, in addrconf_dad_failure()
2121 .preferred_lft = ifp->prefered_lft, in addrconf_dad_failure()
2122 .scope = ifp->scope, in addrconf_dad_failure()
2127 ifp->idev->dev->name); in addrconf_dad_failure()
2131 new_addr = ifp->addr; in addrconf_dad_failure()
2136 spin_unlock_bh(&ifp->lock); in addrconf_dad_failure()
2144 ifp->idev->dev->name); in addrconf_dad_failure()
2158 spin_lock_bh(&ifp->lock); in addrconf_dad_failure()
2163 ifp->state = INET6_IFADDR_STATE_ERRDAD; in addrconf_dad_failure()
2164 spin_unlock_bh(&ifp->lock); in addrconf_dad_failure()
2166 addrconf_mod_dad_work(ifp, 0); in addrconf_dad_failure()
2167 in6_ifa_put(ifp); in addrconf_dad_failure()
2196 static void addrconf_join_anycast(struct inet6_ifaddr *ifp) in addrconf_join_anycast() argument
2200 if (ifp->prefix_len >= 127) /* RFC 6164 */ in addrconf_join_anycast()
2202 ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len); in addrconf_join_anycast()
2205 __ipv6_dev_ac_inc(ifp->idev, &addr); in addrconf_join_anycast()
2209 static void addrconf_leave_anycast(struct inet6_ifaddr *ifp) in addrconf_leave_anycast() argument
2213 if (ifp->prefix_len >= 127) /* RFC 6164 */ in addrconf_leave_anycast()
2215 ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len); in addrconf_leave_anycast()
2218 __ipv6_dev_ac_dec(ifp->idev, &addr); in addrconf_leave_anycast()
2343 struct inet6_ifaddr *ifp; in ipv6_inherit_eui64() local
2346 list_for_each_entry_reverse(ifp, &idev->addr_list, if_list) { in ipv6_inherit_eui64()
2347 if (ifp->scope > IFA_LINK) in ipv6_inherit_eui64()
2349 if (ifp->scope == IFA_LINK && !(ifp->flags&IFA_F_TENTATIVE)) { in ipv6_inherit_eui64()
2350 memcpy(eui, ifp->addr.s6_addr+8, 8); in ipv6_inherit_eui64()
2513 struct inet6_ifaddr *ifp, in manage_tempaddrs() argument
2525 if (ifp != ift->ifpub) in manage_tempaddrs()
2573 ipv6_create_tempaddr(ifp, false); in manage_tempaddrs()
2592 struct inet6_ifaddr *ifp = ipv6_get_ifaddr(net, addr, dev, 1); in addrconf_prefix_rcv_add_addr() local
2595 if (!ifp && valid_lft) { in addrconf_prefix_rcv_add_addr()
2619 ifp = ipv6_add_addr(in6_dev, &cfg, false, NULL); in addrconf_prefix_rcv_add_addr()
2621 if (IS_ERR_OR_NULL(ifp)) in addrconf_prefix_rcv_add_addr()
2625 spin_lock_bh(&ifp->lock); in addrconf_prefix_rcv_add_addr()
2626 ifp->flags |= IFA_F_MANAGETEMPADDR; in addrconf_prefix_rcv_add_addr()
2627 ifp->cstamp = jiffies; in addrconf_prefix_rcv_add_addr()
2628 ifp->tokenized = tokenized; in addrconf_prefix_rcv_add_addr()
2629 spin_unlock_bh(&ifp->lock); in addrconf_prefix_rcv_add_addr()
2630 addrconf_dad_start(ifp); in addrconf_prefix_rcv_add_addr()
2633 if (ifp) { in addrconf_prefix_rcv_add_addr()
2639 spin_lock_bh(&ifp->lock); in addrconf_prefix_rcv_add_addr()
2641 if (ifp->valid_lft > (now - ifp->tstamp) / HZ) in addrconf_prefix_rcv_add_addr()
2642 stored_lft = ifp->valid_lft - (now - ifp->tstamp) / HZ; in addrconf_prefix_rcv_add_addr()
2664 ifp->valid_lft = valid_lft; in addrconf_prefix_rcv_add_addr()
2665 ifp->prefered_lft = prefered_lft; in addrconf_prefix_rcv_add_addr()
2666 ifp->tstamp = now; in addrconf_prefix_rcv_add_addr()
2667 flags = ifp->flags; in addrconf_prefix_rcv_add_addr()
2668 ifp->flags &= ~IFA_F_DEPRECATED; in addrconf_prefix_rcv_add_addr()
2669 spin_unlock_bh(&ifp->lock); in addrconf_prefix_rcv_add_addr()
2672 ipv6_ifa_notify(0, ifp); in addrconf_prefix_rcv_add_addr()
2674 spin_unlock_bh(&ifp->lock); in addrconf_prefix_rcv_add_addr()
2676 manage_tempaddrs(in6_dev, ifp, valid_lft, prefered_lft, in addrconf_prefix_rcv_add_addr()
2679 in6_ifa_put(ifp); in addrconf_prefix_rcv_add_addr()
2914 struct inet6_ifaddr *ifp; in inet6_addr_add() local
2969 ifp = ipv6_add_addr(idev, cfg, true, extack); in inet6_addr_add()
2970 if (!IS_ERR(ifp)) { in inet6_addr_add()
2972 addrconf_prefix_route(&ifp->addr, ifp->prefix_len, in inet6_addr_add()
2973 ifp->rt_priority, dev, expires, in inet6_addr_add()
2980 if (!(ifp->flags & (IFA_F_OPTIMISTIC | IFA_F_NODAD))) in inet6_addr_add()
2981 ipv6_ifa_notify(0, ifp); in inet6_addr_add()
2987 addrconf_dad_start(ifp); in inet6_addr_add()
2989 manage_tempaddrs(idev, ifp, cfg->valid_lft, in inet6_addr_add()
2991 in6_ifa_put(ifp); in inet6_addr_add()
2999 return PTR_ERR(ifp); in inet6_addr_add()
3005 struct inet6_ifaddr *ifp; in inet6_addr_del() local
3021 list_for_each_entry(ifp, &idev->addr_list, if_list) { in inet6_addr_del()
3022 if (ifp->prefix_len == plen && in inet6_addr_del()
3023 ipv6_addr_equal(pfx, &ifp->addr)) { in inet6_addr_del()
3024 in6_ifa_hold(ifp); in inet6_addr_del()
3027 if (!(ifp->flags & IFA_F_TEMPORARY) && in inet6_addr_del()
3029 manage_tempaddrs(idev, ifp, 0, 0, false, in inet6_addr_del()
3031 ipv6_del_addr(ifp); in inet6_addr_del()
3091 struct inet6_ifaddr *ifp; in add_addr() local
3102 ifp = ipv6_add_addr(idev, &cfg, true, NULL); in add_addr()
3103 if (!IS_ERR(ifp)) { in add_addr()
3104 spin_lock_bh(&ifp->lock); in add_addr()
3105 ifp->flags &= ~IFA_F_TENTATIVE; in add_addr()
3106 spin_unlock_bh(&ifp->lock); in add_addr()
3108 ipv6_ifa_notify(RTM_NEWADDR, ifp); in add_addr()
3109 in6_ifa_put(ifp); in add_addr()
3206 struct inet6_ifaddr *ifp; in addrconf_add_linklocal() local
3215 ifp = ipv6_add_addr(idev, &cfg, true, NULL); in addrconf_add_linklocal()
3216 if (!IS_ERR(ifp)) { in addrconf_add_linklocal()
3217 addrconf_prefix_route(&ifp->addr, ifp->prefix_len, 0, idev->dev, in addrconf_add_linklocal()
3219 addrconf_dad_start(ifp); in addrconf_add_linklocal()
3220 in6_ifa_put(ifp); in addrconf_add_linklocal()
3452 struct inet6_ifaddr *ifp) in fixup_permanent_addr() argument
3458 if (!ifp->rt || !ifp->rt->fib6_node) { in fixup_permanent_addr()
3461 f6i = addrconf_f6i_alloc(net, idev, &ifp->addr, false, in fixup_permanent_addr()
3467 spin_lock(&ifp->lock); in fixup_permanent_addr()
3468 prev = ifp->rt; in fixup_permanent_addr()
3469 ifp->rt = f6i; in fixup_permanent_addr()
3470 spin_unlock(&ifp->lock); in fixup_permanent_addr()
3475 if (!(ifp->flags & IFA_F_NOPREFIXROUTE)) { in fixup_permanent_addr()
3476 addrconf_prefix_route(&ifp->addr, ifp->prefix_len, in fixup_permanent_addr()
3477 ifp->rt_priority, idev->dev, 0, 0, in fixup_permanent_addr()
3481 if (ifp->state == INET6_IFADDR_STATE_PREDAD) in fixup_permanent_addr()
3482 addrconf_dad_start(ifp); in fixup_permanent_addr()
3489 struct inet6_ifaddr *ifp, *tmp; in addrconf_permanent_addr() local
3498 list_for_each_entry_safe(ifp, tmp, &idev->addr_list, if_list) { in addrconf_permanent_addr()
3499 if ((ifp->flags & IFA_F_PERMANENT) && in addrconf_permanent_addr()
3500 fixup_permanent_addr(net, idev, ifp) < 0) { in addrconf_permanent_addr()
3502 in6_ifa_hold(ifp); in addrconf_permanent_addr()
3503 ipv6_del_addr(ifp); in addrconf_permanent_addr()
3507 idev->dev->name, &ifp->addr); in addrconf_permanent_addr()
3961 static void addrconf_dad_kick(struct inet6_ifaddr *ifp) in addrconf_dad_kick() argument
3964 struct inet6_dev *idev = ifp->idev; in addrconf_dad_kick()
3967 if (ifp->flags & IFA_F_OPTIMISTIC) in addrconf_dad_kick()
3979 ifp->dad_nonce = nonce; in addrconf_dad_kick()
3980 ifp->dad_probes = idev->cnf.dad_transmits; in addrconf_dad_kick()
3981 addrconf_mod_dad_work(ifp, rand_num); in addrconf_dad_kick()
3984 static void addrconf_dad_begin(struct inet6_ifaddr *ifp) in addrconf_dad_begin() argument
3986 struct inet6_dev *idev = ifp->idev; in addrconf_dad_begin()
3991 addrconf_join_solict(dev, &ifp->addr); in addrconf_dad_begin()
3994 spin_lock(&ifp->lock); in addrconf_dad_begin()
3995 if (ifp->state == INET6_IFADDR_STATE_DEAD) in addrconf_dad_begin()
4002 !(ifp->flags&IFA_F_TENTATIVE) || in addrconf_dad_begin()
4003 ifp->flags & IFA_F_NODAD) { in addrconf_dad_begin()
4006 if (ifp->flags & IFA_F_TENTATIVE && in addrconf_dad_begin()
4007 !(ifp->flags & IFA_F_OPTIMISTIC)) in addrconf_dad_begin()
4009 bump_id = ifp->flags & IFA_F_TENTATIVE; in addrconf_dad_begin()
4010 ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED); in addrconf_dad_begin()
4011 spin_unlock(&ifp->lock); in addrconf_dad_begin()
4014 addrconf_dad_completed(ifp, bump_id, send_na); in addrconf_dad_begin()
4019 spin_unlock(&ifp->lock); in addrconf_dad_begin()
4026 in6_ifa_hold(ifp); in addrconf_dad_begin()
4027 addrconf_dad_stop(ifp, 0); in addrconf_dad_begin()
4035 if (ifp->flags & IFA_F_OPTIMISTIC) { in addrconf_dad_begin()
4036 ip6_ins_rt(net, ifp->rt); in addrconf_dad_begin()
4045 addrconf_dad_kick(ifp); in addrconf_dad_begin()
4047 spin_unlock(&ifp->lock); in addrconf_dad_begin()
4050 ipv6_ifa_notify(RTM_NEWADDR, ifp); in addrconf_dad_begin()
4053 static void addrconf_dad_start(struct inet6_ifaddr *ifp) in addrconf_dad_start() argument
4057 spin_lock_bh(&ifp->lock); in addrconf_dad_start()
4058 if (ifp->state != INET6_IFADDR_STATE_DEAD) { in addrconf_dad_start()
4059 ifp->state = INET6_IFADDR_STATE_PREDAD; in addrconf_dad_start()
4062 spin_unlock_bh(&ifp->lock); in addrconf_dad_start()
4065 addrconf_mod_dad_work(ifp, 0); in addrconf_dad_start()
4070 struct inet6_ifaddr *ifp = container_of(to_delayed_work(w), in addrconf_dad_work() local
4073 struct inet6_dev *idev = ifp->idev; in addrconf_dad_work()
4085 spin_lock_bh(&ifp->lock); in addrconf_dad_work()
4086 if (ifp->state == INET6_IFADDR_STATE_PREDAD) { in addrconf_dad_work()
4088 ifp->state = INET6_IFADDR_STATE_DAD; in addrconf_dad_work()
4089 } else if (ifp->state == INET6_IFADDR_STATE_ERRDAD) { in addrconf_dad_work()
4091 ifp->state = INET6_IFADDR_STATE_POSTDAD; in addrconf_dad_work()
4096 !(ifp->flags & IFA_F_STABLE_PRIVACY)) { in addrconf_dad_work()
4103 ipv6_addr_equal(&ifp->addr, &addr)) { in addrconf_dad_work()
4108 ifp->idev->dev->name); in addrconf_dad_work()
4113 spin_unlock_bh(&ifp->lock); in addrconf_dad_work()
4116 addrconf_dad_begin(ifp); in addrconf_dad_work()
4119 in6_ifa_hold(ifp); in addrconf_dad_work()
4120 addrconf_dad_stop(ifp, 1); in addrconf_dad_work()
4126 if (!ifp->dad_probes && addrconf_dad_end(ifp)) in addrconf_dad_work()
4135 spin_lock(&ifp->lock); in addrconf_dad_work()
4136 if (ifp->state == INET6_IFADDR_STATE_DEAD) { in addrconf_dad_work()
4137 spin_unlock(&ifp->lock); in addrconf_dad_work()
4142 if (ifp->dad_probes == 0) { in addrconf_dad_work()
4149 if (ifp->flags & IFA_F_TENTATIVE && in addrconf_dad_work()
4150 !(ifp->flags & IFA_F_OPTIMISTIC)) in addrconf_dad_work()
4152 bump_id = ifp->flags & IFA_F_TENTATIVE; in addrconf_dad_work()
4153 ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED); in addrconf_dad_work()
4154 spin_unlock(&ifp->lock); in addrconf_dad_work()
4157 addrconf_dad_completed(ifp, bump_id, send_na); in addrconf_dad_work()
4162 ifp->dad_probes--; in addrconf_dad_work()
4163 addrconf_mod_dad_work(ifp, in addrconf_dad_work()
4164 max(NEIGH_VAR(ifp->idev->nd_parms, RETRANS_TIME), in addrconf_dad_work()
4166 spin_unlock(&ifp->lock); in addrconf_dad_work()
4170 addrconf_addr_solict_mult(&ifp->addr, &mcaddr); in addrconf_dad_work()
4171 ndisc_send_ns(ifp->idev->dev, &ifp->addr, &mcaddr, &in6addr_any, in addrconf_dad_work()
4172 ifp->dad_nonce); in addrconf_dad_work()
4174 in6_ifa_put(ifp); in addrconf_dad_work()
4179 static bool ipv6_lonely_lladdr(struct inet6_ifaddr *ifp) in ipv6_lonely_lladdr() argument
4182 struct inet6_dev *idev = ifp->idev; in ipv6_lonely_lladdr()
4187 if (ifp != ifpiter && ifpiter->scope == IFA_LINK && in ipv6_lonely_lladdr()
4196 static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id, in addrconf_dad_completed() argument
4199 struct net_device *dev = ifp->idev->dev; in addrconf_dad_completed()
4203 addrconf_del_dad_work(ifp); in addrconf_dad_completed()
4209 ipv6_ifa_notify(RTM_NEWADDR, ifp); in addrconf_dad_completed()
4215 read_lock_bh(&ifp->idev->lock); in addrconf_dad_completed()
4216 send_mld = ifp->scope == IFA_LINK && ipv6_lonely_lladdr(ifp); in addrconf_dad_completed()
4218 ipv6_accept_ra(ifp->idev) && in addrconf_dad_completed()
4219 ifp->idev->cnf.rtr_solicits != 0 && in addrconf_dad_completed()
4222 read_unlock_bh(&ifp->idev->lock); in addrconf_dad_completed()
4228 ipv6_mc_dad_complete(ifp->idev); in addrconf_dad_completed()
4232 (ifp->idev->cnf.ndisc_notify || in addrconf_dad_completed()
4234 ndisc_send_na(dev, &in6addr_linklocal_allnodes, &ifp->addr, in addrconf_dad_completed()
4235 /*router=*/ !!ifp->idev->cnf.forwarding, in addrconf_dad_completed()
4250 write_lock_bh(&ifp->idev->lock); in addrconf_dad_completed()
4251 spin_lock(&ifp->lock); in addrconf_dad_completed()
4252 ifp->idev->rs_interval = rfc3315_s14_backoff_init( in addrconf_dad_completed()
4253 ifp->idev->cnf.rtr_solicit_interval); in addrconf_dad_completed()
4254 ifp->idev->rs_probes = 1; in addrconf_dad_completed()
4255 ifp->idev->if_flags |= IF_RS_SENT; in addrconf_dad_completed()
4256 addrconf_mod_rs_timer(ifp->idev, ifp->idev->rs_interval); in addrconf_dad_completed()
4257 spin_unlock(&ifp->lock); in addrconf_dad_completed()
4258 write_unlock_bh(&ifp->idev->lock); in addrconf_dad_completed()
4267 if (ifp->flags & IFA_F_TEMPORARY) in addrconf_dad_completed()
4273 struct inet6_ifaddr *ifp; in addrconf_dad_run() local
4276 list_for_each_entry(ifp, &idev->addr_list, if_list) { in addrconf_dad_run()
4277 spin_lock(&ifp->lock); in addrconf_dad_run()
4278 if ((ifp->flags & IFA_F_TENTATIVE && in addrconf_dad_run()
4279 ifp->state == INET6_IFADDR_STATE_DAD) || restart) { in addrconf_dad_run()
4281 ifp->state = INET6_IFADDR_STATE_PREDAD; in addrconf_dad_run()
4282 addrconf_dad_kick(ifp); in addrconf_dad_run()
4284 spin_unlock(&ifp->lock); in addrconf_dad_run()
4373 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v; in if6_seq_show() local
4375 &ifp->addr, in if6_seq_show()
4376 ifp->idev->dev->ifindex, in if6_seq_show()
4377 ifp->prefix_len, in if6_seq_show()
4378 ifp->scope, in if6_seq_show()
4379 (u8) ifp->flags, in if6_seq_show()
4380 ifp->idev->dev->name); in if6_seq_show()
4425 struct inet6_ifaddr *ifp = NULL; in ipv6_chk_home_addr() local
4429 hlist_for_each_entry_rcu(ifp, &net->ipv6.inet6_addr_lst[hash], addr_lst) { in ipv6_chk_home_addr()
4430 if (ipv6_addr_equal(&ifp->addr, addr) && in ipv6_chk_home_addr()
4431 (ifp->flags & IFA_F_HOMEADDRESS)) { in ipv6_chk_home_addr()
4456 struct inet6_ifaddr *ifp; in ipv6_chk_rpl_srh_loop() local
4467 hlist_for_each_entry_rcu(ifp, &net->ipv6.inet6_addr_lst[hash], addr_lst) { in ipv6_chk_rpl_srh_loop()
4469 if (ipv6_addr_equal(&ifp->addr, addr)) { in ipv6_chk_rpl_srh_loop()
4499 struct inet6_ifaddr *ifp; in addrconf_verify_rtnl() local
4512 hlist_for_each_entry_rcu_bh(ifp, &net->ipv6.inet6_addr_lst[i], addr_lst) { in addrconf_verify_rtnl()
4519 if ((ifp->flags & IFA_F_PERMANENT) && in addrconf_verify_rtnl()
4520 (ifp->prefered_lft == INFINITY_LIFE_TIME)) in addrconf_verify_rtnl()
4523 spin_lock(&ifp->lock); in addrconf_verify_rtnl()
4525 age = (now - ifp->tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ; in addrconf_verify_rtnl()
4527 if ((ifp->flags&IFA_F_TEMPORARY) && in addrconf_verify_rtnl()
4528 !(ifp->flags&IFA_F_TENTATIVE) && in addrconf_verify_rtnl()
4529 ifp->prefered_lft != INFINITY_LIFE_TIME && in addrconf_verify_rtnl()
4530 !ifp->regen_count && ifp->ifpub) { in addrconf_verify_rtnl()
4533 unsigned long regen_advance = ifp->idev->cnf.regen_max_retry * in addrconf_verify_rtnl()
4534 ifp->idev->cnf.dad_transmits * in addrconf_verify_rtnl()
4535 max(NEIGH_VAR(ifp->idev->nd_parms, RETRANS_TIME), HZ/100) / HZ; in addrconf_verify_rtnl()
4537 if (age + regen_advance >= ifp->prefered_lft) { in addrconf_verify_rtnl()
4538 struct inet6_ifaddr *ifpub = ifp->ifpub; in addrconf_verify_rtnl()
4539 if (time_before(ifp->tstamp + ifp->prefered_lft * HZ, next)) in addrconf_verify_rtnl()
4540 next = ifp->tstamp + ifp->prefered_lft * HZ; in addrconf_verify_rtnl()
4542 ifp->regen_count++; in addrconf_verify_rtnl()
4543 in6_ifa_hold(ifp); in addrconf_verify_rtnl()
4545 spin_unlock(&ifp->lock); in addrconf_verify_rtnl()
4553 in6_ifa_put(ifp); in addrconf_verify_rtnl()
4556 } else if (time_before(ifp->tstamp + ifp->prefered_lft * HZ - regen_advance * HZ, next)) in addrconf_verify_rtnl()
4557 next = ifp->tstamp + ifp->prefered_lft * HZ - regen_advance * HZ; in addrconf_verify_rtnl()
4560 if (ifp->valid_lft != INFINITY_LIFE_TIME && in addrconf_verify_rtnl()
4561 age >= ifp->valid_lft) { in addrconf_verify_rtnl()
4562 spin_unlock(&ifp->lock); in addrconf_verify_rtnl()
4563 in6_ifa_hold(ifp); in addrconf_verify_rtnl()
4565 ipv6_del_addr(ifp); in addrconf_verify_rtnl()
4568 } else if (ifp->prefered_lft == INFINITY_LIFE_TIME) { in addrconf_verify_rtnl()
4569 spin_unlock(&ifp->lock); in addrconf_verify_rtnl()
4571 } else if (age >= ifp->prefered_lft) { in addrconf_verify_rtnl()
4575 if (!(ifp->flags&IFA_F_DEPRECATED)) { in addrconf_verify_rtnl()
4577 ifp->flags |= IFA_F_DEPRECATED; in addrconf_verify_rtnl()
4580 if ((ifp->valid_lft != INFINITY_LIFE_TIME) && in addrconf_verify_rtnl()
4581 (time_before(ifp->tstamp + ifp->valid_lft * HZ, next))) in addrconf_verify_rtnl()
4582 next = ifp->tstamp + ifp->valid_lft * HZ; in addrconf_verify_rtnl()
4584 spin_unlock(&ifp->lock); in addrconf_verify_rtnl()
4587 in6_ifa_hold(ifp); in addrconf_verify_rtnl()
4589 ipv6_ifa_notify(0, ifp); in addrconf_verify_rtnl()
4590 in6_ifa_put(ifp); in addrconf_verify_rtnl()
4595 if (time_before(ifp->tstamp + ifp->prefered_lft * HZ, next)) in addrconf_verify_rtnl()
4596 next = ifp->tstamp + ifp->prefered_lft * HZ; in addrconf_verify_rtnl()
4597 spin_unlock(&ifp->lock); in addrconf_verify_rtnl()
4693 static int modify_prefix_route(struct inet6_ifaddr *ifp, in modify_prefix_route() argument
4700 f6i = addrconf_get_prefix_route(modify_peer ? &ifp->peer_addr : &ifp->addr, in modify_prefix_route()
4701 ifp->prefix_len, in modify_prefix_route()
4702 ifp->idev->dev, 0, RTF_DEFAULT, true); in modify_prefix_route()
4706 prio = ifp->rt_priority ? : IP6_RT_PRIO_ADDRCONF; in modify_prefix_route()
4709 ip6_del_rt(dev_net(ifp->idev->dev), f6i, false); in modify_prefix_route()
4712 addrconf_prefix_route(modify_peer ? &ifp->peer_addr : &ifp->addr, in modify_prefix_route()
4713 ifp->prefix_len, in modify_prefix_route()
4714 ifp->rt_priority, ifp->idev->dev, in modify_prefix_route()
4728 static int inet6_addr_modify(struct net *net, struct inet6_ifaddr *ifp, in inet6_addr_modify() argument
4744 (ifp->flags & IFA_F_TEMPORARY || ifp->prefix_len != 64)) in inet6_addr_modify()
4747 if (!(ifp->flags & IFA_F_TENTATIVE) || ifp->flags & IFA_F_DADFAILED) in inet6_addr_modify()
4769 memcmp(&ifp->peer_addr, cfg->peer_pfx, sizeof(struct in6_addr))) { in inet6_addr_modify()
4770 if (!ipv6_addr_any(&ifp->peer_addr)) in inet6_addr_modify()
4771 cleanup_prefix_route(ifp, expires, true, true); in inet6_addr_modify()
4775 spin_lock_bh(&ifp->lock); in inet6_addr_modify()
4776 was_managetempaddr = ifp->flags & IFA_F_MANAGETEMPADDR; in inet6_addr_modify()
4777 had_prefixroute = ifp->flags & IFA_F_PERMANENT && in inet6_addr_modify()
4778 !(ifp->flags & IFA_F_NOPREFIXROUTE); in inet6_addr_modify()
4779 ifp->flags &= ~(IFA_F_DEPRECATED | IFA_F_PERMANENT | IFA_F_NODAD | in inet6_addr_modify()
4782 ifp->flags |= cfg->ifa_flags; in inet6_addr_modify()
4783 ifp->tstamp = jiffies; in inet6_addr_modify()
4784 ifp->valid_lft = cfg->valid_lft; in inet6_addr_modify()
4785 ifp->prefered_lft = cfg->preferred_lft; in inet6_addr_modify()
4786 ifp->ifa_proto = cfg->ifa_proto; in inet6_addr_modify()
4788 if (cfg->rt_priority && cfg->rt_priority != ifp->rt_priority) in inet6_addr_modify()
4789 ifp->rt_priority = cfg->rt_priority; in inet6_addr_modify()
4792 ifp->peer_addr = *cfg->peer_pfx; in inet6_addr_modify()
4794 spin_unlock_bh(&ifp->lock); in inet6_addr_modify()
4795 if (!(ifp->flags&IFA_F_TENTATIVE)) in inet6_addr_modify()
4796 ipv6_ifa_notify(0, ifp); in inet6_addr_modify()
4802 rc = modify_prefix_route(ifp, expires, flags, false); in inet6_addr_modify()
4806 addrconf_prefix_route(&ifp->addr, ifp->prefix_len, in inet6_addr_modify()
4807 ifp->rt_priority, ifp->idev->dev, in inet6_addr_modify()
4811 if (had_prefixroute && !ipv6_addr_any(&ifp->peer_addr)) in inet6_addr_modify()
4812 rc = modify_prefix_route(ifp, expires, flags, true); in inet6_addr_modify()
4814 if (rc == -ENOENT && !ipv6_addr_any(&ifp->peer_addr)) { in inet6_addr_modify()
4815 addrconf_prefix_route(&ifp->peer_addr, ifp->prefix_len, in inet6_addr_modify()
4816 ifp->rt_priority, ifp->idev->dev, in inet6_addr_modify()
4823 write_lock_bh(&ifp->idev->lock); in inet6_addr_modify()
4824 action = check_cleanup_prefix_route(ifp, &rt_expires); in inet6_addr_modify()
4825 write_unlock_bh(&ifp->idev->lock); in inet6_addr_modify()
4828 cleanup_prefix_route(ifp, rt_expires, in inet6_addr_modify()
4833 if (was_managetempaddr || ifp->flags & IFA_F_MANAGETEMPADDR) { in inet6_addr_modify()
4835 !(ifp->flags & IFA_F_MANAGETEMPADDR)) { in inet6_addr_modify()
4839 manage_tempaddrs(ifp->idev, ifp, cfg->valid_lft, in inet6_addr_modify()
5750 struct inet6_ifaddr *ifp; in inet6_set_iftoken() local
5816 list_for_each_entry(ifp, &idev->addr_list, if_list) { in inet6_set_iftoken()
5817 spin_lock(&ifp->lock); in inet6_set_iftoken()
5818 if (ifp->tokenized) { in inet6_set_iftoken()
5819 ifp->valid_lft = 0; in inet6_set_iftoken()
5820 ifp->prefered_lft = 0; in inet6_set_iftoken()
5822 spin_unlock(&ifp->lock); in inet6_set_iftoken()
6137 static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp) in __ipv6_ifa_notify() argument
6139 struct net *net = dev_net(ifp->idev->dev); in __ipv6_ifa_notify()
6144 inet6_ifa_notify(event ? : RTM_NEWADDR, ifp); in __ipv6_ifa_notify()
6156 if (ifp->rt && !rcu_access_pointer(ifp->rt->fib6_node)) { in __ipv6_ifa_notify()
6157 ip6_ins_rt(net, ifp->rt); in __ipv6_ifa_notify()
6158 } else if (!ifp->rt && (ifp->idev->dev->flags & IFF_UP)) { in __ipv6_ifa_notify()
6160 &ifp->addr, ifp->idev->dev->name); in __ipv6_ifa_notify()
6163 if (ifp->idev->cnf.forwarding) in __ipv6_ifa_notify()
6164 addrconf_join_anycast(ifp); in __ipv6_ifa_notify()
6165 if (!ipv6_addr_any(&ifp->peer_addr)) in __ipv6_ifa_notify()
6166 addrconf_prefix_route(&ifp->peer_addr, 128, in __ipv6_ifa_notify()
6167 ifp->rt_priority, ifp->idev->dev, in __ipv6_ifa_notify()
6171 if (ifp->idev->cnf.forwarding) in __ipv6_ifa_notify()
6172 addrconf_leave_anycast(ifp); in __ipv6_ifa_notify()
6173 addrconf_leave_solict(ifp->idev, &ifp->addr); in __ipv6_ifa_notify()
6174 if (!ipv6_addr_any(&ifp->peer_addr)) { in __ipv6_ifa_notify()
6177 rt = addrconf_get_prefix_route(&ifp->peer_addr, 128, in __ipv6_ifa_notify()
6178 ifp->idev->dev, 0, 0, in __ipv6_ifa_notify()
6183 if (ifp->rt) { in __ipv6_ifa_notify()
6184 ip6_del_rt(net, ifp->rt, false); in __ipv6_ifa_notify()
6185 ifp->rt = NULL; in __ipv6_ifa_notify()
6193 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp) in ipv6_ifa_notify() argument
6195 if (likely(ifp->idev->dead == 0)) in ipv6_ifa_notify()
6196 __ipv6_ifa_notify(event, ifp); in ipv6_ifa_notify()