Browse Source

[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 10 years ago
parent
commit
721a492020
1 changed files with 6 additions and 6 deletions
  1. 6
    6
      src/usr/lotest.c

+ 6
- 6
src/usr/lotest.c View File

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

Loading…
Cancel
Save