* [PATCH net-next] net: relax SO_TXTIME CAP_NET_ADMIN check
@ 2020-05-07 17:05 Eric Dumazet
2020-05-07 17:11 ` Willem de Bruijn
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Eric Dumazet @ 2020-05-07 17:05 UTC (permalink / raw)
To: David S . Miller; +Cc: netdev, Eric Dumazet, Eric Dumazet, Willem de Bruijn
Now sch_fq has horizon feature, we want to allow QUIC/UDP applications
to use EDT model so that pacing can be offloaded to the kernel (sch_fq)
or the NIC.
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
---
net/core/sock.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/net/core/sock.c b/net/core/sock.c
index b714162213aeae98bfee24d8b457547fe7abab4f..fd85e651ce284b6987f0e8fae94f76ec2c432899 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1152,23 +1152,31 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
break;
case SO_TXTIME:
- if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) {
- ret = -EPERM;
- } else if (optlen != sizeof(struct sock_txtime)) {
+ if (optlen != sizeof(struct sock_txtime)) {
ret = -EINVAL;
+ break;
} else if (copy_from_user(&sk_txtime, optval,
sizeof(struct sock_txtime))) {
ret = -EFAULT;
+ break;
} else if (sk_txtime.flags & ~SOF_TXTIME_FLAGS_MASK) {
ret = -EINVAL;
- } else {
- sock_valbool_flag(sk, SOCK_TXTIME, true);
- sk->sk_clockid = sk_txtime.clockid;
- sk->sk_txtime_deadline_mode =
- !!(sk_txtime.flags & SOF_TXTIME_DEADLINE_MODE);
- sk->sk_txtime_report_errors =
- !!(sk_txtime.flags & SOF_TXTIME_REPORT_ERRORS);
+ break;
}
+ /* CLOCK_MONOTONIC is only used by sch_fq, and this packet
+ * scheduler has enough safe guards.
+ */
+ if (sk_txtime.clockid != CLOCK_MONOTONIC &&
+ !ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) {
+ ret = -EPERM;
+ break;
+ }
+ sock_valbool_flag(sk, SOCK_TXTIME, true);
+ sk->sk_clockid = sk_txtime.clockid;
+ sk->sk_txtime_deadline_mode =
+ !!(sk_txtime.flags & SOF_TXTIME_DEADLINE_MODE);
+ sk->sk_txtime_report_errors =
+ !!(sk_txtime.flags & SOF_TXTIME_REPORT_ERRORS);
break;
case SO_BINDTOIFINDEX:
--
2.26.2.526.g744177e7f7-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: relax SO_TXTIME CAP_NET_ADMIN check
2020-05-07 17:05 [PATCH net-next] net: relax SO_TXTIME CAP_NET_ADMIN check Eric Dumazet
@ 2020-05-07 17:11 ` Willem de Bruijn
2020-05-07 18:09 ` Vinicius Costa Gomes
2020-05-08 1:17 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Willem de Bruijn @ 2020-05-07 17:11 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David S . Miller, netdev, Eric Dumazet
On Thu, May 7, 2020 at 1:05 PM Eric Dumazet <edumazet@google.com> wrote:
>
> Now sch_fq has horizon feature, we want to allow QUIC/UDP applications
> to use EDT model so that pacing can be offloaded to the kernel (sch_fq)
> or the NIC.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Willem de Bruijn <willemb@google.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Thanks Eric! This will really help with enabling pacing offload in
real workloads.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: relax SO_TXTIME CAP_NET_ADMIN check
2020-05-07 17:05 [PATCH net-next] net: relax SO_TXTIME CAP_NET_ADMIN check Eric Dumazet
2020-05-07 17:11 ` Willem de Bruijn
@ 2020-05-07 18:09 ` Vinicius Costa Gomes
2020-05-08 1:17 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Vinicius Costa Gomes @ 2020-05-07 18:09 UTC (permalink / raw)
To: Eric Dumazet, David S . Miller
Cc: netdev, Eric Dumazet, Eric Dumazet, Willem de Bruijn
Hi,
Eric Dumazet <edumazet@google.com> writes:
> Now sch_fq has horizon feature, we want to allow QUIC/UDP applications
> to use EDT model so that pacing can be offloaded to the kernel (sch_fq)
> or the NIC.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Willem de Bruijn <willemb@google.com>
> ---
> net/core/sock.c | 28 ++++++++++++++++++----------
> 1 file changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/net/core/sock.c b/net/core/sock.c
> index b714162213aeae98bfee24d8b457547fe7abab4f..fd85e651ce284b6987f0e8fae94f76ec2c432899 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -1152,23 +1152,31 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
> break;
>
> case SO_TXTIME:
> - if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) {
> - ret = -EPERM;
> - } else if (optlen != sizeof(struct sock_txtime)) {
> + if (optlen != sizeof(struct sock_txtime)) {
> ret = -EINVAL;
> + break;
> } else if (copy_from_user(&sk_txtime, optval,
> sizeof(struct sock_txtime))) {
> ret = -EFAULT;
> + break;
> } else if (sk_txtime.flags & ~SOF_TXTIME_FLAGS_MASK) {
> ret = -EINVAL;
> - } else {
> - sock_valbool_flag(sk, SOCK_TXTIME, true);
> - sk->sk_clockid = sk_txtime.clockid;
> - sk->sk_txtime_deadline_mode =
> - !!(sk_txtime.flags & SOF_TXTIME_DEADLINE_MODE);
> - sk->sk_txtime_report_errors =
> - !!(sk_txtime.flags & SOF_TXTIME_REPORT_ERRORS);
> + break;
> }
> + /* CLOCK_MONOTONIC is only used by sch_fq, and this packet
> + * scheduler has enough safe guards.
> + */
> + if (sk_txtime.clockid != CLOCK_MONOTONIC &&
> + !ns_capable(sock_net(sk)->user_ns, CAP_NET_ADMIN)) {
> + ret = -EPERM;
> + break;
> + }
I was a bit worried until I saw the check above.
Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
> + sock_valbool_flag(sk, SOCK_TXTIME, true);
> + sk->sk_clockid = sk_txtime.clockid;
> + sk->sk_txtime_deadline_mode =
> + !!(sk_txtime.flags & SOF_TXTIME_DEADLINE_MODE);
> + sk->sk_txtime_report_errors =
> + !!(sk_txtime.flags & SOF_TXTIME_REPORT_ERRORS);
> break;
>
> case SO_BINDTOIFINDEX:
> --
> 2.26.2.526.g744177e7f7-goog
>
--
Vinicius
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: relax SO_TXTIME CAP_NET_ADMIN check
2020-05-07 17:05 [PATCH net-next] net: relax SO_TXTIME CAP_NET_ADMIN check Eric Dumazet
2020-05-07 17:11 ` Willem de Bruijn
2020-05-07 18:09 ` Vinicius Costa Gomes
@ 2020-05-08 1:17 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2020-05-08 1:17 UTC (permalink / raw)
To: edumazet; +Cc: netdev, eric.dumazet, willemb
From: Eric Dumazet <edumazet@google.com>
Date: Thu, 7 May 2020 10:05:39 -0700
> Now sch_fq has horizon feature, we want to allow QUIC/UDP applications
> to use EDT model so that pacing can be offloaded to the kernel (sch_fq)
> or the NIC.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Willem de Bruijn <willemb@google.com>
Applied, thanks Eric.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-05-08 1:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-07 17:05 [PATCH net-next] net: relax SO_TXTIME CAP_NET_ADMIN check Eric Dumazet
2020-05-07 17:11 ` Willem de Bruijn
2020-05-07 18:09 ` Vinicius Costa Gomes
2020-05-08 1:17 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).