diff --git a/CHANGELOG b/CHANGELOG index f601dd33..dd43bbf9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,10 @@ HISTORY ++ New features: + 2007-12-03 Simon Goldschmidt + * ip.c: ip_input: check if a packet is for inp first before checking all other + netifs on netif_list (speeds up packet receiving in most cases) + 2007-11-30 Simon Goldschmidt * udp.c, raw.c: task #7497: Sort lists (pcb, netif, ...) for faster access UDP: move a (connected) pcb selected for input to the front of the list of diff --git a/src/core/ipv4/ip.c b/src/core/ipv4/ip.c index 8105df47..e59a71f1 100644 --- a/src/core/ipv4/ip.c +++ b/src/core/ipv4/ip.c @@ -239,7 +239,12 @@ ip_input(struct pbuf *p, struct netif *inp) } else #endif /* LWIP_IGMP */ { - for (netif = netif_list; netif != NULL; netif = netif->next) { + /* start trying with inp. if that's not acceptable, start walking the + list of configured netifs. + 'first' is used as a boolean to mark whether we started walking the list */ + int first = 1; + netif = inp; + do { LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest 0x%"X32_F" netif->ip_addr 0x%"X32_F" (0x%"X32_F", 0x%"X32_F", 0x%"X32_F")\n", iphdr->dest.addr, netif->ip_addr.addr, iphdr->dest.addr & netif->netmask.addr, @@ -258,7 +263,16 @@ ip_input(struct pbuf *p, struct netif *inp) break; } } - } + if (first) { + first = 0; + netif = netif_list; + } else { + netif = netif->next; + } + if (netif == inp) { + netif = netif->next; + } + } while(netif != NULL); } #if LWIP_DHCP