Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7690af3f authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by David S. Miller
Browse files

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



Andrew Morton should be happy now 8)

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c1734376
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -30,21 +30,26 @@ struct ccid {
	int		(*ccid_hc_tx_init)(struct sock *sk);
	void		(*ccid_hc_rx_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,
						    unsigned char option,
						    unsigned char len, u16 idx,
						    unsigned char* value);
	void		(*ccid_hc_rx_insert_options)(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);
	void		(*ccid_hc_rx_insert_options)(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,
						    unsigned char option,
						    unsigned char len, u16 idx,
						    unsigned char* value);
	int		(*ccid_hc_tx_send_packet)(struct sock *sk,
						  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);
@@ -123,7 +128,8 @@ static inline int ccid_hc_tx_parse_options(struct ccid *ccid, struct sock *sk,
{
	int rc = 0;
	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;
}

+36 −20
Original line number Diff line number Diff line
@@ -25,7 +25,8 @@ extern int dccp_debug;
	do { if (dccp_debug) \
		printk(KERN_DEBUG "%s: " format, __FUNCTION__ , ##a); \
	} 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
#define dccp_pr_debug(format, a...)
#define dccp_pr_debug_cat(format, a...)
@@ -72,7 +73,8 @@ static inline const int after48(const u64 seq1, const u64 seq2)
}

/* 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);
}
@@ -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_USER(field)  SNMP_INC_STATS_USER(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_USER(field, val)	SNMP_ADD_STATS_USER(dccp_statistics, field, val)
#define DCCP_ADD_STATS_BH(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_retransmit_skb(struct sock *sk, struct sk_buff *skb);
@@ -234,8 +238,8 @@ extern int dccp_disconnect(struct sock *sk, int flags);
extern int	   dccp_getsockopt(struct sock *sk, int level, int optname,
				   char *optval, int *optlen);
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,
				size_t size);
extern int	   dccp_sendmsg(struct kiocb *iocb, struct sock *sk,
				struct msghdr *msg, size_t size);
extern int	   dccp_recvmsg(struct kiocb *iocb, struct sock *sk,
				struct msghdr *msg, size_t len, int nonblock,
				int flags, int *addr_len);
@@ -246,7 +250,8 @@ extern void dccp_shutdown(struct sock *sk, int how);
extern int	   dccp_v4_checksum(const struct sk_buff *skb,
				    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);

struct dccp_skb_cb {
@@ -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)
{
	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)
	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)
	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)
	dhack->dccph_ack_nr_high = htonl((gsr >> 32)) >> 8;
@@ -332,11 +339,14 @@ static inline void dccp_update_gsr(struct sock *sk, u64 seq)
	struct dccp_sock *dp = dccp_sk(sk);
	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;
	dccp_set_seqno(&dp->dccps_swl, max48(tmp_gsr, dp->dccps_isr));
	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)
@@ -344,7 +354,9 @@ static inline void dccp_update_gss(struct sock *sk, u64 seq)
	struct dccp_sock *dp = dccp_sk(sk);
	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_awh = dp->dccps_gss = seq;
}
@@ -373,16 +385,20 @@ extern struct socket *dccp_ctl_socket;
 *
 * @dccpap_buf_head - circular buffer head
 * @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_nonce - the one-bit sum of the ECN Nonces on all packets acked by the buffer with State 0
 * @dccpap_buf_ackno - ack # of the most recent packet acknowledgeable in the
 * 		       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
 * Ack Vectors it has recently sent. For each packet sent carrying an
 * 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_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_buf_len - circular buffer length
+62 −38
Original line number Diff line number Diff line
@@ -93,7 +93,8 @@ static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb)
	 */
	if (dh->dccph_type == DCCP_PKT_SYNC || 
	    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))
			dccp_update_gsr(sk, DCCP_SKB_CB(skb)->dccpd_seq);
		else
@@ -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) &&
	    (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);

		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;
	} else {
		dccp_pr_debug("Step 6 failed, sending SYNC...\n");
@@ -161,10 +164,13 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
		if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts,
				     DCCP_SKB_CB(skb)->dccpd_seq,
				     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;
			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;
		}

