Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e773e4faa19c54c2f32ddd16add2919588488bd9
Commit:     e773e4faa19c54c2f32ddd16add2919588488bd9
Parent:     6f4fc423b96c8fdf6f5c8b8ad79b75b7fb5a5c59
Author:     Brian Haley <[EMAIL PROTECTED]>
AuthorDate: Fri Aug 24 23:16:08 2007 -0700
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Wed Oct 10 16:48:32 2007 -0700

    [IPV6]: Add v4mapped address inline
    
    Add v4mapped address inline to avoid calls to ipv6_addr_type().
    
    Signed-off-by: Brian Haley <[EMAIL PROTECTED]>
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
---
 include/net/ipv6.h       |    6 ++++++
 net/ipv6/ipv6_sockglue.c |    2 +-
 net/ipv6/tcp_ipv6.c      |    4 ++--
 net/ipv6/udp.c           |    2 +-
 net/sctp/ipv6.c          |    4 ++--
 5 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 9059e0e..9573c8d 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -377,6 +377,12 @@ static inline int ipv6_addr_any(const struct in6_addr *a)
                 a->s6_addr32[2] | a->s6_addr32[3] ) == 0); 
 }
 
+static inline int ipv6_addr_v4mapped(const struct in6_addr *a)
+{
+       return ((a->s6_addr32[0] | a->s6_addr32[1]) == 0 &&
+                a->s6_addr32[2] == htonl(0x0000ffff));
+}
+
 /*
  * find the first different bit between two addresses
  * length of address must be a multiple of 32bits
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 6b038aa..74254fc 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -249,7 +249,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, 
int optname,
                        }
 
                        if (ipv6_only_sock(sk) ||
-                           !(ipv6_addr_type(&np->daddr) & IPV6_ADDR_MAPPED)) {
+                           !ipv6_addr_v4mapped(&np->daddr)) {
                                retv = -EADDRNOTAVAIL;
                                break;
                        }
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 3e06799..a07b59c 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -697,7 +697,7 @@ static int tcp_v6_parse_md5_keys (struct sock *sk, char 
__user *optval,
        if (!cmd.tcpm_keylen) {
                if (!tcp_sk(sk)->md5sig_info)
                        return -ENOENT;
-               if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_MAPPED)
+               if (ipv6_addr_v4mapped(&sin6->sin6_addr))
                        return tcp_v4_md5_do_del(sk, 
sin6->sin6_addr.s6_addr32[3]);
                return tcp_v6_md5_do_del(sk, &sin6->sin6_addr);
        }
@@ -720,7 +720,7 @@ static int tcp_v6_parse_md5_keys (struct sock *sk, char 
__user *optval,
        newkey = kmemdup(cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL);
        if (!newkey)
                return -ENOMEM;
-       if (ipv6_addr_type(&sin6->sin6_addr) & IPV6_ADDR_MAPPED) {
+       if (ipv6_addr_v4mapped(&sin6->sin6_addr)) {
                return tcp_v4_md5_do_add(sk, sin6->sin6_addr.s6_addr32[3],
                                         newkey, cmd.tcpm_keylen);
        }
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index c347f3e..82ff26d 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -612,7 +612,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
                daddr = NULL;
 
        if (daddr) {
-               if (ipv6_addr_type(daddr) == IPV6_ADDR_MAPPED) {
+               if (ipv6_addr_v4mapped(daddr)) {
                        struct sockaddr_in sin;
                        sin.sin_family = AF_INET;
                        sin.sin_port = sin6 ? sin6->sin6_port : inet->dport;
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
index 670fd27..ec29b97 100644
--- a/net/sctp/ipv6.c
+++ b/net/sctp/ipv6.c
@@ -493,7 +493,7 @@ static int sctp_v6_cmp_addr(const union sctp_addr *addr1,
        if (addr1->sa.sa_family != addr2->sa.sa_family) {
                if (addr1->sa.sa_family == AF_INET &&
                    addr2->sa.sa_family == AF_INET6 &&
-                   IPV6_ADDR_MAPPED == ipv6_addr_type(&addr2->v6.sin6_addr)) {
+                   ipv6_addr_v4mapped(&addr2->v6.sin6_addr)) {
                        if (addr2->v6.sin6_port == addr1->v4.sin_port &&
                            addr2->v6.sin6_addr.s6_addr32[3] ==
                            addr1->v4.sin_addr.s_addr)
@@ -501,7 +501,7 @@ static int sctp_v6_cmp_addr(const union sctp_addr *addr1,
                }
                if (addr2->sa.sa_family == AF_INET &&
                    addr1->sa.sa_family == AF_INET6 &&
-                   IPV6_ADDR_MAPPED == ipv6_addr_type(&addr1->v6.sin6_addr)) {
+                   ipv6_addr_v4mapped(&addr1->v6.sin6_addr)) {
                        if (addr1->v6.sin6_port == addr2->v4.sin_port &&
                            addr1->v6.sin6_addr.s6_addr32[3] ==
                            addr2->v4.sin_addr.s_addr)
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to