aboutsummaryrefslogtreecommitdiffstats
path: root/net/dccp/ccids
diff options
context:
space:
mode:
authorGerrit Renker <gerrit@erg.abdn.ac.uk>2010-08-22 15:41:37 -0400
committerDavid S. Miller <davem@davemloft.net>2010-08-23 23:13:30 -0400
commit51c22bb510fefbb1a87c02dbd835383e6e7e3d36 (patch)
tree16c792c63bdf6de0fd92c27f2819161edd15927e /net/dccp/ccids
parent67b67e365f07d6dc70f3bb266af3268bac0a4836 (diff)
dccp ccid-3: No more CCID control blocks in LISTEN state
The CCIDs are activated as last of the features, at the end of the handshake, were the LISTEN state of the master socket is inherited into the server state of the child socket. Thus, the only states visible to CCIDs now are OPEN/PARTOPEN, and the closing states. This allows to remove tests which were previously necessary to protect against referencing a socket in the listening state (in CCID-3), but which now have become redundant. As a further byproduct of enabling the CCIDs only after the connection has been fully established, several typecast-initialisations of ccid3_hc_{rx,tx}_sock can now be eliminated: * the CCID is loaded, so it is not necessary to test if it is NULL, * if it is possible to load a CCID and leave the private area NULL, then this is a bug, which should crash loudly - and earlier, * the test for state==OPEN || state==PARTOPEN now reduces only to the closing phase (e.g. when the node has received an unexpected Reset). Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> Acked-by: Ian McDonald <ian.mcdonald@jandi.co.nz> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp/ccids')
-rw-r--r--net/dccp/ccids/ccid3.c40
1 files changed, 7 insertions, 33 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c
index a666f3febf2b..4340672a817c 100644
--- a/net/dccp/ccids/ccid3.c
+++ b/net/dccp/ccids/ccid3.c
@@ -564,29 +564,17 @@ static void ccid3_hc_tx_exit(struct sock *sk)
564 564
565static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info) 565static void ccid3_hc_tx_get_info(struct sock *sk, struct tcp_info *info)
566{ 566{
567 struct ccid3_hc_tx_sock *hc; 567 info->tcpi_rto = ccid3_hc_tx_sk(sk)->tx_t_rto;
568 568 info->tcpi_rtt = ccid3_hc_tx_sk(sk)->tx_rtt;
569 /* Listen socks doesn't have a private CCID block */
570 if (sk->sk_state == DCCP_LISTEN)
571 return;
572
573 hc = ccid3_hc_tx_sk(sk);
574 info->tcpi_rto = hc->tx_t_rto;
575 info->tcpi_rtt = hc->tx_rtt;
576} 569}
577 570
578static int ccid3_hc_tx_getsockopt(struct sock *sk, const int optname, int len, 571static int ccid3_hc_tx_getsockopt(struct sock *sk, const int optname, int len,
579 u32 __user *optval, int __user *optlen) 572 u32 __user *optval, int __user *optlen)
580{ 573{
581 const struct ccid3_hc_tx_sock *hc; 574 const struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk);
582 struct tfrc_tx_info tfrc; 575 struct tfrc_tx_info tfrc;
583 const void *val; 576 const void *val;
584 577
585 /* Listen socks doesn't have a private CCID block */
586 if (sk->sk_state == DCCP_LISTEN)
587 return -EINVAL;
588
589 hc = ccid3_hc_tx_sk(sk);
590 switch (optname) { 578 switch (optname) {
591 case DCCP_SOCKOPT_CCID_TX_INFO: 579 case DCCP_SOCKOPT_CCID_TX_INFO:
592 if (len < sizeof(tfrc)) 580 if (len < sizeof(tfrc))
@@ -706,14 +694,12 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk,
706 694
707static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb) 695static int ccid3_hc_rx_insert_options(struct sock *sk, struct sk_buff *skb)
708{ 696{
709 const struct ccid3_hc_rx_sock *hc; 697 const struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk);
710 __be32 x_recv, pinv; 698 __be32 x_recv, pinv;
711 699
712 if (!(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN)) 700 if (!(sk->sk_state == DCCP_OPEN || sk->sk_state == DCCP_PARTOPEN))
713 return 0; 701 return 0;
714 702
715 hc = ccid3_hc_rx_sk(sk);
716
717 if (dccp_packet_without_ack(skb)) 703 if (dccp_packet_without_ack(skb))
718 return 0; 704 return 0;
719 705
@@ -876,30 +862,18 @@ static void ccid3_hc_rx_exit(struct sock *sk)
876 862
877static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info) 863static void ccid3_hc_rx_get_info(struct sock *sk, struct tcp_info *info)
878{ 864{
879 const struct ccid3_hc_rx_sock *hc; 865 info->tcpi_ca_state = ccid3_hc_rx_sk(sk)->rx_state;
880
881 /* Listen socks doesn't have a private CCID block */
882 if (sk->sk_state == DCCP_LISTEN)
883 return;
884
885 hc = ccid3_hc_rx_sk(sk);
886 info->tcpi_ca_state = hc->rx_state;
887 info->tcpi_options |= TCPI_OPT_TIMESTAMPS; 866 info->tcpi_options |= TCPI_OPT_TIMESTAMPS;
888 info->tcpi_rcv_rtt = hc->rx_rtt; 867 info->tcpi_rcv_rtt = ccid3_hc_rx_sk(sk)->rx_rtt;
889} 868}
890 869
891static int ccid3_hc_rx_getsockopt(struct sock *sk, const int optname, int len, 870static int ccid3_hc_rx_getsockopt(struct sock *sk, const int optname, int len,
892 u32 __user *optval, int __user *optlen) 871 u32 __user *optval, int __user *optlen)
893{ 872{
894 const struct ccid3_hc_rx_sock *hc; 873 const struct ccid3_hc_rx_sock *hc = ccid3_hc_rx_sk(sk);
895 struct tfrc_rx_info rx_info; 874 struct tfrc_rx_info rx_info;
896 const void *val; 875 const void *val;
897 876
898 /* Listen socks doesn't have a private CCID block */
899 if (sk->sk_state == DCCP_LISTEN)
900 return -EINVAL;
901
902 hc = ccid3_hc_rx_sk(sk);
903 switch (optname) { 877 switch (optname) {
904 case DCCP_SOCKOPT_CCID_RX_INFO: 878 case DCCP_SOCKOPT_CCID_RX_INFO:
905 if (len < sizeof(rx_info)) 879 if (len < sizeof(rx_info))