Browse Source

[ipv6] Use given source address only if it is not the unspecified address

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 years ago
parent
commit
95623e353b
2 changed files with 7 additions and 1 deletions
  1. 6
    0
      src/include/ipxe/in.h
  2. 1
    1
      src/net/ipv6.c

+ 6
- 0
src/include/ipxe/in.h View File

@@ -50,6 +50,12 @@ struct in6_addr {
50 50
 #define s6_addr32       in6_u.u6_addr32
51 51
 };
52 52
 
53
+#define IN6_IS_ADDR_UNSPECIFIED( addr )					\
54
+	( ( ( ( ( const uint32_t * ) (addr) )[0] ) |			\
55
+	    ( ( ( const uint32_t * ) (addr) )[1] ) |			\
56
+	    ( ( ( const uint32_t * ) (addr) )[2] ) |			\
57
+	    ( ( ( const uint32_t * ) (addr) )[3] ) ) == 0 )
58
+
53 59
 #define IN6_IS_ADDR_MULTICAST( addr )					\
54 60
 	( *( ( const uint8_t * ) (addr) ) == 0xff )
55 61
 

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

@@ -399,7 +399,7 @@ static int ipv6_tx ( struct io_buffer *iobuf,
399 399
 		rc = -ENETUNREACH;
400 400
 		goto err;
401 401
 	}
402
-	if ( sin6_src )
402
+	if ( sin6_src && ! IN6_IS_ADDR_UNSPECIFIED ( &sin6_src->sin6_addr ) )
403 403
 		src = &sin6_src->sin6_addr;
404 404
 	memcpy ( &iphdr->src, src, sizeof ( iphdr->src ) );
405 405
 

Loading…
Cancel
Save