* [PATCH net-next] Add a tcp_filter hook before handle ack packet
@ 2017-06-21 2:06 Chenbo Feng
2017-06-22 15:13 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Chenbo Feng @ 2017-06-21 2:06 UTC (permalink / raw)
To: netdev; +Cc: Lorenzo Colitti, Chenbo Feng
From: Chenbo Feng <fengc@google.com>
Currently in both ipv4 and ipv6 code path, the ack packet received when
sk at TCP_NEW_SYN_RECV state is not filtered by socket filter or cgroup
filter since it is handled from tcp_child_process and never reaches the
tcp_filter inside tcp_v4_rcv or tcp_v6_rcv. Adding a tcp_filter hooks
here can make sure all the ingress tcp packet can be correctly filtered.
Signed-off-by: Chenbo Feng <fengc@google.com>
---
net/ipv4/tcp_ipv4.c | 2 ++
net/ipv6/tcp_ipv6.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 1dc8c44..ca3afb0 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1675,6 +1675,8 @@ int tcp_v4_rcv(struct sk_buff *skb)
}
if (nsk == sk) {
reqsk_put(req);
+ } else if (tcp_filter(sk, skb)) {
+ goto discard_and_relse;
} else if (tcp_child_process(sk, nsk, skb)) {
tcp_v4_send_reset(nsk, skb);
goto discard_and_relse;
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index 84ad502..565d89b 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1451,6 +1451,8 @@ static int tcp_v6_rcv(struct sk_buff *skb)
if (nsk == sk) {
reqsk_put(req);
tcp_v6_restore_cb(skb);
+ } else if (tcp_filter(sk, skb)) {
+ goto discard_and_relse;
} else if (tcp_child_process(sk, nsk, skb)) {
tcp_v6_send_reset(nsk, skb);
goto discard_and_relse;
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net-next] Add a tcp_filter hook before handle ack packet
2017-06-21 2:06 [PATCH net-next] Add a tcp_filter hook before handle ack packet Chenbo Feng
@ 2017-06-22 15:13 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-06-22 15:13 UTC (permalink / raw)
To: chenbofeng.kernel; +Cc: netdev, lorenzo, fengc
From: Chenbo Feng <chenbofeng.kernel@gmail.com>
Date: Tue, 20 Jun 2017 19:06:40 -0700
> From: Chenbo Feng <fengc@google.com>
>
> Currently in both ipv4 and ipv6 code path, the ack packet received when
> sk at TCP_NEW_SYN_RECV state is not filtered by socket filter or cgroup
> filter since it is handled from tcp_child_process and never reaches the
> tcp_filter inside tcp_v4_rcv or tcp_v6_rcv. Adding a tcp_filter hooks
> here can make sure all the ingress tcp packet can be correctly filtered.
>
> Signed-off-by: Chenbo Feng <fengc@google.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-22 15:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-21 2:06 [PATCH net-next] Add a tcp_filter hook before handle ack packet Chenbo Feng
2017-06-22 15:13 ` 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).