Compare commits

..

3 Commits

Author SHA1 Message Date
Sebastian Huber
4599f551de dhcp: Clear flags
Do not assume that mem_malloc() returns cleared memory.
2025-08-03 11:35:52 +02:00
Sergey Fionov
41a36098b3 tcp: Fix TCP timestamps for big-endian systems
Current parsing code is building reverse-order integer, and then calls htonl()
to assign right value to "ts_recent" field of pcb.

This works correctly on little-endian machines, where htonl() reverses bytes.
However, on big-endian machines, htonl() is no-op, so bytes stay reversed.

This patch fixes it by building non-reversed integer.
2025-08-03 11:33:53 +02:00
David Cermak
e7ab7e0773 autoip: Choose next address after rate limit
AutoIP now selects a new address after rate limit timeout,
AutoIP tries a new address by incrementing the tried_llipaddr counter
in the ACD_DECLINE case of the callback.

In lwIP pre-2.2.0, address conflict detection was handled within autoip.c, and
the incrementing happened in autoip_restart() (line 150). When ACD was
extracted into a separate module in 2.2.0, this increment was missing for the
rate-limiting path.

Without this change, devices continuously retry the same IP address after rate
limiting, causing them to fail Bonjour Conformance Tests.
2025-08-03 11:24:55 +02:00
3 changed files with 10 additions and 7 deletions

View File

@ -223,9 +223,10 @@ autoip_conflict_callback(struct netif *netif, acd_callback_enum_t state)
autoip_restart(netif); autoip_restart(netif);
break; break;
case ACD_DECLINE: case ACD_DECLINE:
/* "delete" conflicting address so a new one will be selected in /* "delete" conflicting address and increment tried addr so a new one
* autoip_start() */ * will be selected in autoip_start() */
ip4_addr_set_any(&autoip->llipaddr); ip4_addr_set_any(&autoip->llipaddr);
autoip->tried_llipaddr++;
autoip_stop(netif); autoip_stop(netif);
break; break;
default: default:

View File

@ -831,6 +831,8 @@ dhcp_start(struct netif *netif)
return ERR_MEM; return ERR_MEM;
} }
/* clear the flags, the rest is cleared below */
dhcp->flags = 0;
/* store this dhcp client in the netif */ /* store this dhcp client in the netif */
netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP, dhcp); netif_set_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP, dhcp);
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): allocated dhcp\n")); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_start(): allocated dhcp\n"));

View File

@ -1993,17 +1993,17 @@ tcp_parseopt(struct tcp_pcb *pcb)
return; return;
} }
/* TCP timestamp option with valid length */ /* TCP timestamp option with valid length */
tsval = tcp_get_next_optbyte(); tsval = (tcp_get_next_optbyte() << 24);
tsval |= (tcp_get_next_optbyte() << 8);
tsval |= (tcp_get_next_optbyte() << 16); tsval |= (tcp_get_next_optbyte() << 16);
tsval |= (tcp_get_next_optbyte() << 24); tsval |= (tcp_get_next_optbyte() << 8);
tsval |= tcp_get_next_optbyte();
if (flags & TCP_SYN) { if (flags & TCP_SYN) {
pcb->ts_recent = lwip_ntohl(tsval); pcb->ts_recent = tsval;
/* Enable sending timestamps in every segment now that we know /* Enable sending timestamps in every segment now that we know
the remote host supports it. */ the remote host supports it. */
tcp_set_flags(pcb, TF_TIMESTAMP); tcp_set_flags(pcb, TF_TIMESTAMP);
} else if (TCP_SEQ_BETWEEN(pcb->ts_lastacksent, seqno, seqno + tcplen)) { } else if (TCP_SEQ_BETWEEN(pcb->ts_lastacksent, seqno, seqno + tcplen)) {
pcb->ts_recent = lwip_ntohl(tsval); pcb->ts_recent = tsval;
} }
/* Advance to next option (6 bytes already read) */ /* Advance to next option (6 bytes already read) */
tcp_optidx += LWIP_TCP_OPT_LEN_TS - 6; tcp_optidx += LWIP_TCP_OPT_LEN_TS - 6;