Bläddra i källkod

[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 år sedan
förälder
incheckning
024247317d
4 ändrade filer med 21 tillägg och 5 borttagningar
  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 Visa fil

@@ -143,7 +143,7 @@ static unsigned int x509_discard ( void ) {
143 143
 }
144 144
 
145 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 147
 	.discard = x509_discard,
148 148
 };
149 149
 

+ 12
- 1
src/include/ipxe/malloc.h Visa fil

@@ -76,6 +76,17 @@ struct cache_discarder {
76 76
 #define CACHE_DISCARDERS __table ( struct cache_discarder, "cache_discarders" )
77 77
 
78 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 92
 #endif /* _IPXE_MALLOC_H */

+ 7
- 2
src/net/arp.c Visa fil

@@ -525,7 +525,12 @@ static unsigned int arp_discard ( void ) {
525 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 535
 	.discard = arp_discard,
531 536
 };

+ 1
- 1
src/net/tcp.c Visa fil

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

Laddar…
Avbryt
Spara