26 Apr, 2017

1 commit


25 Sep, 2016

1 commit

  • It is valid that the TCP RST packet which does not set ack flag, and bytes
    of ack number are zero. But current seqadj codes would adjust the "0" ack
    to invalid ack number. Actually seqadj need to check the ack flag before
    adjust it for these RST packets.

    The following is my test case

    client is 10.26.98.245, and add one iptable rule:
    iptables -I INPUT -p tcp --sport 12345 -m connbytes --connbytes 2:
    --connbytes-dir reply --connbytes-mode packets -j REJECT --reject-with
    tcp-reset
    This iptables rule could generate on TCP RST without ack flag.

    server:10.172.135.55
    Enable the synproxy with seqadjust by the following iptables rules
    iptables -t raw -A PREROUTING -i eth0 -p tcp -d 10.172.135.55 --dport 12345
    -m tcp --syn -j CT --notrack

    iptables -A INPUT -i eth0 -p tcp -d 10.172.135.55 --dport 12345 -m conntrack
    --ctstate INVALID,UNTRACKED -j SYNPROXY --sack-perm --timestamp --wscale 7
    --mss 1460
    iptables -A OUTPUT -o eth0 -p tcp -s 10.172.135.55 --sport 12345 -m conntrack
    --ctstate INVALID,UNTRACKED -m tcp --tcp-flags SYN,RST,ACK SYN,ACK -j ACCEPT

    The following is my test result.

    1. packet trace on client
    root@routers:/tmp# tcpdump -i eth0 tcp port 12345 -n
    tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
    IP 10.26.98.245.45154 > 10.172.135.55.12345: Flags [S], seq 3695959829,
    win 29200, options [mss 1460,sackOK,TS val 452367884 ecr 0,nop,wscale 7],
    length 0
    IP 10.172.135.55.12345 > 10.26.98.245.45154: Flags [S.], seq 546723266,
    ack 3695959830, win 0, options [mss 1460,sackOK,TS val 15643479 ecr 452367884,
    nop,wscale 7], length 0
    IP 10.26.98.245.45154 > 10.172.135.55.12345: Flags [.], ack 1, win 229,
    options [nop,nop,TS val 452367885 ecr 15643479], length 0
    IP 10.172.135.55.12345 > 10.26.98.245.45154: Flags [.], ack 1, win 226,
    options [nop,nop,TS val 15643479 ecr 452367885], length 0
    IP 10.26.98.245.45154 > 10.172.135.55.12345: Flags [R], seq 3695959830,
    win 0, length 0

    2. seqadj log on server
    [62873.867319] Adjusting sequence number from 602341895->546723267,
    ack from 3695959830->3695959830
    [62873.867644] Adjusting sequence number from 602341895->546723267,
    ack from 3695959830->3695959830
    [62873.869040] Adjusting sequence number from 3695959830->3695959830,
    ack from 0->55618628

    To summarize, it is clear that the seqadj codes adjust the 0 ack when receive
    one TCP RST packet without ack.

    Signed-off-by: Gao Feng
    Signed-off-by: Pablo Neira Ayuso

    Gao Feng
     

18 Aug, 2015

1 commit


05 Jan, 2015

1 commit


06 Jan, 2014

1 commit

  • Avoid potentially spamming the kernel log with WARN splash messages
    when catching wrong usage of seqadj, by simply using WARN_ONCE.

    This is a followup to commit db12cf274353 (netfilter: WARN about
    wrong usage of sequence number adjustments)

    Suggested-by: Flavio Leitner
    Suggested-by: Daniel Borkmann
    Suggested-by: Florian Westphal
    Signed-off-by: Jesper Dangaard Brouer
    Signed-off-by: Pablo Neira Ayuso

    Jesper Dangaard Brouer
     

27 Dec, 2013

1 commit

  • Since commit 41d73ec053d2 (netfilter: nf_conntrack: make sequence
    number adjustments usuable without NAT), the sequence number extension
    is dynamically allocated.

    Instead of dying, give a WARN splash, in case of wrong usage of the
    seqadj code, e.g. when forgetting to allocate via nfct_seqadj_ext_add().

    Wrong usage have been seen in the IPVS code path.

    Signed-off-by: Jesper Dangaard Brouer
    Acked-by: Julian Anastasov
    Signed-off-by: Simon Horman

    Jesper Dangaard Brouer
     

18 Nov, 2013

1 commit

  • In commit 41d73ec053d2, sequence number adjustments were moved to a
    separate file. Unfortunately, the sequence numbers that are stored
    in the nf_ct_seqadj structure are expressed in host byte order. The
    necessary ntohl call was removed when the call to adjust_tcp_sequence
    was collapsed into nf_ct_seqadj_set. This broke the FTP NAT helper.
    Fix it by adding back the byte order conversions.

    Reported-by: Dawid Stawiarski
    Signed-off-by: Phil Oester
    Signed-off-by: Pablo Neira Ayuso

    Phil Oester
     

28 Aug, 2013

2 commits

  • Add a SYNPROXY for netfilter. The code is split into two parts, the synproxy
    core with common functions and an address family specific target.

    The SYNPROXY receives the connection request from the client, responds with
    a SYN/ACK containing a SYN cookie and announcing a zero window and checks
    whether the final ACK from the client contains a valid cookie.

    It then establishes a connection to the original destination and, if
    successful, sends a window update to the client with the window size
    announced by the server.

    Support for timestamps, SACK, window scaling and MSS options can be
    statically configured as target parameters if the features of the server
    are known. If timestamps are used, the timestamp value sent back to
    the client in the SYN/ACK will be different from the real timestamp of
    the server. In order to now break PAWS, the timestamps are translated in
    the direction server->client.

    Signed-off-by: Patrick McHardy
    Tested-by: Martin Topholm
    Signed-off-by: Jesper Dangaard Brouer
    Signed-off-by: Pablo Neira Ayuso

    Patrick McHardy
     
  • Split out sequence number adjustments from NAT and move them to the conntrack
    core to make them usable for SYN proxying. The sequence number adjustment
    information is moved to a seperate extend. The extend is added to new
    conntracks when a NAT mapping is set up for a connection using a helper.

    As a side effect, this saves 24 bytes per connection with NAT in the common
    case that a connection does not have a helper assigned.

    Signed-off-by: Patrick McHardy
    Tested-by: Martin Topholm
    Signed-off-by: Jesper Dangaard Brouer
    Signed-off-by: Pablo Neira Ayuso

    Patrick McHardy