Quellcode durchsuchen

[lotest] Discard packets arriving on the incorrect network device

Commit 24bbaf6 ("[lotest] Allow loopback testing on shared networks")
introduced a regression in which loopback testing packets would be
accepted from any network device.  This produces unexpected results,
such as VLAN loopback testing succeeding even when incorrectly using
the underlying trunk device as either transmitter or receiver.

Fix by discarding any loopback testing packets which arrive on a
network device other than the current loopback testing receiver.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown vor 10 Jahren
Ursprung
Commit
721a492020
1 geänderte Dateien mit 6 neuen und 6 gelöschten Zeilen
  1. 6
    6
      src/usr/lotest.c

+ 6
- 6
src/usr/lotest.c Datei anzeigen

@@ -39,8 +39,8 @@ FILE_LICENCE ( GPL2_OR_LATER );
39 39
  *
40 40
  */
41 41
 
42
-/** Loopback testing in progress flag */
43
-static int lotest_active;
42
+/** Current loopback test receiver */
43
+static struct net_device *lotest_receiver;
44 44
 
45 45
 /** Loopback testing received packets */
46 46
 static LIST_HEAD ( lotest_queue );
@@ -56,13 +56,13 @@ static LIST_HEAD ( lotest_queue );
56 56
  * @ret rc		Return status code
57 57
  */
58 58
 static int lotest_rx ( struct io_buffer *iobuf,
59
-		       struct net_device *netdev __unused,
59
+		       struct net_device *netdev,
60 60
 		       const void *ll_dest __unused,
61 61
 		       const void *ll_source __unused,
62 62
 		       unsigned int flags __unused ) {
63 63
 
64 64
 	/* Add to received packet queue if currently performing a test */
65
-	if ( lotest_active ) {
65
+	if ( netdev == lotest_receiver ) {
66 66
 		list_add_tail ( &iobuf->list, &lotest_queue );
67 67
 	} else {
68 68
 		free_iob ( iobuf );
@@ -223,7 +223,7 @@ int loopback_test ( struct net_device *sender, struct net_device *receiver,
223 223
 
224 224
 	/* Start loopback test */
225 225
 	lotest_flush();
226
-	lotest_active = 1;
226
+	lotest_receiver = receiver;
227 227
 
228 228
 	/* Perform loopback test */
229 229
 	for ( successes = 0 ; ; successes++ ) {
@@ -261,7 +261,7 @@ int loopback_test ( struct net_device *sender, struct net_device *receiver,
261 261
 	printf ( "\n");
262 262
 
263 263
 	/* Stop loopback testing */
264
-	lotest_active = 0;
264
+	lotest_receiver = NULL;
265 265
 	lotest_flush();
266 266
 
267 267
 	/* Dump final statistics */

Laden…
Abbrechen
Speichern