|
|
Log in / Subscribe / Register

Re: [PATCH] Allow TCP connections to cache SYN packet for userspace inspection

From:  Eric Dumazet <eric.dumazet-Re5JQEeQqe8AvxtiuMwx3w-AT-public.gmane.org>
To:  Eric B Munson <emunson-JqFfY2XvxFXQT0dZR+AlfA-AT-public.gmane.org>
Subject:  Re: [PATCH] Allow TCP connections to cache SYN packet for userspace inspection
Date:  Fri, 01 May 2015 11:42:57 -0700
Message-ID:  <1430505777.3711.135.camel@edumazet-glaptop2.roam.corp.google.com>
Cc:  "David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q-AT-public.gmane.org>, Alexey Kuznetsov <kuznet-v/Mj1YrvjDBInbfyfbPRSQ-AT-public.gmane.org>, James Morris <jmorris-gx6/JNMH7DfYtjvyW6yDsg-AT-public.gmane.org>, Hideaki YOSHIFUJI <yoshfuji-VfPWfsRibaP+Ru+s062T9g-AT-public.gmane.org>, Patrick McHardy <kaber-dcUjhNyLwpNeoWH0uzbU5w-AT-public.gmane.org>, netdev-u79uwXL29TY76Z2rM5mHXA-AT-public.gmane.org, linux-api-u79uwXL29TY76Z2rM5mHXA-AT-public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA-AT-public.gmane.org
Archive‑link:  Article

On Fri, 2015-05-01 at 13:43 -0400, Eric B Munson wrote:
> In order to enable policy decisions in userspace, the data contained in
> the SYN packet would be useful for tracking or identifying connections.
> Only parts of this data are available to userspace after the hand shake
> is completed.  This patch exposes a new setsockopt() option that will,
> when used with a listening socket, ask the kernel to cache the skb
> holding the SYN packet for retrieval later.  The SYN skbs will not be
> saved while the kernel is in syn cookie mode.
> 
> The same option will ask the kernel for the packet headers when used
> with getsockopt() with the socket returned from accept().  The cached
> packet will only be available for the first getsockopt() call, the skb
> is consumed after the requested data is copied to userspace.  Subsequent
> calls will return -ENOENT.  Because of this behavior, getsockopt() will
> return -E2BIG if the caller supplied a buffer that is too small to hold
> the skb header.
> 
> Signed-off-by: Eric B Munson <emunson-JqFfY2XvxFXQT0dZR+AlfA@public.gmane.org>
> Cc: Alexey Kuznetsov <kuznet-v/Mj1YrvjDBInbfyfbPRSQ@public.gmane.org>
> Cc: James Morris <jmorris-gx6/JNMH7DfYtjvyW6yDsg@public.gmane.org>
> Cc: Hideaki YOSHIFUJI <yoshfuji-VfPWfsRibaP+Ru+s062T9g@public.gmane.org>
> Cc: Patrick McHardy <kaber-dcUjhNyLwpNeoWH0uzbU5w@public.gmane.org>
> Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> ---

We have a similar patch here at Google, but we do not hold one skb and
dst per saved syn. That can be ~4KB for some drivers.

Only a kmalloc() with the needed part (headers), usually less than 128
bytes. We store the length in first byte of this allocation.

This has a huge difference if you want to have ~4 million request socks.







to post comments


Copyright © 2015, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds