瀏覽代碼

[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 11 年之前
父節點
當前提交
95623e353b
共有 2 個文件被更改,包括 7 次插入1 次删除
  1. 6
    0
      src/include/ipxe/in.h
  2. 1
    1
      src/net/ipv6.c

+ 6
- 0
src/include/ipxe/in.h 查看文件

@@ -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 查看文件

@@ -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…
取消
儲存