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

Commit 8fa6e3d4 authored by David S. Miller's avatar David S. Miller
Browse files
parents c239f279 2f34b329
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ struct ccid_operations {
	int		(*ccid_hc_tx_send_packet)(struct sock *sk,
						  struct sk_buff *skb);
	void		(*ccid_hc_tx_packet_sent)(struct sock *sk,
						  int more, unsigned int len);
						  unsigned int len);
	void		(*ccid_hc_rx_get_info)(struct sock *sk,
					       struct tcp_info *info);
	void		(*ccid_hc_tx_get_info)(struct sock *sk,
@@ -144,10 +144,10 @@ static inline int ccid_hc_tx_send_packet(struct ccid *ccid, struct sock *sk,
}

static inline void ccid_hc_tx_packet_sent(struct ccid *ccid, struct sock *sk,
					  int more, unsigned int len)
					  unsigned int len)
{
	if (ccid->ccid_ops->ccid_hc_tx_packet_sent != NULL)
		ccid->ccid_ops->ccid_hc_tx_packet_sent(sk, more, len);
		ccid->ccid_ops->ccid_hc_tx_packet_sent(sk, len);
}

static inline void ccid_hc_rx_packet_recv(struct ccid *ccid, struct sock *sk,
+1 −1
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ static void ccid2_hc_tx_rto_expire(unsigned long data)
	sock_put(sk);
}

static void ccid2_hc_tx_packet_sent(struct sock *sk, int more, unsigned int len)
static void ccid2_hc_tx_packet_sent(struct sock *sk, unsigned int len)
{
	struct dccp_sock *dp = dccp_sk(sk);
	struct ccid2_hc_tx_sock *hc = ccid2_hc_tx_sk(sk);
+1 −2
Original line number Diff line number Diff line
@@ -351,8 +351,7 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, struct sk_buff *skb)
	return 0;
}

static void ccid3_hc_tx_packet_sent(struct sock *sk, int more,
				    unsigned int len)
static void ccid3_hc_tx_packet_sent(struct sock *sk, unsigned int len)
{
	struct ccid3_hc_tx_sock *hc = ccid3_hc_tx_sk(sk);

+36 −8
Original line number Diff line number Diff line
@@ -153,18 +153,27 @@ static inline u64 max48(const u64 seq1, const u64 seq2)
}

/**
 * dccp_loss_free  -  Evaluates condition for data loss from RFC 4340, 7.7.1
 * @s1:	 start sequence number
 * @s2:  end sequence number
 * dccp_loss_count - Approximate the number of lost data packets in a burst loss
 * @s1:  last known sequence number before the loss ('hole')
 * @s2:  first sequence number seen after the 'hole'
 * @ndp: NDP count on packet with sequence number @s2
 * Returns true if the sequence range s1...s2 has no data loss.
 */
static inline bool dccp_loss_free(const u64 s1, const u64 s2, const u64 ndp)
static inline u64 dccp_loss_count(const u64 s1, const u64 s2, const u64 ndp)
{
	s64 delta = dccp_delta_seqno(s1, s2);

	WARN_ON(delta < 0);
	return (u64)delta <= ndp + 1;
	delta -= ndp + 1;

	return delta > 0 ? delta : 0;
}

/**
 * dccp_loss_free - Evaluate condition for data loss from RFC 4340, 7.7.1
 */
static inline bool dccp_loss_free(const u64 s1, const u64 s2, const u64 ndp)
{
	return dccp_loss_count(s1, s2, ndp) == 0;
}

