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

Commit 49ffc29a authored by Gerrit Renker's avatar Gerrit Renker
Browse files

dccp: Clamping RTT values



This extracts the clamping part of dccp_sample_rtt() and makes it available
to other parts of the code (as e.g. used in the next patch).

Note: The function dccp_sample_rtt() now reduces to subtracting the elapsed
time. This could be eliminated but would require shorter prefixes and thus
is not done by this patch - maybe an idea for later.

Signed-off-by: default avatarGerrit Renker <gerrit@erg.abdn.ac.uk>
parent 2b81143a
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -334,6 +334,13 @@ extern struct sk_buff *dccp_ctl_make_reset(struct sock *sk,
extern int	   dccp_send_reset(struct sock *sk, enum dccp_reset_codes code);
extern int	   dccp_send_reset(struct sock *sk, enum dccp_reset_codes code);
extern void	   dccp_send_close(struct sock *sk, const int active);
extern void	   dccp_send_close(struct sock *sk, const int active);
extern int	   dccp_invalid_packet(struct sk_buff *skb);
extern int	   dccp_invalid_packet(struct sk_buff *skb);

static inline u32  dccp_sane_rtt(long usec_sample)
{
	if (unlikely(usec_sample <= 0 || usec_sample > DCCP_SANE_RTT_MAX))
		DCCP_WARN("RTT sample %ld out of bounds!\n", usec_sample);
	return clamp_val(usec_sample, DCCP_SANE_RTT_MIN, DCCP_SANE_RTT_MAX);
}
extern u32 dccp_sample_rtt(struct sock *sk, long delta);
extern u32 dccp_sample_rtt(struct sock *sk, long delta);


static inline int dccp_bad_service_code(const struct sock *sk,
static inline int dccp_bad_service_code(const struct sock *sk,
+1 −10
Original line number Original line Diff line number Diff line
@@ -707,16 +707,7 @@ u32 dccp_sample_rtt(struct sock *sk, long delta)
	/* dccpor_elapsed_time is either zeroed out or set and > 0 */
	/* dccpor_elapsed_time is either zeroed out or set and > 0 */
	delta -= dccp_sk(sk)->dccps_options_received.dccpor_elapsed_time * 10;
	delta -= dccp_sk(sk)->dccps_options_received.dccpor_elapsed_time * 10;


	if (unlikely(delta <= 0)) {
	return dccp_sane_rtt(delta);
		DCCP_WARN("unusable RTT sample %ld, using min\n", delta);
		return DCCP_SANE_RTT_MIN;
	}
	if (unlikely(delta > DCCP_SANE_RTT_MAX)) {
		DCCP_WARN("RTT sample %ld too large, using max\n", delta);
		return DCCP_SANE_RTT_MAX;
	}

	return delta;
}
}


EXPORT_SYMBOL_GPL(dccp_sample_rtt);
EXPORT_SYMBOL_GPL(dccp_sample_rtt);