[ipxe-devel] [PATCH 08/11] ipv6: Allow manual network configuration

Hannes Reinecke hare at suse.de
Thu May 7 09:25:03 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              | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 36 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..7298372 100644
--- a/src/net/ipv6.c
+++ b/src/net/ipv6.c
@@ -1125,6 +1125,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