diff options
author | Arnaldo Carvalho de Melo <acme@mandriva.com> | 2005-12-14 02:26:10 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-01-03 16:10:58 -0500 |
commit | d83d8461f902c672bc1bd8fbc6a94e19f092da97 (patch) | |
tree | 0534c553ab92baa2eb9dbb5bba64f2c4540b1e89 /net/ipv4 | |
parent | 22712813620fa8e682dbfb253a60ca0131da1e07 (diff) |
[IP_SOCKGLUE]: Remove most of the tcp specific calls
As DCCP needs to be called in the same spots.
Now we have a member in inet_sock (is_icsk), set at sock creation time from
struct inet_protosw->flags (if INET_PROTOSW_ICSK is set, like for TCP and
DCCP) to see if a struct sock instance is a inet_connection_sock for places
like the ones in ip_sockglue.c (v4 and v6) where we previously were looking if
sk_type was SOCK_STREAM, that is insufficient because we now use the same code
for DCCP, that has sk_type SOCK_DCCP.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/af_inet.c | 4 | ||||
-rw-r--r-- | net/ipv4/ip_sockglue.c | 13 | ||||
-rw-r--r-- | net/ipv4/tcp.c | 2 | ||||
-rw-r--r-- | net/ipv4/tcp_input.c | 10 | ||||
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 12 | ||||
-rw-r--r-- | net/ipv4/tcp_output.c | 18 |
6 files changed, 30 insertions, 29 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index d368cf249000..617e858beff1 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -302,6 +302,7 @@ lookup_protocol: | |||
302 | sk->sk_reuse = 1; | 302 | sk->sk_reuse = 1; |
303 | 303 | ||
304 | inet = inet_sk(sk); | 304 | inet = inet_sk(sk); |
305 | inet->is_icsk = INET_PROTOSW_ICSK & answer_flags; | ||
305 | 306 | ||
306 | if (SOCK_RAW == sock->type) { | 307 | if (SOCK_RAW == sock->type) { |
307 | inet->num = protocol; | 308 | inet->num = protocol; |
@@ -869,7 +870,8 @@ static struct inet_protosw inetsw_array[] = | |||
869 | .ops = &inet_stream_ops, | 870 | .ops = &inet_stream_ops, |
870 | .capability = -1, | 871 | .capability = -1, |
871 | .no_check = 0, | 872 | .no_check = 0, |
872 | .flags = INET_PROTOSW_PERMANENT, | 873 | .flags = INET_PROTOSW_PERMANENT | |
874 | INET_PROTOSW_ICSK, | ||
873 | }, | 875 | }, |
874 | 876 | ||
875 | { | 877 | { |
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 4f2d87257309..add019c746f8 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c | |||
@@ -29,8 +29,7 @@ | |||
29 | #include <net/sock.h> | 29 | #include <net/sock.h> |
30 | #include <net/ip.h> | 30 | #include <net/ip.h> |
31 | #include <net/icmp.h> | 31 | #include <net/icmp.h> |
32 | #include <net/tcp.h> | 32 | #include <net/tcp_states.h> |
33 | #include <linux/tcp.h> | ||
34 | #include <linux/udp.h> | 33 | #include <linux/udp.h> |
35 | #include <linux/igmp.h> | 34 | #include <linux/igmp.h> |
36 | #include <linux/netfilter.h> | 35 | #include <linux/netfilter.h> |
@@ -427,8 +426,8 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, | |||
427 | err = ip_options_get_from_user(&opt, optval, optlen); | 426 | err = ip_options_get_from_user(&opt, optval, optlen); |
428 | if (err) | 427 | if (err) |
429 | break; | 428 | break; |
430 | if (sk->sk_type == SOCK_STREAM) { | 429 | if (inet->is_icsk) { |
431 | struct tcp_sock *tp = tcp_sk(sk); | 430 | struct inet_connection_sock *icsk = inet_csk(sk); |
432 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 431 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
433 | if (sk->sk_family == PF_INET || | 432 | if (sk->sk_family == PF_INET || |
434 | (!((1 << sk->sk_state) & | 433 | (!((1 << sk->sk_state) & |
@@ -436,10 +435,10 @@ int ip_setsockopt(struct sock *sk, int level, int optname, char __user *optval, | |||
436 | inet->daddr != LOOPBACK4_IPV6)) { | 435 | inet->daddr != LOOPBACK4_IPV6)) { |
437 | #endif | 436 | #endif |
438 | if (inet->opt) | 437 | if (inet->opt) |
439 | tp->ext_header_len -= inet->opt->optlen; | 438 | icsk->icsk_ext_hdr_len -= inet->opt->optlen; |
440 | if (opt) | 439 | if (opt) |
441 | tp->ext_header_len += opt->optlen; | 440 | icsk->icsk_ext_hdr_len += opt->optlen; |
442 | tcp_sync_mss(sk, tp->pmtu_cookie); | 441 | icsk->icsk_sync_mss(sk, icsk->icsk_pmtu_cookie); |
443 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 442 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
444 | } | 443 | } |
445 | #endif | 444 | #endif |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index eacfe6a3442c..00aa80e93243 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -1914,7 +1914,7 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info) | |||
1914 | info->tcpi_last_data_recv = jiffies_to_msecs(now - icsk->icsk_ack.lrcvtime); | 1914 | info->tcpi_last_data_recv = jiffies_to_msecs(now - icsk->icsk_ack.lrcvtime); |
1915 | info->tcpi_last_ack_recv = jiffies_to_msecs(now - tp->rcv_tstamp); | 1915 | info->tcpi_last_ack_recv = jiffies_to_msecs(now - tp->rcv_tstamp); |
1916 | 1916 | ||
1917 | info->tcpi_pmtu = tp->pmtu_cookie; | 1917 | info->tcpi_pmtu = icsk->icsk_pmtu_cookie; |
1918 | info->tcpi_rcv_ssthresh = tp->rcv_ssthresh; | 1918 | info->tcpi_rcv_ssthresh = tp->rcv_ssthresh; |
1919 | info->tcpi_rtt = jiffies_to_usecs(tp->srtt)>>3; | 1919 | info->tcpi_rtt = jiffies_to_usecs(tp->srtt)>>3; |
1920 | info->tcpi_rttvar = jiffies_to_usecs(tp->mdev)>>2; | 1920 | info->tcpi_rttvar = jiffies_to_usecs(tp->mdev)>>2; |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 7de6184d4bd8..981d1203b152 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -2342,7 +2342,7 @@ static int tcp_ack_update_window(struct sock *sk, struct tcp_sock *tp, | |||
2342 | 2342 | ||
2343 | if (nwin > tp->max_window) { | 2343 | if (nwin > tp->max_window) { |
2344 | tp->max_window = nwin; | 2344 | tp->max_window = nwin; |
2345 | tcp_sync_mss(sk, tp->pmtu_cookie); | 2345 | tcp_sync_mss(sk, inet_csk(sk)->icsk_pmtu_cookie); |
2346 | } | 2346 | } |
2347 | } | 2347 | } |
2348 | } | 2348 | } |
@@ -3967,12 +3967,12 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, | |||
3967 | struct tcphdr *th, unsigned len) | 3967 | struct tcphdr *th, unsigned len) |
3968 | { | 3968 | { |
3969 | struct tcp_sock *tp = tcp_sk(sk); | 3969 | struct tcp_sock *tp = tcp_sk(sk); |
3970 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
3970 | int saved_clamp = tp->rx_opt.mss_clamp; | 3971 | int saved_clamp = tp->rx_opt.mss_clamp; |
3971 | 3972 | ||
3972 | tcp_parse_options(skb, &tp->rx_opt, 0); | 3973 | tcp_parse_options(skb, &tp->rx_opt, 0); |
3973 | 3974 | ||
3974 | if (th->ack) { | 3975 | if (th->ack) { |
3975 | struct inet_connection_sock *icsk; | ||
3976 | /* rfc793: | 3976 | /* rfc793: |
3977 | * "If the state is SYN-SENT then | 3977 | * "If the state is SYN-SENT then |
3978 | * first check the ACK bit | 3978 | * first check the ACK bit |
@@ -4061,7 +4061,7 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, | |||
4061 | if (tp->rx_opt.sack_ok && sysctl_tcp_fack) | 4061 | if (tp->rx_opt.sack_ok && sysctl_tcp_fack) |
4062 | tp->rx_opt.sack_ok |= 2; | 4062 | tp->rx_opt.sack_ok |= 2; |
4063 | 4063 | ||
4064 | tcp_sync_mss(sk, tp->pmtu_cookie); | 4064 | tcp_sync_mss(sk, icsk->icsk_pmtu_cookie); |
4065 | tcp_initialize_rcv_mss(sk); | 4065 | tcp_initialize_rcv_mss(sk); |
4066 | 4066 | ||
4067 | /* Remember, tcp_poll() does not lock socket! | 4067 | /* Remember, tcp_poll() does not lock socket! |
@@ -4071,8 +4071,6 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, | |||
4071 | mb(); | 4071 | mb(); |
4072 | tcp_set_state(sk, TCP_ESTABLISHED); | 4072 | tcp_set_state(sk, TCP_ESTABLISHED); |
4073 | 4073 | ||
4074 | icsk = inet_csk(sk); | ||
4075 | |||
4076 | /* Make sure socket is routed, for correct metrics. */ | 4074 | /* Make sure socket is routed, for correct metrics. */ |
4077 | icsk->icsk_af_ops->rebuild_header(sk); | 4075 | icsk->icsk_af_ops->rebuild_header(sk); |
4078 | 4076 | ||
@@ -4173,7 +4171,7 @@ discard: | |||
4173 | if (tp->ecn_flags&TCP_ECN_OK) | 4171 | if (tp->ecn_flags&TCP_ECN_OK) |
4174 | sock_set_flag(sk, SOCK_NO_LARGESEND); | 4172 | sock_set_flag(sk, SOCK_NO_LARGESEND); |
4175 | 4173 | ||
4176 | tcp_sync_mss(sk, tp->pmtu_cookie); | 4174 | tcp_sync_mss(sk, icsk->icsk_pmtu_cookie); |
4177 | tcp_initialize_rcv_mss(sk); | 4175 | tcp_initialize_rcv_mss(sk); |
4178 | 4176 | ||
4179 | 4177 | ||
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index c2fe61becd61..9b62d80bb20f 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -220,9 +220,9 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) | |||
220 | inet->dport = usin->sin_port; | 220 | inet->dport = usin->sin_port; |
221 | inet->daddr = daddr; | 221 | inet->daddr = daddr; |
222 | 222 | ||
223 | tp->ext_header_len = 0; | 223 | inet_csk(sk)->icsk_ext_hdr_len = 0; |
224 | if (inet->opt) | 224 | if (inet->opt) |
225 | tp->ext_header_len = inet->opt->optlen; | 225 | inet_csk(sk)->icsk_ext_hdr_len = inet->opt->optlen; |
226 | 226 | ||
227 | tp->rx_opt.mss_clamp = 536; | 227 | tp->rx_opt.mss_clamp = 536; |
228 | 228 | ||
@@ -275,7 +275,6 @@ static inline void do_pmtu_discovery(struct sock *sk, struct iphdr *iph, | |||
275 | { | 275 | { |
276 | struct dst_entry *dst; | 276 | struct dst_entry *dst; |
277 | struct inet_sock *inet = inet_sk(sk); | 277 | struct inet_sock *inet = inet_sk(sk); |
278 | struct tcp_sock *tp = tcp_sk(sk); | ||
279 | 278 | ||
280 | /* We are not interested in TCP_LISTEN and open_requests (SYN-ACKs | 279 | /* We are not interested in TCP_LISTEN and open_requests (SYN-ACKs |
281 | * send out by Linux are always <576bytes so they should go through | 280 | * send out by Linux are always <576bytes so they should go through |
@@ -304,7 +303,7 @@ static inline void do_pmtu_discovery(struct sock *sk, struct iphdr *iph, | |||
304 | mtu = dst_mtu(dst); | 303 | mtu = dst_mtu(dst); |
305 | 304 | ||
306 | if (inet->pmtudisc != IP_PMTUDISC_DONT && | 305 | if (inet->pmtudisc != IP_PMTUDISC_DONT && |
307 | tp->pmtu_cookie > mtu) { | 306 | inet_csk(sk)->icsk_pmtu_cookie > mtu) { |
308 | tcp_sync_mss(sk, mtu); | 307 | tcp_sync_mss(sk, mtu); |
309 | 308 | ||
310 | /* Resend the TCP packet because it's | 309 | /* Resend the TCP packet because it's |
@@ -895,9 +894,9 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, | |||
895 | ireq->opt = NULL; | 894 | ireq->opt = NULL; |
896 | newinet->mc_index = inet_iif(skb); | 895 | newinet->mc_index = inet_iif(skb); |
897 | newinet->mc_ttl = skb->nh.iph->ttl; | 896 | newinet->mc_ttl = skb->nh.iph->ttl; |
898 | newtp->ext_header_len = 0; | 897 | inet_csk(newsk)->icsk_ext_hdr_len = 0; |
899 | if (newinet->opt) | 898 | if (newinet->opt) |
900 | newtp->ext_header_len = newinet->opt->optlen; | 899 | inet_csk(newsk)->icsk_ext_hdr_len = newinet->opt->optlen; |
901 | newinet->id = newtp->write_seq ^ jiffies; | 900 | newinet->id = newtp->write_seq ^ jiffies; |
902 | 901 | ||
903 | tcp_sync_mss(newsk, dst_mtu(dst)); | 902 | tcp_sync_mss(newsk, dst_mtu(dst)); |
@@ -1266,6 +1265,7 @@ static int tcp_v4_init_sock(struct sock *sk) | |||
1266 | sock_set_flag(sk, SOCK_USE_WRITE_QUEUE); | 1265 | sock_set_flag(sk, SOCK_USE_WRITE_QUEUE); |
1267 | 1266 | ||
1268 | icsk->icsk_af_ops = &ipv4_specific; | 1267 | icsk->icsk_af_ops = &ipv4_specific; |
1268 | icsk->icsk_sync_mss = tcp_sync_mss; | ||
1269 | 1269 | ||
1270 | sk->sk_sndbuf = sysctl_tcp_wmem[1]; | 1270 | sk->sk_sndbuf = sysctl_tcp_wmem[1]; |
1271 | sk->sk_rcvbuf = sysctl_tcp_rmem[1]; | 1271 | sk->sk_rcvbuf = sysctl_tcp_rmem[1]; |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index af1946c52c37..3a0a914de917 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -621,7 +621,7 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) | |||
621 | It is minimum of user_mss and mss received with SYN. | 621 | It is minimum of user_mss and mss received with SYN. |
622 | It also does not include TCP options. | 622 | It also does not include TCP options. |
623 | 623 | ||
624 | tp->pmtu_cookie is last pmtu, seen by this function. | 624 | inet_csk(sk)->icsk_pmtu_cookie is last pmtu, seen by this function. |
625 | 625 | ||
626 | tp->mss_cache is current effective sending mss, including | 626 | tp->mss_cache is current effective sending mss, including |
627 | all tcp options except for SACKs. It is evaluated, | 627 | all tcp options except for SACKs. It is evaluated, |
@@ -631,17 +631,18 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) | |||
631 | NOTE1. rfc1122 clearly states that advertised MSS | 631 | NOTE1. rfc1122 clearly states that advertised MSS |
632 | DOES NOT include either tcp or ip options. | 632 | DOES NOT include either tcp or ip options. |
633 | 633 | ||
634 | NOTE2. tp->pmtu_cookie and tp->mss_cache are READ ONLY outside | 634 | NOTE2. inet_csk(sk)->icsk_pmtu_cookie and tp->mss_cache |
635 | this function. --ANK (980731) | 635 | are READ ONLY outside this function. --ANK (980731) |
636 | */ | 636 | */ |
637 | 637 | ||
638 | unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu) | 638 | unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu) |
639 | { | 639 | { |
640 | struct tcp_sock *tp = tcp_sk(sk); | 640 | struct tcp_sock *tp = tcp_sk(sk); |
641 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
641 | /* Calculate base mss without TCP options: | 642 | /* Calculate base mss without TCP options: |
642 | It is MMS_S - sizeof(tcphdr) of rfc1122 | 643 | It is MMS_S - sizeof(tcphdr) of rfc1122 |
643 | */ | 644 | */ |
644 | int mss_now = (pmtu - inet_csk(sk)->icsk_af_ops->net_header_len - | 645 | int mss_now = (pmtu - icsk->icsk_af_ops->net_header_len - |
645 | sizeof(struct tcphdr)); | 646 | sizeof(struct tcphdr)); |
646 | 647 | ||
647 | /* Clamp it (mss_clamp does not include tcp options) */ | 648 | /* Clamp it (mss_clamp does not include tcp options) */ |
@@ -649,7 +650,7 @@ unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu) | |||
649 | mss_now = tp->rx_opt.mss_clamp; | 650 | mss_now = tp->rx_opt.mss_clamp; |
650 | 651 | ||
651 | /* Now subtract optional transport overhead */ | 652 | /* Now subtract optional transport overhead */ |
652 | mss_now -= tp->ext_header_len; | 653 | mss_now -= icsk->icsk_ext_hdr_len; |
653 | 654 | ||
654 | /* Then reserve room for full set of TCP options and 8 bytes of data */ | 655 | /* Then reserve room for full set of TCP options and 8 bytes of data */ |
655 | if (mss_now < 48) | 656 | if (mss_now < 48) |
@@ -663,7 +664,7 @@ unsigned int tcp_sync_mss(struct sock *sk, u32 pmtu) | |||
663 | mss_now = max((tp->max_window>>1), 68U - tp->tcp_header_len); | 664 | mss_now = max((tp->max_window>>1), 68U - tp->tcp_header_len); |
664 | 665 | ||
665 | /* And store cached results */ | 666 | /* And store cached results */ |
666 | tp->pmtu_cookie = pmtu; | 667 | icsk->icsk_pmtu_cookie = pmtu; |
667 | tp->mss_cache = mss_now; | 668 | tp->mss_cache = mss_now; |
668 | 669 | ||
669 | return mss_now; | 670 | return mss_now; |
@@ -693,7 +694,7 @@ unsigned int tcp_current_mss(struct sock *sk, int large_allowed) | |||
693 | 694 | ||
694 | if (dst) { | 695 | if (dst) { |
695 | u32 mtu = dst_mtu(dst); | 696 | u32 mtu = dst_mtu(dst); |
696 | if (mtu != tp->pmtu_cookie) | 697 | if (mtu != inet_csk(sk)->icsk_pmtu_cookie) |
697 | mss_now = tcp_sync_mss(sk, mtu); | 698 | mss_now = tcp_sync_mss(sk, mtu); |
698 | } | 699 | } |
699 | 700 | ||
@@ -706,7 +707,8 @@ unsigned int tcp_current_mss(struct sock *sk, int large_allowed) | |||
706 | if (doing_tso) { | 707 | if (doing_tso) { |
707 | xmit_size_goal = (65535 - | 708 | xmit_size_goal = (65535 - |
708 | inet_csk(sk)->icsk_af_ops->net_header_len - | 709 | inet_csk(sk)->icsk_af_ops->net_header_len - |
709 | tp->ext_header_len - tp->tcp_header_len); | 710 | inet_csk(sk)->icsk_ext_hdr_len - |
711 | tp->tcp_header_len); | ||
710 | 712 | ||
711 | if (tp->max_window && | 713 | if (tp->max_window && |
712 | (xmit_size_goal > (tp->max_window >> 1))) | 714 | (xmit_size_goal > (tp->max_window >> 1))) |