Added option LWIP_NETIF_HWADDRHINT (default=off) to cache ARP table indices with each pcb instead of single-entry cache for the complete stack.

This commit is contained in:
goldsimon
2007-07-02 20:41:22 +00:00
parent fa4b711495
commit 96e4ec4a15
12 changed files with 146 additions and 7 deletions

View File

@@ -96,6 +96,11 @@ ip_route(struct ip_addr *dest)
return netif;
}
}
if (netif_default == NULL) {
LWIP_DEBUGF(IP_DEBUG | 2, ("ip_route: No route to 0x%"X32_F"\n", dest->addr));
IP_STATS_INC(ip.rterr);
snmp_inc_ipoutnoroutes();
}
/* no matching netif found, use default netif */
return netif_default;
}
@@ -515,10 +520,6 @@ ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
struct netif *netif;
if ((netif = ip_route(dest)) == NULL) {
LWIP_DEBUGF(IP_DEBUG | 2, ("ip_output: No route to 0x%"X32_F"\n", dest->addr));
IP_STATS_INC(ip.rterr);
snmp_inc_ipoutnoroutes();
return ERR_RTE;
}

View File

@@ -105,6 +105,9 @@ netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
netif->state = state;
netif->num = netifnum++;
netif->input = input;
#if LWIP_NETIF_HWADDRHINT
netif->addr_hint = NULL;
#endif /* LWIP_NETIF_HWADDRHINT*/
netif_set_addr(netif, ipaddr, netmask, gw);

View File

@@ -248,7 +248,13 @@ raw_sendto(struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *ipaddr)
src_ip = &(pcb->local_ip);
}
#if LWIP_NETIF_HWADDRHINT
netif->addr_hint = &(pcb->addr_hint);
#endif /* LWIP_NETIF_HWADDRHINT*/
err = ip_output_if (q, src_ip, ipaddr, pcb->ttl, pcb->tos, pcb->protocol, netif);
#if LWIP_NETIF_HWADDRHINT
netif->addr_hint = NULL;
#endif /* LWIP_NETIF_HWADDRHINT*/
/* did we chain a header earlier? */
if (q != p) {

View File

@@ -456,8 +456,21 @@ tcp_output(struct tcp_pcb *pcb)
tcphdr->chksum = inet_chksum_pseudo(p, &(pcb->local_ip), &(pcb->remote_ip),
IP_PROTO_TCP, p->tot_len);
#endif
#if LWIP_NETIF_HWADDRHINT
{
struct netif *netif;
netif = ip_route(&pcb->remote_ip);
if(netif != NULL){
netif->addr_hint = &(pcb->addr_hint);
ip_output_if(p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl,
pcb->tos, IP_PROTO_TCP, netif);
netif->addr_hint = NULL;
}
}
#else /* LWIP_NETIF_HWADDRHINT*/
ip_output(p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos,
IP_PROTO_TCP);
#endif /* LWIP_NETIF_HWADDRHINT*/
pbuf_free(p);
return ERR_OK;
@@ -602,8 +615,21 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
#endif
TCP_STATS_INC(tcp.xmit);
#if LWIP_NETIF_HWADDRHINT
{
struct netif *netif;
netif = ip_route(&pcb->remote_ip);
if(netif != NULL){
netif->addr_hint = &(pcb->addr_hint);
ip_output_if(seg->p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl,
pcb->tos, IP_PROTO_TCP, netif);
netif->addr_hint = NULL;
}
}
#else /* LWIP_NETIF_HWADDRHINT*/
ip_output(seg->p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos,
IP_PROTO_TCP);
#endif /* LWIP_NETIF_HWADDRHINT*/
}
/**
@@ -776,7 +802,20 @@ tcp_keepalive(struct tcp_pcb *pcb)
TCP_STATS_INC(tcp.xmit);
/* Send output to IP */
#if LWIP_NETIF_HWADDRHINT
{
struct netif *netif;
netif = ip_route(&pcb->remote_ip);
if(netif != NULL){
netif->addr_hint = &(pcb->addr_hint);
ip_output_if(p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl,
0, IP_PROTO_TCP, netif);
netif->addr_hint = NULL;
}
}
#else /* LWIP_NETIF_HWADDRHINT*/
ip_output(p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, 0, IP_PROTO_TCP);
#endif /* LWIP_NETIF_HWADDRHINT*/
pbuf_free(p);

View File

@@ -439,7 +439,13 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
#endif /* CHECKSUM_CHECK_UDP */
/* output to IP */
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDPLITE,)\n"));
#if LWIP_NETIF_HWADDRHINT
netif->addr_hint = &(pcb->addr_hint);
#endif /* LWIP_NETIF_HWADDRHINT*/
err = ip_output_if(q, src_ip, &pcb->remote_ip, pcb->ttl, pcb->tos, IP_PROTO_UDPLITE, netif);
#if LWIP_NETIF_HWADDRHINT
netif->addr_hint = NULL;
#endif /* LWIP_NETIF_HWADDRHINT*/
} else
#endif /* LWIP_UDPLITE */
{ /* UDP */
@@ -456,7 +462,13 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04"X16_F"\n", udphdr->chksum));
LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDP,)\n"));
/* output to IP */
#if LWIP_NETIF_HWADDRHINT
netif->addr_hint = &(pcb->addr_hint);
#endif /* LWIP_NETIF_HWADDRHINT*/
err = ip_output_if(q, src_ip, &pcb->remote_ip, pcb->ttl, pcb->tos, IP_PROTO_UDP, netif);
#if LWIP_NETIF_HWADDRHINT
netif->addr_hint = NULL;
#endif /* LWIP_NETIF_HWADDRHINT*/
}
/* TODO: must this be increased even if error occured? */
snmp_inc_udpoutdatagrams();