@@ -175,7 +181,8 @@ int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
		 */
		if (!inet_csk_ack_scheduled(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,
	case DCCP_PKT_DATAACK:
	case DCCP_PKT_DATA:
		/*
		 * FIXME: check if sk_receive_queue is full, schedule DATA_DROPPED option
		 * if it is.
		 * FIXME: check if sk_receive_queue is full, schedule DATA_DROPPED
		 * option if it is.
		 */
		__skb_pull(skb, dh->dccph_doff * 4);
		__skb_queue_tail(&sk->sk_receive_queue, skb);
@@ -272,8 +279,10 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
		__kfree_skb(sk->sk_send_head);
		sk->sk_send_head = NULL;

		if (!between48(DCCP_SKB_CB(skb)->dccpd_ack_seq, dp->dccps_awl, dp->dccps_awh)) {
			dccp_pr_debug("invalid ackno: S.AWL=%llu, P.ackno=%llu, S.AWH=%llu \n",
		if (!between48(DCCP_SKB_CB(skb)->dccpd_ack_seq,
			       dp->dccps_awl, dp->dccps_awh)) {
			dccp_pr_debug("invalid ackno: S.AWL=%llu, "
				      "P.ackno=%llu, S.AWH=%llu \n",
				      (unsigned long long)dp->dccps_awl,
			   (unsigned long long)DCCP_SKB_CB(skb)->dccpd_ack_seq,
				      (unsigned long long)dp->dccps_awh);
@@ -296,16 +305,17 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
		/*
		 *    Step 10: Process REQUEST state (second part)
		 *       If S.state == REQUEST,
		 *	  / * If we get here, P is a valid Response from the server (see
		 *	     Step 4), and we should move to PARTOPEN state.  PARTOPEN
		 *	     means send an Ack, don't send Data packets, retransmit
		 *	     Acks periodically, and always include any Init Cookie from
		 *	     the Response * /
		 *	  / * If we get here, P is a valid Response from the
		 *	      server (see Step 4), and we should move to
		 *	      PARTOPEN state. PARTOPEN means send an Ack,
		 *	      don't send Data packets, retransmit Acks
		 *	      periodically, and always include any Init Cookie
		 *	      from the Response * /
		 *	  S.state := PARTOPEN
		 *	  Set PARTOPEN timer
		 * 	  Continue with S.state == PARTOPEN
		 *	  / * Step 12 will send the Ack completing the three-way
		 *	     handshake * /
		 *	  / * Step 12 will send the Ack completing the
		 *	      three-way handshake * /
		 */
		dccp_set_state(sk, DCCP_PARTOPEN);

@@ -341,7 +351,8 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,

out_invalid_packet:
	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,
@@ -358,11 +369,12 @@ static int dccp_rcv_respond_partopen_state_process(struct sock *sk,
	case DCCP_PKT_DATAACK:
	case DCCP_PKT_ACK:
		/*
		 * FIXME: we should be reseting the PARTOPEN (DELACK) timer here,
		 * but only if we haven't used the DELACK timer for something else,
		 * like sending a delayed ack for a TIMESTAMP echo, etc, for now
		 * were not clearing it, sending an extra ACK when there is nothing
		 * else to do in DELACK is not a big deal after all.
		 * FIXME: we should be reseting the PARTOPEN (DELACK) timer
		 * here but only if we haven't used the DELACK timer for
		 * something else, like sending a delayed ack for a TIMESTAMP
		 * echo, etc, for now were not clearing it, sending an extra
		 * ACK when there is nothing else to do in DELACK is not a big
		 * deal after all.
		 */

		/* Stop the PARTOPEN timer */
@@ -374,7 +386,8 @@ static int dccp_rcv_respond_partopen_state_process(struct sock *sk,

		if (dh->dccph_type == DCCP_PKT_DATAACK) {
			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;
	}
@@ -399,7 +412,8 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
		if (dccp_parse_options(sk, skb))
			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);

		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,
					     DCCP_ACKPKTS_STATE_RECEIVED))
				goto discard;
			/*
			 * FIXME: this activation is probably wrong, have to study more
			 * TCP delack machinery and how it fits into DCCP draft, but
			 * for now it kinda "works" 8)
			 * FIXME: this activation is probably wrong, have to
			 * study more TCP delack machinery and how it fits into
			 * 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_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,
	 *		Drop packet and return
	*/
	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_time_wait(sk, DCCP_TIME_WAIT, 0);
		return 0;
@@ -450,10 +470,12 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
		 *	  Drop packet and return
		 */
	} 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 &&
		     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);
		goto discard;
	}
@@ -491,11 +513,13 @@ int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,

	case DCCP_RESPOND:
	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;
	}

	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) {
		case DCCP_PARTOPEN:
			sk->sk_state_change(sk);
+74 −40
Original line number Diff line number Diff line
@@ -61,7 +61,8 @@ static int __dccp_v4_check_established(struct sock *sk, const __u16 lport,
	const int dif = sk->sk_bound_dev_if;
	INET_ADDR_COOKIE(acookie, saddr, daddr)
	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];
	const struct sock *sk2;
	const struct hlist_node *node;
@@ -133,11 +134,12 @@ static int dccp_v4_hash_connect(struct sock *sk)
 		local_bh_disable();

 		/* 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.
 		 *
 		 * Now it protects single _advisory_ variable dccp_hashinfo.port_rover,
 		 * hence it is mostly useless.
 		 * Now it protects single _advisory_ variable
		 * dccp_hashinfo.port_rover, hence it is mostly useless.
 		 * Code will work nicely if we just delete it, but
 		 * I am afraid in contented case it will work not better or
 		 * even worse: another cpu just will hit the same bucket
@@ -152,7 +154,8 @@ static int dccp_v4_hash_connect(struct sock *sk)
 			rover++;
 			if ((rover < low) || (rover > high))
 				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);

 			/* Does not bother with rcv_saddr checks,
@@ -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) {
 				spin_unlock(&head->lock);
 				break;
@@ -211,7 +215,8 @@ ok:
		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;
	spin_lock_bh(&head->lock);
	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,
out:
	return err;
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);
	ip_rt_put(rt);
	sk->sk_route_caps = 0;
@@ -365,8 +372,9 @@ static inline void dccp_do_pmtu_discovery(struct sock *sk,
		/*
		 * From: draft-ietf-dccp-spec-11.txt
		 *
		 *	DCCP-Sync packets are the best choice for upward probing,
		 *	since DCCP-Sync probes do not risk application data loss.
		 *	DCCP-Sync packets are the best choice for upward
		 *	probing, since DCCP-Sync probes do not risk application
		 *	data loss.
		 */
		dccp_send_sync(sk, dp->dccps_gsr);
	} /* else let the usual retransmit timer handle it */
@@ -405,11 +413,13 @@ static void dccp_v4_ctl_send_ack(struct sk_buff *rxskb)
	dh->dccph_x	   = 1;

	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);
	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);

	if (err == NET_XMIT_CN || err == 0) {
@@ -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);
}
@@ -465,7 +476,8 @@ out:
void dccp_v4_err(struct sk_buff *skb, u32 info)
{
	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 inet_sock *inet;
	const int type = skb->h.icmph->type;
@@ -605,7 +617,8 @@ out:
	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)
{
@@ -689,7 +702,8 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
	ireq->loc_addr = daddr;
	ireq->rmt_addr = saddr;
	/* 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;

	/* 
@@ -804,7 +818,8 @@ static struct sock *dccp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
	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);
	int checksum_len;
@@ -814,11 +829,13 @@ int dccp_v4_checksum(const struct sk_buff *skb, const u32 saddr, const u32 daddr
		checksum_len = skb->len;
	else {
		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);
	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,
@@ -832,10 +849,12 @@ static int dccp_v4_verify_checksum(struct sk_buff *skb,
		checksum_len = skb->len;
	else {
		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);
	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,
@@ -850,7 +869,9 @@ static struct dst_entry* dccp_v4_route_skb(struct sock *sk,
			    .proto = sk->sk_protocol,
			    .uli_u = { .ports =
				       { .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)) {
		IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
@@ -899,17 +920,20 @@ void dccp_v4_ctl_send_reset(struct sk_buff *rxskb)
	dh->dccph_dport	   = rxdh->dccph_sport;
	dh->dccph_doff	   = dccp_hdr_reset_len / 4;
	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_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,
					      rxskb->nh.iph->daddr);

	bh_lock_sock(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);

	if (err == NET_XMIT_CN || err == 0) {
@@ -933,7 +957,8 @@ int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
	/*
	 *  Step 3: Process LISTEN state
	 *     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
	 *		Cookie.  Only the Init Cookie is processed here,
	 *		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)
	 *	     Generate Reset(No Connection) unless P.type == Reset
	 *	     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) {
		struct sock *nsk = dccp_v4_hnd_req(sk, 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))) {
		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;
	}

@@ -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_ACK &&
	    dh->dccph_type != DCCP_PKT_DATAACK) {
		dccp_pr_debug("P.type (%s) not Data, Ack nor DataAck and P.X == 0\n",
			      dccp_packet_name(dh->dccph_type));
		dccp_pr_debug("P.type (%s) not Data, Ack nor DataAck and "
			      "P.X == 0\n", dccp_packet_name(dh->dccph_type));
		return 1;
	}

@@ -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
	 * 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, 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
	 *
	 * So...
@@ -1072,10 +1100,12 @@ int dccp_v4_rcv(struct sk_buff *skb)
	 * 281473596467416 was received
	 * 281473596467415 was not 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;

		if (discard) {
@@ -1170,7 +1200,8 @@ no_dccp_socket:
	 *		Drop packet and return
	 */
	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);
	}

@@ -1196,7 +1227,8 @@ static int dccp_v4_init_sock(struct sock *sk)
	dccp_options_init(&dp->dccps_options);

	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);

		if (dp->dccps_hc_rx_ackpkts == NULL)
@@ -1211,8 +1243,10 @@ static int dccp_v4_init_sock(struct sock *sk)
	 * setsockopt(CCIDs-I-want/accept). -acme
	 */
	if (likely(!dccp_ctl_socket_init)) {
		dp->dccps_hc_rx_ccid = ccid_init(dp->dccps_options.dccpo_ccid, sk);
		dp->dccps_hc_tx_ccid = ccid_init(dp->dccps_options.dccpo_ccid, sk);
		dp->dccps_hc_rx_ccid = ccid_init(dp->dccps_options.dccpo_ccid,
						 sk);
		dp->dccps_hc_tx_ccid = ccid_init(dp->dccps_options.dccpo_ccid,
						 sk);
	    	if (dp->dccps_hc_rx_ccid == NULL ||
		    dp->dccps_hc_tx_ccid == NULL) {
			ccid_exit(dp->dccps_hc_rx_ccid, sk);
+23 −14

File changed.

Preview size limit exceeded, changes collapsed.

Loading