[LWIP] Correctly synchronize to lwIP 1.4.1 (#6123)

* [TCPIP] Rename lwip library to lwipcore

* [TCPIP] Remove ReactOS-specific code from LWIP library

* [TCPIP] Synchronize LWIP code to 1.4.1

Update to LWIP 1.4.1 should have been done by bd3b0e8ef4
However, I was unable to find the exact revision used in this commit.

So, do the following
- take code from STABLE-1_4_1 commit on https://git.savannah.gnu.org/git/lwip.git
- cherry-pick LWIP 32aa9a41e2013e5ee6eee09317a848647e37badf (CORE-8978)
- cherry-pick LWIP c0b534e5318baf870e2152c70d4d11a3a86181f3
- add a ReactOS-specific change in src/api/tcpip.c (missing include)
- add ReactOS specific file CMakeLists.txt

NOTE: Changes are mostly in unit test files (not used) and CHANGELOG file.

CORE-7140
This commit is contained in:
hpoussin 2023-12-29 13:05:41 +01:00 committed by GitHub
parent d8108a64a4
commit 9cfd8dd918
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
126 changed files with 2251 additions and 1554 deletions

View file

@ -92,8 +92,8 @@ tcp_create_segment_wnd(ip_addr_t* src_ip, ip_addr_t* dst_ip,
/* calculate checksum */
tcphdr->chksum = inet_chksum_pseudo(p,
IP_PROTO_TCP, p->tot_len, src_ip, dst_ip);
tcphdr->chksum = inet_chksum_pseudo(p, src_ip, dst_ip,
IP_PROTO_TCP, p->tot_len);
pbuf_header(p, sizeof(struct ip_hdr));
@ -238,21 +238,17 @@ test_tcp_new_counters_pcb(struct test_tcp_counters* counters)
void test_tcp_input(struct pbuf *p, struct netif *inp)
{
struct ip_hdr *iphdr = (struct ip_hdr*)p->payload;
/* these lines are a hack, don't use them as an example :-) */
ip_addr_copy(*ipX_current_dest_addr(), iphdr->dest);
ip_addr_copy(*ipX_current_src_addr(), iphdr->src);
ip_current_netif() = inp;
ip_current_header() = iphdr;
/* since adding IPv6, p->payload must point to tcp header, not ip header */
pbuf_header(p, -(s16_t)sizeof(struct ip_hdr));
ip_addr_copy(current_iphdr_dest, iphdr->dest);
ip_addr_copy(current_iphdr_src, iphdr->src);
current_netif = inp;
current_header = iphdr;
tcp_input(p, inp);
ipX_current_dest_addr()->addr = 0;
ipX_current_src_addr()->addr = 0;
ip_current_netif() = NULL;
ip_current_header() = NULL;
current_iphdr_dest.addr = 0;
current_iphdr_src.addr = 0;
current_netif = NULL;
current_header = NULL;
}
static err_t test_tcp_netif_output(struct netif *netif, struct pbuf *p,
@ -260,21 +256,18 @@ static err_t test_tcp_netif_output(struct netif *netif, struct pbuf *p,
{
struct test_tcp_txcounters *txcounters = (struct test_tcp_txcounters*)netif->state;
LWIP_UNUSED_ARG(ipaddr);
if (txcounters != NULL)
{
txcounters->num_tx_calls++;
txcounters->num_tx_bytes += p->tot_len;
if (txcounters->copy_tx_packets) {
struct pbuf *p_copy = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM);
err_t err;
EXPECT(p_copy != NULL);
err = pbuf_copy(p_copy, p);
EXPECT(err == ERR_OK);
if (txcounters->tx_packets == NULL) {
txcounters->tx_packets = p_copy;
} else {
pbuf_cat(txcounters->tx_packets, p_copy);
}
txcounters->num_tx_calls++;
txcounters->num_tx_bytes += p->tot_len;
if (txcounters->copy_tx_packets) {
struct pbuf *p_copy = pbuf_alloc(PBUF_LINK, p->tot_len, PBUF_RAM);
err_t err;
EXPECT(p_copy != NULL);
err = pbuf_copy(p_copy, p);
EXPECT(err == ERR_OK);
if (txcounters->tx_packets == NULL) {
txcounters->tx_packets = p_copy;
} else {
pbuf_cat(txcounters->tx_packets, p_copy);
}
}
return ERR_OK;
@ -285,11 +278,9 @@ void test_tcp_init_netif(struct netif *netif, struct test_tcp_txcounters *txcoun
{
struct netif *n;
memset(netif, 0, sizeof(struct netif));
if (txcounters != NULL) {
memset(txcounters, 0, sizeof(struct test_tcp_txcounters));
netif->state = txcounters;
}
memset(txcounters, 0, sizeof(struct test_tcp_txcounters));
netif->output = test_tcp_netif_output;
netif->state = txcounters;
netif->flags |= NETIF_FLAG_UP;
ip_addr_copy(netif->netmask, *netmask);
ip_addr_copy(netif->ip_addr, *ip_addr);

View file

@ -45,9 +45,8 @@ tcp_setup(void)
static void
tcp_teardown(void)
{
tcp_remove_all();
netif_list = NULL;
netif_default = NULL;
tcp_remove_all();
}
@ -78,19 +77,16 @@ START_TEST(test_tcp_recv_inseq)
struct tcp_pcb* pcb;
struct pbuf* p;
char data[] = {1, 2, 3, 4};
ip_addr_t remote_ip, local_ip, netmask;
ip_addr_t remote_ip, local_ip;
u16_t data_len;
u16_t remote_port = 0x100, local_port = 0x101;
struct netif netif;
struct test_tcp_txcounters txcounters;
LWIP_UNUSED_ARG(_i);
/* initialize local vars */
memset(&netif, 0, sizeof(netif));
IP4_ADDR(&local_ip, 192, 168, 1, 1);
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
IP4_ADDR(&netmask, 255, 255, 255, 0);
test_tcp_init_netif(&netif, &txcounters, &local_ip, &netmask);
data_len = sizeof(data);
/* initialize counter struct */
memset(&counters, 0, sizeof(counters));
@ -211,7 +207,7 @@ START_TEST(test_tcp_fast_retx_recover)
EXPECT_RET(pcb->dupacks == 3);
memset(&txcounters, 0, sizeof(txcounters));
/* TODO: check expected data?*/
/* send data5, not output yet */
err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY);
EXPECT_RET(err == ERR_OK);

View file

@ -127,8 +127,6 @@ static void
tcp_oos_teardown(void)
{
tcp_remove_all();
netif_list = NULL;
netif_default = NULL;
}
@ -148,7 +146,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ)
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16};
ip_addr_t remote_ip, local_ip, netmask;
ip_addr_t remote_ip, local_ip;
u16_t data_len;
u16_t remote_port = 0x100, local_port = 0x101;
struct netif netif;
@ -158,8 +156,6 @@ START_TEST(test_tcp_recv_ooseq_FIN_OOSEQ)
memset(&netif, 0, sizeof(netif));
IP4_ADDR(&local_ip, 192, 168, 1, 1);
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
IP4_ADDR(&netmask, 255, 255, 255, 0);
test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
data_len = sizeof(data);
/* initialize counter struct */
memset(&counters, 0, sizeof(counters));
@ -290,7 +286,7 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16};
ip_addr_t remote_ip, local_ip, netmask;
ip_addr_t remote_ip, local_ip;
u16_t data_len;
u16_t remote_port = 0x100, local_port = 0x101;
struct netif netif;
@ -300,8 +296,6 @@ START_TEST(test_tcp_recv_ooseq_FIN_INSEQ)
memset(&netif, 0, sizeof(netif));
IP4_ADDR(&local_ip, 192, 168, 1, 1);
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
IP4_ADDR(&netmask, 255, 255, 255, 0);
test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
data_len = sizeof(data);
/* initialize counter struct */
memset(&counters, 0, sizeof(counters));
@ -463,7 +457,7 @@ START_TEST(test_tcp_recv_ooseq_overrun_rxwin)
struct test_tcp_counters counters;
struct tcp_pcb* pcb;
struct pbuf *pinseq, *p_ovr;
ip_addr_t remote_ip, local_ip, netmask;
ip_addr_t remote_ip, local_ip;
u16_t remote_port = 0x100, local_port = 0x101;
struct netif netif;
int datalen = 0;
@ -477,8 +471,6 @@ START_TEST(test_tcp_recv_ooseq_overrun_rxwin)
memset(&netif, 0, sizeof(netif));
IP4_ADDR(&local_ip, 192, 168, 1, 1);
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
IP4_ADDR(&netmask, 255, 255, 255, 0);
test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
/* initialize counter struct */
memset(&counters, 0, sizeof(counters));
counters.expected_data_len = TCP_WND;
@ -555,7 +547,7 @@ START_TEST(test_tcp_recv_ooseq_max_bytes)
struct test_tcp_counters counters;
struct tcp_pcb* pcb;
struct pbuf *p_ovr;
ip_addr_t remote_ip, local_ip, netmask;
ip_addr_t remote_ip, local_ip;
u16_t remote_port = 0x100, local_port = 0x101;
struct netif netif;
int datalen = 0;
@ -569,8 +561,6 @@ START_TEST(test_tcp_recv_ooseq_max_bytes)
memset(&netif, 0, sizeof(netif));
IP4_ADDR(&local_ip, 192, 168, 1, 1);
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
IP4_ADDR(&netmask, 255, 255, 255, 0);
test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
/* initialize counter struct */
memset(&counters, 0, sizeof(counters));
counters.expected_data_len = TCP_WND;
@ -636,7 +626,7 @@ START_TEST(test_tcp_recv_ooseq_max_pbufs)
struct test_tcp_counters counters;
struct tcp_pcb* pcb;
struct pbuf *p_ovr;
ip_addr_t remote_ip, local_ip, netmask;
ip_addr_t remote_ip, local_ip;
u16_t remote_port = 0x100, local_port = 0x101;
struct netif netif;
int datalen = 0;
@ -650,8 +640,6 @@ START_TEST(test_tcp_recv_ooseq_max_pbufs)
memset(&netif, 0, sizeof(netif));
IP4_ADDR(&local_ip, 192, 168, 1, 1);
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
IP4_ADDR(&netmask, 255, 255, 255, 0);
test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
/* initialize counter struct */
memset(&counters, 0, sizeof(counters));
counters.expected_data_len = TCP_WND;
@ -739,7 +727,7 @@ static void test_tcp_recv_ooseq_double_FINs(int delay_packet)
struct test_tcp_counters counters;
struct tcp_pcb* pcb;
struct pbuf *p_normal_fin, *p_data_after_fin, *p, *p_2nd_fin_ooseq;
ip_addr_t remote_ip, local_ip, netmask;
ip_addr_t remote_ip, local_ip;
u16_t remote_port = 0x100, local_port = 0x101;
struct netif netif;
u32_t exp_rx_calls = 0, exp_rx_bytes = 0, exp_close_calls = 0, exp_oos_pbufs = 0, exp_oos_tcplen = 0;
@ -754,8 +742,6 @@ static void test_tcp_recv_ooseq_double_FINs(int delay_packet)
memset(&netif, 0, sizeof(netif));
IP4_ADDR(&local_ip, 192, 168, 1, 1);
IP4_ADDR(&remote_ip, 192, 168, 1, 2);
IP4_ADDR(&netmask, 255, 255, 255, 0);
test_tcp_init_netif(&netif, NULL, &local_ip, &netmask);
/* initialize counter struct */
memset(&counters, 0, sizeof(counters));
counters.expected_data_len = TCP_WND;
@ -955,4 +941,4 @@ tcp_oos_suite(void)
test_tcp_recv_ooseq_double_FIN_15
};
return create_suite("TCP_OOS", tests, sizeof(tests)/sizeof(TFun), tcp_oos_setup, tcp_oos_teardown);
}
}