diff options
author | John Fastabend <john.fastabend@gmail.com> | 2018-03-28 15:49:15 -0400 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-03-29 18:09:43 -0400 |
commit | 8934ce2fd08171e8605f7fada91ee7619fe17ab8 (patch) | |
tree | 9a75574aadb3cfad15d09bffa0fe9eb6cbd9a03d /net/ipv4/tcp.c | |
parent | 22527437e0a0c96ee3153e9d0382942b0fd4f9dd (diff) |
bpf: sockmap redirect ingress support
Add support for the BPF_F_INGRESS flag in sk_msg redirect helper.
To do this add a scatterlist ring for receiving socks to check
before calling into regular recvmsg call path. Additionally, because
the poll wakeup logic only checked the skb recv queue we need to
add a hook in TCP stack (similar to write side) so that we have
a way to wake up polling socks when a scatterlist is redirected
to that sock.
After this all that is needed is for the redirect helper to
push the scatterlist into the psock receive queue.
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r-- | net/ipv4/tcp.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 0c31be306572..bccc4c270087 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -485,6 +485,14 @@ static void tcp_tx_timestamp(struct sock *sk, u16 tsflags) | |||
485 | } | 485 | } |
486 | } | 486 | } |
487 | 487 | ||
488 | static inline bool tcp_stream_is_readable(const struct tcp_sock *tp, | ||
489 | int target, struct sock *sk) | ||
490 | { | ||
491 | return (tp->rcv_nxt - tp->copied_seq >= target) || | ||
492 | (sk->sk_prot->stream_memory_read ? | ||
493 | sk->sk_prot->stream_memory_read(sk) : false); | ||
494 | } | ||
495 | |||
488 | /* | 496 | /* |
489 | * Wait for a TCP event. | 497 | * Wait for a TCP event. |
490 | * | 498 | * |
@@ -554,7 +562,7 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait) | |||
554 | tp->urg_data) | 562 | tp->urg_data) |
555 | target++; | 563 | target++; |
556 | 564 | ||
557 | if (tp->rcv_nxt - tp->copied_seq >= target) | 565 | if (tcp_stream_is_readable(tp, target, sk)) |
558 | mask |= EPOLLIN | EPOLLRDNORM; | 566 | mask |= EPOLLIN | EPOLLRDNORM; |
559 | 567 | ||
560 | if (!(sk->sk_shutdown & SEND_SHUTDOWN)) { | 568 | if (!(sk->sk_shutdown & SEND_SHUTDOWN)) { |