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)

This commit is contained in:
goldsimon 2007-12-03 17:55:01 +00:00
parent a72e4a406f
commit f3f7bd00e5
2 changed files with 20 additions and 2 deletions

View File

@ -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

View File

@ -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