aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/sock.c
diff options
context:
space:
mode:
authorHannes Frederic Sowa <hannes@stressinduktion.org>2015-10-26 08:51:37 -0400
committerDavid S. Miller <davem@davemloft.net>2015-10-27 22:39:14 -0400
commit080a270f5adec1ada1357eb66321e7222cc34301 (patch)
tree5f45c01b2412b000dfe773a121e426c4e8dbe9c5 /net/core/sock.c
parent6092db1aba2d151acd40a0370b80b5c043936d2d (diff)
sock: don't enable netstamp for af_unix sockets
netstamp_needed is toggled for all socket families if they request timestamping. But some protocols don't need the lower-layer timestamping code at all. This patch starts disabling it for af-unix. E.g. systemd enables timestamping during boot-up on the journald af-unix sockets, thus causing the system to globally enable timestamping in the lower networking stack. Still, it is very probable that timestamping gets activated, by e.g. dhclient or various NTP implementations. Reported-by: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/sock.c')
-rw-r--r--net/core/sock.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index dcc7d62654d5..0ef30aa90132 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -422,13 +422,25 @@ static void sock_warn_obsolete_bsdism(const char *name)
422 } 422 }
423} 423}
424 424
425static bool sock_needs_netstamp(const struct sock *sk)
426{
427 switch (sk->sk_family) {
428 case AF_UNSPEC:
429 case AF_UNIX:
430 return false;
431 default:
432 return true;
433 }
434}
435
425#define SK_FLAGS_TIMESTAMP ((1UL << SOCK_TIMESTAMP) | (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE)) 436#define SK_FLAGS_TIMESTAMP ((1UL << SOCK_TIMESTAMP) | (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE))
426 437
427static void sock_disable_timestamp(struct sock *sk, unsigned long flags) 438static void sock_disable_timestamp(struct sock *sk, unsigned long flags)
428{ 439{
429 if (sk->sk_flags & flags) { 440 if (sk->sk_flags & flags) {
430 sk->sk_flags &= ~flags; 441 sk->sk_flags &= ~flags;
431 if (!(sk->sk_flags & SK_FLAGS_TIMESTAMP)) 442 if (sock_needs_netstamp(sk) &&
443 !(sk->sk_flags & SK_FLAGS_TIMESTAMP))
432 net_disable_timestamp(); 444 net_disable_timestamp();
433 } 445 }
434} 446}
@@ -1582,7 +1594,8 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
1582 if (newsk->sk_prot->sockets_allocated) 1594 if (newsk->sk_prot->sockets_allocated)
1583 sk_sockets_allocated_inc(newsk); 1595 sk_sockets_allocated_inc(newsk);
1584 1596
1585 if (newsk->sk_flags & SK_FLAGS_TIMESTAMP) 1597 if (sock_needs_netstamp(sk) &&
1598 newsk->sk_flags & SK_FLAGS_TIMESTAMP)
1586 net_enable_timestamp(); 1599 net_enable_timestamp();
1587 } 1600 }
1588out: 1601out:
@@ -2510,7 +2523,8 @@ void sock_enable_timestamp(struct sock *sk, int flag)
2510 * time stamping, but time stamping might have been on 2523 * time stamping, but time stamping might have been on
2511 * already because of the other one 2524 * already because of the other one
2512 */ 2525 */
2513 if (!(previous_flags & SK_FLAGS_TIMESTAMP)) 2526 if (sock_needs_netstamp(sk) &&
2527 !(previous_flags & SK_FLAGS_TIMESTAMP))
2514 net_enable_timestamp(); 2528 net_enable_timestamp();
2515 } 2529 }
2516} 2530}