tcp_reset: check the conn is exist when tcp_reset

tcp_input:
If we didn't find an active connection that expected the packet,
If the SYN flag isn't set,
It is an old packet and we send a RST.
conn is NULL when this case

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu 2023-01-19 17:08:59 +08:00 committed by archer
parent 5012195bde
commit 65e08b750c
1 changed files with 2 additions and 2 deletions

View File

@ -477,7 +477,7 @@ void tcp_reset(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn)
ipv6_build_header(ipv6, dev->d_len - IPv6_HDRLEN,
IP_PROTO_TCP, dev->d_ipv6addr, ipv6->srcipaddr,
IP_TTL_DEFAULT, conn->sconn.s_tclass);
IP_TTL_DEFAULT, conn ? conn->sconn.s_tclass : 0);
tcp->tcpchksum = 0;
tcp->tcpchksum = ~tcp_ipv6_chksum(dev);
@ -493,7 +493,7 @@ void tcp_reset(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn)
ipv4_build_header(IPv4BUF, dev->d_len, IP_PROTO_TCP,
&dev->d_ipaddr, (FAR in_addr_t *)ipv4->srcipaddr,
IP_TTL_DEFAULT, conn->sconn.s_tos, NULL);
IP_TTL_DEFAULT, conn ? conn->sconn.s_tos : 0, NULL);
tcp->tcpchksum = 0;
tcp->tcpchksum = ~tcp_ipv4_chksum(dev);