bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Eric Dumazet' <eric.dumazet@gmail.com>,
	Dmitry Yakunin <zeil@yandex-team.ru>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"brakmo@fb.com" <brakmo@fb.com>
Cc: "bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: RE: [PATCH bpf-next] bpf: add SO_KEEPALIVE and related options to bpf_setsockopt
Date: Fri, 29 May 2020 12:41:38 +0000	[thread overview]
Message-ID: <733bf731f95940a495830f3997307eaf@AcuMS.aculab.com> (raw)
In-Reply-To: <b5133e4e-4562-1ea0-9d46-c5fb74528ec8@gmail.com>

From: Eric Dumazet
> Sent: 27 May 2020 17:43
> 
> On 5/27/20 8:05 AM, Dmitry Yakunin wrote:
> > This patch adds support of SO_KEEPALIVE flag and TCP related options
> > to bpf_setsockopt() routine. This is helpful if we want to enable or tune
> > TCP keepalive for applications which don't do it in the userspace code.
> > In order to avoid copy-paste, common code from classic setsockopt was moved
> > to auxiliary functions in the headers.
> 
> 
> Please split this in two patches :
> - one adding the helpers, a pure TCP patch.
> - one for BPF additions.
> 
...
> > diff --git a/net/core/filter.c b/net/core/filter.c
> > index a6fc234..1035e43 100644
> > --- a/net/core/filter.c
> > +++ b/net/core/filter.c
...
> > +			case TCP_KEEPIDLE:
> > +				if (val < 1 || val > MAX_TCP_KEEPIDLE)
> > +					ret = -EINVAL;
> > +				else
> > +					keepalive_time_set(tp, val);
> > +				break;
> > +			case TCP_KEEPINTVL:
> > +				if (val < 1 || val > MAX_TCP_KEEPINTVL)
> > +					ret = -EINVAL;
> > +				else
> > +					tp->keepalive_intvl = val * HZ;
> > +				break;
> > +			case TCP_KEEPCNT:
> > +				if (val < 1 || val > MAX_TCP_KEEPCNT)
> > +					ret = -EINVAL;
> > +				else
> > +					tp->keepalive_probes = val;
> > +				break;
> > +			case TCP_SYNCNT:
> > +				if (val < 1 || val > MAX_TCP_SYNCNT)
> > +					ret = -EINVAL;
> > +				else
> > +					icsk->icsk_syn_retries = val;
> > +				break;
> > +			case TCP_USER_TIMEOUT:
> > +				if (val < 0)
> > +					ret = -EINVAL;
> > +				else
> > +					icsk->icsk_user_timeout = val;
> > +				break;

It also cannot be right to be layer breaking like this
and directly accessing the protocol socket internals.

At least a kernel_setsockopt() function keeps this separate
and ensures that the socket type is correct.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  parent reply	other threads:[~2020-05-29 12:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-27 15:05 [PATCH bpf-next] bpf: add SO_KEEPALIVE and related options to bpf_setsockopt Dmitry Yakunin
2020-05-27 16:42 ` Eric Dumazet
2020-05-27 20:17   ` Dmitry Yakunin
2020-05-29 12:41   ` David Laight [this message]
2020-05-27 17:02 ` Martin KaFai Lau
2020-05-27 20:44   ` Dmitry Yakunin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=733bf731f95940a495830f3997307eaf@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=bpf@vger.kernel.org \
    --cc=brakmo@fb.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=zeil@yandex-team.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).