bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: His Shadow <shadowpilot34@gmail.com>
To: bpf@vger.kernel.org
Subject: Re: Fwd: eBPF sockhash datastructure and stream_parser/stream_verdict programs
Date: Mon, 10 Jan 2022 19:20:46 +0300	[thread overview]
Message-ID: <CAK7W0xc1+sYTP=CPxe6XmGefsjmHvvd-vD2CUL5Xd22h3ZFc2A@mail.gmail.com> (raw)
In-Reply-To: <CAK7W0xe7QSW4F+tEneqMS26PdTgX83rURiSefnDbRu9WusPDaw@mail.gmail.com>

Let's say I'm writing a simple SOCKS4/4a server(yes, obsolete, but
still does it's job), no authorization(although it wouldn't matter).
So I need to read some data from the client: ip and port and maybe
domain if it's 4A. Then I connect to the ip/domain:port and send a
success response. Meanwhile the IP/Domain:port I connected to, before
sending success to the client might send some data, like if the target
was an SSH server, it sends a version string right away if you connect
to it. So it could be missed if I then put client and target socket
into a sockmap/hash and tell them to redirect traffic to each other.
I've tried very hard to figure out a way to use eBPF stream_verdict or
sk_msg_verdict to redirect traffic right when I need it, but I think
it is impossible. Do I have to do SOCKS4/4A parsing inside
stream_parser and communicate with my userspace program via a ring
buffer about the results? But I'm not sure how that could help with
missing bytes. I guess I got interested after I read that article on
cloudflare blog about sockmap
https://blog.cloudflare.com/sockmap-tcp-splicing-of-the-future/ , but
their example of an echo server is plagued with the same problem, if
you put a delay, before socket addition to a sockmap.

      reply	other threads:[~2022-01-10 16:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-03 12:53 eBPF sockhash datastructure and stream_parser/stream_verdict programs His Shadow
2022-01-04  0:44 ` Cong Wang
     [not found]   ` <CAK7W0xezGaA1TZcsxkt_hf+b0LU+396CmetejFBEXjqtvbmDkA@mail.gmail.com>
2022-01-04 10:24     ` Fwd: " His Shadow
2022-01-04 21:09       ` John Fastabend
2022-01-06  7:47         ` His Shadow
2022-01-10 16:20           ` His Shadow [this message]

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='CAK7W0xc1+sYTP=CPxe6XmGefsjmHvvd-vD2CUL5Xd22h3ZFc2A@mail.gmail.com' \
    --to=shadowpilot34@gmail.com \
    --cc=bpf@vger.kernel.org \
    /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).