Commit 677f136c authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: support 64bit rates for getsockopt(SO_MAX_PACING_RATE)

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: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6bdef102
...@@ -1219,6 +1219,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname, ...@@ -1219,6 +1219,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
union { union {
int val; int val;
u64 val64; u64 val64;
unsigned long ulval;
struct linger ling; struct linger ling;
struct old_timeval32 tm32; struct old_timeval32 tm32;
struct __kernel_old_timeval tm; struct __kernel_old_timeval tm;
...@@ -1464,8 +1465,13 @@ int sock_getsockopt(struct socket *sock, int level, int optname, ...@@ -1464,8 +1465,13 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
#endif #endif
case SO_MAX_PACING_RATE: case SO_MAX_PACING_RATE:
/* 32bit version */ if (sizeof(v.ulval) != sizeof(v.val) && len >= sizeof(v.ulval)) {
v.val = min_t(unsigned long, sk->sk_max_pacing_rate, ~0U); 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; break;
case SO_INCOMING_CPU: case SO_INCOMING_CPU:
......
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