[SLOF] [PATCH 3/6] net-snk: Prefer non-link-local unicast IPv6 addresses if possible
Thomas Huth
thuth at redhat.com
Thu Jan 14 10:10:36 AEDT 2016
When the IPv6 code is told to create IPv6 addresses automatically
(by passing NULL as parameter to set_ipv6_address()), the netboot
code currently only uses link-local IPv6 addresses - which is bad
since they can not be routed, e.g. if the TFTP server is not on
the same link.
So set_ipv6_address(NULL) should set own_ip6 preferably to a non-local
unicast address if it has been generated successfully during ipv6_init().
Signed-off-by: Thomas Huth <thuth at redhat.com>
---
clients/net-snk/app/netlib/ipv6.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/clients/net-snk/app/netlib/ipv6.c b/clients/net-snk/app/netlib/ipv6.c
index 0cb0a2e..56b30c3 100644
--- a/clients/net-snk/app/netlib/ipv6.c
+++ b/clients/net-snk/app/netlib/ipv6.c
@@ -58,6 +58,8 @@ static uint8_t null_mac[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
void
set_ipv6_address (int fd, ip6_addr_t *_own_ip6)
{
+ struct ip6addr_list_entry *ile;
+
own_ip6 = malloc (sizeof(struct ip6addr_list_entry));
/* If no address was passed as a parameter generate a link-local
@@ -73,6 +75,20 @@ set_ipv6_address (int fd, ip6_addr_t *_own_ip6)
ip6addr_add (own_ip6);
ipv6_init(fd);
+
+ /*
+ * Check whether we've got a non-link-local address during
+ * ipv6_init() and use that as preferred address if possible
+ */
+ if (_own_ip6 == NULL) {
+ for (ile = first_ip6; ile != NULL ; ile = ile->next) {
+ if (!ip6_is_multicast(&ile->addr) &&
+ !ip6_is_linklocal(&ile->addr)) {
+ own_ip6 = ile;
+ break;
+ }
+ }
+ }
}
/**
--
1.8.3.1
More information about the SLOF
mailing list