net: ipv6: allow explicitly choosing optimistic addresses
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Review int ipv6_chk_addr(struct net *net, const struct in6_addr *addr, · line 1534
Quoted 11 lines · Erik Kline
(quoted diff) +2
-1@@ -1527,7 +1527,8 @@ int ipv6_chk_addr(struct net *net, const struct in6_addr *addr, if (!net_eq(dev_net(ifp->idev->dev), net)) continue; if (ipv6_addr_equal(&ifp->addr, addr) && - !(ifp->flags&IFA_F_TENTATIVE) && + (!(ifp->flags&IFA_F_TENTATIVE) || + ifp->flags&IFA_F_OPTIMISTIC) && (dev == NULL || ifp->idev->dev == dev || !(ifp->scope&(IFA_LINK|IFA_HOST) || strict))) { rcu_read_unlock_bh();
I looked at the callers of ipv6_chk_addr (lxr finds 19 files); from what I saw, this change will make all of them more correct except for ndisc_solicit. With this change, ndisc_solicit could now send neighbour solicitations from optimistic addresses, which is not allowed by the RFC.
Quoted 18 lines · Lorenzo Colitti
Review int ipv6_chk_addr(struct net *net, const struct in6_addr *addr, · line 1534
Quoted 11 lines · Erik Kline
(quoted diff) +2
-1@@ -1527,7 +1527,8 @@ int ipv6_chk_addr(struct net *net, const struct in6_addr *addr, if (!net_eq(dev_net(ifp->idev->dev), net)) continue; if (ipv6_addr_equal(&ifp->addr, addr) && - !(ifp->flags&IFA_F_TENTATIVE) && + (!(ifp->flags&IFA_F_TENTATIVE) || + ifp->flags&IFA_F_OPTIMISTIC) && (dev == NULL || ifp->idev->dev == dev || !(ifp->scope&(IFA_LINK|IFA_HOST) || strict))) { rcu_read_unlock_bh();I looked at the callers of
ipv6_chk_addr(lxr finds 19 files); from what I saw, this change will make all of them more correct except forndisc_solicit. With this change,ndisc_solicitcould now send neighbour solicitations from optimistic addresses, which is not allowed by the RFC.
True. I have a version that fixes this, but ended up splitting ipv6_chk_addr into two:
- ipv6_chk_addr (same as today), and
- ipv6_chk_addr_and_flags (which takes a "u32 banned_flags" argument)
The ugliness of this naming is not lost on me. I briefly tried a version that reuses the "strict" argument to achieve the same thing, but that doesn't seem to be quite correct in all cases either.