Commit ef3f9569 authored by David S. Miller's avatar David S. Miller

Merge branch 'sctp-timestamp-fixes'

Marcelo Ricardo Leitner says:

====================
sctp: packet timestamp fixes

These a couple of fixes regarding sctp/packet timestamps.

Dmitry Vyukov <dvyukov@google.com> reported the counter leak on missing
net_enable_timestamp() (2nd patch) and further testing here revealed the
other two issues.

Please consider these to -stable.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents c5fb8caa 50a5ffb1
...@@ -740,6 +740,8 @@ enum sock_flags { ...@@ -740,6 +740,8 @@ enum sock_flags {
SOCK_SELECT_ERR_QUEUE, /* Wake select on error queue */ SOCK_SELECT_ERR_QUEUE, /* Wake select on error queue */
}; };
#define SK_FLAGS_TIMESTAMP ((1UL << SOCK_TIMESTAMP) | (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE))
static inline void sock_copy_flags(struct sock *nsk, struct sock *osk) static inline void sock_copy_flags(struct sock *nsk, struct sock *osk)
{ {
nsk->sk_flags = osk->sk_flags; nsk->sk_flags = osk->sk_flags;
......
...@@ -433,8 +433,6 @@ static bool sock_needs_netstamp(const struct sock *sk) ...@@ -433,8 +433,6 @@ static bool sock_needs_netstamp(const struct sock *sk)
} }
} }
#define SK_FLAGS_TIMESTAMP ((1UL << SOCK_TIMESTAMP) | (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE))
static void sock_disable_timestamp(struct sock *sk, unsigned long flags) static void sock_disable_timestamp(struct sock *sk, unsigned long flags)
{ {
if (sk->sk_flags & flags) { if (sk->sk_flags & flags) {
......
...@@ -1652,7 +1652,7 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep, ...@@ -1652,7 +1652,7 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
/* Set an expiration time for the cookie. */ /* Set an expiration time for the cookie. */
cookie->c.expiration = ktime_add(asoc->cookie_life, cookie->c.expiration = ktime_add(asoc->cookie_life,
ktime_get()); ktime_get_real());
/* Copy the peer's init packet. */ /* Copy the peer's init packet. */
memcpy(&cookie->c.peer_init[0], init_chunk->chunk_hdr, memcpy(&cookie->c.peer_init[0], init_chunk->chunk_hdr,
...@@ -1780,7 +1780,7 @@ struct sctp_association *sctp_unpack_cookie( ...@@ -1780,7 +1780,7 @@ struct sctp_association *sctp_unpack_cookie(
if (sock_flag(ep->base.sk, SOCK_TIMESTAMP)) if (sock_flag(ep->base.sk, SOCK_TIMESTAMP))
kt = skb_get_ktime(skb); kt = skb_get_ktime(skb);
else else
kt = ktime_get(); kt = ktime_get_real();
if (!asoc && ktime_before(bear_cookie->expiration, kt)) { if (!asoc && ktime_before(bear_cookie->expiration, kt)) {
/* /*
......
...@@ -7167,6 +7167,7 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk, ...@@ -7167,6 +7167,7 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk,
newsk->sk_type = sk->sk_type; newsk->sk_type = sk->sk_type;
newsk->sk_bound_dev_if = sk->sk_bound_dev_if; newsk->sk_bound_dev_if = sk->sk_bound_dev_if;
newsk->sk_flags = sk->sk_flags; newsk->sk_flags = sk->sk_flags;
newsk->sk_tsflags = sk->sk_tsflags;
newsk->sk_no_check_tx = sk->sk_no_check_tx; newsk->sk_no_check_tx = sk->sk_no_check_tx;
newsk->sk_no_check_rx = sk->sk_no_check_rx; newsk->sk_no_check_rx = sk->sk_no_check_rx;
newsk->sk_reuse = sk->sk_reuse; newsk->sk_reuse = sk->sk_reuse;
...@@ -7199,6 +7200,9 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk, ...@@ -7199,6 +7200,9 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk,
newinet->mc_ttl = 1; newinet->mc_ttl = 1;
newinet->mc_index = 0; newinet->mc_index = 0;
newinet->mc_list = NULL; newinet->mc_list = NULL;
if (newsk->sk_flags & SK_FLAGS_TIMESTAMP)
net_enable_timestamp();
} }
static inline void sctp_copy_descendant(struct sock *sk_to, static inline void sctp_copy_descendant(struct sock *sk_to,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment