Skip to contentSkip to conversation

Add a tcp_filter hook before handle ack packet

PATCH Applied Chenbo Feng 2 participants 2 messages Jun 21, 2017 – Jun 22, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add a tcp_filter hook before handle ack packet

From: Chenbo Feng <[email protected]>

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.

---
 net/ipv4/tcp_ipv4.c | 2 ++
 net/ipv6/tcp_ipv6.c | 2 ++
 2 files changed, 4 insertions(+)
net/ipv4/tcp_ipv4.c +2 -0
index 1dc8c44..ca3afb0 100644
@@ -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;
net/ipv6/tcp_ipv6.c +2 -0
index 84ad502..565d89b 100644
@@ -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;
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw

From: Chenbo Feng <[email protected]>
Date: Tue, 20 Jun 2017 19:06:40 -0700

Quoted 9 lines

From: Chenbo Feng <[email protected]>

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.

Applied, thanks.