Browse Source

[arp] Try to avoid discarding ARP cache entries

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>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
024247317d
4 changed files with 21 additions and 5 deletions
  1. 1
    1
      src/crypto/x509.c
  2. 12
    1
      src/include/ipxe/malloc.h
  3. 7
    2
      src/net/arp.c
  4. 1
    1
      src/net/tcp.c

+ 1
- 1
src/crypto/x509.c View File

143
 }
143
 }
144
 
144
 
145
 /** X.509 cache discarder */
145
 /** X.509 cache discarder */
146
-struct cache_discarder x509_cache_discarder __cache_discarder = {
146
+struct cache_discarder x509_discarder __cache_discarder ( CACHE_NORMAL ) = {
147
 	.discard = x509_discard,
147
 	.discard = x509_discard,
148
 };
148
 };
149
 
149
 

+ 12
- 1
src/include/ipxe/malloc.h View File

76
 #define CACHE_DISCARDERS __table ( struct cache_discarder, "cache_discarders" )
76
 #define CACHE_DISCARDERS __table ( struct cache_discarder, "cache_discarders" )
77
 
77
 
78
 /** Declare a cache discarder */
78
 /** Declare a cache discarder */
79
-#define __cache_discarder __table_entry ( CACHE_DISCARDERS, 01 )
79
+#define __cache_discarder( cost ) __table_entry ( CACHE_DISCARDERS, cost )
80
+
81
+/** @defgroup cache_cost Cache discarder costs
82
+ *
83
+ * @{
84
+ */
85
+
86
+#define CACHE_CHEAP	01	/**< Items with a low replacement cost */
87
+#define CACHE_NORMAL	02	/**< Items with a normal replacement cost */
88
+#define CACHE_EXPENSIVE	03	/**< Items with a high replacement cost */
89
+
90
+/** @} */
80
 
91
 
81
 #endif /* _IPXE_MALLOC_H */
92
 #endif /* _IPXE_MALLOC_H */

+ 7
- 2
src/net/arp.c View File

525
 	return 0;
525
 	return 0;
526
 }
526
 }
527
 
527
 
528
-/** ARP cache discarder */
529
-struct cache_discarder arp_cache_discarder __cache_discarder = {
528
+/** ARP cache discarder
529
+ *
530
+ * ARP cache entries are deemed to have a high replacement cost, since
531
+ * flushing an active ARP cache entry midway through a TCP transfer
532
+ * will cause substantial disruption.
533
+ */
534
+struct cache_discarder arp_discarder __cache_discarder ( CACHE_EXPENSIVE ) = {
530
 	.discard = arp_discard,
535
 	.discard = arp_discard,
531
 };
536
 };

+ 1
- 1
src/net/tcp.c View File

1315
 }
1315
 }
1316
 
1316
 
1317
 /** TCP cache discarder */
1317
 /** TCP cache discarder */
1318
-struct cache_discarder tcp_cache_discarder __cache_discarder = {
1318
+struct cache_discarder tcp_discarder __cache_discarder ( CACHE_NORMAL ) = {
1319
 	.discard = tcp_discard,
1319
 	.discard = tcp_discard,
1320
 };
1320
 };
1321
 
1321
 

Loading…
Cancel
Save