Skip to content

Commit

Permalink
[EFR32] Adds fix for IPv6 SLAAC DAD process loopback suppression (#23160
Browse files Browse the repository at this point in the history
)

* Adds fix for loop back suppression during duplicate address detection process

* Added changes based on comments

* Adds fix for temporary loopback suppression during DAD process
  • Loading branch information
rosahay-silabs authored Oct 20, 2022
1 parent ed3c6d1 commit 66c0270
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lwip/efr32/lwipopts-rs911x.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
#define LWIP_IPV6_REASS (0)
#define LWIP_IPV6_DHCP6 0
#define LWIP_IPV6_AUTOCONFIG (1)
#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0 // TODO: Enable this after a fix for NS loopback
#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 1
#define LWIP_IPV6_ROUTER_SUPPORT 1
#define LWIP_ND6_LISTEN_RA 1

Expand Down
2 changes: 1 addition & 1 deletion src/lwip/efr32/lwipopts-wf200.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
#define LWIP_IPV6_REASS (0)
#define LWIP_IPV6_DHCP6 0
#define LWIP_IPV6_AUTOCONFIG (1)
#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 0 // TODO: Enable this after a fix for NS loopback
#define LWIP_IPV6_DUP_DETECT_ATTEMPTS 1
#define LWIP_IPV6_ROUTER_SUPPORT 1
#define LWIP_ND6_LISTEN_RA 1

Expand Down
35 changes: 30 additions & 5 deletions src/platform/EFR32/wifi/ethernetif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,30 @@ static void low_level_input(struct netif * netif, uint8_t * b, uint16_t len)
{
return;
}
if (len < 60)
if (len < LWIP_FRAME_ALIGNMENT)
{ /* 60 : LWIP frame alignment */
len = 60;
len = LWIP_FRAME_ALIGNMENT;
}

/* Drop packets originated from the same interface and is not destined for the said interface */
const uint8_t * src_mac = b + netif->hwaddr_len;
const uint8_t * dst_mac = b;

if (!(ip6_addr_ispreferred(netif_ip6_addr_state(netif, 0))) && (memcmp(netif->hwaddr, src_mac, netif->hwaddr_len) == 0) &&
(memcmp(netif->hwaddr, dst_mac, netif->hwaddr_len) != 0))
{
#ifdef WIFI_DEBUG_ENABLED
EFR32_LOG("%s: DROP, [%02x:%02x:%02x:%02x:%02x:%02x]<-[%02x:%02x:%02x:%02x:%02x:%02x] type=%02x%02x", __func__,

dst_mac[0], dst_mac[1], dst_mac[2], dst_mac[3], dst_mac[4], dst_mac[5],

src_mac[0], src_mac[1], src_mac[2], src_mac[3], src_mac[4], src_mac[5],

b[12], b[13]);
#endif
return;
}

/* We allocate a pbuf chain of pbufs from the Lwip buffer pool
* and copy the data to the pbuf chain
*/
Expand All @@ -135,10 +155,15 @@ static void low_level_input(struct netif * netif, uint8_t * b, uint16_t len)
memcpy((uint8_t *) q->payload, (uint8_t *) b + bufferoffset, q->len);
bufferoffset += q->len;
}

#ifdef WIFI_DEBUG_ENABLED
EFR32_LOG("EN:IN %d,[%02x:%02x:%02x:%02x:%02x%02x][%02x:%02x:%02x:%02x:%02x:%02x]type=%02x%02x", bufferoffset, b[0], b[1],
b[2], b[3], b[4], b[5], b[6], b[7], b[8], b[9], b[10], b[11], b[12], b[13]);
EFR32_LOG("%s: ACCEPT %d, [%02x:%02x:%02x:%02x:%02x:%02x]<-[%02x:%02x:%02x:%02x:%02x:%02x] type=%02x%02x", __func__,
bufferoffset,

dst_mac[0], dst_mac[1], dst_mac[2], dst_mac[3], dst_mac[4], dst_mac[5],

src_mac[0], src_mac[1], src_mac[2], src_mac[3], src_mac[4], src_mac[5],

b[12], b[13]);
#endif

if (netif->input(p, netif) != ERR_OK)
Expand Down

0 comments on commit 66c0270

Please sign in to comment.