Lines Matching full:ifp

154 static void addrconf_join_anycast(struct inet6_ifaddr *ifp);
155 static void addrconf_leave_anycast(struct inet6_ifaddr *ifp);
167 static void addrconf_dad_start(struct inet6_ifaddr *ifp);
169 static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id,
319 static void addrconf_del_dad_work(struct inet6_ifaddr *ifp) in addrconf_del_dad_work() argument
321 if (cancel_delayed_work(&ifp->dad_work)) in addrconf_del_dad_work()
322 __in6_ifa_put(ifp); in addrconf_del_dad_work()
332 static void addrconf_mod_dad_work(struct inet6_ifaddr *ifp, in addrconf_mod_dad_work() argument
335 in6_ifa_hold(ifp); in addrconf_mod_dad_work()
336 if (mod_delayed_work(addrconf_wq, &ifp->dad_work, delay)) in addrconf_mod_dad_work()
337 in6_ifa_put(ifp); in addrconf_mod_dad_work()
975 void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp) in inet6_ifa_finish_destroy() argument
977 WARN_ON(!hlist_unhashed(&ifp->addr_lst)); in inet6_ifa_finish_destroy()
983 in6_dev_put(ifp->idev); in inet6_ifa_finish_destroy()
985 if (cancel_delayed_work(&ifp->dad_work)) in inet6_ifa_finish_destroy()
987 ifp); in inet6_ifa_finish_destroy()
989 if (ifp->state != INET6_IFADDR_STATE_DEAD) { in inet6_ifa_finish_destroy()
990 pr_warn("Freeing alive inet6 address %p\n", ifp); in inet6_ifa_finish_destroy()
994 kfree_rcu(ifp, rcu); in inet6_ifa_finish_destroy()
998 ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp) in ipv6_link_dev_addr() argument
1001 int ifp_scope = ipv6_addr_src_scope(&ifp->addr); in ipv6_link_dev_addr()
1014 list_add_tail_rcu(&ifp->if_list, p); in ipv6_link_dev_addr()
1027 struct inet6_ifaddr *ifp; in ipv6_chk_same_addr() local
1029 hlist_for_each_entry(ifp, &net->ipv6.inet6_addr_lst[hash], addr_lst) { in ipv6_chk_same_addr()
1030 if (ipv6_addr_equal(&ifp->addr, addr)) { in ipv6_chk_same_addr()
1031 if (!dev || ifp->idev->dev == dev) in ipv6_chk_same_addr()
1059 /* On success it returns ifp with increased reference count */
1203 * Check, whether the prefix for ifp would still need a prefix route
1204 * after deleting ifp. The function returns one of the CLEANUP_PREFIX_RT_*
1221 check_cleanup_prefix_route(struct inet6_ifaddr *ifp, unsigned long *expires) in check_cleanup_prefix_route() argument
1224 struct inet6_dev *idev = ifp->idev; in check_cleanup_prefix_route()
1231 if (ifa == ifp) in check_cleanup_prefix_route()
1233 if (ifa->prefix_len != ifp->prefix_len || in check_cleanup_prefix_route()
1234 !ipv6_prefix_equal(&ifa->addr, &ifp->addr, in check_cleanup_prefix_route()
1235 ifp->prefix_len)) in check_cleanup_prefix_route()
1259 cleanup_prefix_route(struct inet6_ifaddr *ifp, unsigned long expires, in cleanup_prefix_route() argument
1265 f6i = addrconf_get_prefix_route(del_peer ? &ifp->peer_addr : &ifp->addr, in cleanup_prefix_route()
1266 ifp->prefix_len, in cleanup_prefix_route()
1267 ifp->idev->dev, 0, RTF_DEFAULT, true); in cleanup_prefix_route()
1270 ip6_del_rt(dev_net(ifp->idev->dev), f6i, false); in cleanup_prefix_route()
1287 /* This function wants to get referenced ifp and releases it before return */
1289 static void ipv6_del_addr(struct inet6_ifaddr *ifp) in ipv6_del_addr() argument
1292 struct net *net = dev_net(ifp->idev->dev); in ipv6_del_addr()
1298 spin_lock_bh(&ifp->lock); in ipv6_del_addr()
1299 state = ifp->state; in ipv6_del_addr()
1300 ifp->state = INET6_IFADDR_STATE_DEAD; in ipv6_del_addr()
1301 spin_unlock_bh(&ifp->lock); in ipv6_del_addr()
1307 hlist_del_init_rcu(&ifp->addr_lst); in ipv6_del_addr()
1310 write_lock_bh(&ifp->idev->lock); in ipv6_del_addr()
1312 if (ifp->flags&IFA_F_TEMPORARY) { in ipv6_del_addr()
1313 list_del(&ifp->tmp_list); in ipv6_del_addr()
1314 if (ifp->ifpub) { in ipv6_del_addr()
1315 in6_ifa_put(ifp->ifpub); in ipv6_del_addr()
1316 ifp->ifpub = NULL; in ipv6_del_addr()
1318 __in6_ifa_put(ifp); in ipv6_del_addr()
1321 if (ifp->flags & IFA_F_PERMANENT && !(ifp->flags & IFA_F_NOPREFIXROUTE)) in ipv6_del_addr()
1322 action = check_cleanup_prefix_route(ifp, &expires); in ipv6_del_addr()
1324 list_del_rcu(&ifp->if_list); in ipv6_del_addr()
1325 __in6_ifa_put(ifp); in ipv6_del_addr()
1327 write_unlock_bh(&ifp->idev->lock); in ipv6_del_addr()
1329 addrconf_del_dad_work(ifp); in ipv6_del_addr()
1331 ipv6_ifa_notify(RTM_DELADDR, ifp); in ipv6_del_addr()
1333 inet6addr_notifier_call_chain(NETDEV_DOWN, ifp); in ipv6_del_addr()
1336 cleanup_prefix_route(ifp, expires, in ipv6_del_addr()
1341 rt6_remove_prefsrc(ifp); in ipv6_del_addr()
1343 in6_ifa_put(ifp); in ipv6_del_addr()
1354 static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, bool block) in ipv6_create_tempaddr() argument
1356 struct inet6_dev *idev = ifp->idev; in ipv6_create_tempaddr()
1379 spin_lock_bh(&ifp->lock); in ipv6_create_tempaddr()
1380 if (ifp->regen_count++ >= READ_ONCE(idev->cnf.regen_max_retry)) { in ipv6_create_tempaddr()
1382 spin_unlock_bh(&ifp->lock); in ipv6_create_tempaddr()
1390 in6_ifa_hold(ifp); in ipv6_create_tempaddr()
1391 memcpy(addr.s6_addr, ifp->addr.s6_addr, 8); in ipv6_create_tempaddr()
1394 age = (now - ifp->tstamp) / HZ; in ipv6_create_tempaddr()
1416 if_public_preferred_lft = ifp->prefered_lft; in ipv6_create_tempaddr()
1419 cfg.valid_lft = min_t(__u32, ifp->valid_lft, in ipv6_create_tempaddr()
1425 cfg.plen = ifp->prefix_len; in ipv6_create_tempaddr()
1426 tmp_tstamp = ifp->tstamp; in ipv6_create_tempaddr()
1427 spin_unlock_bh(&ifp->lock); in ipv6_create_tempaddr()
1451 * ifp->prefered_lft. in ipv6_create_tempaddr()
1461 in6_ifa_put(ifp); in ipv6_create_tempaddr()
1470 if (ifp->flags & IFA_F_OPTIMISTIC) in ipv6_create_tempaddr()
1478 in6_ifa_put(ifp); in ipv6_create_tempaddr()
1486 ift->ifpub = ifp; in ipv6_create_tempaddr()
1909 struct inet6_ifaddr *ifp; in __ipv6_get_lladdr() local
1912 list_for_each_entry_reverse(ifp, &idev->addr_list, if_list) { in __ipv6_get_lladdr()
1913 if (ifp->scope > IFA_LINK) in __ipv6_get_lladdr()
1915 if (ifp->scope == IFA_LINK && in __ipv6_get_lladdr()
1916 !(ifp->flags & banned_flags)) { in __ipv6_get_lladdr()
1917 *addr = ifp->addr; in __ipv6_get_lladdr()
1944 const struct inet6_ifaddr *ifp; in ipv6_count_addresses() local
1948 list_for_each_entry_rcu(ifp, &idev->addr_list, if_list) in ipv6_count_addresses()
1963 * skip_dev_check is set, then the ifp device is not checked against
1978 struct inet6_ifaddr *ifp; in __ipv6_chk_addr_and_flags() local
1987 hlist_for_each_entry_rcu(ifp, &net->ipv6.inet6_addr_lst[hash], addr_lst) { in __ipv6_chk_addr_and_flags()
1988 ndev = ifp->idev->dev; in __ipv6_chk_addr_and_flags()
1996 ifp_flags = (ifp->flags&IFA_F_OPTIMISTIC) in __ipv6_chk_addr_and_flags()
1997 ? (ifp->flags&~IFA_F_TENTATIVE) in __ipv6_chk_addr_and_flags()
1998 : ifp->flags; in __ipv6_chk_addr_and_flags()
1999 if (ipv6_addr_equal(&ifp->addr, addr) && in __ipv6_chk_addr_and_flags()
2002 !(ifp->scope&(IFA_LINK|IFA_HOST) || strict))) { in __ipv6_chk_addr_and_flags()
2089 struct inet6_ifaddr *ifp, *result = NULL; in ipv6_get_ifaddr() local
2092 hlist_for_each_entry_rcu(ifp, &net->ipv6.inet6_addr_lst[hash], addr_lst) { in ipv6_get_ifaddr()
2093 if (ipv6_addr_equal(&ifp->addr, addr)) { in ipv6_get_ifaddr()
2094 if (!dev || ifp->idev->dev == dev || in ipv6_get_ifaddr()
2095 !(ifp->scope&(IFA_LINK|IFA_HOST) || strict)) { in ipv6_get_ifaddr()
2096 if (in6_ifa_hold_safe(ifp)) { in ipv6_get_ifaddr()
2097 result = ifp; in ipv6_get_ifaddr()
2110 static void addrconf_dad_stop(struct inet6_ifaddr *ifp, int dad_failed) in addrconf_dad_stop() argument
2113 ifp->flags |= IFA_F_DADFAILED; in addrconf_dad_stop()
2115 if (ifp->flags&IFA_F_TEMPORARY) { in addrconf_dad_stop()
2117 spin_lock_bh(&ifp->lock); in addrconf_dad_stop()
2118 ifpub = ifp->ifpub; in addrconf_dad_stop()
2121 spin_unlock_bh(&ifp->lock); in addrconf_dad_stop()
2125 spin_unlock_bh(&ifp->lock); in addrconf_dad_stop()
2127 ipv6_del_addr(ifp); in addrconf_dad_stop()
2128 } else if (ifp->flags&IFA_F_PERMANENT || !dad_failed) { in addrconf_dad_stop()
2129 spin_lock_bh(&ifp->lock); in addrconf_dad_stop()
2130 addrconf_del_dad_work(ifp); in addrconf_dad_stop()
2131 ifp->flags |= IFA_F_TENTATIVE; in addrconf_dad_stop()
2133 ifp->flags &= ~IFA_F_OPTIMISTIC; in addrconf_dad_stop()
2134 spin_unlock_bh(&ifp->lock); in addrconf_dad_stop()
2136 ipv6_ifa_notify(0, ifp); in addrconf_dad_stop()
2137 in6_ifa_put(ifp); in addrconf_dad_stop()
2139 ipv6_del_addr(ifp); in addrconf_dad_stop()
2143 static int addrconf_dad_end(struct inet6_ifaddr *ifp) in addrconf_dad_end() argument
2147 spin_lock_bh(&ifp->lock); in addrconf_dad_end()
2148 if (ifp->state == INET6_IFADDR_STATE_DAD) { in addrconf_dad_end()
2149 ifp->state = INET6_IFADDR_STATE_POSTDAD; in addrconf_dad_end()
2152 spin_unlock_bh(&ifp->lock); in addrconf_dad_end()
2157 void addrconf_dad_failure(struct sk_buff *skb, struct inet6_ifaddr *ifp) in addrconf_dad_failure() argument
2159 struct inet6_dev *idev = ifp->idev; in addrconf_dad_failure()
2163 if (addrconf_dad_end(ifp)) { in addrconf_dad_failure()
2164 in6_ifa_put(ifp); in addrconf_dad_failure()
2169 ifp->idev->dev->name, &ifp->addr, eth_hdr(skb)->h_source); in addrconf_dad_failure()
2171 spin_lock_bh(&ifp->lock); in addrconf_dad_failure()
2173 if (ifp->flags & IFA_F_STABLE_PRIVACY) { in addrconf_dad_failure()
2176 int retries = ifp->stable_privacy_retry + 1; in addrconf_dad_failure()
2179 .plen = ifp->prefix_len, in addrconf_dad_failure()
2180 .ifa_flags = ifp->flags, in addrconf_dad_failure()
2181 .valid_lft = ifp->valid_lft, in addrconf_dad_failure()
2182 .preferred_lft = ifp->prefered_lft, in addrconf_dad_failure()
2183 .scope = ifp->scope, in addrconf_dad_failure()
2188 ifp->idev->dev->name); in addrconf_dad_failure()
2192 new_addr = ifp->addr; in addrconf_dad_failure()
2197 spin_unlock_bh(&ifp->lock); in addrconf_dad_failure()
2205 ifp->idev->dev->name); in addrconf_dad_failure()
2219 spin_lock_bh(&ifp->lock); in addrconf_dad_failure()
2224 ifp->state = INET6_IFADDR_STATE_ERRDAD; in addrconf_dad_failure()
2225 spin_unlock_bh(&ifp->lock); in addrconf_dad_failure()
2227 addrconf_mod_dad_work(ifp, 0); in addrconf_dad_failure()
2228 in6_ifa_put(ifp); in addrconf_dad_failure()
2257 static void addrconf_join_anycast(struct inet6_ifaddr *ifp) in addrconf_join_anycast() argument
2261 if (ifp->prefix_len >= 127) /* RFC 6164 */ in addrconf_join_anycast()
2263 ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len); in addrconf_join_anycast()
2266 __ipv6_dev_ac_inc(ifp->idev, &addr); in addrconf_join_anycast()
2270 static void addrconf_leave_anycast(struct inet6_ifaddr *ifp) in addrconf_leave_anycast() argument
2274 if (ifp->prefix_len >= 127) /* RFC 6164 */ in addrconf_leave_anycast()
2276 ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len); in addrconf_leave_anycast()
2279 __ipv6_dev_ac_dec(ifp->idev, &addr); in addrconf_leave_anycast()
2404 struct inet6_ifaddr *ifp; in ipv6_inherit_eui64() local
2407 list_for_each_entry_reverse(ifp, &idev->addr_list, if_list) { in ipv6_inherit_eui64()
2408 if (ifp->scope > IFA_LINK) in ipv6_inherit_eui64()
2410 if (ifp->scope == IFA_LINK && !(ifp->flags&IFA_F_TENTATIVE)) { in ipv6_inherit_eui64()
2411 memcpy(eui, ifp->addr.s6_addr+8, 8); in ipv6_inherit_eui64()
2574 struct inet6_ifaddr *ifp) in delete_tempaddrs() argument
2580 if (ift->ifpub != ifp) in delete_tempaddrs()
2592 struct inet6_ifaddr *ifp, in manage_tempaddrs() argument
2604 if (ifp != ift->ifpub) in manage_tempaddrs()
2658 ipv6_create_tempaddr(ifp, false); in manage_tempaddrs()
2677 struct inet6_ifaddr *ifp = ipv6_get_ifaddr(net, addr, dev, 1); in addrconf_prefix_rcv_add_addr() local
2680 if (!ifp && valid_lft) { in addrconf_prefix_rcv_add_addr()
2704 ifp = ipv6_add_addr(in6_dev, &cfg, false, NULL); in addrconf_prefix_rcv_add_addr()
2706 if (IS_ERR_OR_NULL(ifp)) in addrconf_prefix_rcv_add_addr()
2710 spin_lock_bh(&ifp->lock); in addrconf_prefix_rcv_add_addr()
2711 ifp->flags |= IFA_F_MANAGETEMPADDR; in addrconf_prefix_rcv_add_addr()
2712 ifp->cstamp = jiffies; in addrconf_prefix_rcv_add_addr()
2713 ifp->tokenized = tokenized; in addrconf_prefix_rcv_add_addr()
2714 spin_unlock_bh(&ifp->lock); in addrconf_prefix_rcv_add_addr()
2715 addrconf_dad_start(ifp); in addrconf_prefix_rcv_add_addr()
2718 if (ifp) { in addrconf_prefix_rcv_add_addr()
2724 spin_lock_bh(&ifp->lock); in addrconf_prefix_rcv_add_addr()
2726 if (ifp->valid_lft > (now - ifp->tstamp) / HZ) in addrconf_prefix_rcv_add_addr()
2727 stored_lft = ifp->valid_lft - (now - ifp->tstamp) / HZ; in addrconf_prefix_rcv_add_addr()
2750 ifp->valid_lft = valid_lft; in addrconf_prefix_rcv_add_addr()
2751 ifp->prefered_lft = prefered_lft; in addrconf_prefix_rcv_add_addr()
2752 WRITE_ONCE(ifp->tstamp, now); in addrconf_prefix_rcv_add_addr()
2753 flags = ifp->flags; in addrconf_prefix_rcv_add_addr()
2754 ifp->flags &= ~IFA_F_DEPRECATED; in addrconf_prefix_rcv_add_addr()
2755 spin_unlock_bh(&ifp->lock); in addrconf_prefix_rcv_add_addr()
2758 ipv6_ifa_notify(0, ifp); in addrconf_prefix_rcv_add_addr()
2760 spin_unlock_bh(&ifp->lock); in addrconf_prefix_rcv_add_addr()
2762 manage_tempaddrs(in6_dev, ifp, valid_lft, prefered_lft, in addrconf_prefix_rcv_add_addr()
2765 in6_ifa_put(ifp); in addrconf_prefix_rcv_add_addr()
3015 struct inet6_ifaddr *ifp; in inet6_addr_add() local
3080 ifp = ipv6_add_addr(idev, cfg, true, extack); in inet6_addr_add()
3081 if (!IS_ERR(ifp)) { in inet6_addr_add()
3083 addrconf_prefix_route(&ifp->addr, ifp->prefix_len, in inet6_addr_add()
3084 ifp->rt_priority, dev, expires, in inet6_addr_add()
3091 if (!(ifp->flags & (IFA_F_OPTIMISTIC | IFA_F_NODAD))) in inet6_addr_add()
3092 ipv6_ifa_notify(0, ifp); in inet6_addr_add()
3098 addrconf_dad_start(ifp); in inet6_addr_add()
3100 manage_tempaddrs(idev, ifp, cfg->valid_lft, in inet6_addr_add()
3102 in6_ifa_put(ifp); in inet6_addr_add()
3110 return PTR_ERR(ifp); in inet6_addr_add()
3117 struct inet6_ifaddr *ifp; in inet6_addr_del() local
3139 list_for_each_entry(ifp, &idev->addr_list, if_list) { in inet6_addr_del()
3140 if (ifp->prefix_len == plen && in inet6_addr_del()
3141 ipv6_addr_equal(pfx, &ifp->addr)) { in inet6_addr_del()
3142 in6_ifa_hold(ifp); in inet6_addr_del()
3145 ipv6_del_addr(ifp); in inet6_addr_del()
3147 if (!(ifp->flags & IFA_F_TEMPORARY) && in inet6_addr_del()
3148 (ifp->flags & IFA_F_MANAGETEMPADDR)) in inet6_addr_del()
3149 delete_tempaddrs(idev, ifp); in inet6_addr_del()
3212 struct inet6_ifaddr *ifp; in add_addr() local
3223 ifp = ipv6_add_addr(idev, &cfg, true, NULL); in add_addr()
3224 if (!IS_ERR(ifp)) { in add_addr()
3225 spin_lock_bh(&ifp->lock); in add_addr()
3226 ifp->flags &= ~IFA_F_TENTATIVE; in add_addr()
3227 spin_unlock_bh(&ifp->lock); in add_addr()
3229 ipv6_ifa_notify(RTM_NEWADDR, ifp); in add_addr()
3230 in6_ifa_put(ifp); in add_addr()
3327 struct inet6_ifaddr *ifp; in addrconf_add_linklocal() local
3336 ifp = ipv6_add_addr(idev, &cfg, true, NULL); in addrconf_add_linklocal()
3337 if (!IS_ERR(ifp)) { in addrconf_add_linklocal()
3338 addrconf_prefix_route(&ifp->addr, ifp->prefix_len, 0, idev->dev, in addrconf_add_linklocal()
3340 addrconf_dad_start(ifp); in addrconf_add_linklocal()
3341 in6_ifa_put(ifp); in addrconf_add_linklocal()
3598 struct inet6_ifaddr *ifp) in fixup_permanent_addr() argument
3604 if (!ifp->rt || !ifp->rt->fib6_node) { in fixup_permanent_addr()
3607 f6i = addrconf_f6i_alloc(net, idev, &ifp->addr, false, in fixup_permanent_addr()
3612 /* ifp->rt can be accessed outside of rtnl */ in fixup_permanent_addr()
3613 spin_lock(&ifp->lock); in fixup_permanent_addr()
3614 prev = ifp->rt; in fixup_permanent_addr()
3615 ifp->rt = f6i; in fixup_permanent_addr()
3616 spin_unlock(&ifp->lock); in fixup_permanent_addr()
3621 if (!(ifp->flags & IFA_F_NOPREFIXROUTE)) { in fixup_permanent_addr()
3622 addrconf_prefix_route(&ifp->addr, ifp->prefix_len, in fixup_permanent_addr()
3623 ifp->rt_priority, idev->dev, 0, 0, in fixup_permanent_addr()
3627 if (ifp->state == INET6_IFADDR_STATE_PREDAD) in fixup_permanent_addr()
3628 addrconf_dad_start(ifp); in fixup_permanent_addr()
3635 struct inet6_ifaddr *ifp, *tmp; in addrconf_permanent_addr() local
3644 list_for_each_entry_safe(ifp, tmp, &idev->addr_list, if_list) { in addrconf_permanent_addr()
3645 if ((ifp->flags & IFA_F_PERMANENT) && in addrconf_permanent_addr()
3646 fixup_permanent_addr(net, idev, ifp) < 0) { in addrconf_permanent_addr()
3648 in6_ifa_hold(ifp); in addrconf_permanent_addr()
3649 ipv6_del_addr(ifp); in addrconf_permanent_addr()
3653 idev->dev->name, &ifp->addr); in addrconf_permanent_addr()
4092 static void addrconf_dad_kick(struct inet6_ifaddr *ifp) in addrconf_dad_kick() argument
4094 struct inet6_dev *idev = ifp->idev; in addrconf_dad_kick()
4098 if (ifp->flags & IFA_F_OPTIMISTIC) in addrconf_dad_kick()
4111 ifp->dad_nonce = nonce; in addrconf_dad_kick()
4112 ifp->dad_probes = READ_ONCE(idev->cnf.dad_transmits); in addrconf_dad_kick()
4113 addrconf_mod_dad_work(ifp, rand_num); in addrconf_dad_kick()
4116 static void addrconf_dad_begin(struct inet6_ifaddr *ifp) in addrconf_dad_begin() argument
4118 struct inet6_dev *idev = ifp->idev; in addrconf_dad_begin()
4123 addrconf_join_solict(dev, &ifp->addr); in addrconf_dad_begin()
4126 spin_lock(&ifp->lock); in addrconf_dad_begin()
4127 if (ifp->state == INET6_IFADDR_STATE_DEAD) in addrconf_dad_begin()
4134 !(ifp->flags&IFA_F_TENTATIVE) || in addrconf_dad_begin()
4135 ifp->flags & IFA_F_NODAD) { in addrconf_dad_begin()
4138 if (ifp->flags & IFA_F_TENTATIVE && in addrconf_dad_begin()
4139 !(ifp->flags & IFA_F_OPTIMISTIC)) in addrconf_dad_begin()
4141 bump_id = ifp->flags & IFA_F_TENTATIVE; in addrconf_dad_begin()
4142 ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED); in addrconf_dad_begin()
4143 spin_unlock(&ifp->lock); in addrconf_dad_begin()
4146 addrconf_dad_completed(ifp, bump_id, send_na); in addrconf_dad_begin()
4151 spin_unlock(&ifp->lock); in addrconf_dad_begin()
4158 in6_ifa_hold(ifp); in addrconf_dad_begin()
4159 addrconf_dad_stop(ifp, 0); in addrconf_dad_begin()
4167 if (ifp->flags & IFA_F_OPTIMISTIC) { in addrconf_dad_begin()
4168 ip6_ins_rt(net, ifp->rt); in addrconf_dad_begin()
4177 addrconf_dad_kick(ifp); in addrconf_dad_begin()
4179 spin_unlock(&ifp->lock); in addrconf_dad_begin()
4182 ipv6_ifa_notify(RTM_NEWADDR, ifp); in addrconf_dad_begin()
4185 static void addrconf_dad_start(struct inet6_ifaddr *ifp) in addrconf_dad_start() argument
4189 spin_lock_bh(&ifp->lock); in addrconf_dad_start()
4190 if (ifp->state != INET6_IFADDR_STATE_DEAD) { in addrconf_dad_start()
4191 ifp->state = INET6_IFADDR_STATE_PREDAD; in addrconf_dad_start()
4194 spin_unlock_bh(&ifp->lock); in addrconf_dad_start()
4197 addrconf_mod_dad_work(ifp, 0); in addrconf_dad_start()
4202 struct inet6_ifaddr *ifp = container_of(to_delayed_work(w), in addrconf_dad_work() local
4205 struct inet6_dev *idev = ifp->idev; in addrconf_dad_work()
4217 spin_lock_bh(&ifp->lock); in addrconf_dad_work()
4218 if (ifp->state == INET6_IFADDR_STATE_PREDAD) { in addrconf_dad_work()
4220 ifp->state = INET6_IFADDR_STATE_DAD; in addrconf_dad_work()
4221 } else if (ifp->state == INET6_IFADDR_STATE_ERRDAD) { in addrconf_dad_work()
4223 ifp->state = INET6_IFADDR_STATE_POSTDAD; in addrconf_dad_work()
4228 !(ifp->flags & IFA_F_STABLE_PRIVACY)) { in addrconf_dad_work()
4235 ipv6_addr_equal(&ifp->addr, &addr)) { in addrconf_dad_work()
4240 ifp->idev->dev->name); in addrconf_dad_work()
4245 spin_unlock_bh(&ifp->lock); in addrconf_dad_work()
4248 addrconf_dad_begin(ifp); in addrconf_dad_work()
4251 in6_ifa_hold(ifp); in addrconf_dad_work()
4252 addrconf_dad_stop(ifp, 1); in addrconf_dad_work()
4258 if (!ifp->dad_probes && addrconf_dad_end(ifp)) in addrconf_dad_work()
4267 spin_lock(&ifp->lock); in addrconf_dad_work()
4268 if (ifp->state == INET6_IFADDR_STATE_DEAD) { in addrconf_dad_work()
4269 spin_unlock(&ifp->lock); in addrconf_dad_work()
4274 if (ifp->dad_probes == 0) { in addrconf_dad_work()
4281 if (ifp->flags & IFA_F_TENTATIVE && in addrconf_dad_work()
4282 !(ifp->flags & IFA_F_OPTIMISTIC)) in addrconf_dad_work()
4284 bump_id = ifp->flags & IFA_F_TENTATIVE; in addrconf_dad_work()
4285 ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED); in addrconf_dad_work()
4286 spin_unlock(&ifp->lock); in addrconf_dad_work()
4289 addrconf_dad_completed(ifp, bump_id, send_na); in addrconf_dad_work()
4294 ifp->dad_probes--; in addrconf_dad_work()
4295 addrconf_mod_dad_work(ifp, in addrconf_dad_work()
4296 max(NEIGH_VAR(ifp->idev->nd_parms, RETRANS_TIME), in addrconf_dad_work()
4298 spin_unlock(&ifp->lock); in addrconf_dad_work()
4302 addrconf_addr_solict_mult(&ifp->addr, &mcaddr); in addrconf_dad_work()
4303 ndisc_send_ns(ifp->idev->dev, &ifp->addr, &mcaddr, &in6addr_any, in addrconf_dad_work()
4304 ifp->dad_nonce); in addrconf_dad_work()
4306 in6_ifa_put(ifp); in addrconf_dad_work()
4310 /* ifp->idev must be at least read locked */
4311 static bool ipv6_lonely_lladdr(struct inet6_ifaddr *ifp) in ipv6_lonely_lladdr() argument
4314 struct inet6_dev *idev = ifp->idev; in ipv6_lonely_lladdr()
4319 if (ifp != ifpiter && ifpiter->scope == IFA_LINK && in ipv6_lonely_lladdr()
4328 static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id, in addrconf_dad_completed() argument
4331 struct net_device *dev = ifp->idev->dev; in addrconf_dad_completed()
4335 addrconf_del_dad_work(ifp); in addrconf_dad_completed()
4341 ipv6_ifa_notify(RTM_NEWADDR, ifp); in addrconf_dad_completed()
4347 read_lock_bh(&ifp->idev->lock); in addrconf_dad_completed()
4348 send_mld = ifp->scope == IFA_LINK && ipv6_lonely_lladdr(ifp); in addrconf_dad_completed()
4350 ipv6_accept_ra(ifp->idev) && in addrconf_dad_completed()
4351 READ_ONCE(ifp->idev->cnf.rtr_solicits) != 0 && in addrconf_dad_completed()
4355 read_unlock_bh(&ifp->idev->lock); in addrconf_dad_completed()
4361 ipv6_mc_dad_complete(ifp->idev); in addrconf_dad_completed()
4365 (READ_ONCE(ifp->idev->cnf.ndisc_notify) || in addrconf_dad_completed()
4367 ndisc_send_na(dev, &in6addr_linklocal_allnodes, &ifp->addr, in addrconf_dad_completed()
4368 /*router=*/ !!ifp->idev->cnf.forwarding, in addrconf_dad_completed()
4383 write_lock_bh(&ifp->idev->lock); in addrconf_dad_completed()
4384 spin_lock(&ifp->lock); in addrconf_dad_completed()
4385 ifp->idev->rs_interval = rfc3315_s14_backoff_init( in addrconf_dad_completed()
4386 READ_ONCE(ifp->idev->cnf.rtr_solicit_interval)); in addrconf_dad_completed()
4387 ifp->idev->rs_probes = 1; in addrconf_dad_completed()
4388 ifp->idev->if_flags |= IF_RS_SENT; in addrconf_dad_completed()
4389 addrconf_mod_rs_timer(ifp->idev, ifp->idev->rs_interval); in addrconf_dad_completed()
4390 spin_unlock(&ifp->lock); in addrconf_dad_completed()
4391 write_unlock_bh(&ifp->idev->lock); in addrconf_dad_completed()
4400 if (ifp->flags & IFA_F_TEMPORARY) in addrconf_dad_completed()
4406 struct inet6_ifaddr *ifp; in addrconf_dad_run() local
4409 list_for_each_entry(ifp, &idev->addr_list, if_list) { in addrconf_dad_run()
4410 spin_lock(&ifp->lock); in addrconf_dad_run()
4411 if ((ifp->flags & IFA_F_TENTATIVE && in addrconf_dad_run()
4412 ifp->state == INET6_IFADDR_STATE_DAD) || restart) { in addrconf_dad_run()
4414 ifp->state = INET6_IFADDR_STATE_PREDAD; in addrconf_dad_run()
4415 addrconf_dad_kick(ifp); in addrconf_dad_run()
4417 spin_unlock(&ifp->lock); in addrconf_dad_run()
4506 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v; in if6_seq_show() local
4508 &ifp->addr, in if6_seq_show()
4509 ifp->idev->dev->ifindex, in if6_seq_show()
4510 ifp->prefix_len, in if6_seq_show()
4511 ifp->scope, in if6_seq_show()
4512 (u8) ifp->flags, in if6_seq_show()
4513 ifp->idev->dev->name); in if6_seq_show()
4558 struct inet6_ifaddr *ifp = NULL; in ipv6_chk_home_addr() local
4562 hlist_for_each_entry_rcu(ifp, &net->ipv6.inet6_addr_lst[hash], addr_lst) { in ipv6_chk_home_addr()
4563 if (ipv6_addr_equal(&ifp->addr, addr) && in ipv6_chk_home_addr()
4564 (ifp->flags & IFA_F_HOMEADDRESS)) { in ipv6_chk_home_addr()
4589 struct inet6_ifaddr *ifp; in ipv6_chk_rpl_srh_loop() local
4600 hlist_for_each_entry_rcu(ifp, &net->ipv6.inet6_addr_lst[hash], addr_lst) { in ipv6_chk_rpl_srh_loop()
4602 if (ipv6_addr_equal(&ifp->addr, addr)) { in ipv6_chk_rpl_srh_loop()
4632 struct inet6_ifaddr *ifp; in addrconf_verify_rtnl() local
4645 hlist_for_each_entry_rcu_bh(ifp, &net->ipv6.inet6_addr_lst[i], addr_lst) { in addrconf_verify_rtnl()
4652 if ((ifp->flags & IFA_F_PERMANENT) && in addrconf_verify_rtnl()
4653 (ifp->prefered_lft == INFINITY_LIFE_TIME)) in addrconf_verify_rtnl()
4656 spin_lock(&ifp->lock); in addrconf_verify_rtnl()
4658 age = (now - ifp->tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ; in addrconf_verify_rtnl()
4660 if ((ifp->flags&IFA_F_TEMPORARY) && in addrconf_verify_rtnl()
4661 !(ifp->flags&IFA_F_TENTATIVE) && in addrconf_verify_rtnl()
4662 ifp->prefered_lft != INFINITY_LIFE_TIME && in addrconf_verify_rtnl()
4663 !ifp->regen_count && ifp->ifpub) { in addrconf_verify_rtnl()
4666 unsigned long regen_advance = ipv6_get_regen_advance(ifp->idev); in addrconf_verify_rtnl()
4668 if (age + regen_advance >= ifp->prefered_lft) { in addrconf_verify_rtnl()
4669 struct inet6_ifaddr *ifpub = ifp->ifpub; in addrconf_verify_rtnl()
4670 if (time_before(ifp->tstamp + ifp->prefered_lft * HZ, next)) in addrconf_verify_rtnl()
4671 next = ifp->tstamp + ifp->prefered_lft * HZ; in addrconf_verify_rtnl()
4673 ifp->regen_count++; in addrconf_verify_rtnl()
4674 in6_ifa_hold(ifp); in addrconf_verify_rtnl()
4676 spin_unlock(&ifp->lock); in addrconf_verify_rtnl()
4684 in6_ifa_put(ifp); in addrconf_verify_rtnl()
4687 } else if (time_before(ifp->tstamp + ifp->prefered_lft * HZ - regen_advance * HZ, next)) in addrconf_verify_rtnl()
4688 next = ifp->tstamp + ifp->prefered_lft * HZ - regen_advance * HZ; in addrconf_verify_rtnl()
4691 if (ifp->valid_lft != INFINITY_LIFE_TIME && in addrconf_verify_rtnl()
4692 age >= ifp->valid_lft) { in addrconf_verify_rtnl()
4693 spin_unlock(&ifp->lock); in addrconf_verify_rtnl()
4694 in6_ifa_hold(ifp); in addrconf_verify_rtnl()
4696 ipv6_del_addr(ifp); in addrconf_verify_rtnl()
4699 } else if (ifp->prefered_lft == INFINITY_LIFE_TIME) { in addrconf_verify_rtnl()
4700 spin_unlock(&ifp->lock); in addrconf_verify_rtnl()
4702 } else if (age >= ifp->prefered_lft) { in addrconf_verify_rtnl()
4703 /* jiffies - ifp->tstamp > age >= ifp->prefered_lft */ in addrconf_verify_rtnl()
4706 if (!(ifp->flags&IFA_F_DEPRECATED)) { in addrconf_verify_rtnl()
4708 ifp->flags |= IFA_F_DEPRECATED; in addrconf_verify_rtnl()
4711 if ((ifp->valid_lft != INFINITY_LIFE_TIME) && in addrconf_verify_rtnl()
4712 (time_before(ifp->tstamp + ifp->valid_lft * HZ, next))) in addrconf_verify_rtnl()
4713 next = ifp->tstamp + ifp->valid_lft * HZ; in addrconf_verify_rtnl()
4715 spin_unlock(&ifp->lock); in addrconf_verify_rtnl()
4718 in6_ifa_hold(ifp); in addrconf_verify_rtnl()
4720 ipv6_ifa_notify(0, ifp); in addrconf_verify_rtnl()
4721 in6_ifa_put(ifp); in addrconf_verify_rtnl()
4725 /* ifp->prefered_lft <= ifp->valid_lft */ in addrconf_verify_rtnl()
4726 if (time_before(ifp->tstamp + ifp->prefered_lft * HZ, next)) in addrconf_verify_rtnl()
4727 next = ifp->tstamp + ifp->prefered_lft * HZ; in addrconf_verify_rtnl()
4728 spin_unlock(&ifp->lock); in addrconf_verify_rtnl()
4824 static int modify_prefix_route(struct net *net, struct inet6_ifaddr *ifp, in modify_prefix_route() argument
4832 f6i = addrconf_get_prefix_route(modify_peer ? &ifp->peer_addr : &ifp->addr, in modify_prefix_route()
4833 ifp->prefix_len, in modify_prefix_route()
4834 ifp->idev->dev, 0, RTF_DEFAULT, true); in modify_prefix_route()
4838 prio = ifp->rt_priority ? : IP6_RT_PRIO_ADDRCONF; in modify_prefix_route()
4841 ip6_del_rt(dev_net(ifp->idev->dev), f6i, false); in modify_prefix_route()
4844 addrconf_prefix_route(modify_peer ? &ifp->peer_addr : &ifp->addr, in modify_prefix_route()
4845 ifp->prefix_len, in modify_prefix_route()
4846 ifp->rt_priority, ifp->idev->dev, in modify_prefix_route()
4869 static int inet6_addr_modify(struct net *net, struct inet6_ifaddr *ifp, in inet6_addr_modify() argument
4885 (ifp->flags & IFA_F_TEMPORARY || ifp->prefix_len != 64)) in inet6_addr_modify()
4888 if (!(ifp->flags & IFA_F_TENTATIVE) || ifp->flags & IFA_F_DADFAILED) in inet6_addr_modify()
4910 memcmp(&ifp->peer_addr, cfg->peer_pfx, sizeof(struct in6_addr))) { in inet6_addr_modify()
4911 if (!ipv6_addr_any(&ifp->peer_addr)) in inet6_addr_modify()
4912 cleanup_prefix_route(ifp, expires, true, true); in inet6_addr_modify()
4916 spin_lock_bh(&ifp->lock); in inet6_addr_modify()
4917 was_managetempaddr = ifp->flags & IFA_F_MANAGETEMPADDR; in inet6_addr_modify()
4918 had_prefixroute = ifp->flags & IFA_F_PERMANENT && in inet6_addr_modify()
4919 !(ifp->flags & IFA_F_NOPREFIXROUTE); in inet6_addr_modify()
4920 ifp->flags &= ~(IFA_F_DEPRECATED | IFA_F_PERMANENT | IFA_F_NODAD | in inet6_addr_modify()
4923 ifp->flags |= cfg->ifa_flags; in inet6_addr_modify()
4924 WRITE_ONCE(ifp->tstamp, jiffies); in inet6_addr_modify()
4925 WRITE_ONCE(ifp->valid_lft, cfg->valid_lft); in inet6_addr_modify()
4926 WRITE_ONCE(ifp->prefered_lft, cfg->preferred_lft); in inet6_addr_modify()
4927 WRITE_ONCE(ifp->ifa_proto, cfg->ifa_proto); in inet6_addr_modify()
4929 if (cfg->rt_priority && cfg->rt_priority != ifp->rt_priority) in inet6_addr_modify()
4930 WRITE_ONCE(ifp->rt_priority, cfg->rt_priority); in inet6_addr_modify()
4933 ifp->peer_addr = *cfg->peer_pfx; in inet6_addr_modify()
4935 spin_unlock_bh(&ifp->lock); in inet6_addr_modify()
4936 if (!(ifp->flags&IFA_F_TENTATIVE)) in inet6_addr_modify()
4937 ipv6_ifa_notify(0, ifp); in inet6_addr_modify()
4943 rc = modify_prefix_route(net, ifp, expires, flags, false); in inet6_addr_modify()
4947 addrconf_prefix_route(&ifp->addr, ifp->prefix_len, in inet6_addr_modify()
4948 ifp->rt_priority, ifp->idev->dev, in inet6_addr_modify()
4952 if (had_prefixroute && !ipv6_addr_any(&ifp->peer_addr)) in inet6_addr_modify()
4953 rc = modify_prefix_route(net, ifp, expires, flags, true); in inet6_addr_modify()
4955 if (rc == -ENOENT && !ipv6_addr_any(&ifp->peer_addr)) { in inet6_addr_modify()
4956 addrconf_prefix_route(&ifp->peer_addr, ifp->prefix_len, in inet6_addr_modify()
4957 ifp->rt_priority, ifp->idev->dev, in inet6_addr_modify()
4964 write_lock_bh(&ifp->idev->lock); in inet6_addr_modify()
4965 action = check_cleanup_prefix_route(ifp, &rt_expires); in inet6_addr_modify()
4966 write_unlock_bh(&ifp->idev->lock); in inet6_addr_modify()
4969 cleanup_prefix_route(ifp, rt_expires, in inet6_addr_modify()
4974 if (was_managetempaddr || ifp->flags & IFA_F_MANAGETEMPADDR) { in inet6_addr_modify()
4975 if (was_managetempaddr && !(ifp->flags & IFA_F_MANAGETEMPADDR)) in inet6_addr_modify()
4976 delete_tempaddrs(ifp->idev, ifp); in inet6_addr_modify()
4978 manage_tempaddrs(ifp->idev, ifp, cfg->valid_lft, in inet6_addr_modify()
5889 struct inet6_ifaddr *ifp; in inet6_set_iftoken() local
5955 list_for_each_entry(ifp, &idev->addr_list, if_list) { in inet6_set_iftoken()
5956 spin_lock(&ifp->lock); in inet6_set_iftoken()
5957 if (ifp->tokenized) { in inet6_set_iftoken()
5958 ifp->valid_lft = 0; in inet6_set_iftoken()
5959 ifp->prefered_lft = 0; in inet6_set_iftoken()
5961 spin_unlock(&ifp->lock); in inet6_set_iftoken()
6262 static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp) in __ipv6_ifa_notify() argument
6264 struct net *net = dev_net(ifp->idev->dev); in __ipv6_ifa_notify()
6269 inet6_ifa_notify(event ? : RTM_NEWADDR, ifp); in __ipv6_ifa_notify()
6281 if (ifp->rt && !rcu_access_pointer(ifp->rt->fib6_node)) { in __ipv6_ifa_notify()
6282 ip6_ins_rt(net, ifp->rt); in __ipv6_ifa_notify()
6283 } else if (!ifp->rt && (ifp->idev->dev->flags & IFF_UP)) { in __ipv6_ifa_notify()
6285 &ifp->addr, ifp->idev->dev->name); in __ipv6_ifa_notify()
6288 if (ifp->idev->cnf.forwarding) in __ipv6_ifa_notify()
6289 addrconf_join_anycast(ifp); in __ipv6_ifa_notify()
6290 if (!ipv6_addr_any(&ifp->peer_addr)) in __ipv6_ifa_notify()
6291 addrconf_prefix_route(&ifp->peer_addr, 128, in __ipv6_ifa_notify()
6292 ifp->rt_priority, ifp->idev->dev, in __ipv6_ifa_notify()
6296 if (ifp->idev->cnf.forwarding) in __ipv6_ifa_notify()
6297 addrconf_leave_anycast(ifp); in __ipv6_ifa_notify()
6298 addrconf_leave_solict(ifp->idev, &ifp->addr); in __ipv6_ifa_notify()
6299 if (!ipv6_addr_any(&ifp->peer_addr)) { in __ipv6_ifa_notify()
6302 rt = addrconf_get_prefix_route(&ifp->peer_addr, 128, in __ipv6_ifa_notify()
6303 ifp->idev->dev, 0, 0, in __ipv6_ifa_notify()
6308 if (ifp->rt) { in __ipv6_ifa_notify()
6309 ip6_del_rt(net, ifp->rt, false); in __ipv6_ifa_notify()
6310 ifp->rt = NULL; in __ipv6_ifa_notify()
6318 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp) in ipv6_ifa_notify() argument
6320 if (likely(ifp->idev->dead == 0)) in ipv6_ifa_notify()
6321 __ipv6_ifa_notify(event, ifp); in ipv6_ifa_notify()