Eric Dumazet a écrit :


Hi David, Hi all

I would like to provide a patch to speedup tcp lookups, but I need your comments first.

1) First some peformance data :
--------------------------------

tcp_v4_rcv() waste a lot of time in __tcp_v4_lookup_established()

The most critical code is :

sk_for_each(sk, node, &head->chain) {
    if (TCP_IPV4_MATCH(sk, acookie, saddr, daddr, ports, dif))
        goto hit; /* You sunk my battleship! */
}

The sk_for_each() does use prefetch() hints but only the begining of "struct sock" is prefetched.
So TCP_IPV4_MATCH() has to bring into CPU cache cold cache lines.
Each iteration has to use at least 2 cache lines.

2) The goal
-----------

The idea I have is to change things so that TCP_IPV4_MATCH() may return FALSE in 95% of cases only using the data already in the CPU cache,
using one cache line per iteration.

3) Description of what is planned
----------------------------------

Changes in layout are to move the "__u16 dport ; __u16 num" from "struct inet_sock" to the end of "struct sock_common",
where there is some padding (at least on 64 bits platforms)

File include/net/sock.h

struct sock_common {
    unsigned short      skc_family;
    volatile unsigned char  skc_state;
    unsigned char       skc_reuse;
    int         skc_bound_dev_if;
    struct hlist_node   skc_node;
    struct hlist_node   skc_bind_node;
    atomic_t        skc_refcnt;
+    union  {
+ unsigned int key; /* hash key for fast lookups, or protocol private data */
+        unsigned short us[2];
+        } skc_u;
    };

File include/linux/ip.h

struct inet_sock {
    ...
    __u32           rcv_saddr;  /* Bound local IPv4 addr */
-    __u16           dport;      /* Destination port */
-    __u16           num;        /* Local port */
    ...
+#define inetsk_dport sk.skc_u.us[0]
+#define inetsk_num sk.skc_u.us[1]

Then change every sk->dport to sk->inetsk_dport, and every sk->num to sk->inetsk_num

Doing so even save 8 bytes for sizeof(inet_sock) on 64 bits platforms :)

Then change the the TCP_IPV4_MATCH macro to

File include/net/tcp.h

64 bits platforms :
#define TCP_IPV4_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif)\
    (((__sk)->skc_u.key == (__ports))    &&  \
    ((*((__u64 *)&(inet_sk(__sk)->daddr)))== (__cookie))   &&  \
    (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))

32bits platforms:
#define TCP_IPV4_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif)\
    (((__sk)->skc_u.key == (__ports))    &&  \
    (inet_sk(__sk)->daddr          == (__saddr))   &&  \
    (inet_sk(__sk)->rcv_saddr      == (__daddr))   &&  \
    (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))


This way, the comparison with (__sk->skc_u.key) should reference data already fetched is CPU caches, or in the same cache line than
__sk->skc_node (the next element in hash chain)

Discussion :

Instead of using (dport,num) as a key, we could use the tcp_hashfn() value to have better fast path, but we would use more memory.
The patch would be nicer, not changing "struct inet_sock".

Thank you for your comments and ideas.

Eric Dumazet

Here is the first version of patch that implements fast tcp / udp lookups, using the (dport,num) as a key, stored in struct sock_common, in the same cache line than the 'next pointer' used in iterator (even for 32 bytes cache lines)

Fairly large patch because I had to track all references to inet->num and inet->dport, but small if you look only at include files were all the patch logic is really done. I hope the size of the patch is OK for netdev ?

Tested on x86_64 and i686 machines. No performance results yet.

changed files are :

include/net/sock.h
include/linux/ip.h
include/net/tcp.h
include/net/udp.h

net/ipv4/af_inet.c
net/ipv4/datagram.c
net/ipv4/ip_input.c
net/ipv4/ip_output.c
net/ipv4/ip_sockglue.c
net/ipv4/netfilter/ip_conntrack_core.c
net/ipv4/raw.c
net/ipv4/tcp.c
net/ipv4/tcp_diag.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_minisocks.c
net/ipv4/tcp_output.c
net/ipv4/tcp_timer.c
net/ipv4/udp.c
net/ipv4/ipmr.c

net/ipv6/af_inet6.c
net/ipv6/datagram.c
net/ipv6/ipv6_sockglue.c
net/ipv6/raw.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c

security/selinux/avc.c

Thank you

Signed-off-by: Eric Dumazet <[EMAIL PROTECTED]>
--- linux-2.6.13-rc5/include/net/sock.h 2005-08-02 06:45:48.000000000 +0200
+++ linux-2.6.13-rc5-ed/include/net/sock.h      2005-08-02 20:10:28.000000000 
+0200
@@ -98,6 +98,7 @@
  *     @skc_node: main hash linkage for various protocol lookup tables
  *     @skc_bind_node: bind hash linkage for various protocol lookup tables
  *     @skc_refcnt: reference count
+ *     @skc_u: a hash key to speedup lookups
  *
  *     This is the minimal network layer representation of sockets, the header
  *     for struct sock and struct tcp_tw_bucket.
@@ -110,6 +111,10 @@
        struct hlist_node       skc_node;
        struct hlist_node       skc_bind_node;
        atomic_t                skc_refcnt;
+       union {
+               unsigned int key;
+               unsigned short us[2];
+       } skc_u;
 };
 
 /**
@@ -184,6 +189,9 @@
 #define sk_node                        __sk_common.skc_node
 #define sk_bind_node           __sk_common.skc_bind_node
 #define sk_refcnt              __sk_common.skc_refcnt
+#define sk_key          __sk_common.skc_u.key
+#define sk_us0          __sk_common.skc_u.us[0]
+#define sk_us1          __sk_common.skc_u.us[1]
        unsigned char           sk_shutdown : 2,
                                sk_no_check : 2,
                                sk_userlocks : 4;
--- linux-2.6.13-rc5/include/linux/ip.h 2005-08-02 06:45:48.000000000 +0200
+++ linux-2.6.13-rc5-ed/include/linux/ip.h      2005-08-02 20:04:18.000000000 
+0200
@@ -139,8 +139,10 @@
        /* Socket demultiplex comparisons on incoming packets. */
        __u32                   daddr;          /* Foreign IPv4 addr */
        __u32                   rcv_saddr;      /* Bound local IPv4 addr */
-       __u16                   dport;          /* Destination port */
-       __u16                   num;            /* Local port */
+/*     __u16                   dport;*/                /* Destination port : 
moved to sk.sk_us0 to speedup lookups */
+/*     __u16                   num;*/          /* Local port : moved to 
sk.sk_us1 to speedup lookups */
+#define inetsk_dport sk.sk_us0
+#define inetsk_num sk.sk_us1
        __u32                   saddr;          /* Sending source */
        __s16                   uc_ttl;         /* Unicast TTL */
        __u16                   cmsg_flags;
--- linux-2.6.13-rc5/include/net/tcp.h  2005-08-02 06:45:48.000000000 +0200
+++ linux-2.6.13-rc5-ed/include/net/tcp.h       2005-08-02 20:08:18.000000000 
+0200
@@ -201,8 +201,11 @@
        __u32                   tw_daddr
                __attribute__((aligned(TCP_ADDRCMP_ALIGN_BYTES)));
        __u32                   tw_rcv_saddr;
-       __u16                   tw_dport;
-       __u16                   tw_num;
+/*     __u16                   tw_dport;*/ /* Destination port : moved to 
skc_u.us[0] to speedup lookups */
+/*     __u16                   tw_num;*/ /* Local port : moved to skc_u.us[1] 
to speedup lookups */
+#define tw_dport __tw_common.skc_u.us[0]
+#define tw_num   __tw_common.skc_u.us[1]
+#define tw_key   __tw_common.skc_u.key
        /* And these are ours. */
        int                     tw_hashent;
        int                     tw_timeout;
@@ -337,29 +340,29 @@
        __u64 __name = (((__u64)(__daddr))<<32)|((__u64)(__saddr));
 #endif /* __BIG_ENDIAN */
 #define TCP_IPV4_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif)\
