提交 7690af3f 编写于 作者: A Arnaldo Carvalho de Melo 提交者: David S. Miller

[DCCP]: Just reflow the source code to fit in 80 columns

Andrew Morton should be happy now 8)
Signed-off-by: NArnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 c1734376
...@@ -30,21 +30,26 @@ struct ccid { ...@@ -30,21 +30,26 @@ struct ccid {
int (*ccid_hc_tx_init)(struct sock *sk); int (*ccid_hc_tx_init)(struct sock *sk);
void (*ccid_hc_rx_exit)(struct sock *sk); void (*ccid_hc_rx_exit)(struct sock *sk);
void (*ccid_hc_tx_exit)(struct sock *sk); void (*ccid_hc_tx_exit)(struct sock *sk);
void (*ccid_hc_rx_packet_recv)(struct sock *sk, struct sk_buff *skb); void (*ccid_hc_rx_packet_recv)(struct sock *sk,
struct sk_buff *skb);
int (*ccid_hc_rx_parse_options)(struct sock *sk, int (*ccid_hc_rx_parse_options)(struct sock *sk,
unsigned char option, unsigned char option,
unsigned char len, u16 idx, unsigned char len, u16 idx,
unsigned char* value); unsigned char* value);
void (*ccid_hc_rx_insert_options)(struct sock *sk, struct sk_buff *skb); void (*ccid_hc_rx_insert_options)(struct sock *sk,
void (*ccid_hc_tx_insert_options)(struct sock *sk, struct sk_buff *skb); struct sk_buff *skb);
void (*ccid_hc_tx_packet_recv)(struct sock *sk, struct sk_buff *skb); void (*ccid_hc_tx_insert_options)(struct sock *sk,
struct sk_buff *skb);
void (*ccid_hc_tx_packet_recv)(struct sock *sk,
struct sk_buff *skb);
int (*ccid_hc_tx_parse_options)(struct sock *sk, int (*ccid_hc_tx_parse_options)(struct sock *sk,
unsigned char option, unsigned char option,
unsigned char len, u16 idx, unsigned char len, u16 idx,
unsigned char* value); unsigned char* value);
int (*ccid_hc_tx_send_packet)(struct sock *sk, int (*ccid_hc_tx_send_packet)(struct sock *sk,
struct sk_buff *skb, int len); struct sk_buff *skb, int len);
void (*ccid_hc_tx_packet_sent)(struct sock *sk, int more, int len); void (*ccid_hc_tx_packet_sent)(struct sock *sk, int more,
int len);
}; };
extern int ccid_register(struct ccid *ccid); extern int ccid_register(struct ccid *ccid);
...@@ -123,7 +128,8 @@ static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk, ...@@ -123,7 +128,8 @@ static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk,
{ {
int rc = 0; int rc = 0;
if (ccid->ccid_hc_tx_parse_options != NULL) if (ccid->ccid_hc_tx_parse_options != NULL)
rc = ccid->ccid_hc_tx_parse_options(sk, option, len, idx, value); rc = ccid->ccid_hc_tx_parse_options(sk, option, len, idx,
value);
return rc; return rc;
} }
......
...@@ -25,7 +25,8 @@ extern int dccp_debug; ...@@ -25,7 +25,8 @@ extern int dccp_debug;
do { if (dccp_debug) \ do { if (dccp_debug) \
printk(KERN_DEBUG "%s: " format, __FUNCTION__ , ##a); \ printk(KERN_DEBUG "%s: " format, __FUNCTION__ , ##a); \
} while (0) } while (0)
#define dccp_pr_debug_cat(format, a...) do { if (dccp_debug) printk(format, ##a); } while (0) #define dccp_pr_debug_cat(format, a...) do { if (dccp_debug) \
printk(format, ##a); } while (0)
#else #else
#define dccp_pr_debug(format, a...) #define dccp_pr_debug(format, a...)
#define dccp_pr_debug_cat(format, a...) #define dccp_pr_debug_cat(format, a...)
...@@ -72,7 +73,8 @@ static inline const int after48(const u64 seq1, const u64 seq2) ...@@ -72,7 +73,8 @@ static inline const int after48(const u64 seq1, const u64 seq2)
} }
/* is seq2 <= seq1 <= seq3 ? */ /* is seq2 <= seq1 <= seq3 ? */
static inline const int between48(const u64 seq1, const u64 seq2, const u64 seq3) static inline const int between48(const u64 seq1, const u64 seq2,
const u64 seq3)
{ {
return (seq3 << 16) - (seq2 << 16) >= (seq1 << 16) - (seq2 << 16); return (seq3 << 16) - (seq2 << 16) >= (seq1 << 16) - (seq2 << 16);
} }
...@@ -111,8 +113,10 @@ DECLARE_SNMP_STAT(struct dccp_mib, dccp_statistics); ...@@ -111,8 +113,10 @@ DECLARE_SNMP_STAT(struct dccp_mib, dccp_statistics);
#define DCCP_INC_STATS_BH(field) SNMP_INC_STATS_BH(dccp_statistics, field) #define DCCP_INC_STATS_BH(field) SNMP_INC_STATS_BH(dccp_statistics, field)
#define DCCP_INC_STATS_USER(field) SNMP_INC_STATS_USER(dccp_statistics, field) #define DCCP_INC_STATS_USER(field) SNMP_INC_STATS_USER(dccp_statistics, field)
#define DCCP_DEC_STATS(field) SNMP_DEC_STATS(dccp_statistics, field) #define DCCP_DEC_STATS(field) SNMP_DEC_STATS(dccp_statistics, field)
#define DCCP_ADD_STATS_BH(field, val) SNMP_ADD_STATS_BH(dccp_statistics, field, val) #define DCCP_ADD_STATS_BH(field, val) \
#define DCCP_ADD_STATS_USER(field, val) SNMP_ADD_STATS_USER(dccp_statistics, field, val) SNMP_ADD_STATS_BH(dccp_statistics, field, val)
#define DCCP_ADD_STATS_USER(field, val) \
SNMP_ADD_STATS_USER(dccp_statistics, field, val)
extern int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb); extern int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb);
extern int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb); extern int dccp_retransmit_skb(struct sock *sk, struct sk_buff *skb);
...@@ -234,8 +238,8 @@ extern int dccp_disconnect(struct sock *sk, int flags); ...@@ -234,8 +238,8 @@ extern int dccp_disconnect(struct sock *sk, int flags);
extern int dccp_getsockopt(struct sock *sk, int level, int optname, extern int dccp_getsockopt(struct sock *sk, int level, int optname,
char *optval, int *optlen); char *optval, int *optlen);
extern int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg); extern int dccp_ioctl(struct sock *sk, int cmd, unsigned long arg);
extern int dccp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, extern int dccp_sendmsg(struct kiocb *iocb, struct sock *sk,
size_t size); struct msghdr *msg, size_t size);
extern int dccp_recvmsg(struct kiocb *iocb, struct sock *sk, extern int dccp_recvmsg(struct kiocb *iocb, struct sock *sk,
struct msghdr *msg, size_t len, int nonblock, struct msghdr *msg, size_t len, int nonblock,
int flags, int *addr_len); int flags, int *addr_len);
...@@ -246,7 +250,8 @@ extern void dccp_shutdown(struct sock *sk, int how); ...@@ -246,7 +250,8 @@ extern void dccp_shutdown(struct sock *sk, int how);
extern int dccp_v4_checksum(const struct sk_buff *skb, extern int dccp_v4_checksum(const struct sk_buff *skb,
const u32 saddr, const u32 daddr); const u32 saddr, const u32 daddr);
extern int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code); extern int dccp_v4_send_reset(struct sock *sk,
enum dccp_reset_codes code);
extern void dccp_send_close(struct sock *sk); extern void dccp_send_close(struct sock *sk);
struct dccp_skb_cb { struct dccp_skb_cb {
...@@ -303,7 +308,8 @@ static inline void dccp_inc_seqno(u64 *seqno) ...@@ -303,7 +308,8 @@ static inline void dccp_inc_seqno(u64 *seqno)
static inline void dccp_hdr_set_seq(struct dccp_hdr *dh, const u64 gss) static inline void dccp_hdr_set_seq(struct dccp_hdr *dh, const u64 gss)
{ {
struct dccp_hdr_ext *dhx = (struct dccp_hdr_ext *)((void *)dh + sizeof(*dh)); struct dccp_hdr_ext *dhx = (struct dccp_hdr_ext *)((void *)dh +
sizeof(*dh));
#if defined(__LITTLE_ENDIAN_BITFIELD) #if defined(__LITTLE_ENDIAN_BITFIELD)
dh->dccph_seq = htonl((gss >> 32)) >> 8; dh->dccph_seq = htonl((gss >> 32)) >> 8;
...@@ -315,7 +321,8 @@ static inline void dccp_hdr_set_seq(struct dccp_hdr *dh, const u64 gss) ...@@ -315,7 +321,8 @@ static inline void dccp_hdr_set_seq(struct dccp_hdr *dh, const u64 gss)
dhx->dccph_seq_low = htonl(gss & 0xffffffff); dhx->dccph_seq_low = htonl(gss & 0xffffffff);
} }
static inline void dccp_hdr_set_ack(struct dccp_hdr_ack_bits *dhack, const u64 gsr) static inline void dccp_hdr_set_ack(struct dccp_hdr_ack_bits *dhack,
const u64 gsr)
{ {
#if defined(__LITTLE_ENDIAN_BITFIELD) #if defined(__LITTLE_ENDIAN_BITFIELD)
dhack->dccph_ack_nr_high = htonl((gsr >> 32)) >> 8; dhack->dccph_ack_nr_high = htonl((gsr >> 32)) >> 8;
...@@ -332,11 +339,14 @@ static inline void dccp_update_gsr(struct sock *sk, u64 seq) ...@@ -332,11 +339,14 @@ static inline void dccp_update_gsr(struct sock *sk, u64 seq)
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
u64 tmp_gsr; u64 tmp_gsr;
dccp_set_seqno(&tmp_gsr, dp->dccps_gsr + 1 - (dp->dccps_options.dccpo_sequence_window / 4)); dccp_set_seqno(&tmp_gsr,
(dp->dccps_gsr + 1 -
(dp->dccps_options.dccpo_sequence_window / 4)));
dp->dccps_gsr = seq; dp->dccps_gsr = seq;
dccp_set_seqno(&dp->dccps_swl, max48(tmp_gsr, dp->dccps_isr)); dccp_set_seqno(&dp->dccps_swl, max48(tmp_gsr, dp->dccps_isr));
dccp_set_seqno(&dp->dccps_swh, dccp_set_seqno(&dp->dccps_swh,
dp->dccps_gsr + (3 * dp->dccps_options.dccpo_sequence_window) / 4); (dp->dccps_gsr +
(3 * dp->dccps_options.dccpo_sequence_window) / 4));
} }
static inline void dccp_update_gss(struct sock *sk, u64 seq) static inline void dccp_update_gss(struct sock *sk, u64 seq)
...@@ -344,7 +354,9 @@ static inline void dccp_update_gss(struct sock *sk, u64 seq) ...@@ -344,7 +354,9 @@ static inline void dccp_update_gss(struct sock *sk, u64 seq)
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
u64 tmp_gss; u64 tmp_gss;
dccp_set_seqno(&tmp_gss, dp->dccps_gss - dp->dccps_options.dccpo_sequence_window + 1); dccp_set_seqno(&tmp_gss,
(dp->dccps_gss -
dp->dccps_options.dccpo_sequence_window + 1));
dp->dccps_awl = max48(tmp_gss, dp->dccps_iss); dp->dccps_awl = max48(tmp_gss, dp->dccps_iss);
dp->dccps_awh = dp->dccps_gss = seq; dp->dccps_awh = dp->dccps_gss = seq;
} }
...@@ -373,16 +385,20 @@ extern struct socket *dccp_ctl_socket; ...@@ -373,16 +385,20 @@ extern struct socket *dccp_ctl_socket;
* *
* @dccpap_buf_head - circular buffer head * @dccpap_buf_head - circular buffer head
* @dccpap_buf_tail - circular buffer tail * @dccpap_buf_tail - circular buffer tail
* @dccpap_buf_ackno - ack # of the most recent packet acknoldgeable in the buffer (i.e. %dccpap_buf_head) * @dccpap_buf_ackno - ack # of the most recent packet acknowledgeable in the
* @dccpap_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked by the buffer with State 0 * buffer (i.e. %dccpap_buf_head)
* @dccpap_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked
* by the buffer with State 0
* *
* Additionally, the HC-Receiver must keep some information about the * Additionally, the HC-Receiver must keep some information about the
* Ack Vectors it has recently sent. For each packet sent carrying an * Ack Vectors it has recently sent. For each packet sent carrying an
* Ack Vector, it remembers four variables: * Ack Vector, it remembers four variables:
* *
* @dccpap_ack_seqno - the Sequence Number used for the packet (HC-Receiver seqno) * @dccpap_ack_seqno - the Sequence Number used for the packet
* (HC-Receiver seqno)
* @dccpap_ack_ptr - the value of buf_head at the time of acknowledgement. * @dccpap_ack_ptr - the value of buf_head at the time of acknowledgement.
* @dccpap_ack_ackno - the Acknowledgement Number used for the packet (HC-Sender seqno) * @dccpap_ack_ackno - the Acknowledgement Number used for the packet
* (HC-Sender seqno)
* @dccpap_ack_nonce - the one-bit sum of the ECN Nonces for all State 0. * @dccpap_ack_nonce - the one-bit sum of the ECN Nonces for all State 0.
* *
* @dccpap_buf_len - circular buffer length * @dccpap_buf_len - circular buffer length
......
...@@ -93,7 +93,8 @@ static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb) ...@@ -93,7 +93,8 @@ static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb)
*/ */
if (dh->dccph_type == DCCP_PKT_SYNC || if (dh->dccph_type == DCCP_PKT_SYNC ||
dh->dccph_type == DCCP_PKT_SYNCACK) { dh->dccph_type == DCCP_PKT_SYNCACK) {
if (between48(DCCP_SKB_CB(skb)->dccpd_ack_seq, dp->dccps_awl, dp->dccps_awh) && if (between48(DCCP_SKB_CB(skb)->dccpd_ack_seq,
dp->dccps_awl, dp->dccps_awh) &&
!before48(DCCP_SKB_CB(skb)->dccpd_seq, dp->dccps_swl)) !before48(DCCP_SKB_CB(skb)->dccpd_seq, dp->dccps_swl))
dccp_update_gsr(sk, DCCP_SKB_CB(skb)->dccpd_seq); dccp_update_gsr(sk, DCCP_SKB_CB(skb)->dccpd_seq);
else else
...@@ -122,11 +123,13 @@ static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb) ...@@ -122,11 +123,13 @@ static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb)
if (between48(DCCP_SKB_CB(skb)->dccpd_seq, lswl, dp->dccps_swh) && if (between48(DCCP_SKB_CB(skb)->dccpd_seq, lswl, dp->dccps_swh) &&
(DCCP_SKB_CB(skb)->dccpd_ack_seq == DCCP_PKT_WITHOUT_ACK_SEQ || (DCCP_SKB_CB(skb)->dccpd_ack_seq == DCCP_PKT_WITHOUT_ACK_SEQ ||
between48(DCCP_SKB_CB(skb)->dccpd_ack_seq, lawl, dp->dccps_awh))) { between48(DCCP_SKB_CB(skb)->dccpd_ack_seq,
lawl, dp->dccps_awh))) {
dccp_update_gsr(sk, DCCP_SKB_CB(skb)->dccpd_seq); dccp_update_gsr(sk, DCCP_SKB_CB(skb)->dccpd_seq);
if (dh->dccph_type != DCCP_PKT_SYNC && if (dh->dccph_type != DCCP_PKT_SYNC &&
DCCP_SKB_CB(skb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ) (DCCP_SKB_CB(skb)->dccpd_ack_seq !=
DCCP_PKT_WITHOUT_ACK_SEQ))
dp->dccps_gar = DCCP_SKB_CB(skb)->dccpd_ack_seq; dp->dccps_gar = DCCP_SKB_CB(skb)->dccpd_ack_seq;
} else { } else {
dccp_pr_debug("Step 6 failed, sending SYNC...\n"); dccp_pr_debug("Step 6 failed, sending SYNC...\n");
...@@ -161,10 +164,13 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb, ...@@ -161,10 +164,13 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts, if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts,
DCCP_SKB_CB(skb)->dccpd_seq, DCCP_SKB_CB(skb)->dccpd_seq,
DCCP_ACKPKTS_STATE_RECEIVED)) { DCCP_ACKPKTS_STATE_RECEIVED)) {
LIMIT_NETDEBUG(KERN_INFO "DCCP: acknowledgeable packets buffer full!\n"); LIMIT_NETDEBUG(KERN_INFO "DCCP: acknowledgeable "
"packets buffer full!\n");
ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1; ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1;
inet_csk_schedule_ack(sk); inet_csk_schedule_ack(sk);
inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, TCP_DELACK_MIN, TCP_RTO_MAX); inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
TCP_DELACK_MIN,
DCCP_RTO_MAX);
goto discard; goto discard;
} }
...@@ -175,7 +181,8 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb, ...@@ -175,7 +181,8 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
*/ */
if (!inet_csk_ack_scheduled(sk)) { if (!inet_csk_ack_scheduled(sk)) {
inet_csk_schedule_ack(sk); inet_csk_schedule_ack(sk);
inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, 5 * HZ, TCP_RTO_MAX); inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, 5 * HZ,
DCCP_RTO_MAX);
} }
} }
...@@ -186,8 +193,8 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb, ...@@ -186,8 +193,8 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
case DCCP_PKT_DATAACK: case DCCP_PKT_DATAACK:
case DCCP_PKT_DATA: case DCCP_PKT_DATA:
/* /*
* FIXME: check if sk_receive_queue is full, schedule DATA_DROPPED option * FIXME: check if sk_receive_queue is full, schedule DATA_DROPPED
* if it is. * option if it is.
*/ */
__skb_pull(skb, dh->dccph_doff * 4); __skb_pull(skb, dh->dccph_doff * 4);
__skb_queue_tail(&sk->sk_receive_queue, skb); __skb_queue_tail(&sk->sk_receive_queue, skb);
...@@ -272,11 +279,13 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, ...@@ -272,11 +279,13 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
__kfree_skb(sk->sk_send_head); __kfree_skb(sk->sk_send_head);
sk->sk_send_head = NULL; sk->sk_send_head = NULL;
if (!between48(DCCP_SKB_CB(skb)->dccpd_ack_seq, dp->dccps_awl, dp->dccps_awh)) { if (!between48(DCCP_SKB_CB(skb)->dccpd_ack_seq,
dccp_pr_debug("invalid ackno: S.AWL=%llu, P.ackno=%llu, S.AWH=%llu \n", dp->dccps_awl, dp->dccps_awh)) {
(unsigned long long) dp->dccps_awl, dccp_pr_debug("invalid ackno: S.AWL=%llu, "
(unsigned long long) DCCP_SKB_CB(skb)->dccpd_ack_seq, "P.ackno=%llu, S.AWH=%llu \n",
(unsigned long long) dp->dccps_awh); (unsigned long long)dp->dccps_awl,
(unsigned long long)DCCP_SKB_CB(skb)->dccpd_ack_seq,
(unsigned long long)dp->dccps_awh);
goto out_invalid_packet; goto out_invalid_packet;
} }
...@@ -296,16 +305,17 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, ...@@ -296,16 +305,17 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
/* /*
* Step 10: Process REQUEST state (second part) * Step 10: Process REQUEST state (second part)
* If S.state == REQUEST, * If S.state == REQUEST,
* / * If we get here, P is a valid Response from the server (see * / * If we get here, P is a valid Response from the
* Step 4), and we should move to PARTOPEN state. PARTOPEN * server (see Step 4), and we should move to
* means send an Ack, don't send Data packets, retransmit * PARTOPEN state. PARTOPEN means send an Ack,
* Acks periodically, and always include any Init Cookie from * don't send Data packets, retransmit Acks
* the Response * / * periodically, and always include any Init Cookie
* from the Response * /
* S.state := PARTOPEN * S.state := PARTOPEN
* Set PARTOPEN timer * Set PARTOPEN timer
* Continue with S.state == PARTOPEN * Continue with S.state == PARTOPEN
* / * Step 12 will send the Ack completing the three-way * / * Step 12 will send the Ack completing the
* handshake * / * three-way handshake * /
*/ */
dccp_set_state(sk, DCCP_PARTOPEN); dccp_set_state(sk, DCCP_PARTOPEN);
...@@ -341,7 +351,8 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, ...@@ -341,7 +351,8 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
out_invalid_packet: out_invalid_packet:
return 1; /* dccp_v4_do_rcv will send a reset, but... return 1; /* dccp_v4_do_rcv will send a reset, but...
FIXME: the reset code should be DCCP_RESET_CODE_PACKET_ERROR */ FIXME: the reset code should be
DCCP_RESET_CODE_PACKET_ERROR */
} }
static int dccp_rcv_respond_partopen_state_process(struct sock *sk, static int dccp_rcv_respond_partopen_state_process(struct sock *sk,
...@@ -358,11 +369,12 @@ static int dccp_rcv_respond_partopen_state_process(struct sock *sk, ...@@ -358,11 +369,12 @@ static int dccp_rcv_respond_partopen_state_process(struct sock *sk,
case DCCP_PKT_DATAACK: case DCCP_PKT_DATAACK:
case DCCP_PKT_ACK: case DCCP_PKT_ACK:
/* /*
* FIXME: we should be reseting the PARTOPEN (DELACK) timer here, * FIXME: we should be reseting the PARTOPEN (DELACK) timer
* but only if we haven't used the DELACK timer for something else, * here but only if we haven't used the DELACK timer for
* like sending a delayed ack for a TIMESTAMP echo, etc, for now * something else, like sending a delayed ack for a TIMESTAMP
* were not clearing it, sending an extra ACK when there is nothing * echo, etc, for now were not clearing it, sending an extra
* else to do in DELACK is not a big deal after all. * ACK when there is nothing else to do in DELACK is not a big
* deal after all.
*/ */
/* Stop the PARTOPEN timer */ /* Stop the PARTOPEN timer */
...@@ -374,7 +386,8 @@ static int dccp_rcv_respond_partopen_state_process(struct sock *sk, ...@@ -374,7 +386,8 @@ static int dccp_rcv_respond_partopen_state_process(struct sock *sk,
if (dh->dccph_type == DCCP_PKT_DATAACK) { if (dh->dccph_type == DCCP_PKT_DATAACK) {
dccp_rcv_established(sk, skb, dh, len); dccp_rcv_established(sk, skb, dh, len);
queued = 1; /* packet was queued (by dccp_rcv_established) */ queued = 1; /* packet was queued
(by dccp_rcv_established) */
} }
break; break;
} }
...@@ -399,7 +412,8 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, ...@@ -399,7 +412,8 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
if (dccp_parse_options(sk, skb)) if (dccp_parse_options(sk, skb))
goto discard; goto discard;
if (DCCP_SKB_CB(skb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ) if (DCCP_SKB_CB(skb)->dccpd_ack_seq !=
DCCP_PKT_WITHOUT_ACK_SEQ)
dccp_event_ack_recv(sk, skb); dccp_event_ack_recv(sk, skb);
ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb); ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb);
...@@ -415,14 +429,17 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, ...@@ -415,14 +429,17 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
DCCP_ACKPKTS_STATE_RECEIVED)) DCCP_ACKPKTS_STATE_RECEIVED))
goto discard; goto discard;
/* /*
* FIXME: this activation is probably wrong, have to study more * FIXME: this activation is probably wrong, have to
* TCP delack machinery and how it fits into DCCP draft, but * study more TCP delack machinery and how it fits into
* for now it kinda "works" 8) * DCCP draft, but for now it kinda "works" 8)
*/ */
if (dp->dccps_hc_rx_ackpkts->dccpap_ack_seqno == DCCP_MAX_SEQNO + 1 && if ((dp->dccps_hc_rx_ackpkts->dccpap_ack_seqno ==
DCCP_MAX_SEQNO + 1) &&
!inet_csk_ack_scheduled(sk)) { !inet_csk_ack_scheduled(sk)) {
inet_csk_schedule_ack(sk); inet_csk_schedule_ack(sk);
inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, TCP_DELACK_MIN, TCP_RTO_MAX); inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
TCP_DELACK_MIN,
DCCP_RTO_MAX);
} }
} }
} }
...@@ -436,7 +453,10 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, ...@@ -436,7 +453,10 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
* Drop packet and return * Drop packet and return
*/ */
if (dh->dccph_type == DCCP_PKT_RESET) { if (dh->dccph_type == DCCP_PKT_RESET) {
/* Queue the equivalent of TCP fin so that dccp_recvmsg exits the loop */ /*
* Queue the equivalent of TCP fin so that dccp_recvmsg
* exits the loop
*/
dccp_fin(sk, skb); dccp_fin(sk, skb);
dccp_time_wait(sk, DCCP_TIME_WAIT, 0); dccp_time_wait(sk, DCCP_TIME_WAIT, 0);
return 0; return 0;
...@@ -450,10 +470,12 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, ...@@ -450,10 +470,12 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
* Drop packet and return * Drop packet and return
*/ */
} else if ((dp->dccps_role != DCCP_ROLE_CLIENT && } else if ((dp->dccps_role != DCCP_ROLE_CLIENT &&
(dh->dccph_type == DCCP_PKT_RESPONSE || dh->dccph_type == DCCP_PKT_CLOSEREQ)) || (dh->dccph_type == DCCP_PKT_RESPONSE ||
dh->dccph_type == DCCP_PKT_CLOSEREQ)) ||
(dp->dccps_role == DCCP_ROLE_CLIENT && (dp->dccps_role == DCCP_ROLE_CLIENT &&
dh->dccph_type == DCCP_PKT_REQUEST) || dh->dccph_type == DCCP_PKT_REQUEST) ||
(sk->sk_state == DCCP_RESPOND && dh->dccph_type == DCCP_PKT_DATA)) { (sk->sk_state == DCCP_RESPOND &&
dh->dccph_type == DCCP_PKT_DATA)) {
dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq); dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq);
goto discard; goto discard;
} }
...@@ -491,11 +513,13 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb, ...@@ -491,11 +513,13 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
case DCCP_RESPOND: case DCCP_RESPOND:
case DCCP_PARTOPEN: case DCCP_PARTOPEN:
queued = dccp_rcv_respond_partopen_state_process(sk, skb, dh, len); queued = dccp_rcv_respond_partopen_state_process(sk, skb,
dh, len);
break; break;
} }
if (dh->dccph_type == DCCP_PKT_ACK || dh->dccph_type == DCCP_PKT_DATAACK) { if (dh->dccph_type == DCCP_PKT_ACK ||
dh->dccph_type == DCCP_PKT_DATAACK) {
switch (old_state) { switch (old_state) {
case DCCP_PARTOPEN: case DCCP_PARTOPEN:
sk->sk_state_change(sk); sk->sk_state_change(sk);
......
...@@ -61,7 +61,8 @@ static int __dccp_v4_check_established(struct sock *sk, const __u16 lport, ...@@ -61,7 +61,8 @@ static int __dccp_v4_check_established(struct sock *sk, const __u16 lport,
const int dif = sk->sk_bound_dev_if; const int dif = sk->sk_bound_dev_if;
INET_ADDR_COOKIE(acookie, saddr, daddr) INET_ADDR_COOKIE(acookie, saddr, daddr)
const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport); const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport);
const int hash = inet_ehashfn(daddr, lport, saddr, inet->dport, dccp_hashinfo.ehash_size); const int hash = inet_ehashfn(daddr, lport, saddr, inet->dport,
dccp_hashinfo.ehash_size);
struct inet_ehash_bucket *head = &dccp_hashinfo.ehash[hash]; struct inet_ehash_bucket *head = &dccp_hashinfo.ehash[hash];
const struct sock *sk2; const struct sock *sk2;
const struct hlist_node *node; const struct hlist_node *node;
...@@ -133,11 +134,12 @@ static int dccp_v4_hash_connect(struct sock *sk) ...@@ -133,11 +134,12 @@ static int dccp_v4_hash_connect(struct sock *sk)
local_bh_disable(); local_bh_disable();
/* TODO. Actually it is not so bad idea to remove /* TODO. Actually it is not so bad idea to remove
* dccp_hashinfo.portalloc_lock before next submission to Linus. * dccp_hashinfo.portalloc_lock before next submission to
* Linus.
* As soon as we touch this place at all it is time to think. * As soon as we touch this place at all it is time to think.
* *
* Now it protects single _advisory_ variable dccp_hashinfo.port_rover, * Now it protects single _advisory_ variable
* hence it is mostly useless. * dccp_hashinfo.port_rover, hence it is mostly useless.
* Code will work nicely if we just delete it, but * Code will work nicely if we just delete it, but
* I am afraid in contented case it will work not better or * I am afraid in contented case it will work not better or
* even worse: another cpu just will hit the same bucket * even worse: another cpu just will hit the same bucket
...@@ -152,7 +154,8 @@ static int dccp_v4_hash_connect(struct sock *sk) ...@@ -152,7 +154,8 @@ static int dccp_v4_hash_connect(struct sock *sk)
rover++; rover++;
if ((rover < low) || (rover > high)) if ((rover < low) || (rover > high))
rover = low; rover = low;
head = &dccp_hashinfo.bhash[inet_bhashfn(rover, dccp_hashinfo.bhash_size)]; head = &dccp_hashinfo.bhash[inet_bhashfn(rover,
dccp_hashinfo.bhash_size)];
spin_lock(&head->lock); spin_lock(&head->lock);
/* Does not bother with rcv_saddr checks, /* Does not bother with rcv_saddr checks,
...@@ -172,7 +175,8 @@ static int dccp_v4_hash_connect(struct sock *sk) ...@@ -172,7 +175,8 @@ static int dccp_v4_hash_connect(struct sock *sk)
} }
} }
tb = inet_bind_bucket_create(dccp_hashinfo.bind_bucket_cachep, head, rover); tb = inet_bind_bucket_create(dccp_hashinfo.bind_bucket_cachep,
head, rover);
if (tb == NULL) { if (tb == NULL) {
spin_unlock(&head->lock); spin_unlock(&head->lock);
break; break;
...@@ -211,7 +215,8 @@ static int dccp_v4_hash_connect(struct sock *sk) ...@@ -211,7 +215,8 @@ static int dccp_v4_hash_connect(struct sock *sk)
goto out; goto out;
} }
head = &dccp_hashinfo.bhash[inet_bhashfn(snum, dccp_hashinfo.bhash_size)]; head = &dccp_hashinfo.bhash[inet_bhashfn(snum,
dccp_hashinfo.bhash_size)];
tb = inet_csk(sk)->icsk_bind_hash; tb = inet_csk(sk)->icsk_bind_hash;
spin_lock_bh(&head->lock); spin_lock_bh(&head->lock);
if (sk_head(&tb->owners) == sk && sk->sk_bind_node.next == NULL) { if (sk_head(&tb->owners) == sk && sk->sk_bind_node.next == NULL) {
...@@ -313,7 +318,9 @@ static int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, ...@@ -313,7 +318,9 @@ static int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr,
out: out:
return err; return err;
failure: failure:
/* This unhashes the socket and releases the local port, if necessary. */ /*
* This unhashes the socket and releases the local port, if necessary.
*/
dccp_set_state(sk, DCCP_CLOSED); dccp_set_state(sk, DCCP_CLOSED);
ip_rt_put(rt); ip_rt_put(rt);
sk->sk_route_caps = 0; sk->sk_route_caps = 0;
...@@ -365,8 +372,9 @@ static inline void dccp_do_pmtu_discovery(struct sock *sk, ...@@ -365,8 +372,9 @@ static inline void dccp_do_pmtu_discovery(struct sock *sk,
/* /*
* From: draft-ietf-dccp-spec-11.txt * From: draft-ietf-dccp-spec-11.txt
* *
* DCCP-Sync packets are the best choice for upward probing, * DCCP-Sync packets are the best choice for upward
* since DCCP-Sync probes do not risk application data loss. * probing, since DCCP-Sync probes do not risk application
* data loss.
*/ */
dccp_send_sync(sk, dp->dccps_gsr); dccp_send_sync(sk, dp->dccps_gsr);
} /* else let the usual retransmit timer handle it */ } /* else let the usual retransmit timer handle it */
...@@ -405,11 +413,13 @@ static void dccp_v4_ctl_send_ack(struct sk_buff *rxskb) ...@@ -405,11 +413,13 @@ static void dccp_v4_ctl_send_ack(struct sk_buff *rxskb)
dh->dccph_x = 1; dh->dccph_x = 1;
dccp_hdr_set_seq(dh, DCCP_SKB_CB(rxskb)->dccpd_ack_seq); dccp_hdr_set_seq(dh, DCCP_SKB_CB(rxskb)->dccpd_ack_seq);
dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), DCCP_SKB_CB(rxskb)->dccpd_seq); dccp_hdr_set_ack(dccp_hdr_ack_bits(skb),
DCCP_SKB_CB(rxskb)->dccpd_seq);
bh_lock_sock(dccp_ctl_socket->sk); bh_lock_sock(dccp_ctl_socket->sk);
err = ip_build_and_send_pkt(skb, dccp_ctl_socket->sk, err = ip_build_and_send_pkt(skb, dccp_ctl_socket->sk,
rxskb->nh.iph->daddr, rxskb->nh.iph->saddr, NULL); rxskb->nh.iph->daddr,
rxskb->nh.iph->saddr, NULL);
bh_unlock_sock(dccp_ctl_socket->sk); bh_unlock_sock(dccp_ctl_socket->sk);
if (err == NET_XMIT_CN || err == 0) { if (err == NET_XMIT_CN || err == 0) {
...@@ -418,7 +428,8 @@ static void dccp_v4_ctl_send_ack(struct sk_buff *rxskb) ...@@ -418,7 +428,8 @@ static void dccp_v4_ctl_send_ack(struct sk_buff *rxskb)
} }
} }
static void dccp_v4_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req) static void dccp_v4_reqsk_send_ack(struct sk_buff *skb,
struct request_sock *req)
{ {
dccp_v4_ctl_send_ack(skb); dccp_v4_ctl_send_ack(skb);
} }
...@@ -465,7 +476,8 @@ static int dccp_v4_send_response(struct sock *sk, struct request_sock *req, ...@@ -465,7 +476,8 @@ static int dccp_v4_send_response(struct sock *sk, struct request_sock *req,
void dccp_v4_err(struct sk_buff *skb, u32 info) void dccp_v4_err(struct sk_buff *skb, u32 info)
{ {
const struct iphdr *iph = (struct iphdr *)skb->data; const struct iphdr *iph = (struct iphdr *)skb->data;
const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data + (iph->ihl << 2)); const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data +
(iph->ihl << 2));
struct dccp_sock *dp; struct dccp_sock *dp;
struct inet_sock *inet; struct inet_sock *inet;
const int type = skb->h.icmph->type; const int type = skb->h.icmph->type;
...@@ -605,7 +617,8 @@ void dccp_v4_err(struct sk_buff *skb, u32 info) ...@@ -605,7 +617,8 @@ void dccp_v4_err(struct sk_buff *skb, u32 info)
sock_put(sk); sock_put(sk);
} }
extern struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst, enum dccp_reset_codes code); extern struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst,
enum dccp_reset_codes code);
int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code) int dccp_v4_send_reset(struct sock *sk, enum dccp_reset_codes code)
{ {
...@@ -689,7 +702,8 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb) ...@@ -689,7 +702,8 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
ireq->loc_addr = daddr; ireq->loc_addr = daddr;
ireq->rmt_addr = saddr; ireq->rmt_addr = saddr;
/* FIXME: Merge Aristeu's option parsing code when ready */ /* FIXME: Merge Aristeu's option parsing code when ready */
req->rcv_wnd = 100; /* Fake, option parsing will get the right value */ req->rcv_wnd = 100; /* Fake, option parsing will get the
right value */
ireq->opt = NULL; ireq->opt = NULL;
/* /*
...@@ -804,7 +818,8 @@ static struct sock *dccp_v4_hnd_req(struct sock *sk, struct sk_buff *skb) ...@@ -804,7 +818,8 @@ static struct sock *dccp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
return sk; return sk;
} }
int dccp_v4_checksum(const struct sk_buff *skb, const u32 saddr, const u32 daddr) int dccp_v4_checksum(const struct sk_buff *skb, const u32 saddr,
const u32 daddr)
{ {
const struct dccp_hdr* dh = dccp_hdr(skb); const struct dccp_hdr* dh = dccp_hdr(skb);
int checksum_len; int checksum_len;
...@@ -814,11 +829,13 @@ int dccp_v4_checksum(const struct sk_buff *skb, const u32 saddr, const u32 daddr ...@@ -814,11 +829,13 @@ int dccp_v4_checksum(const struct sk_buff *skb, const u32 saddr, const u32 daddr
checksum_len = skb->len; checksum_len = skb->len;
else { else {
checksum_len = (dh->dccph_cscov + dh->dccph_x) * sizeof(u32); checksum_len = (dh->dccph_cscov + dh->dccph_x) * sizeof(u32);
checksum_len = checksum_len < skb->len ? checksum_len : skb->len; checksum_len = checksum_len < skb->len ? checksum_len :
skb->len;
} }
tmp = csum_partial((unsigned char *)dh, checksum_len, 0); tmp = csum_partial((unsigned char *)dh, checksum_len, 0);
return csum_tcpudp_magic(saddr, daddr, checksum_len, IPPROTO_DCCP, tmp); return csum_tcpudp_magic(saddr, daddr, checksum_len,
IPPROTO_DCCP, tmp);
} }
static int dccp_v4_verify_checksum(struct sk_buff *skb, static int dccp_v4_verify_checksum(struct sk_buff *skb,
...@@ -832,10 +849,12 @@ static int dccp_v4_verify_checksum(struct sk_buff *skb, ...@@ -832,10 +849,12 @@ static int dccp_v4_verify_checksum(struct sk_buff *skb,
checksum_len = skb->len; checksum_len = skb->len;
else { else {
checksum_len = (dh->dccph_cscov + dh->dccph_x) * sizeof(u32); checksum_len = (dh->dccph_cscov + dh->dccph_x) * sizeof(u32);
checksum_len = checksum_len < skb->len ? checksum_len : skb->len; checksum_len = checksum_len < skb->len ? checksum_len :
skb->len;
} }
tmp = csum_partial((unsigned char *)dh, checksum_len, 0); tmp = csum_partial((unsigned char *)dh, checksum_len, 0);
return csum_tcpudp_magic(saddr, daddr, checksum_len, IPPROTO_DCCP, tmp) == 0 ? 0 : -1; return csum_tcpudp_magic(saddr, daddr, checksum_len,
IPPROTO_DCCP, tmp) == 0 ? 0 : -1;
} }
static struct dst_entry* dccp_v4_route_skb(struct sock *sk, static struct dst_entry* dccp_v4_route_skb(struct sock *sk,
...@@ -850,7 +869,9 @@ static struct dst_entry* dccp_v4_route_skb(struct sock *sk, ...@@ -850,7 +869,9 @@ static struct dst_entry* dccp_v4_route_skb(struct sock *sk,
.proto = sk->sk_protocol, .proto = sk->sk_protocol,
.uli_u = { .ports = .uli_u = { .ports =
{ .sport = dccp_hdr(skb)->dccph_dport, { .sport = dccp_hdr(skb)->dccph_dport,
.dport = dccp_hdr(skb)->dccph_sport } } }; .dport = dccp_hdr(skb)->dccph_sport }
}
};
if (ip_route_output_flow(&rt, &fl, sk, 0)) { if (ip_route_output_flow(&rt, &fl, sk, 0)) {
IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES); IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
...@@ -899,17 +920,20 @@ void dccp_v4_ctl_send_reset(struct sk_buff *rxskb) ...@@ -899,17 +920,20 @@ void dccp_v4_ctl_send_reset(struct sk_buff *rxskb)
dh->dccph_dport = rxdh->dccph_sport; dh->dccph_dport = rxdh->dccph_sport;
dh->dccph_doff = dccp_hdr_reset_len / 4; dh->dccph_doff = dccp_hdr_reset_len / 4;
dh->dccph_x = 1; dh->dccph_x = 1;
dccp_hdr_reset(skb)->dccph_reset_code = DCCP_SKB_CB(rxskb)->dccpd_reset_code; dccp_hdr_reset(skb)->dccph_reset_code =
DCCP_SKB_CB(rxskb)->dccpd_reset_code;
dccp_hdr_set_seq(dh, DCCP_SKB_CB(rxskb)->dccpd_ack_seq); dccp_hdr_set_seq(dh, DCCP_SKB_CB(rxskb)->dccpd_ack_seq);
dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), DCCP_SKB_CB(rxskb)->dccpd_seq); dccp_hdr_set_ack(dccp_hdr_ack_bits(skb),
DCCP_SKB_CB(rxskb)->dccpd_seq);
dh->dccph_checksum = dccp_v4_checksum(skb, rxskb->nh.iph->saddr, dh->dccph_checksum = dccp_v4_checksum(skb, rxskb->nh.iph->saddr,
rxskb->nh.iph->daddr); rxskb->nh.iph->daddr);
bh_lock_sock(dccp_ctl_socket->sk); bh_lock_sock(dccp_ctl_socket->sk);
err = ip_build_and_send_pkt(skb, dccp_ctl_socket->sk, err = ip_build_and_send_pkt(skb, dccp_ctl_socket->sk,
rxskb->nh.iph->daddr, rxskb->nh.iph->saddr, NULL); rxskb->nh.iph->daddr,
rxskb->nh.iph->saddr, NULL);
bh_unlock_sock(dccp_ctl_socket->sk); bh_unlock_sock(dccp_ctl_socket->sk);
if (err == NET_XMIT_CN || err == 0) { if (err == NET_XMIT_CN || err == 0) {
...@@ -933,7 +957,8 @@ int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) ...@@ -933,7 +957,8 @@ int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
/* /*
* Step 3: Process LISTEN state * Step 3: Process LISTEN state
* If S.state == LISTEN, * If S.state == LISTEN,
* If P.type == Request or P contains a valid Init Cookie option, * If P.type == Request or P contains a valid Init Cookie
* option,
* * Must scan the packet's options to check for an Init * * Must scan the packet's options to check for an Init
* Cookie. Only the Init Cookie is processed here, * Cookie. Only the Init Cookie is processed here,
* however; other options are processed in Step 8. This * however; other options are processed in Step 8. This
...@@ -950,7 +975,8 @@ int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) ...@@ -950,7 +975,8 @@ int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
* Generate Reset(No Connection) unless P.type == Reset * Generate Reset(No Connection) unless P.type == Reset
* Drop packet and return * Drop packet and return
* *
* NOTE: the check for the packet types is done in dccp_rcv_state_process * NOTE: the check for the packet types is done in
* dccp_rcv_state_process
*/ */
if (sk->sk_state == DCCP_LISTEN) { if (sk->sk_state == DCCP_LISTEN) {
struct sock *nsk = dccp_v4_hnd_req(sk, skb); struct sock *nsk = dccp_v4_hnd_req(sk, skb);
...@@ -1007,7 +1033,8 @@ static inline int dccp_invalid_packet(struct sk_buff *skb) ...@@ -1007,7 +1033,8 @@ static inline int dccp_invalid_packet(struct sk_buff *skb)
} }
if (!pskb_may_pull(skb, dh->dccph_doff * sizeof(u32))) { if (!pskb_may_pull(skb, dh->dccph_doff * sizeof(u32))) {
dccp_pr_debug("P.Data Offset(%u) too small 2\n", dh->dccph_doff); dccp_pr_debug("P.Data Offset(%u) too small 2\n",
dh->dccph_doff);
return 1; return 1;
} }
...@@ -1021,8 +1048,8 @@ static inline int dccp_invalid_packet(struct sk_buff *skb) ...@@ -1021,8 +1048,8 @@ static inline int dccp_invalid_packet(struct sk_buff *skb)
dh->dccph_type != DCCP_PKT_DATA && dh->dccph_type != DCCP_PKT_DATA &&
dh->dccph_type != DCCP_PKT_ACK && dh->dccph_type != DCCP_PKT_ACK &&
dh->dccph_type != DCCP_PKT_DATAACK) { dh->dccph_type != DCCP_PKT_DATAACK) {
dccp_pr_debug("P.type (%s) not Data, Ack nor DataAck and P.X == 0\n", dccp_pr_debug("P.type (%s) not Data, Ack nor DataAck and "
dccp_packet_name(dh->dccph_type)); "P.X == 0\n", dccp_packet_name(dh->dccph_type));
return 1; return 1;
} }
...@@ -1055,10 +1082,11 @@ int dccp_v4_rcv(struct sk_buff *skb) ...@@ -1055,10 +1082,11 @@ int dccp_v4_rcv(struct sk_buff *skb)
* dccp_ackpkts_add, you'll get something like this on a session that * dccp_ackpkts_add, you'll get something like this on a session that
* sends 10 DATA/DATAACK packets: * sends 10 DATA/DATAACK packets:
* *
* dccp_ackpkts_print: 281473596467422 |0,0|3,0|0,0|3,0|0,0|3,0|0,0|3,0|0,1| * ackpkts_print: 281473596467422 |0,0|3,0|0,0|3,0|0,0|3,0|0,0|3,0|0,1|
* *
* 0, 0 means: DCCP_ACKPKTS_STATE_RECEIVED, RLE == just this packet * 0, 0 means: DCCP_ACKPKTS_STATE_RECEIVED, RLE == just this packet
* 0, 1 means: DCCP_ACKPKTS_STATE_RECEIVED, RLE == two adjacent packets with the same state * 0, 1 means: DCCP_ACKPKTS_STATE_RECEIVED, RLE == two adjacent packets
* with the same state
* 3, 0 means: DCCP_ACKPKTS_STATE_NOT_RECEIVED, RLE == just this packet * 3, 0 means: DCCP_ACKPKTS_STATE_NOT_RECEIVED, RLE == just this packet
* *
* So... * So...
...@@ -1072,10 +1100,12 @@ int dccp_v4_rcv(struct sk_buff *skb) ...@@ -1072,10 +1100,12 @@ int dccp_v4_rcv(struct sk_buff *skb)
* 281473596467416 was received * 281473596467416 was received
* 281473596467415 was not received * 281473596467415 was not received
* 281473596467414 was received * 281473596467414 was received
* 281473596467413 was received (this one was the 3way handshake RESPONSE) * 281473596467413 was received (this one was the 3way handshake
* RESPONSE)
* *
*/ */
if (dh->dccph_type == DCCP_PKT_DATA || dh->dccph_type == DCCP_PKT_DATAACK) { if (dh->dccph_type == DCCP_PKT_DATA ||
dh->dccph_type == DCCP_PKT_DATAACK) {
static int discard = 0; static int discard = 0;
if (discard) { if (discard) {
...@@ -1170,7 +1200,8 @@ int dccp_v4_rcv(struct sk_buff *skb) ...@@ -1170,7 +1200,8 @@ int dccp_v4_rcv(struct sk_buff *skb)
* Drop packet and return * Drop packet and return
*/ */
if (dh->dccph_type != DCCP_PKT_RESET) { if (dh->dccph_type != DCCP_PKT_RESET) {
DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_NO_CONNECTION; DCCP_SKB_CB(skb)->dccpd_reset_code =
DCCP_RESET_CODE_NO_CONNECTION;
dccp_v4_ctl_send_reset(skb); dccp_v4_ctl_send_reset(skb);
} }
...@@ -1196,7 +1227,8 @@ static int dccp_v4_init_sock(struct sock *sk) ...@@ -1196,7 +1227,8 @@ static int dccp_v4_init_sock(struct sock *sk)
dccp_options_init(&dp->dccps_options); dccp_options_init(&dp->dccps_options);
if (dp->dccps_options.dccpo_send_ack_vector) { if (dp->dccps_options.dccpo_send_ack_vector) {
dp->dccps_hc_rx_ackpkts = dccp_ackpkts_alloc(DCCP_MAX_ACK_VECTOR_LEN, dp->dccps_hc_rx_ackpkts =
dccp_ackpkts_alloc(DCCP_MAX_ACK_VECTOR_LEN,
GFP_KERNEL); GFP_KERNEL);
if (dp->dccps_hc_rx_ackpkts == NULL) if (dp->dccps_hc_rx_ackpkts == NULL)
...@@ -1211,8 +1243,10 @@ static int dccp_v4_init_sock(struct sock *sk) ...@@ -1211,8 +1243,10 @@ static int dccp_v4_init_sock(struct sock *sk)
* setsockopt(CCIDs-I-want/accept). -acme * setsockopt(CCIDs-I-want/accept). -acme
*/ */
if (likely(!dccp_ctl_socket_init)) { if (likely(!dccp_ctl_socket_init)) {
dp->dccps_hc_rx_ccid = ccid_init(dp->dccps_options.dccpo_ccid, sk); dp->dccps_hc_rx_ccid = ccid_init(dp->dccps_options.dccpo_ccid,
dp->dccps_hc_tx_ccid = ccid_init(dp->dccps_options.dccpo_ccid, sk); sk);
dp->dccps_hc_tx_ccid = ccid_init(dp->dccps_options.dccpo_ccid,
sk);
if (dp->dccps_hc_rx_ccid == NULL || if (dp->dccps_hc_rx_ccid == NULL ||
dp->dccps_hc_tx_ccid == NULL) { dp->dccps_hc_tx_ccid == NULL) {
ccid_exit(dp->dccps_hc_rx_ccid, sk); ccid_exit(dp->dccps_hc_rx_ccid, sk);
......
...@@ -69,8 +69,8 @@ void dccp_time_wait(struct sock *sk, int state, int timeo) ...@@ -69,8 +69,8 @@ void dccp_time_wait(struct sock *sk, int state, int timeo)
* socket up. We've got bigger problems than * socket up. We've got bigger problems than
* non-graceful socket closings. * non-graceful socket closings.
*/ */
if (net_ratelimit()) LIMIT_NETDEBUG(KERN_INFO "DCCP: time wait bucket "
printk(KERN_INFO "DCCP: time wait bucket table overflow\n"); "table overflow\n");
} }
dccp_done(sk); dccp_done(sk);
...@@ -98,19 +98,23 @@ struct sock *dccp_create_openreq_child(struct sock *sk, ...@@ -98,19 +98,23 @@ struct sock *dccp_create_openreq_child(struct sock *sk,
newicsk->icsk_rto = DCCP_TIMEOUT_INIT; newicsk->icsk_rto = DCCP_TIMEOUT_INIT;
if (newdp->dccps_options.dccpo_send_ack_vector) { if (newdp->dccps_options.dccpo_send_ack_vector) {
newdp->dccps_hc_rx_ackpkts = dccp_ackpkts_alloc(DCCP_MAX_ACK_VECTOR_LEN, newdp->dccps_hc_rx_ackpkts =
dccp_ackpkts_alloc(DCCP_MAX_ACK_VECTOR_LEN,
GFP_ATOMIC); GFP_ATOMIC);
/* /*
* XXX: We're using the same CCIDs set on the parent, i.e. sk_clone * XXX: We're using the same CCIDs set on the parent,
* copied the master sock and left the CCID pointers for this child, * i.e. sk_clone copied the master sock and left the
* that is why we do the __ccid_get calls. * CCID pointers for this child, that is why we do the
* __ccid_get calls.
*/ */
if (unlikely(newdp->dccps_hc_rx_ackpkts == NULL)) if (unlikely(newdp->dccps_hc_rx_ackpkts == NULL))
goto out_free; goto out_free;
} }
if (unlikely(ccid_hc_rx_init(newdp->dccps_hc_rx_ccid, newsk) != 0 || if (unlikely(ccid_hc_rx_init(newdp->dccps_hc_rx_ccid,
ccid_hc_tx_init(newdp->dccps_hc_tx_ccid, newsk) != 0)) { newsk) != 0 ||
ccid_hc_tx_init(newdp->dccps_hc_tx_ccid,
newsk) != 0)) {
dccp_ackpkts_free(newdp->dccps_hc_rx_ackpkts); dccp_ackpkts_free(newdp->dccps_hc_rx_ackpkts);
ccid_hc_rx_exit(newdp->dccps_hc_rx_ccid, newsk); ccid_hc_rx_exit(newdp->dccps_hc_rx_ccid, newsk);
ccid_hc_tx_exit(newdp->dccps_hc_tx_ccid, newsk); ccid_hc_tx_exit(newdp->dccps_hc_tx_ccid, newsk);
...@@ -129,7 +133,8 @@ struct sock *dccp_create_openreq_child(struct sock *sk, ...@@ -129,7 +133,8 @@ struct sock *dccp_create_openreq_child(struct sock *sk,
* Step 3: Process LISTEN state * Step 3: Process LISTEN state
* *
* Choose S.ISS (initial seqno) or set from Init Cookie * Choose S.ISS (initial seqno) or set from Init Cookie
* Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init
* Cookie
*/ */
/* See dccp_v4_conn_request */ /* See dccp_v4_conn_request */
...@@ -160,13 +165,15 @@ struct sock *dccp_check_req(struct sock *sk, struct sk_buff *skb, ...@@ -160,13 +165,15 @@ struct sock *dccp_check_req(struct sock *sk, struct sk_buff *skb,
/* Check for retransmitted REQUEST */ /* Check for retransmitted REQUEST */
if (dccp_hdr(skb)->dccph_type == DCCP_PKT_REQUEST) { if (dccp_hdr(skb)->dccph_type == DCCP_PKT_REQUEST) {
if (after48(DCCP_SKB_CB(skb)->dccpd_seq, dccp_rsk(req)->dreq_isr)) { if (after48(DCCP_SKB_CB(skb)->dccpd_seq,
dccp_rsk(req)->dreq_isr)) {
struct dccp_request_sock *dreq = dccp_rsk(req); struct dccp_request_sock *dreq = dccp_rsk(req);
dccp_pr_debug("Retransmitted REQUEST\n"); dccp_pr_debug("Retransmitted REQUEST\n");
/* Send another RESPONSE packet */ /* Send another RESPONSE packet */
dccp_set_seqno(&dreq->dreq_iss, dreq->dreq_iss + 1); dccp_set_seqno(&dreq->dreq_iss, dreq->dreq_iss + 1);
dccp_set_seqno(&dreq->dreq_isr, DCCP_SKB_CB(skb)->dccpd_seq); dccp_set_seqno(&dreq->dreq_isr,
DCCP_SKB_CB(skb)->dccpd_seq);
req->rsk_ops->rtx_syn_ack(sk, req, NULL); req->rsk_ops->rtx_syn_ack(sk, req, NULL);
} }
/* Network Duplicate, discard packet */ /* Network Duplicate, discard packet */
...@@ -181,7 +188,8 @@ struct sock *dccp_check_req(struct sock *sk, struct sk_buff *skb, ...@@ -181,7 +188,8 @@ struct sock *dccp_check_req(struct sock *sk, struct sk_buff *skb,
/* Invalid ACK */ /* Invalid ACK */
if (DCCP_SKB_CB(skb)->dccpd_ack_seq != dccp_rsk(req)->dreq_iss) { if (DCCP_SKB_CB(skb)->dccpd_ack_seq != dccp_rsk(req)->dreq_iss) {
dccp_pr_debug("Invalid ACK number: ack_seq=%llu, dreq_iss=%llu\n", dccp_pr_debug("Invalid ACK number: ack_seq=%llu, "
"dreq_iss=%llu\n",
(unsigned long long) (unsigned long long)
DCCP_SKB_CB(skb)->dccpd_ack_seq, DCCP_SKB_CB(skb)->dccpd_ack_seq,
(unsigned long long) (unsigned long long)
...@@ -223,7 +231,8 @@ int dccp_child_process(struct sock *parent, struct sock *child, ...@@ -223,7 +231,8 @@ int dccp_child_process(struct sock *parent, struct sock *child,
const int state = child->sk_state; const int state = child->sk_state;
if (!sock_owned_by_user(child)) { if (!sock_owned_by_user(child)) {
ret = dccp_rcv_state_process(child, skb, dccp_hdr(skb), skb->len); ret = dccp_rcv_state_process(child, skb, dccp_hdr(skb),
skb->len);
/* Wakeup parent, send SIGIO */ /* Wakeup parent, send SIGIO */
if (state == DCCP_RESPOND && child->sk_state != state) if (state == DCCP_RESPOND && child->sk_state != state)
......
...@@ -59,14 +59,15 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) ...@@ -59,14 +59,15 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
{ {
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
#ifdef DCCP_DEBUG #ifdef DCCP_DEBUG
const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT rx opt: " : const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
"server rx opt: "; "CLIENT rx opt: " : "server rx opt: ";
#endif #endif
const struct dccp_hdr *dh = dccp_hdr(skb); const struct dccp_hdr *dh = dccp_hdr(skb);
const u8 pkt_type = DCCP_SKB_CB(skb)->dccpd_type; const u8 pkt_type = DCCP_SKB_CB(skb)->dccpd_type;
unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb); unsigned char *options = (unsigned char *)dh + dccp_hdr_len(skb);
unsigned char *opt_ptr = options; unsigned char *opt_ptr = options;
const unsigned char *opt_end = (unsigned char *)dh + (dh->dccph_doff * 4); const unsigned char *opt_end = (unsigned char *)dh +
(dh->dccph_doff * 4);
struct dccp_options_received *opt_recv = &dp->dccps_options_received; struct dccp_options_received *opt_recv = &dp->dccps_options_received;
unsigned char opt, len; unsigned char opt, len;
unsigned char *value; unsigned char *value;
...@@ -106,7 +107,8 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) ...@@ -106,7 +107,8 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
goto out_invalid_option; goto out_invalid_option;
opt_recv->dccpor_ndp = dccp_decode_value_var(value, len); opt_recv->dccpor_ndp = dccp_decode_value_var(value, len);
dccp_pr_debug("%sNDP count=%d\n", debug_prefix, opt_recv->dccpor_ndp); dccp_pr_debug("%sNDP count=%d\n", debug_prefix,
opt_recv->dccpor_ndp);
break; break;
case DCCPO_ACK_VECTOR_0: case DCCPO_ACK_VECTOR_0:
if (len > DCCP_MAX_ACK_VECTOR_LEN) if (len > DCCP_MAX_ACK_VECTOR_LEN)
...@@ -124,7 +126,8 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) ...@@ -124,7 +126,8 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
DCCP_SKB_CB(skb)->dccpd_ack_seq); DCCP_SKB_CB(skb)->dccpd_ack_seq);
dccp_ackvector_print(DCCP_SKB_CB(skb)->dccpd_ack_seq, dccp_ackvector_print(DCCP_SKB_CB(skb)->dccpd_ack_seq,
value, len); value, len);
dccp_ackpkts_check_rcv_ackvector(dp->dccps_hc_rx_ackpkts, sk, dccp_ackpkts_check_rcv_ackvector(dp->dccps_hc_rx_ackpkts,
sk,
DCCP_SKB_CB(skb)->dccpd_ack_seq, DCCP_SKB_CB(skb)->dccpd_ack_seq,
len, value); len, value);
break; break;
...@@ -148,15 +151,21 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) ...@@ -148,15 +151,21 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
opt_recv->dccpor_timestamp_echo = ntohl(*(u32 *)value); opt_recv->dccpor_timestamp_echo = ntohl(*(u32 *)value);
dccp_pr_debug("%sTIMESTAMP_ECHO=%u, len=%d, ackno=%llu, diff=%u\n", dccp_pr_debug("%sTIMESTAMP_ECHO=%u, len=%d, ackno=%llu, "
debug_prefix, opt_recv->dccpor_timestamp_echo, "diff=%u\n",
debug_prefix,
opt_recv->dccpor_timestamp_echo,
len + 2, len + 2,
(unsigned long long) (unsigned long long)
DCCP_SKB_CB(skb)->dccpd_ack_seq, DCCP_SKB_CB(skb)->dccpd_ack_seq,
tcp_time_stamp - opt_recv->dccpor_timestamp_echo); (tcp_time_stamp -
opt_recv->dccpor_timestamp_echo));
opt_recv->dccpor_elapsed_time = dccp_decode_value_var(value + 4, len - 4);
dccp_pr_debug("%sTIMESTAMP_ECHO ELAPSED_TIME=%d\n", debug_prefix, opt_recv->dccpor_elapsed_time =
dccp_decode_value_var(value + 4,
len - 4);
dccp_pr_debug("%sTIMESTAMP_ECHO ELAPSED_TIME=%d\n",
debug_prefix,
opt_recv->dccpor_elapsed_time); opt_recv->dccpor_elapsed_time);
break; break;
case DCCPO_ELAPSED_TIME: case DCCPO_ELAPSED_TIME:
...@@ -165,33 +174,41 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb) ...@@ -165,33 +174,41 @@ int dccp_parse_options(struct sock *sk, struct sk_buff *skb)
if (pkt_type == DCCP_PKT_DATA) if (pkt_type == DCCP_PKT_DATA)
continue; continue;
opt_recv->dccpor_elapsed_time = dccp_decode_value_var(value, len); opt_recv->dccpor_elapsed_time =
dccp_decode_value_var(value, len);
dccp_pr_debug("%sELAPSED_TIME=%d\n", debug_prefix, dccp_pr_debug("%sELAPSED_TIME=%d\n", debug_prefix,
opt_recv->dccpor_elapsed_time); opt_recv->dccpor_elapsed_time);
break; break;
/* /*
* From draft-ietf-dccp-spec-11.txt: * From draft-ietf-dccp-spec-11.txt:
* *
* Option numbers 128 through 191 are for options sent from the HC- * Option numbers 128 through 191 are for
* Sender to the HC-Receiver; option numbers 192 through 255 are for * options sent from the HC-Sender to the
* options sent from the HC-Receiver to the HC-Sender. * HC-Receiver; option numbers 192 through 255
* are for options sent from the HC-Receiver to
* the HC-Sender.
*/ */
case 128 ... 191: { case 128 ... 191: {
const u16 idx = value - options; const u16 idx = value - options;
if (ccid_hc_rx_parse_options(dp->dccps_hc_rx_ccid, sk, opt, len, idx, value) != 0) if (ccid_hc_rx_parse_options(dp->dccps_hc_rx_ccid, sk,
opt, len, idx,
value) != 0)
goto out_invalid_option; goto out_invalid_option;
} }
break; break;
case 192 ... 255: { case 192 ... 255: {
const u16 idx = value - options; const u16 idx = value - options;
if (ccid_hc_tx_parse_options(dp->dccps_hc_tx_ccid, sk, opt, len, idx, value) != 0) if (ccid_hc_tx_parse_options(dp->dccps_hc_tx_ccid, sk,
opt, len, idx,
value) != 0)
goto out_invalid_option; goto out_invalid_option;
} }
break; break;
default: default:
pr_info("DCCP(%p): option %d(len=%d) not implemented, ignoring\n", pr_info("DCCP(%p): option %d(len=%d) not "
"implemented, ignoring\n",
sk, opt, len); sk, opt, len);
break; break;
} }
...@@ -231,7 +248,8 @@ void dccp_insert_option(struct sock *sk, struct sk_buff *skb, ...@@ -231,7 +248,8 @@ void dccp_insert_option(struct sock *sk, struct sk_buff *skb,
unsigned char *to; unsigned char *to;
if (DCCP_SKB_CB(skb)->dccpd_opt_len + len + 2 > DCCP_MAX_OPT_LEN) { if (DCCP_SKB_CB(skb)->dccpd_opt_len + len + 2 > DCCP_MAX_OPT_LEN) {
LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert %d option!\n", option); LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert "
"%d option!\n", option);
return; return;
} }
...@@ -287,8 +305,8 @@ void dccp_insert_option_elapsed_time(struct sock *sk, ...@@ -287,8 +305,8 @@ void dccp_insert_option_elapsed_time(struct sock *sk,
{ {
#ifdef DCCP_DEBUG #ifdef DCCP_DEBUG
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT TX opt: " : const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
"server TX opt: "; "CLIENT TX opt: " : "server TX opt: ";
#endif #endif
const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time); const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
const int len = 2 + elapsed_time_len; const int len = 2 + elapsed_time_len;
...@@ -299,7 +317,8 @@ void dccp_insert_option_elapsed_time(struct sock *sk, ...@@ -299,7 +317,8 @@ void dccp_insert_option_elapsed_time(struct sock *sk,
return; return;
if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) { if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) {
LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert elapsed time!\n"); LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to "
"insert elapsed time!\n");
return; return;
} }
...@@ -323,8 +342,8 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb) ...@@ -323,8 +342,8 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
{ {
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
#ifdef DCCP_DEBUG #ifdef DCCP_DEBUG
const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT TX opt: " : const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
"server TX opt: "; "CLIENT TX opt: " : "server TX opt: ";
#endif #endif
struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts; struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts;
int len = ap->dccpap_buf_vector_len + 2; int len = ap->dccpap_buf_vector_len + 2;
...@@ -335,7 +354,8 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb) ...@@ -335,7 +354,8 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
dccp_insert_option_elapsed_time(sk, skb, elapsed_time); dccp_insert_option_elapsed_time(sk, skb, elapsed_time);
if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) { if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) {
LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert ACK Vector!\n"); LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to "
"insert ACK Vector!\n");
return; return;
} }
...@@ -360,7 +380,8 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb) ...@@ -360,7 +380,8 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
/* Check if buf_head wraps */ /* Check if buf_head wraps */
if (ap->dccpap_buf_head + len > ap->dccpap_buf_len) { if (ap->dccpap_buf_head + len > ap->dccpap_buf_len) {
const unsigned int tailsize = ap->dccpap_buf_len - ap->dccpap_buf_head; const unsigned int tailsize = (ap->dccpap_buf_len -
ap->dccpap_buf_head);
memcpy(to, from, tailsize); memcpy(to, from, tailsize);
to += tailsize; to += tailsize;
...@@ -375,8 +396,8 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb) ...@@ -375,8 +396,8 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
* For each acknowledgement it sends, the HC-Receiver will add an * For each acknowledgement it sends, the HC-Receiver will add an
* acknowledgement record. ack_seqno will equal the HC-Receiver * acknowledgement record. ack_seqno will equal the HC-Receiver
* sequence number it used for the ack packet; ack_ptr will equal * sequence number it used for the ack packet; ack_ptr will equal
* buf_head; ack_ackno will equal buf_ackno; and ack_nonce will equal * buf_head; ack_ackno will equal buf_ackno; and ack_nonce will
* buf_nonce. * equal buf_nonce.
* *
* This implemention uses just one ack record for now. * This implemention uses just one ack record for now.
*/ */
...@@ -386,33 +407,38 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb) ...@@ -386,33 +407,38 @@ static void dccp_insert_option_ack_vector(struct sock *sk, struct sk_buff *skb)
ap->dccpap_ack_nonce = ap->dccpap_buf_nonce; ap->dccpap_ack_nonce = ap->dccpap_buf_nonce;
ap->dccpap_ack_vector_len = ap->dccpap_buf_vector_len; ap->dccpap_ack_vector_len = ap->dccpap_buf_vector_len;
dccp_pr_debug("%sACK Vector 0, len=%d, ack_seqno=%llu, ack_ackno=%llu\n", dccp_pr_debug("%sACK Vector 0, len=%d, ack_seqno=%llu, "
"ack_ackno=%llu\n",
debug_prefix, ap->dccpap_ack_vector_len, debug_prefix, ap->dccpap_ack_vector_len,
(unsigned long long) ap->dccpap_ack_seqno, (unsigned long long) ap->dccpap_ack_seqno,
(unsigned long long) ap->dccpap_ack_ackno); (unsigned long long) ap->dccpap_ack_ackno);
} }
static inline void dccp_insert_option_timestamp(struct sock *sk, struct sk_buff *skb) static inline void dccp_insert_option_timestamp(struct sock *sk,
struct sk_buff *skb)
{ {
const u32 now = htonl(tcp_time_stamp); const u32 now = htonl(tcp_time_stamp);
dccp_insert_option(sk, skb, DCCPO_TIMESTAMP, &now, sizeof(now)); dccp_insert_option(sk, skb, DCCPO_TIMESTAMP, &now, sizeof(now));
} }
static void dccp_insert_option_timestamp_echo(struct sock *sk, struct sk_buff *skb) static void dccp_insert_option_timestamp_echo(struct sock *sk,
struct sk_buff *skb)
{ {
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
#ifdef DCCP_DEBUG #ifdef DCCP_DEBUG
const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT TX opt: " : const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
"server TX opt: "; "CLIENT TX opt: " : "server TX opt: ";
#endif #endif
u32 tstamp_echo; u32 tstamp_echo;
const u32 elapsed_time = jiffies_to_usecs(jiffies - dp->dccps_timestamp_time) / 10; const u32 elapsed_time = jiffies_to_usecs(jiffies -
dp->dccps_timestamp_time) / 10;
const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time); const int elapsed_time_len = dccp_elapsed_time_len(elapsed_time);
const int len = 6 + elapsed_time_len; const int len = 6 + elapsed_time_len;
unsigned char *to; unsigned char *to;
if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) { if (DCCP_SKB_CB(skb)->dccpd_opt_len + len > DCCP_MAX_OPT_LEN) {
LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert timestamp echo!\n"); LIMIT_NETDEBUG(KERN_INFO "DCCP: packet too small to insert "
"timestamp echo!\n");
return; return;
} }
...@@ -447,7 +473,8 @@ void dccp_insert_options(struct sock *sk, struct sk_buff *skb) ...@@ -447,7 +473,8 @@ void dccp_insert_options(struct sock *sk, struct sk_buff *skb)
if (!dccp_packet_without_ack(skb)) { if (!dccp_packet_without_ack(skb)) {
if (dp->dccps_options.dccpo_send_ack_vector && if (dp->dccps_options.dccpo_send_ack_vector &&
dp->dccps_hc_rx_ackpkts->dccpap_buf_ackno != DCCP_MAX_SEQNO + 1) (dp->dccps_hc_rx_ackpkts->dccpap_buf_ackno !=
DCCP_MAX_SEQNO + 1))
dccp_insert_option_ack_vector(sk, skb); dccp_insert_option_ack_vector(sk, skb);
dccp_insert_option_timestamp(sk, skb); dccp_insert_option_timestamp(sk, skb);
...@@ -481,8 +508,12 @@ struct dccp_ackpkts *dccp_ackpkts_alloc(unsigned int len, int priority) ...@@ -481,8 +508,12 @@ struct dccp_ackpkts *dccp_ackpkts_alloc(unsigned int len, int priority)
memset(ap->dccpap_buf, 0xFF, len); memset(ap->dccpap_buf, 0xFF, len);
#endif #endif
ap->dccpap_buf_len = len; ap->dccpap_buf_len = len;
ap->dccpap_buf_head = ap->dccpap_buf_tail = ap->dccpap_buf_len - 1; ap->dccpap_buf_head =
ap->dccpap_buf_ackno = ap->dccpap_ack_ackno = ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1; ap->dccpap_buf_tail =
ap->dccpap_buf_len - 1;
ap->dccpap_buf_ackno =
ap->dccpap_ack_ackno =
ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1;
ap->dccpap_buf_nonce = ap->dccpap_buf_nonce = 0; ap->dccpap_buf_nonce = ap->dccpap_buf_nonce = 0;
ap->dccpap_ack_ptr = 0; ap->dccpap_ack_ptr = 0;
ap->dccpap_time = 0; ap->dccpap_time = 0;
...@@ -567,15 +598,16 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state) ...@@ -567,15 +598,16 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state)
* *
* From Appendix A: * From Appendix A:
* *
* Of course, the circular buffer may overflow, either when the HC- * Of course, the circular buffer may overflow, either when the
* Sender is sending data at a very high rate, when the HC-Receiver's * HC-Sender is sending data at a very high rate, when the
* acknowledgements are not reaching the HC-Sender, or when the HC- * HC-Receiver's acknowledgements are not reaching the HC-Sender,
* Sender is forgetting to acknowledge those acks (so the HC-Receiver * or when the HC-Sender is forgetting to acknowledge those acks
* is unable to clean up old state). In this case, the HC-Receiver * (so the HC-Receiver is unable to clean up old state). In this
* should either compress the buffer (by increasing run lengths when * case, the HC-Receiver should either compress the buffer (by
* possible), transfer its state to a larger buffer, or, as a last * increasing run lengths when possible), transfer its state to
* resort, drop all received packets, without processing them * a larger buffer, or, as a last resort, drop all received
* whatsoever, until its buffer shrinks again. * packets, without processing them whatsoever, until its buffer
* shrinks again.
*/ */
/* See if this is the first ackno being inserted */ /* See if this is the first ackno being inserted */
...@@ -583,15 +615,17 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state) ...@@ -583,15 +615,17 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state)
ap->dccpap_buf[ap->dccpap_buf_head] = state; ap->dccpap_buf[ap->dccpap_buf_head] = state;
ap->dccpap_buf_vector_len = 1; ap->dccpap_buf_vector_len = 1;
} else if (after48(ackno, ap->dccpap_buf_ackno)) { } else if (after48(ackno, ap->dccpap_buf_ackno)) {
const u64 delta = dccp_delta_seqno(ap->dccpap_buf_ackno, ackno); const u64 delta = dccp_delta_seqno(ap->dccpap_buf_ackno,
ackno);
/* /*
* Look if the state of this packet is the same as the previous ackno * Look if the state of this packet is the same as the
* and if so if we can bump the head len. * previous ackno and if so if we can bump the head len.
*/ */
if (delta == 1 && if (delta == 1 &&
dccp_ackpkts_state(ap, ap->dccpap_buf_head) == state && dccp_ackpkts_state(ap, ap->dccpap_buf_head) == state &&
dccp_ackpkts_len(ap, ap->dccpap_buf_head) < DCCP_ACKPKTS_LEN_MASK) (dccp_ackpkts_len(ap, ap->dccpap_buf_head) <
DCCP_ACKPKTS_LEN_MASK))
ap->dccpap_buf[ap->dccpap_buf_head]++; ap->dccpap_buf[ap->dccpap_buf_head]++;
else if (dccp_ackpkts_set_buf_head_state(ap, delta, state)) else if (dccp_ackpkts_set_buf_head_state(ap, delta, state))
return -ENOBUFS; return -ENOBUFS;
...@@ -599,9 +633,10 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state) ...@@ -599,9 +633,10 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state)
/* /*
* A.1.2. Old Packets * A.1.2. Old Packets
* *
* When a packet with Sequence Number S arrives, and S <= buf_ackno, * When a packet with Sequence Number S arrives, and
* the HC-Receiver will scan the table for the byte corresponding to S. * S <= buf_ackno, the HC-Receiver will scan the table
* (Indexing structures could reduce the complexity of this scan.) * for the byte corresponding to S. (Indexing structures
* could reduce the complexity of this scan.)
*/ */
u64 delta = dccp_delta_seqno(ackno, ap->dccpap_buf_ackno); u64 delta = dccp_delta_seqno(ackno, ap->dccpap_buf_ackno);
unsigned int index = ap->dccpap_buf_head; unsigned int index = ap->dccpap_buf_head;
...@@ -610,11 +645,12 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state) ...@@ -610,11 +645,12 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state)
const u8 len = dccp_ackpkts_len(ap, index); const u8 len = dccp_ackpkts_len(ap, index);
const u8 state = dccp_ackpkts_state(ap, index); const u8 state = dccp_ackpkts_state(ap, index);
/* /*
* valid packets not yet in dccpap_buf have a reserved entry, with * valid packets not yet in dccpap_buf have a reserved
* a len equal to 0 * entry, with a len equal to 0.
*/ */
if (state == DCCP_ACKPKTS_STATE_NOT_RECEIVED && if (state == DCCP_ACKPKTS_STATE_NOT_RECEIVED &&
len == 0 && delta == 0) { /* Found our reserved seat! */ len == 0 && delta == 0) { /* Found our
reserved seat! */
dccp_pr_debug("Found %llu reserved seat!\n", dccp_pr_debug("Found %llu reserved seat!\n",
(unsigned long long) ackno); (unsigned long long) ackno);
ap->dccpap_buf[index] = state; ap->dccpap_buf[index] = state;
...@@ -639,13 +675,14 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state) ...@@ -639,13 +675,14 @@ int dccp_ackpkts_add(struct dccp_ackpkts *ap, u64 ackno, u8 state)
out_duplicate: out_duplicate:
/* Duplicate packet */ /* Duplicate packet */
dccp_pr_debug("Received a dup or already considered lost packet: %llu\n", dccp_pr_debug("Received a dup or already considered lost "
(unsigned long long) ackno); "packet: %llu\n", (unsigned long long) ackno);
return -EILSEQ; return -EILSEQ;
} }
#ifdef DCCP_DEBUG #ifdef DCCP_DEBUG
void dccp_ackvector_print(const u64 ackno, const unsigned char *vector, int len) void dccp_ackvector_print(const u64 ackno, const unsigned char *vector,
int len)
{ {
if (!dccp_debug) if (!dccp_debug)
return; return;
...@@ -678,8 +715,9 @@ static void dccp_ackpkts_trow_away_ack_record(struct dccp_ackpkts *ap) ...@@ -678,8 +715,9 @@ static void dccp_ackpkts_trow_away_ack_record(struct dccp_ackpkts *ap)
* As we're keeping track of the ack vector size * As we're keeping track of the ack vector size
* (dccpap_buf_vector_len) and the sent ack vector size * (dccpap_buf_vector_len) and the sent ack vector size
* (dccpap_ack_vector_len) we don't need dccpap_buf_tail at all, but * (dccpap_ack_vector_len) we don't need dccpap_buf_tail at all, but
* keep this code here as in the future we'll implement a vector of ack * keep this code here as in the future we'll implement a vector of
* records, as suggested in draft-ietf-dccp-spec-11.txt Appendix A. -acme * ack records, as suggested in draft-ietf-dccp-spec-11.txt
* Appendix A. -acme
*/ */
#if 0 #if 0
ap->dccpap_buf_tail = ap->dccpap_ack_ptr + 1; ap->dccpap_buf_tail = ap->dccpap_ack_ptr + 1;
...@@ -699,10 +737,11 @@ void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap, struct sock *sk, ...@@ -699,10 +737,11 @@ void dccp_ackpkts_check_rcv_ackno(struct dccp_ackpkts *ap, struct sock *sk,
if (ackno == ap->dccpap_ack_seqno) { if (ackno == ap->dccpap_ack_seqno) {
#ifdef DCCP_DEBUG #ifdef DCCP_DEBUG
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT rx ack: " : const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ?
"server rx ack: "; "CLIENT rx ack: " : "server rx ack: ";
#endif #endif
dccp_pr_debug("%sACK packet 0, len=%d, ack_seqno=%llu, ack_ackno=%llu, ACKED!\n", dccp_pr_debug("%sACK packet 0, len=%d, ack_seqno=%llu, "
"ack_ackno=%llu, ACKED!\n",
debug_prefix, 1, debug_prefix, 1,
(unsigned long long) ap->dccpap_ack_seqno, (unsigned long long) ap->dccpap_ack_seqno,
(unsigned long long) ap->dccpap_ack_ackno); (unsigned long long) ap->dccpap_ack_ackno);
...@@ -722,20 +761,21 @@ static void dccp_ackpkts_check_rcv_ackvector(struct dccp_ackpkts *ap, ...@@ -722,20 +761,21 @@ static void dccp_ackpkts_check_rcv_ackvector(struct dccp_ackpkts *ap,
if (ap->dccpap_ack_seqno == DCCP_MAX_SEQNO + 1) if (ap->dccpap_ack_seqno == DCCP_MAX_SEQNO + 1)
return; return;
/* /*
* We're in the receiver half connection, so if the received an ACK vector * We're in the receiver half connection, so if the received an ACK
* ackno (e.g. 50) before dccpap_ack_seqno (e.g. 52), we're not interested. * vector ackno (e.g. 50) before dccpap_ack_seqno (e.g. 52), we're
* not interested.
* *
* Extra explanation with example: * Extra explanation with example:
* *
* if we received an ACK vector with ackno 50, it can only be acking * if we received an ACK vector with ackno 50, it can only be acking
* 50, 49, 48, etc, not 52 (the seqno for the ACK vector we sent). * 50, 49, 48, etc, not 52 (the seqno for the ACK vector we sent).
*/ */
// dccp_pr_debug("is %llu < %llu? ", ackno, ap->dccpap_ack_seqno); /* dccp_pr_debug("is %llu < %llu? ", ackno, ap->dccpap_ack_seqno); */
if (before48(ackno, ap->dccpap_ack_seqno)) { if (before48(ackno, ap->dccpap_ack_seqno)) {
// dccp_pr_debug_cat("yes\n"); /* dccp_pr_debug_cat("yes\n"); */
return; return;
} }
// dccp_pr_debug_cat("no\n"); /* dccp_pr_debug_cat("no\n"); */
i = len; i = len;
while (i--) { while (i--) {
...@@ -744,18 +784,25 @@ static void dccp_ackpkts_check_rcv_ackvector(struct dccp_ackpkts *ap, ...@@ -744,18 +784,25 @@ static void dccp_ackpkts_check_rcv_ackvector(struct dccp_ackpkts *ap,
dccp_set_seqno(&ackno_end_rl, ackno - rl); dccp_set_seqno(&ackno_end_rl, ackno - rl);
// dccp_pr_debug("is %llu <= %llu <= %llu? ", ackno_end_rl, ap->dccpap_ack_seqno, ackno); /*
* dccp_pr_debug("is %llu <= %llu <= %llu? ", ackno_end_rl,
* ap->dccpap_ack_seqno, ackno);
*/
if (between48(ap->dccpap_ack_seqno, ackno_end_rl, ackno)) { if (between48(ap->dccpap_ack_seqno, ackno_end_rl, ackno)) {
const u8 state = (*vector & DCCP_ACKPKTS_STATE_MASK) >> 6; const u8 state = (*vector &
// dccp_pr_debug_cat("yes\n"); DCCP_ACKPKTS_STATE_MASK) >> 6;
/* dccp_pr_debug_cat("yes\n"); */
if (state != DCCP_ACKPKTS_STATE_NOT_RECEIVED) { if (state != DCCP_ACKPKTS_STATE_NOT_RECEIVED) {
#ifdef DCCP_DEBUG #ifdef DCCP_DEBUG
struct dccp_sock *dp = dccp_sk(sk); struct dccp_sock *dp = dccp_sk(sk);
const char *debug_prefix = dp->dccps_role == DCCP_ROLE_CLIENT ? "CLIENT rx ack: " : const char *debug_prefix =
"server rx ack: "; dp->dccps_role == DCCP_ROLE_CLIENT ?
"CLIENT rx ack: " : "server rx ack: ";
#endif #endif
dccp_pr_debug("%sACK vector 0, len=%d, ack_seqno=%llu, ack_ackno=%llu, ACKED!\n", dccp_pr_debug("%sACK vector 0, len=%d, "
"ack_seqno=%llu, ack_ackno=%llu, "
"ACKED!\n",
debug_prefix, len, debug_prefix, len,
(unsigned long long) (unsigned long long)
ap->dccpap_ack_seqno, ap->dccpap_ack_seqno,
...@@ -764,13 +811,13 @@ static void dccp_ackpkts_check_rcv_ackvector(struct dccp_ackpkts *ap, ...@@ -764,13 +811,13 @@ static void dccp_ackpkts_check_rcv_ackvector(struct dccp_ackpkts *ap,
dccp_ackpkts_trow_away_ack_record(ap); dccp_ackpkts_trow_away_ack_record(ap);
} }
/* /*
* If dccpap_ack_seqno was not received, no problem we'll * If dccpap_ack_seqno was not received, no problem
* send another ACK vector. * we'll send another ACK vector.
*/ */
ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1; ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1;
break; break;
} }
// dccp_pr_debug_cat("no\n"); /* dccp_pr_debug_cat("no\n"); */
dccp_set_seqno(&ackno, ackno_end_rl - 1); dccp_set_seqno(&ackno, ackno_end_rl - 1);
++vector; ++vector;
......
...@@ -45,8 +45,8 @@ int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb) ...@@ -45,8 +45,8 @@ int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
u64 ackno = dp->dccps_gsr; u64 ackno = dp->dccps_gsr;
/* /*
* FIXME: study DCCP_PKT_SYNC[ACK] to see what is the right thing * FIXME: study DCCP_PKT_SYNC[ACK] to see what is the right
* to do here... * thing to do here...
*/ */
dccp_inc_seqno(&dp->dccps_gss); dccp_inc_seqno(&dp->dccps_gss);
...@@ -65,7 +65,9 @@ int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb) ...@@ -65,7 +65,9 @@ int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
skb->h.raw = skb_push(skb, dccp_header_size); skb->h.raw = skb_push(skb, dccp_header_size);
dh = dccp_hdr(skb); dh = dccp_hdr(skb);
/* Data packets are not cloned as they are never retransmitted */ /*
* Data packets are not cloned as they are never retransmitted
*/
if (skb_cloned(skb)) if (skb_cloned(skb))
skb_set_owner_w(skb, sk); skb_set_owner_w(skb, sk);
...@@ -86,10 +88,12 @@ int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb) ...@@ -86,10 +88,12 @@ int dccp_transmit_skb(struct sock *sk, struct sk_buff *skb)
switch (dcb->dccpd_type) { switch (dcb->dccpd_type) {
case DCCP_PKT_REQUEST: case DCCP_PKT_REQUEST:
dccp_hdr_request(skb)->dccph_req_service = dcb->dccpd_service; dccp_hdr_request(skb)->dccph_req_service =
dcb->dccpd_service;
break; break;
case DCCP_PKT_RESET: case DCCP_PKT_RESET:
dccp_hdr_reset(skb)->dccph_reset_code = dcb->dccpd_reset_code; dccp_hdr_reset(skb)->dccph_reset_code =
dcb->dccpd_reset_code;
break; break;
} }
...@@ -123,10 +127,13 @@ unsigned int dccp_sync_mss(struct sock *sk, u32 pmtu) ...@@ -123,10 +127,13 @@ unsigned int dccp_sync_mss(struct sock *sk, u32 pmtu)
int mss_now; int mss_now;
/* /*
* FIXME: we really should be using the af_specific thing to support IPv6. * FIXME: we really should be using the af_specific thing to support
* mss_now = pmtu - tp->af_specific->net_header_len - sizeof(struct dccp_hdr) - sizeof(struct dccp_hdr_ext); * IPv6.
* mss_now = pmtu - tp->af_specific->net_header_len -
* sizeof(struct dccp_hdr) - sizeof(struct dccp_hdr_ext);
*/ */
mss_now = pmtu - sizeof(struct iphdr) - sizeof(struct dccp_hdr) - sizeof(struct dccp_hdr_ext); mss_now = pmtu - sizeof(struct iphdr) - sizeof(struct dccp_hdr) -
sizeof(struct dccp_hdr_ext);
/* Now subtract optional transport overhead */ /* Now subtract optional transport overhead */
mss_now -= dp->dccps_ext_header_len; mss_now -= dp->dccps_ext_header_len;
...@@ -223,7 +230,8 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst, ...@@ -223,7 +230,8 @@ struct sk_buff *dccp_make_response(struct sock *sk, struct dst_entry *dst,
dh->dccph_sport = inet_sk(sk)->sport; dh->dccph_sport = inet_sk(sk)->sport;
dh->dccph_dport = inet_rsk(req)->rmt_port; dh->dccph_dport = inet_rsk(req)->rmt_port;
dh->dccph_doff = (dccp_header_size + DCCP_SKB_CB(skb)->dccpd_opt_len) / 4; dh->dccph_doff = (dccp_header_size +
DCCP_SKB_CB(skb)->dccpd_opt_len) / 4;
dh->dccph_type = DCCP_PKT_RESPONSE; dh->dccph_type = DCCP_PKT_RESPONSE;
dh->dccph_x = 1; dh->dccph_x = 1;
dccp_hdr_set_seq(dh, dccp_rsk(req)->dreq_iss); dccp_hdr_set_seq(dh, dccp_rsk(req)->dreq_iss);
...@@ -271,7 +279,8 @@ struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst, ...@@ -271,7 +279,8 @@ struct sk_buff *dccp_make_reset(struct sock *sk, struct dst_entry *dst,
dh->dccph_sport = inet_sk(sk)->sport; dh->dccph_sport = inet_sk(sk)->sport;
dh->dccph_dport = inet_sk(sk)->dport; dh->dccph_dport = inet_sk(sk)->dport;
dh->dccph_doff = (dccp_header_size + DCCP_SKB_CB(skb)->dccpd_opt_len) / 4; dh->dccph_doff = (dccp_header_size +
DCCP_SKB_CB(skb)->dccpd_opt_len) / 4;
dh->dccph_type = DCCP_PKT_RESET; dh->dccph_type = DCCP_PKT_RESET;
dh->dccph_x = 1; dh->dccph_x = 1;
dccp_hdr_set_seq(dh, dp->dccps_gss); dccp_hdr_set_seq(dh, dp->dccps_gss);
...@@ -348,7 +357,9 @@ void dccp_send_ack(struct sock *sk) ...@@ -348,7 +357,9 @@ void dccp_send_ack(struct sock *sk)
if (skb == NULL) { if (skb == NULL) {
inet_csk_schedule_ack(sk); inet_csk_schedule_ack(sk);
inet_csk(sk)->icsk_ack.ato = TCP_ATO_MIN; inet_csk(sk)->icsk_ack.ato = TCP_ATO_MIN;
inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, TCP_DELACK_MAX, TCP_RTO_MAX); inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
TCP_DELACK_MAX,
DCCP_RTO_MAX);
return; return;
} }
...@@ -416,8 +427,10 @@ void dccp_send_sync(struct sock *sk, u64 seq) ...@@ -416,8 +427,10 @@ void dccp_send_sync(struct sock *sk, u64 seq)
dccp_transmit_skb(sk, skb); dccp_transmit_skb(sk, skb);
} }
/* Send a DCCP_PKT_CLOSE/CLOSEREQ. The caller locks the socket for us. This cannot be /*
* allowed to fail queueing a DCCP_PKT_CLOSE/CLOSEREQ frame under any circumstances. * Send a DCCP_PKT_CLOSE/CLOSEREQ. The caller locks the socket for us. This
* cannot be allowed to fail queueing a DCCP_PKT_CLOSE/CLOSEREQ frame under
* any circumstances.
*/ */
void dccp_send_close(struct sock *sk) void dccp_send_close(struct sock *sk)
{ {
...@@ -435,7 +448,8 @@ void dccp_send_close(struct sock *sk) ...@@ -435,7 +448,8 @@ void dccp_send_close(struct sock *sk)
/* Reserve space for headers and prepare control bits. */ /* Reserve space for headers and prepare control bits. */
skb_reserve(skb, sk->sk_prot->max_header); skb_reserve(skb, sk->sk_prot->max_header);
skb->csum = 0; skb->csum = 0;
DCCP_SKB_CB(skb)->dccpd_type = dp->dccps_role == DCCP_ROLE_CLIENT ? DCCP_PKT_CLOSE : DCCP_PKT_CLOSEREQ; DCCP_SKB_CB(skb)->dccpd_type = dp->dccps_role == DCCP_ROLE_CLIENT ?
DCCP_PKT_CLOSE : DCCP_PKT_CLOSEREQ;
skb_set_owner_w(skb, sk); skb_set_owner_w(skb, sk);
dccp_transmit_skb(sk, skb); dccp_transmit_skb(sk, skb);
......
...@@ -156,8 +156,8 @@ void dccp_tx_hist_delete(struct dccp_tx_hist *hist) ...@@ -156,8 +156,8 @@ void dccp_tx_hist_delete(struct dccp_tx_hist *hist)
EXPORT_SYMBOL_GPL(dccp_tx_hist_delete); EXPORT_SYMBOL_GPL(dccp_tx_hist_delete);
struct dccp_tx_hist_entry *dccp_tx_hist_find_entry(const struct list_head *list, struct dccp_tx_hist_entry *
const u64 seq) dccp_tx_hist_find_entry(const struct list_head *list, const u64 seq)
{ {
struct dccp_tx_hist_entry *packet = NULL, *entry; struct dccp_tx_hist_entry *packet = NULL, *entry;
...@@ -172,7 +172,8 @@ struct dccp_tx_hist_entry *dccp_tx_hist_find_entry(const struct list_head *list, ...@@ -172,7 +172,8 @@ struct dccp_tx_hist_entry *dccp_tx_hist_find_entry(const struct list_head *list,
EXPORT_SYMBOL_GPL(dccp_tx_hist_find_entry); EXPORT_SYMBOL_GPL(dccp_tx_hist_find_entry);
void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist, struct list_head *list, void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist,
struct list_head *list,
struct dccp_tx_hist_entry *packet) struct dccp_tx_hist_entry *packet)
{ {
struct dccp_tx_hist_entry *next; struct dccp_tx_hist_entry *next;
......
...@@ -115,7 +115,8 @@ extern void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist, ...@@ -115,7 +115,8 @@ extern void dccp_tx_hist_purge_older(struct dccp_tx_hist *hist,
extern void dccp_tx_hist_purge(struct dccp_tx_hist *hist, extern void dccp_tx_hist_purge(struct dccp_tx_hist *hist,
struct list_head *list); struct list_head *list);
static inline struct dccp_tx_hist_entry *dccp_tx_hist_head(struct list_head *list) static inline struct dccp_tx_hist_entry *
dccp_tx_hist_head(struct list_head *list)
{ {
struct dccp_tx_hist_entry *head = NULL; struct dccp_tx_hist_entry *head = NULL;
...@@ -163,7 +164,8 @@ static inline void dccp_rx_hist_add_entry(struct list_head *list, ...@@ -163,7 +164,8 @@ static inline void dccp_rx_hist_add_entry(struct list_head *list,
list_add(&entry->dccphrx_node, list); list_add(&entry->dccphrx_node, list);
} }
static inline struct dccp_rx_hist_entry *dccp_rx_hist_head(struct list_head *list) static inline struct dccp_rx_hist_entry *
dccp_rx_hist_head(struct list_head *list)
{ {
struct dccp_rx_hist_entry *head = NULL; struct dccp_rx_hist_entry *head = NULL;
......
...@@ -255,12 +255,16 @@ int dccp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -255,12 +255,16 @@ int dccp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
/* FIXME */ /* FIXME */
#if 0 #if 0
/* Are we at urgent data? Stop if we have read anything or have SIGURG pending. */ /*
* Are we at urgent data? Stop if we have read anything or
* have SIGURG pending.
*/
if (tp->urg_data && tp->urg_seq == *seq) { if (tp->urg_data && tp->urg_seq == *seq) {
if (copied) if (copied)
break; break;
if (signal_pending(current)) { if (signal_pending(current)) {
copied = timeo ? sock_intr_errno(timeo) : -EAGAIN; copied = timeo ? sock_intr_errno(timeo) :
-EAGAIN;
break; break;
} }
} }
...@@ -285,7 +289,8 @@ int dccp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -285,7 +289,8 @@ int dccp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
dccp_pr_debug("found fin ok!\n"); dccp_pr_debug("found fin ok!\n");
goto found_fin_ok; goto found_fin_ok;
} }
dccp_pr_debug("packet_type=%s\n", dccp_packet_name(dh->dccph_type)); dccp_pr_debug("packet_type=%s\n",
dccp_packet_name(dh->dccph_type));
BUG_TRAP(flags & MSG_PEEK); BUG_TRAP(flags & MSG_PEEK);
skb = skb->next; skb = skb->next;
} while (skb != (struct sk_buff *)&sk->sk_receive_queue); } while (skb != (struct sk_buff *)&sk->sk_receive_queue);
...@@ -541,7 +546,8 @@ struct proto_ops inet_dccp_ops = { ...@@ -541,7 +546,8 @@ struct proto_ops inet_dccp_ops = {
.getname = inet_getname, .getname = inet_getname,
.poll = sock_no_poll, .poll = sock_no_poll,
.ioctl = inet_ioctl, .ioctl = inet_ioctl,
.listen = inet_dccp_listen, /* FIXME: work on inet_listen to rename it to sock_common_listen */ /* FIXME: work on inet_listen to rename it to sock_common_listen */
.listen = inet_dccp_listen,
.shutdown = inet_shutdown, .shutdown = inet_shutdown,
.setsockopt = sock_common_setsockopt, .setsockopt = sock_common_setsockopt,
.getsockopt = sock_common_getsockopt, .getsockopt = sock_common_getsockopt,
...@@ -638,10 +644,10 @@ static int __init dccp_init(void) ...@@ -638,10 +644,10 @@ static int __init dccp_init(void)
if (rc) if (rc)
goto out; goto out;
dccp_hashinfo.bind_bucket_cachep = kmem_cache_create("dccp_bind_bucket", dccp_hashinfo.bind_bucket_cachep =
sizeof(struct inet_bind_bucket), kmem_cache_create("dccp_bind_bucket",
0, SLAB_HWCACHE_ALIGN, sizeof(struct inet_bind_bucket), 0,
NULL, NULL); SLAB_HWCACHE_ALIGN, NULL, NULL);
if (!dccp_hashinfo.bind_bucket_cachep) if (!dccp_hashinfo.bind_bucket_cachep)
goto out_proto_unregister; goto out_proto_unregister;
...@@ -657,14 +663,16 @@ static int __init dccp_init(void) ...@@ -657,14 +663,16 @@ static int __init dccp_init(void)
goal = num_physpages >> (23 - PAGE_SHIFT); goal = num_physpages >> (23 - PAGE_SHIFT);
if (thash_entries) if (thash_entries)
goal = (thash_entries * sizeof(struct inet_ehash_bucket)) >> PAGE_SHIFT; goal = (thash_entries *
sizeof(struct inet_ehash_bucket)) >> PAGE_SHIFT;
for (ehash_order = 0; (1UL << ehash_order) < goal; ehash_order++) for (ehash_order = 0; (1UL << ehash_order) < goal; ehash_order++)
; ;
do { do {
dccp_hashinfo.ehash_size = (1UL << ehash_order) * PAGE_SIZE / dccp_hashinfo.ehash_size = (1UL << ehash_order) * PAGE_SIZE /
sizeof(struct inet_ehash_bucket); sizeof(struct inet_ehash_bucket);
dccp_hashinfo.ehash_size >>= 1; dccp_hashinfo.ehash_size >>= 1;
while (dccp_hashinfo.ehash_size & (dccp_hashinfo.ehash_size - 1)) while (dccp_hashinfo.ehash_size &
(dccp_hashinfo.ehash_size - 1))
dccp_hashinfo.ehash_size--; dccp_hashinfo.ehash_size--;
dccp_hashinfo.ehash = (struct inet_ehash_bucket *) dccp_hashinfo.ehash = (struct inet_ehash_bucket *)
__get_free_pages(GFP_ATOMIC, ehash_order); __get_free_pages(GFP_ATOMIC, ehash_order);
...@@ -686,7 +694,8 @@ static int __init dccp_init(void) ...@@ -686,7 +694,8 @@ static int __init dccp_init(void)
do { do {
dccp_hashinfo.bhash_size = (1UL << bhash_order) * PAGE_SIZE / dccp_hashinfo.bhash_size = (1UL << bhash_order) * PAGE_SIZE /
sizeof(struct inet_bind_hashbucket); sizeof(struct inet_bind_hashbucket);
if ((dccp_hashinfo.bhash_size > (64 * 1024)) && bhash_order > 0) if ((dccp_hashinfo.bhash_size > (64 * 1024)) &&
bhash_order > 0)
continue; continue;
dccp_hashinfo.bhash = (struct inet_bind_hashbucket *) dccp_hashinfo.bhash = (struct inet_bind_hashbucket *)
__get_free_pages(GFP_ATOMIC, bhash_order); __get_free_pages(GFP_ATOMIC, bhash_order);
......
...@@ -45,11 +45,13 @@ static int dccp_write_timeout(struct sock *sk) ...@@ -45,11 +45,13 @@ static int dccp_write_timeout(struct sock *sk)
if (sk->sk_state == DCCP_REQUESTING || sk->sk_state == DCCP_PARTOPEN) { if (sk->sk_state == DCCP_REQUESTING || sk->sk_state == DCCP_PARTOPEN) {
if (icsk->icsk_retransmits != 0) if (icsk->icsk_retransmits != 0)
dst_negative_advice(&sk->sk_dst_cache); dst_negative_advice(&sk->sk_dst_cache);
retry_until = icsk->icsk_syn_retries ? : /* FIXME! */ 3 /* FIXME! sysctl_tcp_syn_retries */; retry_until = icsk->icsk_syn_retries ? :
/* FIXME! */ 3 /* FIXME! sysctl_tcp_syn_retries */;
} else { } else {
if (icsk->icsk_retransmits >= /* FIXME! sysctl_tcp_retries1 */ 5 /* FIXME! */) { if (icsk->icsk_retransmits >=
/* NOTE. draft-ietf-tcpimpl-pmtud-01.txt requires pmtu black /* FIXME! sysctl_tcp_retries1 */ 5 /* FIXME! */) {
hole detection. :-( /* NOTE. draft-ietf-tcpimpl-pmtud-01.txt requires pmtu
black hole detection. :-(
It is place to make it. It is not made. I do not want It is place to make it. It is not made. I do not want
to make it. It is disguisting. It does not work in any to make it. It is disguisting. It does not work in any
...@@ -96,14 +98,17 @@ static void dccp_delack_timer(unsigned long data) ...@@ -96,14 +98,17 @@ static void dccp_delack_timer(unsigned long data)
/* Try again later. */ /* Try again later. */
icsk->icsk_ack.blocked = 1; icsk->icsk_ack.blocked = 1;
NET_INC_STATS_BH(LINUX_MIB_DELAYEDACKLOCKED); NET_INC_STATS_BH(LINUX_MIB_DELAYEDACKLOCKED);
sk_reset_timer(sk, &icsk->icsk_delack_timer, jiffies + TCP_DELACK_MIN); sk_reset_timer(sk, &icsk->icsk_delack_timer,
jiffies + TCP_DELACK_MIN);
goto out; goto out;
} }
if (sk->sk_state == DCCP_CLOSED || !(icsk->icsk_ack.pending & ICSK_ACK_TIMER)) if (sk->sk_state == DCCP_CLOSED ||
!(icsk->icsk_ack.pending & ICSK_ACK_TIMER))
goto out; goto out;
if (time_after(icsk->icsk_ack.timeout, jiffies)) { if (time_after(icsk->icsk_ack.timeout, jiffies)) {
sk_reset_timer(sk, &icsk->icsk_delack_timer, icsk->icsk_ack.timeout); sk_reset_timer(sk, &icsk->icsk_delack_timer,
icsk->icsk_ack.timeout);
goto out; goto out;
} }
...@@ -112,7 +117,8 @@ static void dccp_delack_timer(unsigned long data) ...@@ -112,7 +117,8 @@ static void dccp_delack_timer(unsigned long data)
if (inet_csk_ack_scheduled(sk)) { if (inet_csk_ack_scheduled(sk)) {
if (!icsk->icsk_ack.pingpong) { if (!icsk->icsk_ack.pingpong) {
/* Delayed ACK missed: inflate ATO. */ /* Delayed ACK missed: inflate ATO. */
icsk->icsk_ack.ato = min(icsk->icsk_ack.ato << 1, icsk->icsk_rto); icsk->icsk_ack.ato = min(icsk->icsk_ack.ato << 1,
icsk->icsk_rto);
} else { } else {
/* Delayed ACK missed: leave pingpong mode and /* Delayed ACK missed: leave pingpong mode and
* deflate ATO. * deflate ATO.
...@@ -167,7 +173,7 @@ static void dccp_retransmit_timer(struct sock *sk) ...@@ -167,7 +173,7 @@ static void dccp_retransmit_timer(struct sock *sk)
inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
min(icsk->icsk_rto, min(icsk->icsk_rto,
TCP_RESOURCE_PROBE_INTERVAL), TCP_RESOURCE_PROBE_INTERVAL),
TCP_RTO_MAX); DCCP_RTO_MAX);
goto out; goto out;
} }
...@@ -175,7 +181,8 @@ static void dccp_retransmit_timer(struct sock *sk) ...@@ -175,7 +181,8 @@ static void dccp_retransmit_timer(struct sock *sk)
icsk->icsk_retransmits++; icsk->icsk_retransmits++;
icsk->icsk_rto = min(icsk->icsk_rto << 1, DCCP_RTO_MAX); icsk->icsk_rto = min(icsk->icsk_rto << 1, DCCP_RTO_MAX);
inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto, TCP_RTO_MAX); inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto,
DCCP_RTO_MAX);
if (icsk->icsk_retransmits > 3 /* FIXME: sysctl_dccp_retries1 */) if (icsk->icsk_retransmits > 3 /* FIXME: sysctl_dccp_retries1 */)
__sk_dst_reset(sk); __sk_dst_reset(sk);
out:; out:;
...@@ -190,7 +197,8 @@ static void dccp_write_timer(unsigned long data) ...@@ -190,7 +197,8 @@ static void dccp_write_timer(unsigned long data)
bh_lock_sock(sk); bh_lock_sock(sk);
if (sock_owned_by_user(sk)) { if (sock_owned_by_user(sk)) {
/* Try again later */ /* Try again later */
sk_reset_timer(sk, &icsk->icsk_retransmit_timer, jiffies + (HZ / 20)); sk_reset_timer(sk, &icsk->icsk_retransmit_timer,
jiffies + (HZ / 20));
goto out; goto out;
} }
...@@ -198,7 +206,8 @@ static void dccp_write_timer(unsigned long data) ...@@ -198,7 +206,8 @@ static void dccp_write_timer(unsigned long data)
goto out; goto out;
if (time_after(icsk->icsk_timeout, jiffies)) { if (time_after(icsk->icsk_timeout, jiffies)) {
sk_reset_timer(sk, &icsk->icsk_retransmit_timer, icsk->icsk_timeout); sk_reset_timer(sk, &icsk->icsk_retransmit_timer,
icsk->icsk_timeout);
goto out; goto out;
} }
...@@ -220,7 +229,8 @@ static void dccp_write_timer(unsigned long data) ...@@ -220,7 +229,8 @@ static void dccp_write_timer(unsigned long data)
*/ */
static void dccp_response_timer(struct sock *sk) static void dccp_response_timer(struct sock *sk)
{ {
inet_csk_reqsk_queue_prune(sk, TCP_SYNQ_INTERVAL, DCCP_TIMEOUT_INIT, DCCP_RTO_MAX); inet_csk_reqsk_queue_prune(sk, TCP_SYNQ_INTERVAL, DCCP_TIMEOUT_INIT,
DCCP_RTO_MAX);
} }
static void dccp_keepalive_timer(unsigned long data) static void dccp_keepalive_timer(unsigned long data)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册