[SOCK]: Introduce sk_setup_caps
authorArnaldo Carvalho de Melo <acme@ghostprotocols.net>
Wed, 10 Aug 2005 02:49:02 +0000 (19:49 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Mon, 29 Aug 2005 22:37:48 +0000 (15:37 -0700)
From tcp_v4_setup_caps, that always is preceded by a call to
__sk_dst_set, so coalesce this sequence into sk_setup_caps, removing
one call to a TCP function in the IP layer.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/sock.h
include/net/tcp.h
net/ipv4/ip_output.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_minisocks.c

index f91ee82522ffcd7206982858ac2bed80540a0aa1..69d869e41c3550d3a6c2b6f2cd273b358c4f540e 100644 (file)
@@ -1025,6 +1025,16 @@ sk_dst_check(struct sock *sk, u32 cookie)
        return dst;
 }
 
+static inline void sk_setup_caps(struct sock *sk, struct dst_entry *dst)
+{
+       __sk_dst_set(sk, dst);
+       sk->sk_route_caps = dst->dev->features;
+       if (sk->sk_route_caps & NETIF_F_TSO) {
+               if (sock_flag(sk, SOCK_NO_LARGESEND) || dst->header_len)
+                       sk->sk_route_caps &= ~NETIF_F_TSO;
+       }
+}
+
 static inline void sk_charge_skb(struct sock *sk, struct sk_buff *skb)
 {
        sk->sk_wmem_queued   += skb->truesize;
index 31984733777bc6dda7c6ecc05bd5e1681c44d320..d95661a3aeeb51eeb18a173a69d54e4aca8c8e7a 100644 (file)
@@ -1658,15 +1658,6 @@ static inline int tcp_paws_check(const struct tcp_options_received *rx_opt, int
        return 1;
 }
 
-static inline void tcp_v4_setup_caps(struct sock *sk, struct dst_entry *dst)
-{
-       sk->sk_route_caps = dst->dev->features;
-       if (sk->sk_route_caps & NETIF_F_TSO) {
-               if (sock_flag(sk, SOCK_NO_LARGESEND) || dst->header_len)
-                       sk->sk_route_caps &= ~NETIF_F_TSO;
-       }
-}
-
 #define TCP_CHECK_TIMER(sk) do { } while (0)
 
 static inline int tcp_use_frto(const struct sock *sk)
index c934f5316c3bc1362e85029f3978448501028b96..c72fc878f06d7f7c1e0d4870d442de4e6a21c570 100644 (file)
 #include <net/ip.h>
 #include <net/protocol.h>
 #include <net/route.h>
-#include <net/tcp.h>
-#include <net/udp.h>
 #include <linux/skbuff.h>
 #include <net/sock.h>
 #include <net/arp.h>
 #include <net/icmp.h>
-#include <net/raw.h>
 #include <net/checksum.h>
 #include <net/inetpeer.h>
 #include <net/checksum.h>
@@ -84,6 +81,7 @@
 #include <linux/netfilter_bridge.h>
 #include <linux/mroute.h>
 #include <linux/netlink.h>
+#include <linux/tcp.h>
 
 /*
  *      Shall we try to damage output packets if routing dev changes?
@@ -329,8 +327,7 @@ int ip_queue_xmit(struct sk_buff *skb, int ipfragok)
                        if (ip_route_output_flow(&rt, &fl, sk, 0))
                                goto no_route;
                }
-               __sk_dst_set(sk, &rt->u.dst);
-               tcp_v4_setup_caps(sk, &rt->u.dst);
+               sk_setup_caps(sk, &rt->u.dst);
        }
        skb->dst = dst_clone(&rt->u.dst);
 
index c7c99d3363687aa1fe185a5fd05b844d6f1da2dc..4a5daecbd2ac185c604518fb4862b7b710ba8984 100644 (file)
@@ -837,8 +837,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
                goto failure;
 
        /* OK, now commit destination to socket.  */
-       __sk_dst_set(sk, &rt->u.dst);
-       tcp_v4_setup_caps(sk, &rt->u.dst);
+       sk_setup_caps(sk, &rt->u.dst);
 
        if (!tp->write_seq)
                tp->write_seq = secure_tcp_sequence_number(inet->saddr,
@@ -1553,8 +1552,7 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
        if (!newsk)
                goto exit;
 
-       newsk->sk_dst_cache = dst;
-       tcp_v4_setup_caps(newsk, dst);
+       sk_setup_caps(newsk, dst);
 
        newtp                 = tcp_sk(newsk);
        newinet               = inet_sk(newsk);
@@ -1855,8 +1853,7 @@ static int tcp_v4_reselect_saddr(struct sock *sk)
        if (err)
                return err;
 
-       __sk_dst_set(sk, &rt->u.dst);
-       tcp_v4_setup_caps(sk, &rt->u.dst);
+       sk_setup_caps(sk, &rt->u.dst);
 
        new_saddr = rt->rt_src;
 
@@ -1914,8 +1911,7 @@ int tcp_v4_rebuild_header(struct sock *sk)
                err = ip_route_output_flow(&rt, &fl, sk, 0);
        }
        if (!err) {
-               __sk_dst_set(sk, &rt->u.dst);
-               tcp_v4_setup_caps(sk, &rt->u.dst);
+               sk_setup_caps(sk, &rt->u.dst);
                return 0;
        }
 
index f8e288c8d69374a22f1bfc1cc3cc753a76672696..7c46a553c4af5663ad044a2102f4b8bcc2b10512 100644 (file)
@@ -711,6 +711,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
                bh_lock_sock(newsk);
 
                rwlock_init(&newsk->sk_dst_lock);
+               newsk->sk_dst_cache = NULL;
                atomic_set(&newsk->sk_rmem_alloc, 0);
                skb_queue_head_init(&newsk->sk_receive_queue);
                atomic_set(&newsk->sk_wmem_alloc, 0);