david/ipxe
Archived
1
0

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2013-11-08 15:52:07 +00:00
parent 4484edd1c0
commit 95623e353b
2 changed files with 7 additions and 1 deletions

View File

@ -50,6 +50,12 @@ struct in6_addr {
#define s6_addr32 in6_u.u6_addr32 #define s6_addr32 in6_u.u6_addr32
}; };
#define IN6_IS_ADDR_UNSPECIFIED( addr ) \
( ( ( ( ( const uint32_t * ) (addr) )[0] ) | \
( ( ( const uint32_t * ) (addr) )[1] ) | \
( ( ( const uint32_t * ) (addr) )[2] ) | \
( ( ( const uint32_t * ) (addr) )[3] ) ) == 0 )
#define IN6_IS_ADDR_MULTICAST( addr ) \ #define IN6_IS_ADDR_MULTICAST( addr ) \
( *( ( const uint8_t * ) (addr) ) == 0xff ) ( *( ( const uint8_t * ) (addr) ) == 0xff )

View File

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