Commit 8fac365f authored by Chenbo Feng's avatar Chenbo Feng Committed by David S. Miller

tcp: Add a tcp_filter hook before handle ack packet

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: default avatarChenbo Feng <fengc@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2da55390
...@@ -1729,6 +1729,8 @@ int tcp_v4_rcv(struct sk_buff *skb) ...@@ -1729,6 +1729,8 @@ int tcp_v4_rcv(struct sk_buff *skb)
} }
if (nsk == sk) { if (nsk == sk) {
reqsk_put(req); reqsk_put(req);
} else if (tcp_filter(sk, skb)) {
goto discard_and_relse;
} else if (tcp_child_process(sk, nsk, skb)) { } else if (tcp_child_process(sk, nsk, skb)) {
tcp_v4_send_reset(nsk, skb); tcp_v4_send_reset(nsk, skb);
goto discard_and_relse; goto discard_and_relse;
......
...@@ -1464,6 +1464,8 @@ static int tcp_v6_rcv(struct sk_buff *skb) ...@@ -1464,6 +1464,8 @@ static int tcp_v6_rcv(struct sk_buff *skb)
if (nsk == sk) { if (nsk == sk) {
reqsk_put(req); reqsk_put(req);
tcp_v6_restore_cb(skb); tcp_v6_restore_cb(skb);
} else if (tcp_filter(sk, skb)) {
goto discard_and_relse;
} else if (tcp_child_process(sk, nsk, skb)) { } else if (tcp_child_process(sk, nsk, skb)) {
tcp_v6_send_reset(nsk, skb); tcp_v6_send_reset(nsk, skb);
goto discard_and_relse; goto discard_and_relse;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment