net/tcp: add connection info to tcp_stream structure
Changes: * Avoid use net_server_ip in tcp code, use tcp_stream data instead * Ignore packets from other connections if connection already created. This prevents us from connection break caused by other tcp stream. Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:

committed by
Tom Rini

parent
ddedfe1cb8
commit
2b17749870
12
net/net.c
12
net/net.c
@@ -420,7 +420,7 @@ int net_init(void)
|
||||
/* Only need to setup buffer pointers once. */
|
||||
first_call = 0;
|
||||
if (IS_ENABLED(CONFIG_PROT_TCP))
|
||||
tcp_set_tcp_state(tcp_stream_get(), TCP_CLOSED);
|
||||
tcp_init();
|
||||
}
|
||||
|
||||
return net_init_loop();
|
||||
@@ -908,10 +908,10 @@ int net_send_udp_packet(uchar *ether, struct in_addr dest, int dport, int sport,
|
||||
}
|
||||
|
||||
#if defined(CONFIG_PROT_TCP)
|
||||
int net_send_tcp_packet(int payload_len, int dport, int sport, u8 action,
|
||||
u32 tcp_seq_num, u32 tcp_ack_num)
|
||||
int net_send_tcp_packet(int payload_len, struct in_addr dhost, int dport,
|
||||
int sport, u8 action, u32 tcp_seq_num, u32 tcp_ack_num)
|
||||
{
|
||||
return net_send_ip_packet(net_server_ethaddr, net_server_ip, dport,
|
||||
return net_send_ip_packet(net_server_ethaddr, dhost, dport,
|
||||
sport, payload_len, IPPROTO_TCP, action,
|
||||
tcp_seq_num, tcp_ack_num);
|
||||
}
|
||||
@@ -953,12 +953,12 @@ int net_send_ip_packet(uchar *ether, struct in_addr dest, int dport, int sport,
|
||||
break;
|
||||
#if defined(CONFIG_PROT_TCP)
|
||||
case IPPROTO_TCP:
|
||||
tcp = tcp_stream_get();
|
||||
tcp = tcp_stream_get(0, dest, dport, sport);
|
||||
if (!tcp)
|
||||
return -EINVAL;
|
||||
|
||||
pkt_hdr_size = eth_hdr_size
|
||||
+ tcp_set_tcp_header(tcp, pkt + eth_hdr_size, dport, sport,
|
||||
+ tcp_set_tcp_header(tcp, pkt + eth_hdr_size,
|
||||
payload_len, action, tcp_seq_num,
|
||||
tcp_ack_num);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user