[PATCH] set a destination for the IPv6 default gateway



Hi,

The attached patch appears to be required for setting the default
gateway for IPv6 with libnl3 (tested with libnl3 3.0). It comes with a
small fix to catch the return code for nm_netlink_route_add() so
success is correctly reported as such (or to get the "right" error
message).

Regards,

Mathieu Trudel-Lapierre <mathieu-tl ubuntu com>
Freenode: cyphermox, Jabber: mathieu tl gmail com
4096R/EE018C93 1967 8F7D 03A1 8F38 732E  FF82 C126 33E1 EE01 8C93
From 53abe8f2e54ea02aefabb768f159ca40497db02f Mon Sep 17 00:00:00 2001
From: Mathieu Trudel-Lapierre <mathieu trudel-lapierre canonical com>
Date: Fri, 7 Oct 2011 15:28:27 -0400
Subject: [PATCH] fix default route destination and error reporting

---
 src/nm-system.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/nm-system.c b/src/nm-system.c
index 473fcec..9d425e6 100644
--- a/src/nm-system.c
+++ b/src/nm-system.c
@@ -984,6 +984,7 @@ replace_default_ip6_route (int ifindex, const struct in6_addr *gw)
 	struct nl_sock *nlh;
 	const char *iface;
 	int err = -1;
+	const struct in6_addr dest = { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } };
 
 	g_return_val_if_fail (ifindex > 0, FALSE);
 
@@ -1000,7 +1001,7 @@ replace_default_ip6_route (int ifindex, const struct in6_addr *gw)
 	g_return_val_if_fail (route != NULL, -ENOMEM);
 
 	/* Add the new default route */
-	nm_netlink_route_add(route, AF_INET6, NULL, 0, gw, NLM_F_REPLACE);
+	err = nm_netlink_route_add(route, AF_INET6, &dest, 0, gw, NLM_F_REPLACE);
 	if (err == -NLE_EXIST) {
 		/* FIXME: even though we use NLM_F_REPLACE the kernel won't replace
 		 * the route if it's the same.  Should try to remove it first, then
-- 
1.7.5.4



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]