File: tcp_reset

package info (click to toggle)
nftables 1.1.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,384 kB
  • sloc: ansic: 50,901; sh: 20,277; yacc: 5,861; python: 1,746; lex: 1,367; makefile: 392
file content (32 lines) | stat: -rwxr-xr-x 906 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash

# NFT_TEST_REQUIRES(NFT_TEST_HAVE_socat)

# regression check for issue fixed with kernel commit
# b975d3ee5962 ("net: add and use skb_get_hash_net")
# without it, flow dissector used to WARN().

ip link set lo up

$NFT -f - <<EOF
table inet filter {
  chain input {
    type filter hook input priority filter; policy accept;
    meta nftrace set 1
    ip daddr 127.0.0.1 tcp dport 5555 reject with tcp reset
    ip6 daddr ::1 tcp dport 5555 reject with tcp reset
    tcp dport 5555 counter
   }
   chain output {
    type filter hook output priority filter; policy accept;
    # empty chain, so nf_hook_slow is called from ip_local_out.
   }
}
EOF
[ $? -ne 0 ] && exit 1

socat -u STDIN TCP:127.0.0.1:5555,connect-timeout=2 < /dev/null > /dev/null
socat -u STDIN TCP:[::1]:5555,connect-timeout=2 < /dev/null > /dev/null

$NFT list ruleset |grep -q 'counter packets 0 bytes 0' || exit 1
exit 0