enum {
@@ -414,6 +423,23 @@ static inline void dccp_update_gsr(struct sock *sk, u64 seq)
	dp->dccps_gsr = seq;
	/* Sequence validity window depends on remote Sequence Window (7.5.1) */
	dp->dccps_swl = SUB48(ADD48(dp->dccps_gsr, 1), dp->dccps_r_seq_win / 4);
	/*
	 * Adjust SWL so that it is not below ISR. In contrast to RFC 4340,
	 * 7.5.1 we perform this check beyond the initial handshake: W/W' are
	 * always > 32, so for the first W/W' packets in the lifetime of a
	 * connection we always have to adjust SWL.
	 * A second reason why we are doing this is that the window depends on
	 * the feature-remote value of Sequence Window: nothing stops the peer
	 * from updating this value while we are busy adjusting SWL for the
	 * first W packets (we would have to count from scratch again then).
	 * Therefore it is safer to always make sure that the Sequence Window
	 * is not artificially extended by a peer who grows SWL downwards by
	 * continually updating the feature-remote Sequence-Window.
	 * If sequence numbers wrap it is bad luck. But that will take a while
	 * (48 bit), and this measure prevents Sequence-number attacks.
	 */
	if (before48(dp->dccps_swl, dp->dccps_isr))
		dp->dccps_swl = dp->dccps_isr;
	dp->dccps_swh = ADD48(dp->dccps_gsr, (3 * dp->dccps_r_seq_win) / 4);
}

@@ -424,14 +450,16 @@ static inline void dccp_update_gss(struct sock *sk, u64 seq)
	dp->dccps_gss = seq;
	/* Ack validity window depends on local Sequence Window value (7.5.1) */
	dp->dccps_awl = SUB48(ADD48(dp->dccps_gss, 1), dp->dccps_l_seq_win);
	/* Adjust AWL so that it is not below ISS - see comment above for SWL */
	if (before48(dp->dccps_awl, dp->dccps_iss))
		dp->dccps_awl = dp->dccps_iss;
	dp->dccps_awh = dp->dccps_gss;
}

static inline int dccp_ack_pending(const struct sock *sk)
{
	const struct dccp_sock *dp = dccp_sk(sk);
	return dp->dccps_timestamp_echo != 0 ||
	       (dp->dccps_hc_rx_ackvec != NULL &&
	return (dp->dccps_hc_rx_ackvec != NULL &&
		dccp_ackvec_pending(dp->dccps_hc_rx_ackvec)) ||
	       inet_csk_ack_scheduled(sk);
}
+7 −13
Original line number Diff line number Diff line
@@ -259,7 +259,7 @@ static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb)
				      sysctl_dccp_sync_ratelimit)))
			return 0;

		DCCP_WARN("DCCP: Step 6 failed for %s packet, "
		DCCP_WARN("Step 6 failed for %s packet, "
			  "(LSWL(%llu) <= P.seqno(%llu) <= S.SWH(%llu)) and "
			  "(P.ackno %s or LAWL(%llu) <= P.ackno(%llu) <= S.AWH(%llu), "
			  "sending SYNC...\n",  dccp_packet_name(dh->dccph_type),
@@ -441,20 +441,14 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk,
		kfree_skb(sk->sk_send_head);
		sk->sk_send_head = NULL;

		dp->dccps_isr = DCCP_SKB_CB(skb)->dccpd_seq;
		dccp_update_gsr(sk, dp->dccps_isr);
		/*
		 * SWL and AWL are initially adjusted so that they are not less than
		 * the initial Sequence Numbers received and sent, respectively:
		 *	SWL := max(GSR + 1 - floor(W/4), ISR),
		 *	AWL := max(GSS - W' + 1, ISS).
		 * These adjustments MUST be applied only at the beginning of the
		 * connection.
		 *
		 * AWL was adjusted in dccp_v4_connect -acme
		 * Set ISR, GSR from packet. ISS was set in dccp_v{4,6}_connect
		 * and GSS in dccp_transmit_skb(). Setting AWL/AWH and SWL/SWH
		 * is done as part of activating the feature values below, since
		 * these settings depend on the local/remote Sequence Window
		 * features, which were undefined or not confirmed until now.
		 */
		dccp_set_seqno(&dp->dccps_swl,
			       max48(dp->dccps_swl, dp->dccps_isr));
		dp->dccps_gsr = dp->dccps_isr = DCCP_SKB_CB(skb)->dccpd_seq;

		dccp_sync_mss(sk, icsk->icsk_pmtu_cookie);

Loading