Skip to content

Commit

Permalink
napt: Fixes and improvements
Browse files Browse the repository at this point in the history
 1. Fix enable/disable to properly allocate and deallocate tables.
    Current algorithm is just broken.
 2. Introduce eviction policy when table gets full: oldest connection
    is evicted, instead of new ones getting silently dropped. this
    results in much better behavior with small tables than before.
    When TCP connection is dropped, RSTs are sent both ways to inform
    parties instead of dropping silently. thiw requires additional 8
    bytes per entry but is, again, a big improvement for clients in
    terms of usability.
 3. FIxed handling of timestamp wraparound (every ~50 days of uptime).
 3. Added ip_portmap_get() to retrieve current port mapping settings.
 4. Added ip_napt_get_stats() for some insight into the state of NAT.
  • Loading branch information
rojer committed Mar 27, 2022
1 parent 76303df commit fb1f355
Show file tree
Hide file tree
Showing 5 changed files with 390 additions and 171 deletions.
3 changes: 2 additions & 1 deletion src/core/ipv4/dhcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,15 @@ dhcp_check(struct netif *netif)
static void
dhcp_handle_offer(struct netif *netif, struct dhcp_msg *msg_in)
{
u8_t n;
struct dhcp *dhcp = netif_dhcp_data(netif);

LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_handle_offer(netif=%p) %c%c%"U16_F"\n",
(void *)netif, netif->name[0], netif->name[1], (u16_t)netif->num));

/* Vendor Specific Information */
#if ESP_DHCP && !ESP_DHCP_DISABLE_VENDOR_CLASS_IDENTIFIER
for (u8_t n = 0; (n < DHCP_OPTION_VSI_MAX) && dhcp_option_given(dhcp, DHCP_OPTION_IDX_VSI + n); n++) {
for (n = 0; (n < DHCP_OPTION_VSI_MAX) && dhcp_option_given(dhcp, DHCP_OPTION_IDX_VSI + n); n++) {
dhcp_option_vsi[n] = lwip_htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_VSI + n));
}
#endif /* ESP_DHCP && !ESP_DHCP_DISABLE_VENDOR_CLASS_IDENTIFIER */
Expand Down
Loading

0 comments on commit fb1f355

Please sign in to comment.