[ipxe-devel] [PATCH 07/10] ipv6: Allow manual network configuration

Hannes Reinecke hare at suse.de
Thu Apr 30 13:18:47 UTC 2015


Not on every system IPv6 autoconfiguration is working properly,
so this patch adds a new netX/ip6 setting which will set the
IPv6 address. Netmask and gateway are expected to be set via NDP.

Signed-off-by: Hannes Reinecke <hare at suse.de>
---
 src/include/ipxe/settings.h |  2 ++
 src/net/ipv6.c              | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/src/include/ipxe/settings.h b/src/include/ipxe/settings.h
index 95a553c..8249ec0 100644
--- a/src/include/ipxe/settings.h
+++ b/src/include/ipxe/settings.h
@@ -429,6 +429,8 @@ gateway_setting __setting ( SETTING_IP, gateway );
 extern const struct setting
 dns_setting __setting ( SETTING_IP_EXTRA, dns );
 extern const struct setting
+ip6_setting __setting ( SETTING_IP_EXTRA, ip6 );
+extern const struct setting
 hostname_setting __setting ( SETTING_HOST, hostname );
 extern const struct setting
 domain_setting __setting ( SETTING_IP_EXTRA, domain );
diff --git a/src/net/ipv6.c b/src/net/ipv6.c
index 4d2a053..c1b0664 100644
--- a/src/net/ipv6.c
+++ b/src/net/ipv6.c
@@ -34,6 +34,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
 #include <ipxe/ipstat.h>
 #include <ipxe/ndp.h>
 #include <ipxe/ipv6.h>
+#include <ipxe/dhcpv6.h>
 
 /** @file
  *
@@ -1099,6 +1100,15 @@ int ipv6_probe ( struct net_device *netdev ) {
 	return 0;
 }
 
+/** IPv6 address setting */
+const struct setting ip6_setting __setting ( SETTING_IPV6, ip6 ) = {
+	.name = "ip6",
+	.description = "IPv6 address",
+	.tag = DHCPV6_IAADDR,
+	.type = &setting_type_ipv6,
+	.scope = &ipv6_scope,
+};
+
 /**
  * Destroy IPv6 network device
  *
@@ -1125,6 +1135,40 @@ struct net_driver ipv6_driver __net_driver = {
 	.remove = ipv6_remove,
 };
 
+/**
+ * Update IPv6 routing table based on configured settings
+ *
+ * @ret rc		Return status code
+ */
+static int ipv6_update_routes ( void ) {
+	struct net_device *netdev;
+	struct settings *settings;
+	struct in6_addr address;
+	int rc;
+
+	/* Update configured routes for each configured network device */
+	for_each_netdev ( netdev ) {
+		settings = netdev_settings ( netdev );
+		/* Get IPv6 address */
+		rc = fetch_ipv6_setting ( settings, &ip6_setting, &address );
+		if (rc < 0) {
+			DBGC( netdev, "IPv6 %s failed "
+			      "to retrieve address: %s\n",
+			      netdev->name, strerror(rc));
+			continue;
+		}
+		/* Update address */
+		ipv6_set_address( netdev, &address );
+	}
+
+	return 0;
+}
+
+/** IPv6 settings applicator */
+struct settings_applicator ipv6_settings_applicator __settings_applicator = {
+	.apply = ipv6_update_routes,
+};
+
 /* Drag in objects via ipv6_protocol */
 REQUIRING_SYMBOL ( ipv6_protocol );
 
-- 
1.8.4.5




More information about the ipxe-devel mailing list