Skip to content

Commit

Permalink
net: support 64bit rates for getsockopt(SO_MAX_PACING_RATE)
Browse files Browse the repository at this point in the history
For legacy applications using 32bit variable, SO_MAX_PACING_RATE
has to cap the returned value to 0xFFFFFFFF, meaning that
rates above 34.35 Gbit are capped.

This patch allows applications to read socket pacing rate
at full resolution, if they provide a 64bit variable to store it,
and the kernel is 64bit.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Mar 2, 2019
1 parent 6bdef10 commit 677f136
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
union {
int val;
u64 val64;
unsigned long ulval;
struct linger ling;
struct old_timeval32 tm32;
struct __kernel_old_timeval tm;
Expand Down Expand Up @@ -1464,8 +1465,13 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
#endif

case SO_MAX_PACING_RATE:
/* 32bit version */
v.val = min_t(unsigned long, sk->sk_max_pacing_rate, ~0U);
if (sizeof(v.ulval) != sizeof(v.val) && len >= sizeof(v.ulval)) {
lv = sizeof(v.ulval);
v.ulval = sk->sk_max_pacing_rate;
} else {
/* 32bit version */
v.val = min_t(unsigned long, sk->sk_max_pacing_rate, ~0U);
}
break;

case SO_INCOMING_CPU:
Expand Down

0 comments on commit 677f136

Please sign in to comment.