diff --git a/src/lwip/efr32/lwipopts-rs911x.h b/src/lwip/efr32/lwipopts-rs911x.h index 2a6de667ba75c2..839636b3ae7f0a 100644 --- a/src/lwip/efr32/lwipopts-rs911x.h +++ b/src/lwip/efr32/lwipopts-rs911x.h @@ -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 diff --git a/src/lwip/efr32/lwipopts-wf200.h b/src/lwip/efr32/lwipopts-wf200.h index 5825a5af87b53f..0811154e84c1c1 100644 --- a/src/lwip/efr32/lwipopts-wf200.h +++ b/src/lwip/efr32/lwipopts-wf200.h @@ -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 diff --git a/src/platform/EFR32/wifi/ethernetif.cpp b/src/platform/EFR32/wifi/ethernetif.cpp index 36221fbfd29de4..09fbf421235fdd 100644 --- a/src/platform/EFR32/wifi/ethernetif.cpp +++ b/src/platform/EFR32/wifi/ethernetif.cpp @@ -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 */ @@ -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)