Browse Source

Fix locking bug and backport e304a89ddb

pull/1/head
Xadhoom 5 years ago
parent
commit
9b8607bfe8
  1. 2
      ext/lwip-contrib
  2. 4
      src/VirtualTap.cpp
  3. 22
      src/lwipopts.h

2
ext/lwip-contrib

@ -1 +1 @@
Subproject commit 07a75f9e085663118a5f07c8aaa7f4d91c7de658 Subproject commit 1f9e26e221a41542563834222c4ec8399be1908f

4
src/VirtualTap.cpp

@ -224,7 +224,9 @@ void VirtualTap::put(const MAC &from,const MAC &to,unsigned int etherType,
const void *data,unsigned int len) const void *data,unsigned int len)
{ {
if (len <= _mtu && _enabled) { if (len <= _mtu && _enabled) {
LOCK_TCPIP_CORE();
_lwip_eth_rx(this, from, to, etherType, data, len); _lwip_eth_rx(this, from, to, etherType, data, len);
UNLOCK_TCPIP_CORE();
} }
} }
@ -523,12 +525,14 @@ void _lwip_eth_rx(VirtualTap *tap, const MAC &from, const MAC &to, unsigned int
// Feed packet into stack // Feed packet into stack
int err; int err;
if(tap->netif4)
if (Utils::ntoh(ethhdr.type) == 0x800 || Utils::ntoh(ethhdr.type) == 0x806) { if (Utils::ntoh(ethhdr.type) == 0x800 || Utils::ntoh(ethhdr.type) == 0x806) {
if ((err = ((struct netif *)tap->netif4)->input(p, (struct netif *)tap->netif4)) != ERR_OK) { if ((err = ((struct netif *)tap->netif4)->input(p, (struct netif *)tap->netif4)) != ERR_OK) {
DEBUG_ERROR("packet input error (%d)", err); DEBUG_ERROR("packet input error (%d)", err);
pbuf_free(p); pbuf_free(p);
} }
} }
if(tap->netif6)
if (Utils::ntoh(ethhdr.type) == 0x86DD) { if (Utils::ntoh(ethhdr.type) == 0x86DD) {
if ((err = ((struct netif *)tap->netif6)->input(p, (struct netif *)tap->netif6)) != ERR_OK) { if ((err = ((struct netif *)tap->netif6)->input(p, (struct netif *)tap->netif6)) != ERR_OK) {
DEBUG_ERROR("packet input error (%d)", err); DEBUG_ERROR("packet input error (%d)", err);

22
src/lwipopts.h

@ -49,8 +49,9 @@
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
// Misc // Misc
#define IPV6_FRAG_COPYHEADER 1
#define LWIP_STATS_LARGE 1 #define LWIP_STATS_LARGE 1
#define LWIP_NOASSERT 1 //#define LWIP_NOASSERT 1
#if __ANDROID__ #if __ANDROID__
#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS 0 #define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS 0
#endif #endif
@ -119,7 +120,7 @@
// tcpip // tcpip
#define TCPIP_MBOX_SIZE 0 #define TCPIP_MBOX_SIZE 0
#define LWIP_TCPIP_CORE_LOCKING 1 #define LWIP_TCPIP_CORE_LOCKING 1
#define LWIP_TCPIP_CORE_LOCKING_INPUT 0 #define LWIP_TCPIP_CORE_LOCKING_INPUT 1
// netconn // netconn
#define LWIP_NETCONN_FULLDUPLEX 0 #define LWIP_NETCONN_FULLDUPLEX 0
// netif // netif
@ -128,6 +129,23 @@
#define LWIP_NETIF_TX_SINGLE_PBUF 0 #define LWIP_NETIF_TX_SINGLE_PBUF 0
#define TCPIP_THREAD_PRIO 1 #define TCPIP_THREAD_PRIO 1
#define LWIP_ASSERT_CORE_LOCKED() sys_check_core_locking()
#define LWIP_MARK_TCPIP_THREAD() sys_mark_tcpip_thread()
#define LOCK_TCPIP_CORE() sys_lock_tcpip_core()
#define UNLOCK_TCPIP_CORE() sys_unlock_tcpip_core()
#ifdef __cplusplus
extern "C" {
#endif
void sys_check_core_locking();
void sys_mark_tcpip_thread();
void sys_lock_tcpip_core();
void sys_unlock_tcpip_core();
#ifdef __cplusplus
}
#endif
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
------------------------------------ Timers ------------------------------------ ------------------------------------ Timers ------------------------------------
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/

Loading…
Cancel
Save