mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-22 02:35:25 +00:00
2008-05-28 Dan Williams <dcbw@redhat.com>
Patch from Benoit Boissinot <bboissin+networkmanager@gmail.com> * src/NetworkManagerSystem.c - (nm_system_device_flush_ip4_routes_with_iface): implement with libnl - (nm_system_vpn_device_set_from_ip4_config): don't flush routes here, was causing -EINVAL errors since the libnl code actually does flush the routes on VPN interfaces now * src/backends/NetworkManagerArch.c src/backends/NetworkManagerDebian.c src/backends/NetworkManagerFrugalware.c src/backends/NetworkManagerGeneric.c src/backends/NetworkManagerGentoo.c src/backends/NetworkManagerMandriva.c src/backends/NetworkManagerPaldo.c src/backends/NetworkManagerRedHat.c src/backends/NetworkManagerSlackware.c src/backends/NetworkManagerSuSE.c - (nm_system_device_flush_ip4_routes, nm_system_device_flush_ip4_routes_with_iface): remove git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3698 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
0b52ca0ba1
commit
34bba77f61
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
|||
2008-05-28 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
Patch from Benoit Boissinot <bboissin+networkmanager@gmail.com>
|
||||
|
||||
* src/NetworkManagerSystem.c
|
||||
- (nm_system_device_flush_ip4_routes_with_iface): implement with libnl
|
||||
- (nm_system_vpn_device_set_from_ip4_config): don't flush routes here,
|
||||
was causing -EINVAL errors since the libnl code actually does flush
|
||||
the routes on VPN interfaces now
|
||||
|
||||
* src/backends/NetworkManagerArch.c
|
||||
src/backends/NetworkManagerDebian.c
|
||||
src/backends/NetworkManagerFrugalware.c
|
||||
src/backends/NetworkManagerGeneric.c
|
||||
src/backends/NetworkManagerGentoo.c
|
||||
src/backends/NetworkManagerMandriva.c
|
||||
src/backends/NetworkManagerPaldo.c
|
||||
src/backends/NetworkManagerRedHat.c
|
||||
src/backends/NetworkManagerSlackware.c
|
||||
src/backends/NetworkManagerSuSE.c
|
||||
- (nm_system_device_flush_ip4_routes,
|
||||
nm_system_device_flush_ip4_routes_with_iface): remove
|
||||
|
||||
2008-05-28 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* libnm-util/nm-setting-wireless.c
|
||||
|
|
|
@ -367,10 +367,6 @@ nm_system_vpn_device_set_from_ip4_config (NMDevice *active_device,
|
|||
if (nm_ip4_config_get_mtu (config))
|
||||
nm_system_device_set_mtu (iface, nm_ip4_config_get_mtu (config));
|
||||
|
||||
sleep (1);
|
||||
|
||||
nm_system_device_flush_ip4_routes_with_iface (iface);
|
||||
|
||||
if (g_slist_length (routes) == 0) {
|
||||
nm_system_device_replace_default_ip4_route (iface, 0, 0);
|
||||
} else {
|
||||
|
@ -705,3 +701,77 @@ void nm_system_device_flush_ip4_addresses_with_iface (const char *iface)
|
|||
nl_cache_free (addr_cache);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes
|
||||
*
|
||||
* Flush all network addresses associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes (NMDevice *dev)
|
||||
{
|
||||
g_return_if_fail (dev != NULL);
|
||||
|
||||
nm_system_device_flush_ip4_routes_with_iface (nm_device_get_iface (dev));
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
const char *iface;
|
||||
struct nl_handle *nlh;
|
||||
int iface_idx;
|
||||
} RouteCheckData;
|
||||
|
||||
static void
|
||||
check_one_route (struct nl_object *object, void *user_data)
|
||||
{
|
||||
RouteCheckData *data = (RouteCheckData *) user_data;
|
||||
struct rtnl_route *route = (struct rtnl_route *) object;
|
||||
int err;
|
||||
|
||||
/* Delete all IPv4 routes from this interface */
|
||||
if (rtnl_route_get_oif (route) != data->iface_idx)
|
||||
return;
|
||||
if (rtnl_route_get_family (route) != AF_INET)
|
||||
return;
|
||||
|
||||
err = rtnl_route_del (data->nlh, route, 0);
|
||||
if (err < 0) {
|
||||
nm_warning ("(%s) error %d returned from rtnl_route_del(): %s",
|
||||
data->iface, err, nl_geterror());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes_with_iface
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes_with_iface (const char *iface)
|
||||
{
|
||||
struct nl_handle *nlh = NULL;
|
||||
struct nl_cache *route_cache = NULL;
|
||||
int iface_idx;
|
||||
RouteCheckData check_data;
|
||||
|
||||
g_return_if_fail (iface != NULL);
|
||||
iface_idx = nm_netlink_iface_to_index (iface);
|
||||
g_return_if_fail (iface_idx >= 0);
|
||||
|
||||
nlh = nm_netlink_get_default_handle ();
|
||||
g_return_if_fail (nlh != NULL);
|
||||
|
||||
memset (&check_data, 0, sizeof (check_data));
|
||||
check_data.iface = iface;
|
||||
check_data.nlh = nlh;
|
||||
check_data.iface_idx = iface_idx;
|
||||
|
||||
route_cache = rtnl_route_alloc_cache (nlh);
|
||||
g_return_if_fail (route_cache != NULL);
|
||||
nl_cache_mngt_provide (route_cache);
|
||||
|
||||
/* Remove routing table entries */
|
||||
nl_cache_foreach (route_cache, check_one_route, &check_data);
|
||||
|
||||
nl_cache_free (route_cache);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,139 +67,6 @@ void nm_system_init (void)
|
|||
nm_generic_init ();
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_addresses
|
||||
*
|
||||
* Flush all network addresses associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes (NMDevice *dev)
|
||||
{
|
||||
nm_generic_device_flush_ip4_routes (dev);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes_with_iface
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes_with_iface (const char *iface)
|
||||
{
|
||||
nm_generic_device_flush_ip4_routes_with_iface (iface);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_setup_static_ip4_config
|
||||
*
|
||||
* Set up the device with a particular IPv4 address/netmask/gateway.
|
||||
*
|
||||
* Returns: TRUE on success
|
||||
* FALSE on error
|
||||
*
|
||||
*/
|
||||
#if 0
|
||||
gboolean nm_system_device_setup_static_ip4_config (NMDevice *dev)
|
||||
{
|
||||
#define IPBITS (sizeof (guint32) * 8)
|
||||
struct in_addr temp_addr;
|
||||
struct in_addr temp_addr2;
|
||||
char *s_tmp;
|
||||
char *s_tmp2;
|
||||
int i;
|
||||
guint32 addr;
|
||||
guint32 netmask;
|
||||
guint32 prefix = IPBITS; /* initialize with # bits in ipv4 address */
|
||||
guint32 broadcast;
|
||||
char *buf;
|
||||
int err;
|
||||
const char *iface;
|
||||
|
||||
g_return_val_if_fail (dev != NULL, FALSE);
|
||||
g_return_val_if_fail (!nm_device_config_get_use_dhcp (dev), FALSE);
|
||||
|
||||
addr = nm_device_config_get_ip4_address (dev);
|
||||
netmask = nm_device_config_get_ip4_netmask (dev);
|
||||
iface = nm_device_get_iface (dev);
|
||||
broadcast = nm_device_config_get_ip4_broadcast (dev);
|
||||
|
||||
/* get the prefix from the netmask */
|
||||
for (i = 0; i < IPBITS; i++)
|
||||
{
|
||||
if (!(ntohl (netmask) & ((2 << i) - 1)))
|
||||
prefix--;
|
||||
}
|
||||
|
||||
/* Calculate the broadcast address if the user didn't specify one */
|
||||
if (!broadcast)
|
||||
broadcast = ((addr & (int)netmask) | ~(int)netmask);
|
||||
|
||||
/*
|
||||
* Try and work out if someone else has our IP
|
||||
* using RFC 2131 Duplicate Address Detection
|
||||
*/
|
||||
temp_addr.s_addr = addr;
|
||||
buf = g_strdup_printf ("%s -q -D -c 1 -I %s %s",ARPING,
|
||||
iface, inet_ntoa (temp_addr));
|
||||
if ((err = nm_spawn_process (buf)))
|
||||
{
|
||||
nm_warning ("Error: Duplicate address '%s' detected for "
|
||||
"device '%s' \n", iface, inet_ntoa (temp_addr));
|
||||
goto error;
|
||||
}
|
||||
g_free (buf);
|
||||
|
||||
/* set our IP address */
|
||||
temp_addr.s_addr = addr;
|
||||
temp_addr2.s_addr = broadcast;
|
||||
s_tmp = g_strdup (inet_ntoa (temp_addr));
|
||||
s_tmp2 = g_strdup (inet_ntoa (temp_addr2));
|
||||
buf = g_strdup_printf ("/sbin/ip addr add %s/%d brd %s dev %s label %s",
|
||||
s_tmp, prefix, s_tmp2, iface, iface);
|
||||
g_free (s_tmp);
|
||||
g_free (s_tmp2);
|
||||
if ((err = nm_spawn_process (buf)))
|
||||
{
|
||||
nm_warning ("Error: could not set network configuration for "
|
||||
"device '%s' using command:\n '%s'",
|
||||
iface, buf);
|
||||
goto error;
|
||||
}
|
||||
g_free (buf);
|
||||
|
||||
/* Alert other computers of our new address */
|
||||
temp_addr.s_addr = addr;
|
||||
buf = g_strdup_printf ("%s -q -A -c 1 -I %s %s", ARPING,iface,
|
||||
inet_ntoa (temp_addr));
|
||||
nm_spawn_process (buf);
|
||||
g_free (buf);
|
||||
g_usleep (G_USEC_PER_SEC * 2);
|
||||
buf = g_strdup_printf ("%s -q -U -c 1 -I %s %s", ARPING, iface,
|
||||
inet_ntoa (temp_addr));
|
||||
nm_spawn_process (buf);
|
||||
g_free (buf);
|
||||
|
||||
/* set the default route to be this device's gateway */
|
||||
temp_addr.s_addr = nm_device_config_get_ip4_gateway (dev);
|
||||
buf = g_strdup_printf ("/sbin/ip route replace default via %s dev %s",
|
||||
inet_ntoa (temp_addr), iface);
|
||||
if ((err = nm_spawn_process (buf)))
|
||||
{
|
||||
nm_warning ("Error: could not set default route using "
|
||||
"command:\n '%s'", buf);
|
||||
goto error;
|
||||
}
|
||||
g_free (buf);
|
||||
return(TRUE);
|
||||
|
||||
error:
|
||||
g_free (buf);
|
||||
nm_system_device_flush_ip4_addresses (dev);
|
||||
nm_system_device_flush_ip4_routes (dev);
|
||||
return(FALSE);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* nm_system_enable_loopback
|
||||
*
|
||||
|
|
|
@ -56,28 +56,6 @@ void nm_system_init (void)
|
|||
nm_generic_init ();
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_addresses
|
||||
*
|
||||
* Flush all network addresses associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes (NMDevice *dev)
|
||||
{
|
||||
nm_generic_device_flush_ip4_routes (dev);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes_with_iface
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes_with_iface (const char *iface)
|
||||
{
|
||||
nm_generic_device_flush_ip4_routes_with_iface (iface);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_enable_loopback
|
||||
*
|
||||
|
|
|
@ -50,37 +50,6 @@ void nm_system_init (void)
|
|||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes (NMDevice *dev)
|
||||
{
|
||||
g_return_if_fail (dev != NULL);
|
||||
|
||||
nm_system_device_flush_ip4_routes_with_iface (nm_device_get_iface (dev));
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes_with_iface
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes_with_iface (const char *iface)
|
||||
{
|
||||
char *buf;
|
||||
|
||||
g_return_if_fail (iface != NULL);
|
||||
|
||||
/* Remove routing table entries */
|
||||
buf = g_strdup_printf ("/usr/sbin/ip -4 route flush dev %s", iface);
|
||||
nm_spawn_process (buf);
|
||||
g_free (buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_enable_loopback
|
||||
*
|
||||
|
|
|
@ -58,37 +58,6 @@ void nm_generic_init (void)
|
|||
nm_system_kill_all_dhcp_daemons ();
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_generic_device_flush_ip4_addresses
|
||||
*
|
||||
* Flush all network addresses associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_generic_device_flush_ip4_routes (NMDevice *dev)
|
||||
{
|
||||
g_return_if_fail (dev != NULL);
|
||||
|
||||
nm_system_device_flush_ip4_routes_with_iface (nm_device_get_iface (dev));
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_generic_device_flush_ip4_routes_with_iface
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_generic_device_flush_ip4_routes_with_iface (const char *iface)
|
||||
{
|
||||
char *buf;
|
||||
|
||||
g_return_if_fail (iface != NULL);
|
||||
|
||||
/* Remove routing table entries */
|
||||
buf = g_strdup_printf (IP_BINARY_PATH" -4 route flush dev %s", iface);
|
||||
nm_spawn_process (buf);
|
||||
g_free (buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_generic_enable_loopback
|
||||
*
|
||||
|
|
|
@ -54,28 +54,6 @@ void nm_system_init (void)
|
|||
nm_generic_init ();
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes (NMDevice *dev)
|
||||
{
|
||||
nm_generic_device_flush_ip4_routes (dev);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes_with_iface
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes_with_iface (const char *iface)
|
||||
{
|
||||
nm_generic_device_flush_ip4_routes_with_iface (iface);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_enable_loopback
|
||||
*
|
||||
|
|
|
@ -53,29 +53,6 @@ void nm_system_init (void)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes (NMDevice *dev)
|
||||
{
|
||||
nm_generic_device_flush_ip4_routes (dev);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes_with_iface
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes_with_iface (const char *iface)
|
||||
{
|
||||
nm_generic_device_flush_ip4_routes_with_iface (iface);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_enable_loopback
|
||||
*
|
||||
|
|
|
@ -53,30 +53,6 @@ void nm_system_init (void)
|
|||
nm_generic_init ();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes (NMDevice *dev)
|
||||
{
|
||||
nm_generic_device_flush_ip4_routes (dev);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes_with_iface
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes_with_iface (const char *iface)
|
||||
{
|
||||
nm_generic_device_flush_ip4_routes_with_iface (iface);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_enable_loopback
|
||||
*
|
||||
|
|
|
@ -50,30 +50,6 @@ void nm_system_init (void)
|
|||
nm_generic_init ();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes (NMDevice *dev)
|
||||
{
|
||||
nm_generic_device_flush_ip4_routes (dev);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes_with_iface
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes_with_iface (const char *iface)
|
||||
{
|
||||
nm_generic_device_flush_ip4_routes_with_iface (iface);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_enable_loopback
|
||||
*
|
||||
|
|
|
@ -53,28 +53,6 @@ void nm_system_init (void)
|
|||
nm_generic_init ();
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes (NMDevice *dev)
|
||||
{
|
||||
nm_generic_device_flush_ip4_routes (dev);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes_with_iface
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes_with_iface (const char *iface)
|
||||
{
|
||||
nm_generic_device_flush_ip4_routes_with_iface (iface);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_enable_loopback
|
||||
*
|
||||
|
|
|
@ -59,30 +59,6 @@ void nm_system_init (void)
|
|||
nm_generic_init ();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes (NMDevice *dev)
|
||||
{
|
||||
nm_generic_device_flush_ip4_routes (dev);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_routes_with_iface
|
||||
*
|
||||
* Flush all routes associated with a network device
|
||||
*
|
||||
*/
|
||||
void nm_system_device_flush_ip4_routes_with_iface (const char *iface)
|
||||
{
|
||||
nm_generic_device_flush_ip4_routes_with_iface (iface);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_enable_loopback
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue