summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/ipxe/in.h6
-rw-r--r--src/net/ipv6.c2
2 files changed, 7 insertions, 1 deletions
diff --git a/src/include/ipxe/in.h b/src/include/ipxe/in.h
index a37784e2e..0f19bbd7c 100644
--- a/src/include/ipxe/in.h
+++ b/src/include/ipxe/in.h
@@ -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 )
diff --git a/src/net/ipv6.c b/src/net/ipv6.c
index 8279f0587..abe993d0f 100644
--- a/src/net/ipv6.c
+++ b/src/net/ipv6.c
@@ -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 ) );