TCPCT part 1b: generate Responder Cookie secret
[safe/jmp/linux-2.6] / net / ipv6 / anycast.c
index 463bd95..f1c74c8 100644 (file)
@@ -48,29 +48,6 @@ static int ipv6_dev_ac_dec(struct net_device *dev, struct in6_addr *addr);
 /* Big ac list lock for all the sockets */
 static DEFINE_RWLOCK(ipv6_sk_ac_lock);
 
-static int
-ip6_onlink(struct in6_addr *addr, struct net_device *dev)
-{
-       struct inet6_dev        *idev;
-       struct inet6_ifaddr     *ifa;
-       int     onlink;
-
-       onlink = 0;
-       rcu_read_lock();
-       idev = __in6_dev_get(dev);
-       if (idev) {
-               read_lock_bh(&idev->lock);
-               for (ifa=idev->addr_list; ifa; ifa=ifa->if_next) {
-                       onlink = ipv6_prefix_equal(addr, &ifa->addr,
-                                                  ifa->prefix_len);
-                       if (onlink)
-                               break;
-               }
-               read_unlock_bh(&idev->lock);
-       }
-       rcu_read_unlock();
-       return onlink;
-}
 
 /*
  *     socket join an anycast group
@@ -83,7 +60,7 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, struct in6_addr *addr)
        struct inet6_dev *idev;
        struct ipv6_ac_socklist *pac;
        struct net *net = sock_net(sk);
-       int     ishost = !ipv6_devconf.forwarding;
+       int     ishost = !net->ipv6.devconf_all->forwarding;
        int     err = 0;
 
        if (!capable(CAP_NET_ADMIN))
@@ -142,7 +119,7 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, struct in6_addr *addr)
         * This obviates the need for propagating anycast routes while
         * still allowing some non-router anycast participation.
         */
-       if (!ip6_onlink(addr, dev)) {
+       if (!ipv6_chk_prefix(addr, dev)) {
                if (ishost)
                        err = -EADDRNOTAVAIL;
                if (err)
@@ -337,9 +314,7 @@ int ipv6_dev_ac_inc(struct net_device *dev, struct in6_addr *addr)
        idev->ac_list = aca;
        write_unlock_bh(&idev->lock);
 
-       dst_hold(&rt->u.dst);
-       if (ip6_ins_rt(rt))
-               dst_release(&rt->u.dst);
+       ip6_ins_rt(rt);
 
        addrconf_join_solict(dev, &aca->aca_addr);
 
@@ -381,10 +356,7 @@ int __ipv6_dev_ac_dec(struct inet6_dev *idev, struct in6_addr *addr)
        addrconf_leave_solict(idev, &aca->aca_addr);
 
        dst_hold(&aca->aca_rt->u.dst);
-       if (ip6_del_rt(aca->aca_rt))
-               dst_free(&aca->aca_rt->u.dst);
-       else
-               dst_release(&aca->aca_rt->u.dst);
+       ip6_del_rt(aca->aca_rt);
 
        aca_put(aca);
        return 0;
@@ -432,13 +404,13 @@ int ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
 
        if (dev)
                return ipv6_chk_acast_dev(dev, addr);
-       read_lock(&dev_base_lock);
-       for_each_netdev(net, dev)
+       rcu_read_lock();
+       for_each_netdev_rcu(net, dev)
                if (ipv6_chk_acast_dev(dev, addr)) {
                        found = 1;
                        break;
                }
-       read_unlock(&dev_base_lock);
+       rcu_read_unlock();
        return found;
 }
 
@@ -459,9 +431,9 @@ static inline struct ifacaddr6 *ac6_get_first(struct seq_file *seq)
        struct net *net = seq_file_net(seq);
 
        state->idev = NULL;
-       for_each_netdev(net, state->dev) {
+       for_each_netdev_rcu(net, state->dev) {
                struct inet6_dev *idev;
-               idev = in6_dev_get(state->dev);
+               idev = __in6_dev_get(state->dev);
                if (!idev)
                        continue;
                read_lock_bh(&idev->lock);
@@ -471,7 +443,6 @@ static inline struct ifacaddr6 *ac6_get_first(struct seq_file *seq)
                        break;
                }
                read_unlock_bh(&idev->lock);
-               in6_dev_put(idev);
        }
        return im;
 }
@@ -482,16 +453,15 @@ static struct ifacaddr6 *ac6_get_next(struct seq_file *seq, struct ifacaddr6 *im
 
        im = im->aca_next;
        while (!im) {
-               if (likely(state->idev != NULL)) {
+               if (likely(state->idev != NULL))
                        read_unlock_bh(&state->idev->lock);
-                       in6_dev_put(state->idev);
-               }
-               state->dev = next_net_device(state->dev);
+
+               state->dev = next_net_device_rcu(state->dev);
                if (!state->dev) {
                        state->idev = NULL;
                        break;
                }
-               state->idev = in6_dev_get(state->dev);
+               state->idev = __in6_dev_get(state->dev);
                if (!state->idev)
                        continue;
                read_lock_bh(&state->idev->lock);
@@ -510,29 +480,30 @@ static struct ifacaddr6 *ac6_get_idx(struct seq_file *seq, loff_t pos)
 }
 
 static void *ac6_seq_start(struct seq_file *seq, loff_t *pos)
-       __acquires(dev_base_lock)
+       __acquires(RCU)
 {
-       read_lock(&dev_base_lock);
+       rcu_read_lock();
        return ac6_get_idx(seq, *pos);
 }
 
 static void *ac6_seq_next(struct seq_file *seq, void *v, loff_t *pos)
 {
-       struct ifacaddr6 *im;
-       im = ac6_get_next(seq, v);
+       struct ifacaddr6 *im = ac6_get_next(seq, v);
+
        ++*pos;
        return im;
 }
 
 static void ac6_seq_stop(struct seq_file *seq, void *v)
-       __releases(dev_base_lock)
+       __releases(RCU)
 {
        struct ac6_iter_state *state = ac6_seq_private(seq);
+
        if (likely(state->idev != NULL)) {
                read_unlock_bh(&state->idev->lock);
-               in6_dev_put(state->idev);
+               state->idev = NULL;
        }
-       read_unlock(&dev_base_lock);
+       rcu_read_unlock();
 }
 
 static int ac6_seq_show(struct seq_file *seq, void *v)
@@ -540,11 +511,9 @@ static int ac6_seq_show(struct seq_file *seq, void *v)
        struct ifacaddr6 *im = (struct ifacaddr6 *)v;
        struct ac6_iter_state *state = ac6_seq_private(seq);
 
-       seq_printf(seq,
-                  "%-4d %-15s " NIP6_SEQFMT " %5d\n",
+       seq_printf(seq, "%-4d %-15s %pi6 %5d\n",
                   state->dev->ifindex, state->dev->name,
-                  NIP6(im->aca_addr),
-                  im->aca_users);
+                  &im->aca_addr, im->aca_users);
        return 0;
 }