Bläddra i källkod

[ipv6] Treat sin6_scope_id consistently

sin6_scope_id is never exposed outside of the local system, and so
should be a native-endian quantity.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 år sedan
förälder
incheckning
fec127cb07
2 ändrade filer med 5 tillägg och 5 borttagningar
  1. 3
    3
      src/net/ipv6.c
  2. 2
    2
      src/net/ndp.c

+ 3
- 3
src/net/ipv6.c Visa fil

@@ -386,7 +386,7 @@ static int ipv6_tx ( struct io_buffer *iobuf,
386 386
 			 sizeof ( iphdr->src ) );
387 387
 	}
388 388
 	if ( ( ! IN6_IS_ADDR_MULTICAST ( next_hop ) ) &&
389
-	     ( ( miniroute = ipv6_route ( ntohl ( sin6_dest->sin6_scope_id ),
389
+	     ( ( miniroute = ipv6_route ( sin6_dest->sin6_scope_id,
390 390
 					  &next_hop ) ) != NULL ) ) {
391 391
 		memcpy ( &iphdr->src, &miniroute->address,
392 392
 			 sizeof ( iphdr->src ) );
@@ -599,12 +599,12 @@ static int ipv6_rx ( struct io_buffer *iobuf, struct net_device *netdev,
599 599
 	src.sin6.sin6_family = AF_INET6;
600 600
 	memcpy ( &src.sin6.sin6_addr, &iphdr->src,
601 601
 		 sizeof ( src.sin6.sin6_addr ) );
602
-	src.sin6.sin6_scope_id = htonl ( netdev->index );
602
+	src.sin6.sin6_scope_id = netdev->index;
603 603
 	memset ( &dest, 0, sizeof ( dest ) );
604 604
 	dest.sin6.sin6_family = AF_INET6;
605 605
 	memcpy ( &dest.sin6.sin6_addr, &iphdr->dest,
606 606
 		 sizeof ( dest.sin6.sin6_addr ) );
607
-	dest.sin6.sin6_scope_id = htonl ( netdev->index );
607
+	dest.sin6.sin6_scope_id = netdev->index;
608 608
 	iob_pull ( iobuf, hdrlen );
609 609
 	pshdr_csum = ipv6_pshdr_chksum ( iphdr, iob_len ( iobuf ),
610 610
 					 next_header, TCPIP_EMPTY_CSUM );

+ 2
- 2
src/net/ndp.c Visa fil

@@ -119,12 +119,12 @@ static int ndp_tx_request ( struct net_device *netdev,
119 119
 	sin6_src.sin6_family = AF_INET6;
120 120
 	memcpy ( &sin6_src.sin6_addr, net_source,
121 121
 		 sizeof ( sin6_src.sin6_addr ) );
122
-	sin6_src.sin6_scope_id = htons ( netdev->index );
122
+	sin6_src.sin6_scope_id = netdev->index;
123 123
 
124 124
 	/* Construct multicast destination address */
125 125
 	memset ( &sin6_dest, 0, sizeof ( sin6_dest ) );
126 126
 	sin6_dest.sin6_family = AF_INET6;
127
-	sin6_dest.sin6_scope_id = htons ( netdev->index );
127
+	sin6_dest.sin6_scope_id = netdev->index;
128 128
 	ipv6_solicited_node ( &sin6_dest.sin6_addr, net_dest );
129 129
 
130 130
 	/* Transmit neighbour discovery packet */

Laddar…
Avbryt
Spara