Skip to content

Commit

Permalink
[arp] Try to avoid discarding ARP cache entries
Browse files Browse the repository at this point in the history
Discarding the active ARP cache entry in the middle of a download will
substantially disrupt the TCP stream.  Try to minimise any such
disruption by treating ARP cache entries as expensive, and discarding
them only when nothing else is available to discard.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Jul 9, 2012
1 parent 8d95e1d commit 0242473
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/crypto/x509.c
Expand Up @@ -143,7 +143,7 @@ static unsigned int x509_discard ( void ) {
}

/** X.509 cache discarder */
struct cache_discarder x509_cache_discarder __cache_discarder = {
struct cache_discarder x509_discarder __cache_discarder ( CACHE_NORMAL ) = {
.discard = x509_discard,
};

Expand Down
13 changes: 12 additions & 1 deletion src/include/ipxe/malloc.h
Expand Up @@ -76,6 +76,17 @@ struct cache_discarder {
#define CACHE_DISCARDERS __table ( struct cache_discarder, "cache_discarders" )

/** Declare a cache discarder */
#define __cache_discarder __table_entry ( CACHE_DISCARDERS, 01 )
#define __cache_discarder( cost ) __table_entry ( CACHE_DISCARDERS, cost )

/** @defgroup cache_cost Cache discarder costs
*
* @{
*/

#define CACHE_CHEAP 01 /**< Items with a low replacement cost */
#define CACHE_NORMAL 02 /**< Items with a normal replacement cost */
#define CACHE_EXPENSIVE 03 /**< Items with a high replacement cost */

/** @} */

#endif /* _IPXE_MALLOC_H */
9 changes: 7 additions & 2 deletions src/net/arp.c
Expand Up @@ -525,7 +525,12 @@ static unsigned int arp_discard ( void ) {
return 0;
}

/** ARP cache discarder */
struct cache_discarder arp_cache_discarder __cache_discarder = {
/** ARP cache discarder
*
* ARP cache entries are deemed to have a high replacement cost, since
* flushing an active ARP cache entry midway through a TCP transfer
* will cause substantial disruption.
*/
struct cache_discarder arp_discarder __cache_discarder ( CACHE_EXPENSIVE ) = {
.discard = arp_discard,
};
2 changes: 1 addition & 1 deletion src/net/tcp.c
Expand Up @@ -1315,7 +1315,7 @@ static unsigned int tcp_discard ( void ) {
}

/** TCP cache discarder */
struct cache_discarder tcp_cache_discarder __cache_discarder = {
struct cache_discarder tcp_discarder __cache_discarder ( CACHE_NORMAL ) = {
.discard = tcp_discard,
};

Expand Down

0 comments on commit 0242473

Please sign in to comment.