]> err.no Git - linux-2.6/commitdiff
[IPV6]: Unify ip6_onlink() and ipip6_onlink().
authorYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Sun, 16 Mar 2008 02:54:23 +0000 (22:54 -0400)
committerYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Thu, 3 Apr 2008 01:06:00 +0000 (10:06 +0900)
Both are identical, let's create ipv6_chk_prefix() and use it
in both places.

include/net/addrconf.h
net/ipv6/addrconf.c
net/ipv6/anycast.c
net/ipv6/sit.c

index d89b0bc7ab75015cf36101ca8628e889b39ae77c..bdcc863a60a4cf5b485c1e93dc7079020829febb 100644 (file)
@@ -71,6 +71,10 @@ extern int                   ipv6_chk_addr(struct net *net,
 extern int                     ipv6_chk_home_addr(struct net *net,
                                                   struct in6_addr *addr);
 #endif
+
+extern int                     ipv6_chk_prefix(struct in6_addr *addr,
+                                               struct net_device *dev);
+
 extern struct inet6_ifaddr      *ipv6_get_ifaddr(struct net *net,
                                                 struct in6_addr *addr,
                                                 struct net_device *dev,
index 5ab9973571efbcf91a6bde5b390722e54c24babe..c17f8c0b933e59d651cef4d191619c6731882c81 100644 (file)
@@ -1249,6 +1249,31 @@ int ipv6_chk_same_addr(struct net *net, const struct in6_addr *addr,
        return ifp != NULL;
 }
 
+int ipv6_chk_prefix(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;
+}
+
+EXPORT_SYMBOL(ipv6_chk_prefix);
+
 struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, struct in6_addr *addr,
                                     struct net_device *dev, int strict)
 {
index 463bd95d6b13598e8d77b2a1227681549e7ac4ff..36e817492095911f255bc2dc521169f28caf74b8 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
@@ -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)
index 08a483a8de5083dda156e24b64c6f1805cf980f6..cc16fe07bbff68f6485c91b32fb19bb79184feb7 100644 (file)
@@ -344,31 +344,6 @@ out:
        return 0;
 }
 
-/* copied directly from anycast.c */
-static int
-ipip6_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;
-}
-
 static int
 isatap_chksrc(struct sk_buff *skb, struct iphdr *iph, struct ip_tunnel *t)
 {
@@ -386,7 +361,7 @@ isatap_chksrc(struct sk_buff *skb, struct iphdr *iph, struct ip_tunnel *t)
                struct in6_addr *addr6 = &ipv6_hdr(skb)->saddr;
                if (ipv6_addr_is_isatap(addr6) &&
                    (addr6->s6_addr32[3] == iph->saddr) &&
-                   ipip6_onlink(addr6, t->dev))
+                   ipv6_chk_prefix(addr6, t->dev))
                        skb->ndisc_nodetype = NDISC_NODETYPE_HOST;
                else
                        ok = 0;