wenquan2015 opened a new pull request, #17713:
URL: https://github.com/apache/nuttx/pull/17713

   Discard fin packet in LISTEN state
   
   *Note: Please adhere to [Contributing 
Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).*
   
   ## Summary
   
   discard fin packet in LISTEN state
   
   ## Impact
   
   tcp
   
   ## Testing
   
   ```
   from scapy.all import *
   targetip="10.0.1.2"
   targetport=5000
   pkt=IP(dst=targetip)/TCP(dport=targetport,flags="SF")
   ret=sr1(pkt, timeout=2)
   assert ret==None
   print("success SF")
   
   pkt=IP(dst=targetip)/TCP(dport=targetport,flags="R")
   ret=sr1(pkt, timeout=2)
   assert ret==None
   print("success R")
   
   pkt=IP(dst=targetip)/TCP(dport=targetport,flags="AR")
   ret=sr1(pkt, timeout=2)
   assert ret==None
   print("success AR")
   
   pkt=IP(dst=targetip)/TCP(dport=targetport,flags="F")
   ret=sr1(pkt, timeout=2)
   assert ret==None
   print("success F")
   
   pkt=IP(dst=targetip)/TCP(dport=targetport,flags="FA")
   ret=sr1(pkt, timeout=2)
   assert ret!=None and ret[TCP].flags & 0x04
   print("success FA")
   
   pkt=IP(dst=targetip)/TCP(dport=targetport,flags="A")
   ret=sr1(pkt, timeout=2)
   assert ret!=None and ret[TCP].flags & 0x04
   print("success A")
   ```
   test result:
   ```
   mi@mi-ThinkCentre-M760t:~/python-scripts$ sudo python tcpflag_listen.py
   MoTTY X11 proxy: No authorisation provided
   MoTTY X11 proxy: No authorisation provided
   Begin emission:
   Finished sending 1 packets.
   .
   Received 1 packets, got 0 answers, remaining 1 packets
   success SF
   Begin emission:
   Finished sending 1 packets.
   
   Received 0 packets, got 0 answers, remaining 1 packets
   success R
   Begin emission:
   Finished sending 1 packets.
   
   Received 0 packets, got 0 answers, remaining 1 packets
   success AR
   Begin emission:
   Finished sending 1 packets.
   
   Received 0 packets, got 0 answers, remaining 1 packets
   success F
   Begin emission:
   Finished sending 1 packets.
   *
   Received 1 packets, got 1 answers, remaining 0 packets
   success FA
   Begin emission:
   Finished sending 1 packets.
   *
   Received 1 packets, got 1 answers, remaining 0 packets
   success A
   
   ```
   ```
   15:56:18.657759 IP 10.0.1.1.20 > 10.0.1.2.5000: Flags [FS], seq 0, win 8192, 
length 0
   15:56:20.680335 IP 10.0.1.1.20 > 10.0.1.2.5000: Flags [R], seq 0, win 8192, 
length 0
   15:56:22.698519 IP 10.0.1.1.20 > 10.0.1.2.5000: Flags [R.], seq 0, ack 0, 
win 8192, length 0
   15:56:24.724152 IP 10.0.1.1.20 > 10.0.1.2.5000: Flags [F], seq 0, win 8192, 
length 0
   15:56:26.744255 IP 10.0.1.1.20 > 10.0.1.2.5000: Flags [F.], seq 0, ack 1, 
win 8192, length 0
   15:56:26.748421 IP 10.0.1.2.5000 > 10.0.1.1.20: Flags [R.], seq 1, ack 1, 
win 0, length 0
   15:56:26.774659 IP 10.0.1.1.20 > 10.0.1.2.5000: Flags [.], ack 1, win 8192, 
length 0
   15:56:26.778412 IP 10.0.1.2.5000 > 10.0.1.1.20: Flags [R.], seq 1, ack 0, 
win 0, length 0
   
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to