]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[ipv6] Use given source address only if it is not the unspecified address
authorMichael Brown <mcb30@ipxe.org>
Fri, 8 Nov 2013 15:52:07 +0000 (15:52 +0000)
committerMichael Brown <mcb30@ipxe.org>
Thu, 14 Nov 2013 12:35:43 +0000 (12:35 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/in.h
src/net/ipv6.c

index a37784e2e488d331a455e2eecc5768c9da44ed46..0f19bbd7c4b2ab7d71d46db14dfc3ec204c1fd2e 100644 (file)
@@ -50,6 +50,12 @@ struct in6_addr {
 #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 )                                  \
        ( *( ( const uint8_t * ) (addr) ) == 0xff )
 
index 8279f058790b7c72b2e96b5354d4cb27e7568029..abe993d0f39f0065b258a7ccd29299ed796fe545 100644 (file)
@@ -399,7 +399,7 @@ static int ipv6_tx ( struct io_buffer *iobuf,
                rc = -ENETUNREACH;
                goto err;
        }
-       if ( sin6_src )
+       if ( sin6_src && ! IN6_IS_ADDR_UNSPECIFIED ( &sin6_src->sin6_addr ) )
                src = &sin6_src->sin6_addr;
        memcpy ( &iphdr->src, src, sizeof ( iphdr->src ) );