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 manage_tempaddrs() argument
2586 if (ifp != ift->ifpub) in manage_tempaddrs()
2640 ipv6_create_tempaddr(ifp, false); in manage_tempaddrs()
2659 struct inet6_ifaddr *ifp = ipv6_get_ifaddr(net, addr, dev, 1); in addrconf_prefix_rcv_add_addr() local
2662 if (!ifp && valid_lft) { in addrconf_prefix_rcv_add_addr()
2686 ifp = ipv6_add_addr(in6_dev, &cfg, false, NULL); in addrconf_prefix_rcv_add_addr()
2688 if (IS_ERR_OR_NULL(ifp)) in addrconf_prefix_rcv_add_addr()
2692 spin_lock_bh(&ifp->lock); in addrconf_prefix_rcv_add_addr()
2693 ifp->flags |= IFA_F_MANAGETEMPADDR; in addrconf_prefix_rcv_add_addr()
2694 ifp->cstamp = jiffies; in addrconf_prefix_rcv_add_addr()
2695 ifp->tokenized = tokenized; in addrconf_prefix_rcv_add_addr()
2696 spin_unlock_bh(&ifp->lock); in addrconf_prefix_rcv_add_addr()
2697 addrconf_dad_start(ifp); in addrconf_prefix_rcv_add_addr()
2700 if (ifp) { in addrconf_prefix_rcv_add_addr()
2706 spin_lock_bh(&ifp->lock); in addrconf_prefix_rcv_add_addr()
2708 if (ifp->valid_lft > (now - ifp->tstamp) / HZ) in addrconf_prefix_rcv_add_addr()
2709 stored_lft = ifp->valid_lft - (now - ifp->tstamp) / HZ; in addrconf_prefix_rcv_add_addr()
2732 ifp->valid_lft = valid_lft; in addrconf_prefix_rcv_add_addr()
2733 ifp->prefered_lft = prefered_lft; in addrconf_prefix_rcv_add_addr()
2734 WRITE_ONCE(ifp->tstamp, now); in addrconf_prefix_rcv_add_addr()
2735 flags = ifp->flags; in addrconf_prefix_rcv_add_addr()
2736 ifp->flags &= ~IFA_F_DEPRECATED; in addrconf_prefix_rcv_add_addr()
2737 spin_unlock_bh(&ifp->lock); in addrconf_prefix_rcv_add_addr()
2740 ipv6_ifa_notify(0, ifp); in addrconf_prefix_rcv_add_addr()
2742 spin_unlock_bh(&ifp->lock); in addrconf_prefix_rcv_add_addr()
2744 manage_tempaddrs(in6_dev, ifp, valid_lft, prefered_lft, in addrconf_prefix_rcv_add_addr()
2747 in6_ifa_put(ifp); in addrconf_prefix_rcv_add_addr()
2997 struct inet6_ifaddr *ifp; in inet6_addr_add() local
3062 ifp = ipv6_add_addr(idev, cfg, true, extack); in inet6_addr_add()
3063 if (!IS_ERR(ifp)) { in inet6_addr_add()
3065 addrconf_prefix_route(&ifp->addr, ifp->prefix_len, in inet6_addr_add()
3066 ifp->rt_priority, dev, expires, in inet6_addr_add()
3073 if (!(ifp->flags & (IFA_F_OPTIMISTIC | IFA_F_NODAD))) in inet6_addr_add()
3074 ipv6_ifa_notify(0, ifp); in inet6_addr_add()
3080 addrconf_dad_start(ifp); in inet6_addr_add()
3082 manage_tempaddrs(idev, ifp, cfg->valid_lft, in inet6_addr_add()
3084 in6_ifa_put(ifp); in inet6_addr_add()
3092 return PTR_ERR(ifp); in inet6_addr_add()
3099 struct inet6_ifaddr *ifp; in inet6_addr_del() local
3121 list_for_each_entry(ifp, &idev->addr_list, if_list) { in inet6_addr_del()
3122 if (ifp->prefix_len == plen && in inet6_addr_del()
3123 ipv6_addr_equal(pfx, &ifp->addr)) { in inet6_addr_del()
3124 in6_ifa_hold(ifp); in inet6_addr_del()
3127 if (!(ifp->flags & IFA_F_TEMPORARY) && in inet6_addr_del()
3129 manage_tempaddrs(idev, ifp, 0, 0, false, in inet6_addr_del()
3131 ipv6_del_addr(ifp); in inet6_addr_del()
3193 struct inet6_ifaddr *ifp; in add_addr() local
3204 ifp = ipv6_add_addr(idev, &cfg, true, NULL); in add_addr()
3205 if (!IS_ERR(ifp)) { in add_addr()
3206 spin_lock_bh(&ifp->lock); in add_addr()
3207 ifp->flags &= ~IFA_F_TENTATIVE; in add_addr()
3208 spin_unlock_bh(&ifp->lock); in add_addr()
3210 ipv6_ifa_notify(RTM_NEWADDR, ifp); in add_addr()
3211 in6_ifa_put(ifp); in add_addr()
3308 struct inet6_ifaddr *ifp; in addrconf_add_linklocal() local
3317 ifp = ipv6_add_addr(idev, &cfg, true, NULL); in addrconf_add_linklocal()
3318 if (!IS_ERR(ifp)) { in addrconf_add_linklocal()
3319 addrconf_prefix_route(&ifp->addr, ifp->prefix_len, 0, idev->dev, in addrconf_add_linklocal()
3321 addrconf_dad_start(ifp); in addrconf_add_linklocal()
3322 in6_ifa_put(ifp); in addrconf_add_linklocal()
3579 struct inet6_ifaddr *ifp) in fixup_permanent_addr() argument
3585 if (!ifp->rt || !ifp->rt->fib6_node) { in fixup_permanent_addr()
3588 f6i = addrconf_f6i_alloc(net, idev, &ifp->addr, false, in fixup_permanent_addr()
3593 /* ifp->rt can be accessed outside of rtnl */ in fixup_permanent_addr()
3594 spin_lock(&ifp->lock); in fixup_permanent_addr()
3595 prev = ifp->rt; in fixup_permanent_addr()
3596 ifp->rt = f6i; in fixup_permanent_addr()
3597 spin_unlock(&ifp->lock); in fixup_permanent_addr()
3602 if (!(ifp->flags & IFA_F_NOPREFIXROUTE)) { in fixup_permanent_addr()
3603 addrconf_prefix_route(&ifp->addr, ifp->prefix_len, in fixup_permanent_addr()
3604 ifp->rt_priority, idev->dev, 0, 0, in fixup_permanent_addr()
3608 if (ifp->state == INET6_IFADDR_STATE_PREDAD) in fixup_permanent_addr()
3609 addrconf_dad_start(ifp); in fixup_permanent_addr()
3616 struct inet6_ifaddr *ifp, *tmp; in addrconf_permanent_addr() local
3625 list_for_each_entry_safe(ifp, tmp, &idev->addr_list, if_list) { in addrconf_permanent_addr()
3626 if ((ifp->flags & IFA_F_PERMANENT) && in addrconf_permanent_addr()
3627 fixup_permanent_addr(net, idev, ifp) < 0) { in addrconf_permanent_addr()
3629 in6_ifa_hold(ifp); in addrconf_permanent_addr()
3630 ipv6_del_addr(ifp); in addrconf_permanent_addr()
3634 idev->dev->name, &ifp->addr); in addrconf_permanent_addr()
4073 static void addrconf_dad_kick(struct inet6_ifaddr *ifp) in addrconf_dad_kick() argument
4075 struct inet6_dev *idev = ifp->idev; in addrconf_dad_kick()
4079 if (ifp->flags & IFA_F_OPTIMISTIC) in addrconf_dad_kick()
4092 ifp->dad_nonce = nonce; in addrconf_dad_kick()
4093 ifp->dad_probes = READ_ONCE(idev->cnf.dad_transmits); in addrconf_dad_kick()
4094 addrconf_mod_dad_work(ifp, rand_num); in addrconf_dad_kick()
4097 static void addrconf_dad_begin(struct inet6_ifaddr *ifp) in addrconf_dad_begin() argument
4099 struct inet6_dev *idev = ifp->idev; in addrconf_dad_begin()
4104 addrconf_join_solict(dev, &ifp->addr); in addrconf_dad_begin()
4107 spin_lock(&ifp->lock); in addrconf_dad_begin()
4108 if (ifp->state == INET6_IFADDR_STATE_DEAD) in addrconf_dad_begin()
4115 !(ifp->flags&IFA_F_TENTATIVE) || in addrconf_dad_begin()
4116 ifp->flags & IFA_F_NODAD) { in addrconf_dad_begin()
4119 if (ifp->flags & IFA_F_TENTATIVE && in addrconf_dad_begin()
4120 !(ifp->flags & IFA_F_OPTIMISTIC)) in addrconf_dad_begin()
4122 bump_id = ifp->flags & IFA_F_TENTATIVE; in addrconf_dad_begin()
4123 ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED); in addrconf_dad_begin()
4124 spin_unlock(&ifp->lock); in addrconf_dad_begin()
4127 addrconf_dad_completed(ifp, bump_id, send_na); in addrconf_dad_begin()
4132 spin_unlock(&ifp->lock); in addrconf_dad_begin()
4139 in6_ifa_hold(ifp); in addrconf_dad_begin()
4140 addrconf_dad_stop(ifp, 0); in addrconf_dad_begin()
4148 if (ifp->flags & IFA_F_OPTIMISTIC) { in addrconf_dad_begin()
4149 ip6_ins_rt(net, ifp->rt); in addrconf_dad_begin()
4158 addrconf_dad_kick(ifp); in addrconf_dad_begin()
4160 spin_unlock(&ifp->lock); in addrconf_dad_begin()
4163 ipv6_ifa_notify(RTM_NEWADDR, ifp); in addrconf_dad_begin()
4166 static void addrconf_dad_start(struct inet6_ifaddr *ifp) in addrconf_dad_start() argument
4170 spin_lock_bh(&ifp->lock); in addrconf_dad_start()
4171 if (ifp->state != INET6_IFADDR_STATE_DEAD) { in addrconf_dad_start()
4172 ifp->state = INET6_IFADDR_STATE_PREDAD; in addrconf_dad_start()
4175 spin_unlock_bh(&ifp->lock); in addrconf_dad_start()
4178 addrconf_mod_dad_work(ifp, 0); in addrconf_dad_start()
4183 struct inet6_ifaddr *ifp = container_of(to_delayed_work(w), in addrconf_dad_work() local
4186 struct inet6_dev *idev = ifp->idev; in addrconf_dad_work()
4198 spin_lock_bh(&ifp->lock); in addrconf_dad_work()
4199 if (ifp->state == INET6_IFADDR_STATE_PREDAD) { in addrconf_dad_work()
4201 ifp->state = INET6_IFADDR_STATE_DAD; in addrconf_dad_work()
4202 } else if (ifp->state == INET6_IFADDR_STATE_ERRDAD) { in addrconf_dad_work()
4204 ifp->state = INET6_IFADDR_STATE_POSTDAD; in addrconf_dad_work()
4209 !(ifp->flags & IFA_F_STABLE_PRIVACY)) { in addrconf_dad_work()
4216 ipv6_addr_equal(&ifp->addr, &addr)) { in addrconf_dad_work()
4221 ifp->idev->dev->name); in addrconf_dad_work()
4226 spin_unlock_bh(&ifp->lock); in addrconf_dad_work()
4229 addrconf_dad_begin(ifp); in addrconf_dad_work()
4232 in6_ifa_hold(ifp); in addrconf_dad_work()
4233 addrconf_dad_stop(ifp, 1); in addrconf_dad_work()
4239 if (!ifp->dad_probes && addrconf_dad_end(ifp)) in addrconf_dad_work()
4248 spin_lock(&ifp->lock); in addrconf_dad_work()
4249 if (ifp->state == INET6_IFADDR_STATE_DEAD) { in addrconf_dad_work()
4250 spin_unlock(&ifp->lock); in addrconf_dad_work()
4255 if (ifp->dad_probes == 0) { in addrconf_dad_work()
4262 if (ifp->flags & IFA_F_TENTATIVE && in addrconf_dad_work()
4263 !(ifp->flags & IFA_F_OPTIMISTIC)) in addrconf_dad_work()
4265 bump_id = ifp->flags & IFA_F_TENTATIVE; in addrconf_dad_work()
4266 ifp->flags &= ~(IFA_F_TENTATIVE|IFA_F_OPTIMISTIC|IFA_F_DADFAILED); in addrconf_dad_work()
4267 spin_unlock(&ifp->lock); in addrconf_dad_work()
4270 addrconf_dad_completed(ifp, bump_id, send_na); in addrconf_dad_work()
4275 ifp->dad_probes--; in addrconf_dad_work()
4276 addrconf_mod_dad_work(ifp, in addrconf_dad_work()
4277 max(NEIGH_VAR(ifp->idev->nd_parms, RETRANS_TIME), in addrconf_dad_work()
4279 spin_unlock(&ifp->lock); in addrconf_dad_work()
4283 addrconf_addr_solict_mult(&ifp->addr, &mcaddr); in addrconf_dad_work()
4284 ndisc_send_ns(ifp->idev->dev, &ifp->addr, &mcaddr, &in6addr_any, in addrconf_dad_work()
4285 ifp->dad_nonce); in addrconf_dad_work()
4287 in6_ifa_put(ifp); in addrconf_dad_work()
4291 /* ifp->idev must be at least read locked */
4292 static bool ipv6_lonely_lladdr(struct inet6_ifaddr *ifp) in ipv6_lonely_lladdr() argument
4295 struct inet6_dev *idev = ifp->idev; in ipv6_lonely_lladdr()
4300 if (ifp != ifpiter && ifpiter->scope == IFA_LINK && in ipv6_lonely_lladdr()
4309 static void addrconf_dad_completed(struct inet6_ifaddr *ifp, bool bump_id, in addrconf_dad_completed() argument
4312 struct net_device *dev = ifp->idev->dev; in addrconf_dad_completed()
4316 addrconf_del_dad_work(ifp); in addrconf_dad_completed()
4322 ipv6_ifa_notify(RTM_NEWADDR, ifp); in addrconf_dad_completed()
4328 read_lock_bh(&ifp->idev->lock); in addrconf_dad_completed()
4329 send_mld = ifp->scope == IFA_LINK && ipv6_lonely_lladdr(ifp); in addrconf_dad_completed()
4331 ipv6_accept_ra(ifp->idev) && in addrconf_dad_completed()
4332 READ_ONCE(ifp->idev->cnf.rtr_solicits) != 0 && in addrconf_dad_completed()
4336 read_unlock_bh(&ifp->idev->lock); in addrconf_dad_completed()
4342 ipv6_mc_dad_complete(ifp->idev); in addrconf_dad_completed()
4346 (READ_ONCE(ifp->idev->cnf.ndisc_notify) || in addrconf_dad_completed()
4348 ndisc_send_na(dev, &in6addr_linklocal_allnodes, &ifp->addr, in addrconf_dad_completed()
4349 /*router=*/ !!ifp->idev->cnf.forwarding, in addrconf_dad_completed()
4364 write_lock_bh(&ifp->idev->lock); in addrconf_dad_completed()
4365 spin_lock(&ifp->lock); in addrconf_dad_completed()
4366 ifp->idev->rs_interval = rfc3315_s14_backoff_init( in addrconf_dad_completed()
4367 READ_ONCE(ifp->idev->cnf.rtr_solicit_interval)); in addrconf_dad_completed()
4368 ifp->idev->rs_probes = 1; in addrconf_dad_completed()
4369 ifp->idev->if_flags |= IF_RS_SENT; in addrconf_dad_completed()
4370 addrconf_mod_rs_timer(ifp->idev, ifp->idev->rs_interval); in addrconf_dad_completed()
4371 spin_unlock(&ifp->lock); in addrconf_dad_completed()
4372 write_unlock_bh(&ifp->idev->lock); in addrconf_dad_completed()
4381 if (ifp->flags & IFA_F_TEMPORARY) in addrconf_dad_completed()
4387 struct inet6_ifaddr *ifp; in addrconf_dad_run() local
4390 list_for_each_entry(ifp, &idev->addr_list, if_list) { in addrconf_dad_run()
4391 spin_lock(&ifp->lock); in addrconf_dad_run()
4392 if ((ifp->flags & IFA_F_TENTATIVE && in addrconf_dad_run()
4393 ifp->state == INET6_IFADDR_STATE_DAD) || restart) { in addrconf_dad_run()
4395 ifp->state = INET6_IFADDR_STATE_PREDAD; in addrconf_dad_run()
4396 addrconf_dad_kick(ifp); in addrconf_dad_run()
4398 spin_unlock(&ifp->lock); in addrconf_dad_run()
4487 struct inet6_ifaddr *ifp = (struct inet6_ifaddr *)v; in if6_seq_show() local
4489 &ifp->addr, in if6_seq_show()
4490 ifp->idev->dev->ifindex, in if6_seq_show()
4491 ifp->prefix_len, in if6_seq_show()
4492 ifp->scope, in if6_seq_show()
4493 (u8) ifp->flags, in if6_seq_show()
4494 ifp->idev->dev->name); in if6_seq_show()
4539 struct inet6_ifaddr *ifp = NULL; in ipv6_chk_home_addr() local
4543 hlist_for_each_entry_rcu(ifp, &net->ipv6.inet6_addr_lst[hash], addr_lst) { in ipv6_chk_home_addr()
4544 if (ipv6_addr_equal(&ifp->addr, addr) && in ipv6_chk_home_addr()
4545 (ifp->flags & IFA_F_HOMEADDRESS)) { in ipv6_chk_home_addr()
4570 struct inet6_ifaddr *ifp; in ipv6_chk_rpl_srh_loop() local
4581 hlist_for_each_entry_rcu(ifp, &net->ipv6.inet6_addr_lst[hash], addr_lst) { in ipv6_chk_rpl_srh_loop()
4583 if (ipv6_addr_equal(&ifp->addr, addr)) { in ipv6_chk_rpl_srh_loop()
4613 struct inet6_ifaddr *ifp; in addrconf_verify_rtnl() local
4626 hlist_for_each_entry_rcu_bh(ifp, &net->ipv6.inet6_addr_lst[i], addr_lst) { in addrconf_verify_rtnl()
4633 if ((ifp->flags & IFA_F_PERMANENT) && in addrconf_verify_rtnl()
4634 (ifp->prefered_lft == INFINITY_LIFE_TIME)) in addrconf_verify_rtnl()
4637 spin_lock(&ifp->lock); in addrconf_verify_rtnl()
4639 age = (now - ifp->tstamp + ADDRCONF_TIMER_FUZZ_MINUS) / HZ; in addrconf_verify_rtnl()
4641 if ((ifp->flags&IFA_F_TEMPORARY) && in addrconf_verify_rtnl()
4642 !(ifp->flags&IFA_F_TENTATIVE) && in addrconf_verify_rtnl()
4643 ifp->prefered_lft != INFINITY_LIFE_TIME && in addrconf_verify_rtnl()
4644 !ifp->regen_count && ifp->ifpub) { in addrconf_verify_rtnl()
4647 unsigned long regen_advance = ipv6_get_regen_advance(ifp->idev); in addrconf_verify_rtnl()
4649 if (age + regen_advance >= ifp->prefered_lft) { in addrconf_verify_rtnl()
4650 struct inet6_ifaddr *ifpub = ifp->ifpub; in addrconf_verify_rtnl()
4651 if (time_before(ifp->tstamp + ifp->prefered_lft * HZ, next)) in addrconf_verify_rtnl()
4652 next = ifp->tstamp + ifp->prefered_lft * HZ; in addrconf_verify_rtnl()
4654 ifp->regen_count++; in addrconf_verify_rtnl()
4655 in6_ifa_hold(ifp); in addrconf_verify_rtnl()
4657 spin_unlock(&ifp->lock); in addrconf_verify_rtnl()
4665 in6_ifa_put(ifp); in addrconf_verify_rtnl()
4668 } else if (time_before(ifp->tstamp + ifp->prefered_lft * HZ - regen_advance * HZ, next)) in addrconf_verify_rtnl()
4669 next = ifp->tstamp + ifp->prefered_lft * HZ - regen_advance * HZ; in addrconf_verify_rtnl()
4672 if (ifp->valid_lft != INFINITY_LIFE_TIME && in addrconf_verify_rtnl()
4673 age >= ifp->valid_lft) { in addrconf_verify_rtnl()
4674 spin_unlock(&ifp->lock); in addrconf_verify_rtnl()
4675 in6_ifa_hold(ifp); in addrconf_verify_rtnl()
4677 ipv6_del_addr(ifp); in addrconf_verify_rtnl()
4680 } else if (ifp->prefered_lft == INFINITY_LIFE_TIME) { in addrconf_verify_rtnl()
4681 spin_unlock(&ifp->lock); in addrconf_verify_rtnl()
4683 } else if (age >= ifp->prefered_lft) { in addrconf_verify_rtnl()
4684 /* jiffies - ifp->tstamp > age >= ifp->prefered_lft */ in addrconf_verify_rtnl()
4687 if (!(ifp->flags&IFA_F_DEPRECATED)) { in addrconf_verify_rtnl()
4689 ifp->flags |= IFA_F_DEPRECATED; in addrconf_verify_rtnl()
4692 if ((ifp->valid_lft != INFINITY_LIFE_TIME) && in addrconf_verify_rtnl()
4693 (time_before(ifp->tstamp + ifp->valid_lft * HZ, next))) in addrconf_verify_rtnl()
4694 next = ifp->tstamp + ifp->valid_lft * HZ; in addrconf_verify_rtnl()
4696 spin_unlock(&ifp->lock); in addrconf_verify_rtnl()
4699 in6_ifa_hold(ifp); in addrconf_verify_rtnl()
4701 ipv6_ifa_notify(0, ifp); in addrconf_verify_rtnl()
4702 in6_ifa_put(ifp); in addrconf_verify_rtnl()
4706 /* ifp->prefered_lft <= ifp->valid_lft */ in addrconf_verify_rtnl()
4707 if (time_before(ifp->tstamp + ifp->prefered_lft * HZ, next)) in addrconf_verify_rtnl()
4708 next = ifp->tstamp + ifp->prefered_lft * HZ; in addrconf_verify_rtnl()
4709 spin_unlock(&ifp->lock); in addrconf_verify_rtnl()
4805 static int modify_prefix_route(struct inet6_ifaddr *ifp, in modify_prefix_route() argument
4813 f6i = addrconf_get_prefix_route(modify_peer ? &ifp->peer_addr : &ifp->addr, in modify_prefix_route()
4814 ifp->prefix_len, in modify_prefix_route()
4815 ifp->idev->dev, 0, RTF_DEFAULT, true); in modify_prefix_route()
4819 prio = ifp->rt_priority ? : IP6_RT_PRIO_ADDRCONF; in modify_prefix_route()
4822 ip6_del_rt(dev_net(ifp->idev->dev), f6i, false); in modify_prefix_route()
4825 addrconf_prefix_route(modify_peer ? &ifp->peer_addr : &ifp->addr, in modify_prefix_route()
4826 ifp->prefix_len, in modify_prefix_route()
4827 ifp->rt_priority, ifp->idev->dev, in modify_prefix_route()
4849 static int inet6_addr_modify(struct net *net, struct inet6_ifaddr *ifp, in inet6_addr_modify() argument
4865 (ifp->flags & IFA_F_TEMPORARY || ifp->prefix_len != 64)) in inet6_addr_modify()
4868 if (!(ifp->flags & IFA_F_TENTATIVE) || ifp->flags & IFA_F_DADFAILED) in inet6_addr_modify()
4890 memcmp(&ifp->peer_addr, cfg->peer_pfx, sizeof(struct in6_addr))) { in inet6_addr_modify()
4891 if (!ipv6_addr_any(&ifp->peer_addr)) in inet6_addr_modify()
4892 cleanup_prefix_route(ifp, expires, true, true); in inet6_addr_modify()
4896 spin_lock_bh(&ifp->lock); in inet6_addr_modify()
4897 was_managetempaddr = ifp->flags & IFA_F_MANAGETEMPADDR; in inet6_addr_modify()
4898 had_prefixroute = ifp->flags & IFA_F_PERMANENT && in inet6_addr_modify()
4899 !(ifp->flags & IFA_F_NOPREFIXROUTE); in inet6_addr_modify()
4900 ifp->flags &= ~(IFA_F_DEPRECATED | IFA_F_PERMANENT | IFA_F_NODAD | in inet6_addr_modify()
4903 ifp->flags |= cfg->ifa_flags; in inet6_addr_modify()
4904 WRITE_ONCE(ifp->tstamp, jiffies); in inet6_addr_modify()
4905 WRITE_ONCE(ifp->valid_lft, cfg->valid_lft); in inet6_addr_modify()
4906 WRITE_ONCE(ifp->prefered_lft, cfg->preferred_lft); in inet6_addr_modify()
4907 WRITE_ONCE(ifp->ifa_proto, cfg->ifa_proto); in inet6_addr_modify()
4909 if (cfg->rt_priority && cfg->rt_priority != ifp->rt_priority) in inet6_addr_modify()
4910 WRITE_ONCE(ifp->rt_priority, cfg->rt_priority); in inet6_addr_modify()
4913 ifp->peer_addr = *cfg->peer_pfx; in inet6_addr_modify()
4915 spin_unlock_bh(&ifp->lock); in inet6_addr_modify()
4916 if (!(ifp->flags&IFA_F_TENTATIVE)) in inet6_addr_modify()
4917 ipv6_ifa_notify(0, ifp); in inet6_addr_modify()
4923 rc = modify_prefix_route(ifp, expires, flags, false); in inet6_addr_modify()
4927 addrconf_prefix_route(&ifp->addr, ifp->prefix_len, in inet6_addr_modify()
4928 ifp->rt_priority, ifp->idev->dev, in inet6_addr_modify()
4932 if (had_prefixroute && !ipv6_addr_any(&ifp->peer_addr)) in inet6_addr_modify()
4933 rc = modify_prefix_route(ifp, expires, flags, true); in inet6_addr_modify()
4935 if (rc == -ENOENT && !ipv6_addr_any(&ifp->peer_addr)) { in inet6_addr_modify()
4936 addrconf_prefix_route(&ifp->peer_addr, ifp->prefix_len, in inet6_addr_modify()
4937 ifp->rt_priority, ifp->idev->dev, in inet6_addr_modify()
4944 write_lock_bh(&ifp->idev->lock); in inet6_addr_modify()
4945 action = check_cleanup_prefix_route(ifp, &rt_expires); in inet6_addr_modify()
4946 write_unlock_bh(&ifp->idev->lock); in inet6_addr_modify()
4949 cleanup_prefix_route(ifp, rt_expires, in inet6_addr_modify()
4954 if (was_managetempaddr || ifp->flags & IFA_F_MANAGETEMPADDR) { in inet6_addr_modify()
4956 !(ifp->flags & IFA_F_MANAGETEMPADDR)) { in inet6_addr_modify()
4960 manage_tempaddrs(ifp->idev, ifp, cfg->valid_lft, in inet6_addr_modify()
5874 struct inet6_ifaddr *ifp; in inet6_set_iftoken() local
5940 list_for_each_entry(ifp, &idev->addr_list, if_list) { in inet6_set_iftoken()
5941 spin_lock(&ifp->lock); in inet6_set_iftoken()
5942 if (ifp->tokenized) { in inet6_set_iftoken()
5943 ifp->valid_lft = 0; in inet6_set_iftoken()
5944 ifp->prefered_lft = 0; in inet6_set_iftoken()
5946 spin_unlock(&ifp->lock); in inet6_set_iftoken()
6247 static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp) in __ipv6_ifa_notify() argument
6249 struct net *net = dev_net(ifp->idev->dev); in __ipv6_ifa_notify()
6254 inet6_ifa_notify(event ? : RTM_NEWADDR, ifp); in __ipv6_ifa_notify()
6266 if (ifp->rt && !rcu_access_pointer(ifp->rt->fib6_node)) { in __ipv6_ifa_notify()
6267 ip6_ins_rt(net, ifp->rt); in __ipv6_ifa_notify()
6268 } else if (!ifp->rt && (ifp->idev->dev->flags & IFF_UP)) { in __ipv6_ifa_notify()
6270 &ifp->addr, ifp->idev->dev->name); in __ipv6_ifa_notify()
6273 if (ifp->idev->cnf.forwarding) in __ipv6_ifa_notify()
6274 addrconf_join_anycast(ifp); in __ipv6_ifa_notify()
6275 if (!ipv6_addr_any(&ifp->peer_addr)) in __ipv6_ifa_notify()
6276 addrconf_prefix_route(&ifp->peer_addr, 128, in __ipv6_ifa_notify()
6277 ifp->rt_priority, ifp->idev->dev, in __ipv6_ifa_notify()
6281 if (ifp->idev->cnf.forwarding) in __ipv6_ifa_notify()
6282 addrconf_leave_anycast(ifp); in __ipv6_ifa_notify()
6283 addrconf_leave_solict(ifp->idev, &ifp->addr); in __ipv6_ifa_notify()
6284 if (!ipv6_addr_any(&ifp->peer_addr)) { in __ipv6_ifa_notify()
6287 rt = addrconf_get_prefix_route(&ifp->peer_addr, 128, in __ipv6_ifa_notify()
6288 ifp->idev->dev, 0, 0, in __ipv6_ifa_notify()
6293 if (ifp->rt) { in __ipv6_ifa_notify()
6294 ip6_del_rt(net, ifp->rt, false); in __ipv6_ifa_notify()
6295 ifp->rt = NULL; in __ipv6_ifa_notify()
6303 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp) in ipv6_ifa_notify() argument
6305 if (likely(ifp->idev->dead == 0)) in ipv6_ifa_notify()
6306 __ipv6_ifa_notify(event, ifp); in ipv6_ifa_notify()