-       (((*((__u64 *)&(inet_sk(__sk)->daddr)))== (__cookie))   &&      \
-        ((*((__u32 *)&(inet_sk(__sk)->dport)))== (__ports))    &&      \
+       (((__sk)->sk_key== (__ports))   &&      \
+        ((*((__u64 *)&(inet_sk(__sk)->daddr)))== (__cookie))   &&      \
         (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
 #define TCP_IPV4_TW_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif)\
-       (((*((__u64 *)&(tcptw_sk(__sk)->tw_daddr))) == (__cookie)) &&   \
-        ((*((__u32 *)&(tcptw_sk(__sk)->tw_dport))) == (__ports)) &&    \
+       (((__sk)->sk_key== (__ports))    &&  \
+        ((*((__u64 *)&(tcptw_sk(__sk)->tw_daddr))) == (__cookie)) &&   \
         (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
 #else /* 32-bit arch */
 #define TCP_V4_ADDR_COOKIE(__name, __saddr, __daddr)
 #define TCP_IPV4_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif)\
-       ((inet_sk(__sk)->daddr                  == (__saddr))   &&      \
+       (((__sk)->sk_key== (__ports))   &&      \
+        (inet_sk(__sk)->daddr                  == (__saddr))   &&      \
         (inet_sk(__sk)->rcv_saddr              == (__daddr))   &&      \
-        ((*((__u32 *)&(inet_sk(__sk)->dport)))== (__ports))    &&      \
         (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
 #define TCP_IPV4_TW_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif)\
-       ((tcptw_sk(__sk)->tw_daddr              == (__saddr))   &&      \
+       (((__sk)->sk_key== (__ports))    &&  \
+        (tcptw_sk(__sk)->tw_daddr              == (__saddr))   &&      \
         (tcptw_sk(__sk)->tw_rcv_saddr          == (__daddr))   &&      \
-        ((*((__u32 *)&(tcptw_sk(__sk)->tw_dport))) == (__ports)) &&    \
         (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif))))
 #endif /* 64-bit arch */
 
 #define TCP_IPV6_MATCH(__sk, __saddr, __daddr, __ports, __dif)    \
-       (((*((__u32 *)&(inet_sk(__sk)->dport)))== (__ports))    && \
+       (((__sk)->sk_key== (__ports))    &&  \
         ((__sk)->sk_family             == AF_INET6)            && \
         ipv6_addr_equal(&inet6_sk(__sk)->daddr, (__saddr))     && \
         ipv6_addr_equal(&inet6_sk(__sk)->rcv_saddr, (__daddr)) && \
@@ -373,7 +376,7 @@
 
 static __inline__ int tcp_sk_listen_hashfn(struct sock *sk)
 {
-       return tcp_lhashfn(inet_sk(sk)->num);
+       return tcp_lhashfn(inet_sk(sk)->inetsk_num);
 }
 
 #define MAX_TCP_HEADER (128 + MAX_HEADER)
--- linux-2.6.13-rc5/include/net/udp.h  2005-08-02 06:45:48.000000000 +0200
+++ linux-2.6.13-rc5-ed/include/net/udp.h       2005-08-02 14:52:31.000000000 
+0200
@@ -46,7 +46,7 @@
        struct hlist_node *node;
 
        sk_for_each(sk, node, &udp_hash[num & (UDP_HTABLE_SIZE - 1)])
-               if (inet_sk(sk)->num == num)
+               if (inet_sk(sk)->inetsk_num == num)
                        return 1;
        return 0;
 }
--- linux-2.6.13-rc5/net/ipv4/af_inet.c 2005-08-02 06:45:48.000000000 +0200
+++ linux-2.6.13-rc5-ed/net/ipv4/af_inet.c      2005-08-02 15:31:34.000000000 
+0200
@@ -176,12 +176,12 @@
        /* We may need to bind the socket. */
        lock_sock(sk);
        inet = inet_sk(sk);
-       if (!inet->num) {
+       if (!inet->inetsk_num) {
                if (sk->sk_prot->get_port(sk, 0)) {
                        release_sock(sk);
                        return -EAGAIN;
                }
-               inet->sport = htons(inet->num);
+               inet->sport = htons(inet->inetsk_num);
        }
        release_sock(sk);
        return 0;
@@ -292,7 +292,7 @@
        inet = inet_sk(sk);
 
        if (SOCK_RAW == sock->type) {
-               inet->num = protocol;
+               inet->inetsk_num = protocol;
                if (IPPROTO_RAW == protocol)
                        inet->hdrincl = 1;
        }
@@ -321,13 +321,13 @@
        atomic_inc(&inet_sock_nr);
 #endif
 
-       if (inet->num) {
+       if (inet->inetsk_num) {
                /* It assumes that any protocol which allows
                 * the user to assign a number at socket
                 * creation time automatically
                 * shares.
                 */
-               inet->sport = htons(inet->num);
+               inet->sport = htons(inet->inetsk_num);
                /* Add to protocol hash chains. */
                sk->sk_prot->hash(sk);
        }
@@ -432,7 +432,7 @@
 
        /* Check these errors (active socket, double bind). */
        err = -EINVAL;
-       if (sk->sk_state != TCP_CLOSE || inet->num)
+       if (sk->sk_state != TCP_CLOSE || inet->inetsk_num)
                goto out_release_sock;
 
        inet->rcv_saddr = inet->saddr = addr->sin_addr.s_addr;
@@ -450,9 +450,9 @@
                sk->sk_userlocks |= SOCK_BINDADDR_LOCK;
        if (snum)
                sk->sk_userlocks |= SOCK_BINDPORT_LOCK;
-       inet->sport = htons(inet->num);
+       inet->sport = htons(inet->inetsk_num);
        inet->daddr = 0;
-       inet->dport = 0;
+       inet->inetsk_dport = 0;
        sk_dst_reset(sk);
        err = 0;
 out_release_sock:
@@ -469,7 +469,7 @@
        if (uaddr->sa_family == AF_UNSPEC)
                return sk->sk_prot->disconnect(sk, flags);
 
-       if (!inet_sk(sk)->num && inet_autobind(sk))
+       if (!inet_sk(sk)->inetsk_num && inet_autobind(sk))
                return -EAGAIN;
        return sk->sk_prot->connect(sk, (struct sockaddr *)uaddr, addr_len);
 }
@@ -623,11 +623,11 @@
 
        sin->sin_family = AF_INET;
        if (peer) {
-               if (!inet->dport ||
+               if (!inet->inetsk_dport ||
                    (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)) &&
                     peer == 1))
                        return -ENOTCONN;
-               sin->sin_port = inet->dport;
+               sin->sin_port = inet->inetsk_dport;
                sin->sin_addr.s_addr = inet->daddr;
        } else {
                __u32 addr = inet->rcv_saddr;
@@ -647,7 +647,7 @@
        struct sock *sk = sock->sk;
 
        /* We may need to bind the socket. */
-       if (!inet_sk(sk)->num && inet_autobind(sk))
+       if (!inet_sk(sk)->inetsk_num && inet_autobind(sk))
                return -EAGAIN;
 
        return sk->sk_prot->sendmsg(iocb, sk, msg, size);
@@ -659,7 +659,7 @@
        struct sock *sk = sock->sk;
 
        /* We may need to bind the socket. */
-       if (!inet_sk(sk)->num && inet_autobind(sk))
+       if (!inet_sk(sk)->inetsk_num && inet_autobind(sk))
                return -EAGAIN;
 
        if (sk->sk_prot->sendpage)
--- linux-2.6.13-rc5/net/ipv4/datagram.c        2005-08-02 06:45:48.000000000 
+0200
+++ linux-2.6.13-rc5-ed/net/ipv4/datagram.c     2005-08-02 15:20:47.000000000 
+0200
@@ -61,7 +61,7 @@
        if (!inet->rcv_saddr)
                inet->rcv_saddr = rt->rt_src;
        inet->daddr = rt->rt_dst;
-       inet->dport = usin->sin_port;
+       inet->inetsk_dport = usin->sin_port;
        sk->sk_state = TCP_ESTABLISHED;
        inet->id = jiffies;
 
--- linux-2.6.13-rc5/net/ipv4/ip_input.c        2005-08-02 06:45:48.000000000 
+0200
+++ linux-2.6.13-rc5-ed/net/ipv4/ip_input.c     2005-08-02 14:55:33.000000000 
+0200
@@ -168,7 +168,7 @@
                /* If socket is bound to an interface, only report
                 * the packet if it came  from that interface.
                 */
-               if (sk && inet_sk(sk)->num == protocol &&
+               if (sk && inet_sk(sk)->inetsk_num == protocol &&
                    (!sk->sk_bound_dev_if ||
                     sk->sk_bound_dev_if == skb->dev->ifindex)) {
                        if (skb->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
--- linux-2.6.13-rc5/net/ipv4/ip_output.c       2005-08-02 06:45:48.000000000 
+0200
+++ linux-2.6.13-rc5-ed/net/ipv4/ip_output.c    2005-08-02 14:57:04.000000000 
+0200
@@ -320,7 +320,7 @@
                                            .proto = sk->sk_protocol,
                                            .uli_u = { .ports =
                                                       { .sport = inet->sport,
-                                                        .dport = inet->dport } 
} };
+                                                        .dport = 
inet->inetsk_dport } } };
 
                        /* If this fails, retransmit mechanism of transport 
layer will
                         * keep trying until route appears or the connection 
times
@@ -766,7 +766,7 @@
        maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen;
 
        if (inet->cork.length + length > 0xFFFF - fragheaderlen) {
-               ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->dport, 
mtu-exthdrlen);
+               ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->inetsk_dport, 
mtu-exthdrlen);
                return -EMSGSIZE;
        }
 
@@ -1004,7 +1004,7 @@
        maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen;
 
        if (inet->cork.length + size > 0xFFFF - fragheaderlen) {
-               ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->dport, mtu);
+               ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->inetsk_dport, 
mtu);
                return -EMSGSIZE;
        }
 
--- linux-2.6.13-rc5/net/ipv4/ip_sockglue.c     2005-08-02 06:45:48.000000000 
+0200
+++ linux-2.6.13-rc5-ed/net/ipv4/ip_sockglue.c  2005-08-02 14:57:42.000000000 
+0200
@@ -192,7 +192,7 @@
 {
        struct ip_ra_chain *ra, *new_ra, **rap;
 
-       if (sk->sk_type != SOCK_RAW || inet_sk(sk)->num == IPPROTO_RAW)
+       if (sk->sk_type != SOCK_RAW || inet_sk(sk)->inetsk_num == IPPROTO_RAW)
                return -EINVAL;
 
        new_ra = on ? kmalloc(sizeof(*new_ra), GFP_KERNEL) : NULL;
--- linux-2.6.13-rc5/net/ipv4/netfilter/ip_conntrack_core.c     2005-08-02 
06:45:48.000000000 +0200
+++ linux-2.6.13-rc5-ed/net/ipv4/netfilter/ip_conntrack_core.c  2005-08-02 
15:33:18.000000000 +0200
@@ -1034,7 +1034,7 @@
        tuple.src.ip = inet->rcv_saddr;
        tuple.src.u.tcp.port = inet->sport;
        tuple.dst.ip = inet->daddr;
-       tuple.dst.u.tcp.port = inet->dport;
+       tuple.dst.u.tcp.port = inet->inetsk_dport;
        tuple.dst.protonum = IPPROTO_TCP;
 
        /* We only do TCP at the moment: is there a better way? */
--- linux-2.6.13-rc5/net/ipv4/raw.c     2005-08-02 06:45:48.000000000 +0200
+++ linux-2.6.13-rc5-ed/net/ipv4/raw.c  2005-08-02 15:22:41.000000000 +0200
@@ -85,7 +85,7 @@
 
 static void raw_v4_hash(struct sock *sk)
 {
-       struct hlist_head *head = &raw_v4_htable[inet_sk(sk)->num &
+       struct hlist_head *head = &raw_v4_htable[inet_sk(sk)->inetsk_num &
                                                 (RAWV4_HTABLE_SIZE - 1)];
 
        write_lock_bh(&raw_v4_lock);
@@ -111,7 +111,7 @@
        sk_for_each_from(sk, node) {
                struct inet_sock *inet = inet_sk(sk);
 
-               if (inet->num == num                                    &&
+               if (inet->inetsk_num == num                                     
&&
                    !(inet->daddr && inet->daddr != raddr)              &&
                    !(inet->rcv_saddr && inet->rcv_saddr != laddr)      &&
                    !(sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif))
@@ -270,7 +270,7 @@
        int err;
 
        if (length > rt->u.dst.dev->mtu) {
-               ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->dport,
+               ip_local_error(sk, EMSGSIZE, rt->rt_dst, inet->inetsk_dport,
                               rt->u.dst.dev->mtu);
                return -EMSGSIZE;
        }
@@ -623,7 +623,7 @@
 {
        struct raw_sock *rp = raw_sk(sk);
 
-       if (inet_sk(sk)->num == IPPROTO_ICMP)
+       if (inet_sk(sk)->inetsk_num == IPPROTO_ICMP)
                memset(&rp->filter, 0, sizeof(rp->filter));
        return 0;
 }
@@ -663,7 +663,7 @@
                return ip_setsockopt(sk, level, optname, optval, optlen);
 
        if (optname == ICMP_FILTER) {
-               if (inet_sk(sk)->num != IPPROTO_ICMP)
+               if (inet_sk(sk)->inetsk_num != IPPROTO_ICMP)
                        return -EOPNOTSUPP;
                else
                        return raw_seticmpfilter(sk, optval, optlen);
@@ -678,7 +678,7 @@
                return ip_getsockopt(sk, level, optname, optval, optlen);
 
        if (optname == ICMP_FILTER) {
-               if (inet_sk(sk)->num != IPPROTO_ICMP)
+               if (inet_sk(sk)->inetsk_num != IPPROTO_ICMP)
                        return -EOPNOTSUPP;
                else
                        return raw_geticmpfilter(sk, optval, optlen);
@@ -813,7 +813,7 @@
        unsigned int dest = inet->daddr,
                     src = inet->rcv_saddr;
        __u16 destp = 0,
-             srcp  = inet->num;
+             srcp  = inet->inetsk_num;
 
        sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
                " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p",
--- linux-2.6.13-rc5/net/ipv4/tcp.c     2005-08-02 06:45:48.000000000 +0200
+++ linux-2.6.13-rc5-ed/net/ipv4/tcp.c  2005-08-02 19:24:02.000000000 +0200
@@ -269,10 +269,10 @@
 
 int sysctl_tcp_fin_timeout = TCP_FIN_TIMEOUT;
 
-DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics);
+DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics) __read_mostly;
 
-kmem_cache_t *tcp_bucket_cachep;
-kmem_cache_t *tcp_timewait_cachep;
+kmem_cache_t *tcp_bucket_cachep __read_mostly;
+kmem_cache_t *tcp_timewait_cachep __read_mostly;
 
 atomic_t tcp_orphan_count = ATOMIC_INIT(0);
 
@@ -477,8 +477,8 @@
         * after validation is complete.
         */
        sk->sk_state = TCP_LISTEN;
-       if (!sk->sk_prot->get_port(sk, inet->num)) {
-               inet->sport = htons(inet->num);
+       if (!sk->sk_prot->get_port(sk, inet->inetsk_num)) {
+               inet->sport = htons(inet->inetsk_num);
 
                sk_dst_reset(sk);
                sk->sk_prot->hash(sk);
@@ -1587,7 +1587,7 @@
        BUG_TRAP(sk_unhashed(sk));
 
        /* If it has not 0 inet_sk(sk)->num, it must be bound */
-       BUG_TRAP(!inet_sk(sk)->num || tcp_sk(sk)->bind_hash);
+       BUG_TRAP(!inet_sk(sk)->inetsk_num || tcp_sk(sk)->bind_hash);
 
        sk->sk_prot->destroy(sk);
 
@@ -1795,7 +1795,7 @@
        sk_stream_writequeue_purge(sk);
        __skb_queue_purge(&tp->out_of_order_queue);
 
-       inet->dport = 0;
+       inet->inetsk_dport = 0;
 
        if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK))
                inet_reset_saddr(sk);
@@ -1819,7 +1819,7 @@
        tcp_sack_reset(&tp->rx_opt);
        __sk_dst_reset(sk);
 
-       BUG_TRAP(!inet->num || tp->bind_hash);
+       BUG_TRAP(!inet->inetsk_num || tp->bind_hash);
 
        sk->sk_error_report(sk);
        return err;
--- linux-2.6.13-rc5/net/ipv4/tcp_diag.c        2005-08-02 06:45:48.000000000 
+0200
+++ linux-2.6.13-rc5-ed/net/ipv4/tcp_diag.c     2005-08-02 15:34:57.000000000 
+0200
@@ -110,7 +110,7 @@
        }
 
        r->id.tcpdiag_sport = inet->sport;
-       r->id.tcpdiag_dport = inet->dport;
+       r->id.tcpdiag_dport = inet->inetsk_dport;
        r->id.tcpdiag_src[0] = inet->rcv_saddr;
        r->id.tcpdiag_dst[0] = inet->daddr;
 
@@ -426,8 +426,8 @@
                        entry.saddr = &inet->rcv_saddr;
                        entry.daddr = &inet->daddr;
                }
-               entry.sport = inet->num;
-               entry.dport = ntohs(inet->dport);
+               entry.sport = inet->inetsk_num;
+               entry.dport = ntohs(inet->inetsk_dport);
                entry.userlocks = sk->sk_userlocks;
 
                if (!tcpdiag_bc_run(RTA_DATA(bc), RTA_PAYLOAD(bc), &entry))
@@ -521,7 +521,7 @@
 
        if (cb->nlh->nlmsg_len > 4 + NLMSG_SPACE(sizeof(*r))) {
                bc = (struct rtattr *)(r + 1);
-               entry.sport = inet->num;
+               entry.sport = inet->inetsk_num;
                entry.userlocks = sk->sk_userlocks;
        }
 
@@ -666,7 +666,7 @@
                        if (r->id.tcpdiag_sport != inet->sport &&
                            r->id.tcpdiag_sport)
                                goto next_normal;
-                       if (r->id.tcpdiag_dport != inet->dport && 
r->id.tcpdiag_dport)
+                       if (r->id.tcpdiag_dport != inet->inetsk_dport && 
r->id.tcpdiag_dport)
                                goto next_normal;
                        if (tcpdiag_dump_sock(skb, sk, cb) < 0) {
                                read_unlock_bh(&head->lock);
@@ -686,7 +686,7 @@
                                if (r->id.tcpdiag_sport != inet->sport &&
                                    r->id.tcpdiag_sport)
                                        goto next_dying;
-                               if (r->id.tcpdiag_dport != inet->dport &&
+                               if (r->id.tcpdiag_dport != inet->inetsk_dport &&
                                    r->id.tcpdiag_dport)
                                        goto next_dying;
                                if (tcpdiag_dump_sock(skb, sk, cb) < 0) {
--- linux-2.6.13-rc5/net/ipv4/tcp_ipv4.c        2005-08-02 06:45:48.000000000 
+0200
+++ linux-2.6.13-rc5-ed/net/ipv4/tcp_ipv4.c     2005-08-02 15:15:48.000000000 
+0200
@@ -117,9 +117,9 @@
 {
        struct inet_sock *inet = inet_sk(sk);
        __u32 laddr = inet->rcv_saddr;
-       __u16 lport = inet->num;
+       __u16 lport = inet->inetsk_num;
        __u32 faddr = inet->daddr;
-       __u16 fport = inet->dport;
+       __u16 fport = inet->inetsk_dport;
 
        return tcp_hashfn(laddr, lport, faddr, fport);
 }
@@ -154,7 +154,7 @@
 static __inline__ void __tcp_inherit_port(struct sock *sk, struct sock *child)
 {
        struct tcp_bind_hashbucket *head =
-                               &tcp_bhash[tcp_bhashfn(inet_sk(child)->num)];
+                               
&tcp_bhash[tcp_bhashfn(inet_sk(child)->inetsk_num)];
        struct tcp_bind_bucket *tb;
 
        spin_lock(&head->lock);
@@ -174,7 +174,7 @@
 void tcp_bind_hash(struct sock *sk, struct tcp_bind_bucket *tb,
                   unsigned short snum)
 {
-       inet_sk(sk)->num = snum;
+       inet_sk(sk)->inetsk_num = snum;
        sk_add_bind_node(sk, &tb->owners);
        tcp_sk(sk)->bind_hash = tb;
 }
@@ -304,14 +304,14 @@
 static void __tcp_put_port(struct sock *sk)
 {
        struct inet_sock *inet = inet_sk(sk);
-       struct tcp_bind_hashbucket *head = &tcp_bhash[tcp_bhashfn(inet->num)];
+       struct tcp_bind_hashbucket *head = 
&tcp_bhash[tcp_bhashfn(inet->inetsk_num)];
        struct tcp_bind_bucket *tb;
 
        spin_lock(&head->lock);
        tb = tcp_sk(sk)->bind_hash;
        __sk_del_bind_node(sk);
        tcp_sk(sk)->bind_hash = NULL;
-       inet->num = 0;
+       inet->inetsk_num = 0;
        tcp_bucket_destroy(tb);
        spin_unlock(&head->lock);
 }
@@ -425,7 +425,7 @@
        sk_for_each(sk, node, head) {
                struct inet_sock *inet = inet_sk(sk);
 
-               if (inet->num == hnum && !ipv6_only_sock(sk)) {
+               if (inet->inetsk_num == hnum && !ipv6_only_sock(sk)) {
                        __u32 rcv_saddr = inet->rcv_saddr;
 
                        score = (sk->sk_family == PF_INET ? 1 : 0);
@@ -462,7 +462,7 @@
        if (!hlist_empty(head)) {
                struct inet_sock *inet = inet_sk((sk = __sk_head(head)));
 
-               if (inet->num == hnum && !sk->sk_node.next &&
+               if (inet->inetsk_num == hnum && !sk->sk_node.next &&
                    (!inet->rcv_saddr || inet->rcv_saddr == daddr) &&
                    (sk->sk_family == PF_INET || !ipv6_only_sock(sk)) &&
                    !sk->sk_bound_dev_if)
@@ -557,8 +557,8 @@
        u32 saddr = inet->daddr;
        int dif = sk->sk_bound_dev_if;
        TCP_V4_ADDR_COOKIE(acookie, saddr, daddr)
-       __u32 ports = TCP_COMBINED_PORTS(inet->dport, lport);
-       int hash = tcp_hashfn(daddr, lport, saddr, inet->dport);
+       __u32 ports = TCP_COMBINED_PORTS(inet->inetsk_dport, lport);
+       int hash = tcp_hashfn(daddr, lport, saddr, inet->inetsk_dport);
        struct tcp_ehash_bucket *head = &tcp_ehash[hash];
        struct sock *sk2;
        struct hlist_node *node;
@@ -613,7 +613,7 @@
 unique:
        /* Must record num and sport now. Otherwise we will see
         * in hash table socket with a funny identity. */
-       inet->num = lport;
+       inet->inetsk_num = lport;
        inet->sport = htons(lport);
        sk->sk_hashent = hash;
        BUG_TRAP(sk_unhashed(sk));
@@ -644,7 +644,7 @@
        const struct inet_sock *inet = inet_sk(sk);
 
        return secure_tcp_port_ephemeral(inet->rcv_saddr, inet->daddr, 
-                                        inet->dport);
+                                        inet->inetsk_dport);
 }
 
 /*
@@ -652,7 +652,7 @@
  */
 static inline int tcp_v4_hash_connect(struct sock *sk)
 {
-       unsigned short snum = inet_sk(sk)->num;
+       unsigned short snum = inet_sk(sk)->inetsk_num;
        struct tcp_bind_hashbucket *head;
        struct tcp_bind_bucket *tb;
        int ret;
@@ -808,7 +808,7 @@
                }
        }
 
-       inet->dport = usin->sin_port;
+       inet->inetsk_dport = usin->sin_port;
        inet->daddr = daddr;
 
        tp->ext_header_len = 0;
@@ -827,7 +827,7 @@
        if (err)
                goto failure;
 
-       err = ip_route_newports(&rt, inet->sport, inet->dport, sk);
+       err = ip_route_newports(&rt, inet->sport, inet->inetsk_dport, sk);
        if (err)
                goto failure;
 
@@ -855,7 +855,7 @@
        tcp_set_state(sk, TCP_CLOSE);
        ip_rt_put(rt);
        sk->sk_route_caps = 0;
-       inet->dport = 0;
+       inet->inetsk_dport = 0;
        return err;
 }
 
@@ -1857,7 +1857,7 @@
                               RT_CONN_FLAGS(sk),
                               sk->sk_bound_dev_if,
                               IPPROTO_TCP,
-                              inet->sport, inet->dport, sk);
+                              inet->sport, inet->inetsk_dport, sk);
        if (err)
                return err;
 
@@ -1915,7 +1915,7 @@
                                    .proto = IPPROTO_TCP,
                                    .uli_u = { .ports =
                                               { .sport = inet->sport,
-                                                .dport = inet->dport } } };
+                                                .dport = inet->inetsk_dport } 
} };
                                                
                err = ip_route_output_flow(&rt, &fl, sk, 0);
        }
@@ -1944,7 +1944,7 @@
 
        sin->sin_family         = AF_INET;
        sin->sin_addr.s_addr    = inet->daddr;
-       sin->sin_port           = inet->dport;
+       sin->sin_port           = inet->inetsk_dport;
 }
 
 /* VJ's idea. Save last timestamp seen from this destination
@@ -2472,7 +2472,7 @@
        struct inet_sock *inet = inet_sk(sp);
        unsigned int dest = inet->daddr;
        unsigned int src = inet->rcv_saddr;
-       __u16 destp = ntohs(inet->dport);
+       __u16 destp = ntohs(inet->inetsk_dport);
        __u16 srcp = ntohs(inet->sport);
 
        if (tp->pending == TCP_TIME_RETRANS) {
--- linux-2.6.13-rc5/net/ipv4/tcp_minisocks.c   2005-08-02 06:45:48.000000000 
+0200
+++ linux-2.6.13-rc5-ed/net/ipv4/tcp_minisocks.c        2005-08-02 
15:17:26.000000000 +0200
@@ -303,7 +303,7 @@
           Note, that any socket with inet_sk(sk)->num != 0 MUST be bound in
           binding cache, even if it is closed.
         */
-       bhead = &tcp_bhash[tcp_bhashfn(inet_sk(sk)->num)];
+       bhead = &tcp_bhash[tcp_bhashfn(inet_sk(sk)->inetsk_num)];
        spin_lock(&bhead->lock);
        tw->tw_tb = tcp_sk(sk)->bind_hash;
        BUG_TRAP(tcp_sk(sk)->bind_hash);
@@ -346,11 +346,11 @@
                tw->tw_daddr            = inet->daddr;
                tw->tw_rcv_saddr        = inet->rcv_saddr;
                tw->tw_bound_dev_if     = sk->sk_bound_dev_if;
-               tw->tw_num              = inet->num;
+               tw->tw_num              = inet->inetsk_num;
                tw->tw_state            = TCP_TIME_WAIT;
                tw->tw_substate         = state;
                tw->tw_sport            = inet->sport;
-               tw->tw_dport            = inet->dport;
+               tw->tw_dport            = inet->inetsk_dport;
                tw->tw_family           = sk->sk_family;
                tw->tw_reuse            = sk->sk_reuse;
                tw->tw_rcv_wscale       = tp->rx_opt.rcv_wscale;
@@ -705,7 +705,7 @@
                tcp_sk(newsk)->bind_hash = NULL;
 
                /* Clone the TCP header template */
-               inet_sk(newsk)->dport = ireq->rmt_port;
+               inet_sk(newsk)->inetsk_dport = ireq->rmt_port;
 
                sock_lock_init(newsk);
                bh_lock_sock(newsk);
--- linux-2.6.13-rc5/net/ipv4/tcp_output.c      2005-08-02 06:45:48.000000000 
+0200
+++ linux-2.6.13-rc5-ed/net/ipv4/tcp_output.c   2005-08-02 15:01:27.000000000 
+0200
@@ -316,7 +316,7 @@
 
                /* Build TCP header and checksum it. */
                th->source              = inet->sport;
-               th->dest                = inet->dport;
+               th->dest                = inet->inetsk_dport;
                th->seq                 = htonl(tcb->seq);
                th->ack_seq             = htonl(tp->rcv_nxt);
                *(((__u16 *)th) + 6)    = htons(((tcp_header_size >> 2) << 12) 
| tcb->flags);
--- linux-2.6.13-rc5/net/ipv4/tcp_timer.c       2005-08-02 06:45:48.000000000 
+0200
+++ linux-2.6.13-rc5-ed/net/ipv4/tcp_timer.c    2005-08-02 15:02:18.000000000 
+0200
@@ -334,8 +334,8 @@
                if (net_ratelimit()) {
                        struct inet_sock *inet = inet_sk(sk);
                        printk(KERN_DEBUG "TCP: Treason uncloaked! Peer 
%u.%u.%u.%u:%u/%u shrinks window %u:%u. Repaired.\n",
-                              NIPQUAD(inet->daddr), htons(inet->dport),
-                              inet->num, tp->snd_una, tp->snd_nxt);
+                              NIPQUAD(inet->daddr), htons(inet->inetsk_dport),
+                              inet->inetsk_num, tp->snd_una, tp->snd_nxt);
                }
 #endif
                if (tcp_time_stamp - tp->rcv_tstamp > TCP_RTO_MAX) {
--- linux-2.6.13-rc5/net/ipv4/udp.c     2005-08-02 06:45:48.000000000 +0200
+++ linux-2.6.13-rc5-ed/net/ipv4/udp.c  2005-08-02 15:24:58.000000000 +0200
@@ -173,7 +173,7 @@
                            &udp_hash[snum & (UDP_HTABLE_SIZE - 1)]) {
                        struct inet_sock *inet2 = inet_sk(sk2);
 
-                       if (inet2->num == snum &&
+                       if (inet2->inetsk_num == snum &&
                            sk2 != sk &&
                            !ipv6_only_sock(sk2) &&
                            (!sk2->sk_bound_dev_if ||
@@ -186,7 +186,7 @@
                                goto fail;
                }
        }
-       inet->num = snum;
+       inet->inetsk_num = snum;
        if (sk_unhashed(sk)) {
                struct hlist_head *h = &udp_hash[snum & (UDP_HTABLE_SIZE - 1)];
 
@@ -210,7 +210,7 @@
 {
        write_lock_bh(&udp_hash_lock);
        if (sk_del_node_init(sk)) {
-               inet_sk(sk)->num = 0;
+               inet_sk(sk)->inetsk_num = 0;
                sock_prot_dec_use(sk->sk_prot);
        }
        write_unlock_bh(&udp_hash_lock);
@@ -230,7 +230,7 @@
        sk_for_each(sk, node, &udp_hash[hnum & (UDP_HTABLE_SIZE - 1)]) {
                struct inet_sock *inet = inet_sk(sk);
 
-               if (inet->num == hnum && !ipv6_only_sock(sk)) {
+               if (inet->inetsk_num == hnum && !ipv6_only_sock(sk)) {
                        int score = (sk->sk_family == PF_INET ? 1 : 0);
                        if (inet->rcv_saddr) {
                                if (inet->rcv_saddr != daddr)
@@ -242,8 +242,8 @@
                                        continue;
                                score+=2;
                        }
-                       if (inet->dport) {
-                               if (inet->dport != sport)
+                       if (inet->inetsk_dport) {
+                               if (inet->inetsk_dport != sport)
                                        continue;
                                score+=2;
                        }
@@ -289,9 +289,9 @@
        sk_for_each_from(s, node) {
                struct inet_sock *inet = inet_sk(s);
 
-               if (inet->num != hnum                                   ||
+               if (inet->inetsk_num != hnum                                    
||
                    (inet->daddr && inet->daddr != rmt_addr)            ||
-                   (inet->dport != rmt_port && inet->dport)            ||
+                   (inet->inetsk_dport != rmt_port && inet->inetsk_dport)      
        ||
                    (inet->rcv_saddr && inet->rcv_saddr != loc_addr)    ||
                    ipv6_only_sock(s)                                   ||
                    (s->sk_bound_dev_if && s->sk_bound_dev_if != dif))
@@ -544,7 +544,7 @@
                if (sk->sk_state != TCP_ESTABLISHED)
                        return -EDESTADDRREQ;
                daddr = inet->daddr;
-               dport = inet->dport;
+               dport = inet->inetsk_dport;
                /* Open fast path for connected socket.
                   Route will not be used, if at least one option is set.
                 */
@@ -875,7 +875,7 @@
         
        sk->sk_state = TCP_CLOSE;
        inet->daddr = 0;
-       inet->dport = 0;
+       inet->inetsk_dport = 0;
        sk->sk_bound_dev_if = 0;
        if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK))
                inet_reset_saddr(sk);
@@ -1512,7 +1512,7 @@
        struct inet_sock *inet = inet_sk(sp);
        unsigned int dest = inet->daddr;
        unsigned int src  = inet->rcv_saddr;
-       __u16 destp       = ntohs(inet->dport);
+       __u16 destp       = ntohs(inet->inetsk_dport);
        __u16 srcp        = ntohs(inet->sport);
 
        sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X"
--- linux-2.6.13-rc5/net/ipv6/af_inet6.c        2005-08-02 06:45:48.000000000 
+0200
+++ linux-2.6.13-rc5-ed/net/ipv6/af_inet6.c     2005-08-02 15:42:32.000000000 
+0200
@@ -180,7 +180,7 @@
        inet = inet_sk(sk);
 
        if (SOCK_RAW == sock->type) {
-               inet->num = protocol;
+               inet->inetsk_num = protocol;
                if (IPPROTO_RAW == protocol)
                        inet->hdrincl = 1;
        }
@@ -218,12 +218,12 @@
        atomic_inc(&inet6_sock_nr);
        atomic_inc(&inet_sock_nr);
 #endif
-       if (inet->num) {
+       if (inet->inetsk_num) {
                /* It assumes that any protocol which allows
                 * the user to assign a number at socket
                 * creation time automatically shares.
                 */
-               inet->sport = ntohs(inet->num);
+               inet->sport = ntohs(inet->inetsk_num);
                sk->sk_prot->hash(sk);
        }
        if (sk->sk_prot->init) {
@@ -270,7 +270,7 @@
        lock_sock(sk);
 
        /* Check these errors (active socket, double bind). */
-       if (sk->sk_state != TCP_CLOSE || inet->num) {
+       if (sk->sk_state != TCP_CLOSE || inet->inetsk_num) {
                err = -EINVAL;
                goto out;
        }
@@ -343,8 +343,8 @@
                sk->sk_userlocks |= SOCK_BINDADDR_LOCK;
        if (snum)
                sk->sk_userlocks |= SOCK_BINDPORT_LOCK;
-       inet->sport = ntohs(inet->num);
-       inet->dport = 0;
+       inet->sport = ntohs(inet->inetsk_num);
+       inet->inetsk_dport = 0;
        inet->daddr = 0;
 out:
        release_sock(sk);
@@ -411,12 +411,12 @@
        sin->sin6_flowinfo = 0;
        sin->sin6_scope_id = 0;
        if (peer) {
-               if (!inet->dport)
+               if (!inet->inetsk_dport)
                        return -ENOTCONN;
                if (((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_SYN_SENT)) &&
                    peer == 1)
                        return -ENOTCONN;
-               sin->sin6_port = inet->dport;
+               sin->sin6_port = inet->inetsk_dport;
                ipv6_addr_copy(&sin->sin6_addr, &np->daddr);
                if (np->sndflow)
                        sin->sin6_flowinfo = np->flow_label;
--- linux-2.6.13-rc5/net/ipv6/datagram.c        2005-08-02 06:45:48.000000000 
+0200
+++ linux-2.6.13-rc5-ed/net/ipv6/datagram.c     2005-08-02 15:50:08.000000000 
+0200
@@ -137,7 +137,7 @@
        ipv6_addr_copy(&np->daddr, daddr);
        np->flow_label = fl.fl6_flowlabel;
 
-       inet->dport = usin->sin6_port;
+       inet->inetsk_dport = usin->sin6_port;
 
        /*
         *      Check for a route to destination an obtain the
@@ -148,7 +148,7 @@
        ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
        ipv6_addr_copy(&fl.fl6_src, &np->saddr);
        fl.oif = sk->sk_bound_dev_if;
-       fl.fl_ip_dport = inet->dport;
+       fl.fl_ip_dport = inet->inetsk_dport;
        fl.fl_ip_sport = inet->sport;
 
        if (!fl.oif && (addr_type&IPV6_ADDR_MULTICAST))
--- linux-2.6.13-rc5/net/ipv6/ipv6_sockglue.c   2005-08-02 06:45:48.000000000 
+0200
+++ linux-2.6.13-rc5-ed/net/ipv6/ipv6_sockglue.c        2005-08-02 
15:43:24.000000000 +0200
@@ -70,7 +70,7 @@
        struct ip6_ra_chain *ra, *new_ra, **rap;
 
        /* RA packet may be delivered ONLY to IPPROTO_RAW socket */
-       if (sk->sk_type != SOCK_RAW || inet_sk(sk)->num != IPPROTO_RAW)
+       if (sk->sk_type != SOCK_RAW || inet_sk(sk)->inetsk_num != IPPROTO_RAW)
                return -EINVAL;
 
        new_ra = (sel>=0) ? kmalloc(sizeof(*new_ra), GFP_KERNEL) : NULL;
@@ -202,7 +202,7 @@
                goto e_inval;
 
        case IPV6_V6ONLY:
-               if (inet_sk(sk)->num)
+               if (inet_sk(sk)->inetsk_num)
                        goto e_inval;
                np->ipv6only = valbool;
                retv = 0;
--- linux-2.6.13-rc5/net/ipv6/raw.c     2005-08-02 06:45:48.000000000 +0200
+++ linux-2.6.13-rc5-ed/net/ipv6/raw.c  2005-08-02 15:46:49.000000000 +0200
@@ -61,7 +61,7 @@
 
 static void raw_v6_hash(struct sock *sk)
 {
-       struct hlist_head *list = &raw_v6_htable[inet_sk(sk)->num &
+       struct hlist_head *list = &raw_v6_htable[inet_sk(sk)->inetsk_num &
                                                 (RAWV6_HTABLE_SIZE - 1)];
 
        write_lock_bh(&raw_v6_lock);
@@ -87,7 +87,7 @@
        int is_multicast = ipv6_addr_is_multicast(loc_addr);
 
        sk_for_each_from(sk, node)
-               if (inet_sk(sk)->num == num) {
+               if (inet_sk(sk)->inetsk_num == num) {
                        struct ipv6_pinfo *np = inet6_sk(sk);
 
                        if (!ipv6_addr_any(&np->daddr) &&
@@ -331,7 +331,7 @@
                        skb->ip_summed = CHECKSUM_UNNECESSARY;
                        if (csum_ipv6_magic(&skb->nh.ipv6h->saddr,
                                            &skb->nh.ipv6h->daddr,
-                                           skb->len, inet->num, skb->csum)) {
+                                           skb->len, inet->inetsk_num, 
skb->csum)) {
                                LIMIT_NETDEBUG(
                                printk(KERN_DEBUG "raw v6 hw csum failure.\n"));
                                skb->ip_summed = CHECKSUM_NONE;
@@ -340,7 +340,7 @@
                if (skb->ip_summed == CHECKSUM_NONE)
                        skb->csum = ~csum_ipv6_magic(&skb->nh.ipv6h->saddr,
                                                     &skb->nh.ipv6h->daddr,
-                                                    skb->len, inet->num, 0);
+                                                    skb->len, 
inet->inetsk_num, 0);
        }
 
        if (inet->hdrincl) {
@@ -674,8 +674,8 @@
                proto = ntohs(sin6->sin6_port);
 
                if (!proto)
-                       proto = inet->num;
-               else if (proto != inet->num)
+                       proto = inet->inetsk_num;
+               else if (proto != inet->inetsk_num)
                        return(-EINVAL);
 
                if (proto > 255)
@@ -708,7 +708,7 @@
                if (sk->sk_state != TCP_ESTABLISHED) 
                        return -EDESTADDRREQ;
                
-               proto = inet->num;
+               proto = inet->inetsk_num;
                daddr = &np->daddr;
                fl.fl6_flowlabel = np->flow_label;
        }
@@ -875,7 +875,7 @@
                        break;
 
                case SOL_ICMPV6:
-                       if (inet_sk(sk)->num != IPPROTO_ICMPV6)
+                       if (inet_sk(sk)->inetsk_num != IPPROTO_ICMPV6)
                                return -EOPNOTSUPP;
                        return rawv6_seticmpfilter(sk, level, optname, optval,
                                                   optlen);
@@ -922,7 +922,7 @@
                        break;
 
                case SOL_ICMPV6:
-                       if (inet_sk(sk)->num != IPPROTO_ICMPV6)
+                       if (inet_sk(sk)->inetsk_num != IPPROTO_ICMPV6)
                                return -EOPNOTSUPP;
                        return rawv6_geticmpfilter(sk, level, optname, optval,
                                                   optlen);
@@ -986,7 +986,7 @@
 
 static void rawv6_close(struct sock *sk, long timeout)
 {
-       if (inet_sk(sk)->num == IPPROTO_RAW)
+       if (inet_sk(sk)->inetsk_num == IPPROTO_RAW)
                ip6_ra_control(sk, -1, NULL);
 
        sk_common_release(sk);
@@ -994,7 +994,7 @@
 
 static int rawv6_init_sk(struct sock *sk)
 {
-       if (inet_sk(sk)->num == IPPROTO_ICMPV6) {
+       if (inet_sk(sk)->inetsk_num == IPPROTO_ICMPV6) {
                struct raw6_sock *rp = raw6_sk(sk);
                rp->checksum = 1;
                rp->offset   = 2;
@@ -1102,7 +1102,7 @@
        dest  = &np->daddr;
        src   = &np->rcv_saddr;
        destp = 0;
-       srcp  = inet_sk(sp)->num;
+       srcp  = inet_sk(sp)->inetsk_num;
        seq_printf(seq,
                   "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
                   "%02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p\n",
--- linux-2.6.13-rc5/net/ipv6/tcp_ipv6.c        2005-08-02 06:45:48.000000000 
+0200
+++ linux-2.6.13-rc5-ed/net/ipv6/tcp_ipv6.c     2005-08-02 15:54:42.000000000 
+0200
@@ -93,8 +93,8 @@
        struct ipv6_pinfo *np = inet6_sk(sk);
        struct in6_addr *laddr = &np->rcv_saddr;
        struct in6_addr *faddr = &np->daddr;
-       __u16 lport = inet->num;
-       __u16 fport = inet->dport;
+       __u16 lport = inet->inetsk_num;
+       __u16 fport = inet->inetsk_dport;
        return tcp_v6_hashfn(laddr, lport, faddr, fport);
 }
 
@@ -260,7 +260,7 @@
        hiscore=0;
        read_lock(&tcp_lhash_lock);
        sk_for_each(sk, node, &tcp_listening_hash[tcp_lhashfn(hnum)]) {
-               if (inet_sk(sk)->num == hnum && sk->sk_family == PF_INET6) {
+               if (inet_sk(sk)->inetsk_num == hnum && sk->sk_family == 
PF_INET6) {
                        struct ipv6_pinfo *np = inet6_sk(sk);
                        
                        score = 1;
@@ -322,7 +322,7 @@
                /* FIXME: acme: check this... */
                struct tcp_tw_bucket *tw = (struct tcp_tw_bucket *)sk;
 
-               if(*((__u32 *)&(tw->tw_dport))  == ports        &&
+               if (tw->tw_key == ports &&
                   sk->sk_family                == PF_INET6) {
                        if(ipv6_addr_equal(&tw->tw_v6_daddr, saddr)     &&
                           ipv6_addr_equal(&tw->tw_v6_rcv_saddr, daddr) &&
@@ -454,8 +454,8 @@
        struct in6_addr *daddr = &np->rcv_saddr;
        struct in6_addr *saddr = &np->daddr;
        int dif = sk->sk_bound_dev_if;
-       u32 ports = TCP_COMBINED_PORTS(inet->dport, lport);
-       int hash = tcp_v6_hashfn(daddr, inet->num, saddr, inet->dport);
+       u32 ports = TCP_COMBINED_PORTS(inet->inetsk_dport, lport);
+       int hash = tcp_v6_hashfn(daddr, inet->inetsk_num, saddr, 
inet->inetsk_dport);
        struct tcp_ehash_bucket *head = &tcp_ehash[hash];
        struct sock *sk2;
        struct hlist_node *node;
@@ -467,7 +467,7 @@
        sk_for_each(sk2, node, &(head + tcp_ehash_size)->chain) {
                tw = (struct tcp_tw_bucket*)sk2;
 
-               if(*((__u32 *)&(tw->tw_dport))  == ports        &&
+               if (tw->tw_key == ports &&
                   sk2->sk_family               == PF_INET6     &&
                   ipv6_addr_equal(&tw->tw_v6_daddr, saddr)     &&
                   ipv6_addr_equal(&tw->tw_v6_rcv_saddr, daddr) &&
@@ -529,12 +529,12 @@
 
        return secure_tcpv6_port_ephemeral(np->rcv_saddr.s6_addr32,
                                           np->daddr.s6_addr32,
-                                          inet->dport);
+                                          inet->inetsk_dport);
 }
 
 static int tcp_v6_hash_connect(struct sock *sk)
 {
-       unsigned short snum = inet_sk(sk)->num;
+       unsigned short snum = inet_sk(sk)->inetsk_num;
        struct tcp_bind_hashbucket *head;
        struct tcp_bind_bucket *tb;
        int ret;
@@ -790,7 +790,7 @@
 
        tp->rx_opt.mss_clamp = IPV6_MIN_MTU - sizeof(struct tcphdr) - 
sizeof(struct ipv6hdr);
 
-       inet->dport = usin->sin6_port;
+       inet->inetsk_dport = usin->sin6_port;
 
        tcp_set_state(sk, TCP_SYN_SENT);
        err = tcp_v6_hash_connect(sk);
@@ -801,7 +801,7 @@
                tp->write_seq = 
secure_tcpv6_sequence_number(np->saddr.s6_addr32,
                                                             
np->daddr.s6_addr32,
                                                             inet->sport,
-                                                            inet->dport);
+                                                            
inet->inetsk_dport);
 
        err = tcp_connect(sk);
        if (err)
@@ -813,7 +813,7 @@
        tcp_set_state(sk, TCP_CLOSE);
        __sk_dst_reset(sk);
 failure:
-       inet->dport = 0;
+       inet->inetsk_dport = 0;
        sk->sk_route_caps = 0;
        return err;
 }
@@ -882,7 +882,7 @@
                        ipv6_addr_copy(&fl.fl6_dst, &np->daddr);
                        ipv6_addr_copy(&fl.fl6_src, &np->saddr);
                        fl.oif = sk->sk_bound_dev_if;
-                       fl.fl_ip_dport = inet->dport;
+                       fl.fl_ip_dport = inet->inetsk_dport;
                        fl.fl_ip_sport = inet->sport;
 
                        if ((err = ip6_dst_lookup(sk, &dst, &fl))) {
@@ -1844,7 +1844,7 @@
                ipv6_addr_copy(&fl.fl6_src, &np->saddr);
                fl.fl6_flowlabel = np->flow_label;
                fl.oif = sk->sk_bound_dev_if;
-               fl.fl_ip_dport = inet->dport;
+               fl.fl_ip_dport = inet->inetsk_dport;
                fl.fl_ip_sport = inet->sport;
 
                if (np->opt && np->opt->srcrt) {
@@ -1893,7 +1893,7 @@
        IP6_ECN_flow_xmit(sk, fl.fl6_flowlabel);
        fl.oif = sk->sk_bound_dev_if;
        fl.fl_ip_sport = inet->sport;
-       fl.fl_ip_dport = inet->dport;
+       fl.fl_ip_dport = inet->inetsk_dport;
 
        if (np->opt && np->opt->srcrt) {
                struct rt0_hdr *rt0 = (struct rt0_hdr *) np->opt->srcrt;
@@ -1941,7 +1941,7 @@
 
        sin6->sin6_family = AF_INET6;
        ipv6_addr_copy(&sin6->sin6_addr, &np->daddr);
-       sin6->sin6_port = inet_sk(sk)->dport;
+       sin6->sin6_port = inet_sk(sk)->inetsk_dport;
        /* We do not store received flowlabel for TCP */
        sin6->sin6_flowinfo = 0;
        sin6->sin6_scope_id = 0;
@@ -2090,7 +2090,7 @@
 
        dest  = &np->daddr;
        src   = &np->rcv_saddr;
-       destp = ntohs(inet->dport);
+       destp = ntohs(inet->inetsk_dport);
        srcp  = ntohs(inet->sport);
        if (tp->pending == TCP_TIME_RETRANS) {
                timer_active    = 1;
--- linux-2.6.13-rc5/net/ipv6/udp.c     2005-08-02 06:45:48.000000000 +0200
+++ linux-2.6.13-rc5-ed/net/ipv6/udp.c  2005-08-02 15:45:41.000000000 +0200
@@ -111,7 +111,7 @@
        } else {
                sk_for_each(sk2, node,
                            &udp_hash[snum & (UDP_HTABLE_SIZE - 1)]) {
-                       if (inet_sk(sk2)->num == snum &&
+                       if (inet_sk(sk2)->inetsk_num == snum &&
                            sk2 != sk &&
                            (!sk2->sk_bound_dev_if ||
                             !sk->sk_bound_dev_if ||
@@ -122,7 +122,7 @@
                }
        }
 
-       inet_sk(sk)->num = snum;
+       inet_sk(sk)->inetsk_num = snum;
        if (sk_unhashed(sk)) {
                sk_add_node(sk, &udp_hash[snum & (UDP_HTABLE_SIZE - 1)]);
                sock_prot_inc_use(sk->sk_prot);
@@ -144,7 +144,7 @@
 {
        write_lock_bh(&udp_hash_lock);
        if (sk_del_node_init(sk)) {
-               inet_sk(sk)->num = 0;
+               inet_sk(sk)->inetsk_num = 0;
                sock_prot_dec_use(sk->sk_prot);
        }
        write_unlock_bh(&udp_hash_lock);
@@ -162,11 +162,11 @@
        sk_for_each(sk, node, &udp_hash[hnum & (UDP_HTABLE_SIZE - 1)]) {
                struct inet_sock *inet = inet_sk(sk);
 
-               if (inet->num == hnum && sk->sk_family == PF_INET6) {
+               if (inet->inetsk_num == hnum && sk->sk_family == PF_INET6) {
                        struct ipv6_pinfo *np = inet6_sk(sk);
                        int score = 0;
-                       if (inet->dport) {
-                               if (inet->dport != sport)
+                       if (inet->inetsk_dport) {
+                               if (inet->inetsk_dport != sport)
                                        continue;
                                score++;
                        }
@@ -390,10 +390,10 @@
        sk_for_each_from(s, node) {
                struct inet_sock *inet = inet_sk(s);
 
-               if (inet->num == num && s->sk_family == PF_INET6) {
+               if (inet->inetsk_num == num && s->sk_family == PF_INET6) {
                        struct ipv6_pinfo *np = inet6_sk(s);
-                       if (inet->dport) {
-                               if (inet->dport != rmt_port)
+                       if (inet->inetsk_dport) {
+                               if (inet->inetsk_dport != rmt_port)
                                        continue;
                        }
                        if (!ipv6_addr_any(&np->daddr) &&
@@ -672,7 +672,7 @@
                if (ipv6_addr_type(daddr) == IPV6_ADDR_MAPPED) {
                        struct sockaddr_in sin;
                        sin.sin_family = AF_INET;
-                       sin.sin_port = sin6 ? sin6->sin6_port : inet->dport;
+                       sin.sin_port = sin6 ? sin6->sin6_port : 
inet->inetsk_dport;
                        sin.sin_addr.s_addr = daddr->s6_addr32[3];
                        msg->msg_name = &sin;
                        msg->msg_namelen = sizeof(sin);
@@ -745,7 +745,7 @@
                if (sk->sk_state != TCP_ESTABLISHED)
                        return -EDESTADDRREQ;
 
-               fl->fl_ip_dport = inet->dport;
+               fl->fl_ip_dport = inet->inetsk_dport;
                daddr = &np->daddr;
                fl->fl6_flowlabel = np->flow_label;
        }
@@ -981,7 +981,7 @@
 
        dest  = &np->daddr;
        src   = &np->rcv_saddr;
-       destp = ntohs(inet->dport);
+       destp = ntohs(inet->inetsk_dport);
        srcp  = ntohs(inet->sport);
        seq_printf(seq,
                   "%4d: %08X%08X%08X%08X:%04X %08X%08X%08X%08X:%04X "
--- linux-2.6.13-rc5/net/ipv4/ipmr.c    2005-08-02 06:45:48.000000000 +0200
+++ linux-2.6.13-rc5-ed/net/ipv4/ipmr.c 2005-08-02 17:51:42.000000000 +0200
@@ -868,7 +868,7 @@
        {
                case MRT_INIT:
                        if (sk->sk_type != SOCK_RAW ||
-                           inet_sk(sk)->num != IPPROTO_IGMP)
+                           inet_sk(sk)->inetsk_num != IPPROTO_IGMP)
                                return -EOPNOTSUPP;
                        if(optlen!=sizeof(int))
                                return -ENOPROTOOPT;
--- linux-2.6.13-rc5/security/selinux/avc.c     2005-08-02 06:45:48.000000000 
+0200
+++ linux-2.6.13-rc5-ed/security/selinux/avc.c  2005-08-02 18:15:09.000000000 
+0200
@@ -608,7 +608,7 @@
                                                            inet->sport,
                                                            "laddr", "lport");
                                        avc_print_ipv4_addr(ab, inet->daddr,
-                                                           inet->dport,
+                                                           inet->inetsk_dport,
                                                            "faddr", "fport");
                                        break;
                                }
@@ -620,7 +620,7 @@
                                                            inet->sport,
                                                            "laddr", "lport");
                                        avc_print_ipv6_addr(ab, &inet6->daddr,
-                                                           inet->dport,
+                                                           inet->inetsk_dport,
                                                            "faddr", "fport");
                                        break;
                                }

Reply via email to