mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-22 02:35:25 +00:00
2008-04-25 Dan Williams <dcbw@redhat.com>
Patch from Benoit Boissinot <bboissin+networkmanager@gmail.com> * src/NetworkManagerSystem.c - (nm_system_device_replace_default_ip4_route): new function; a libnl implementation of nm_system_device_replace_default_route() * src/NetworkManagerPolicy.c - (update_default_route): use nm_system_device_replace_default_ip4_route() * src/backends/NetworkManagerArch.c src/backends/NetworkManagerDebian.c src/backends/NetworkManagerFrugalware.c src/backends/NetworkManagerGeneric.c src/backends/NetworkManagerGeneric.h 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_replace_default_route): remove git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3597 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
00461c208b
commit
ad96e82e8b
24
ChangeLog
24
ChangeLog
|
@ -1,3 +1,27 @@
|
|||
2008-04-25 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
Patch from Benoit Boissinot <bboissin+networkmanager@gmail.com>
|
||||
|
||||
* src/NetworkManagerSystem.c
|
||||
- (nm_system_device_replace_default_ip4_route): new function; a libnl
|
||||
implementation of nm_system_device_replace_default_route()
|
||||
|
||||
* src/NetworkManagerPolicy.c
|
||||
- (update_default_route): use nm_system_device_replace_default_ip4_route()
|
||||
|
||||
* src/backends/NetworkManagerArch.c
|
||||
src/backends/NetworkManagerDebian.c
|
||||
src/backends/NetworkManagerFrugalware.c
|
||||
src/backends/NetworkManagerGeneric.c
|
||||
src/backends/NetworkManagerGeneric.h
|
||||
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_replace_default_route): remove
|
||||
|
||||
2008-04-25 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
Patch from Benoit Boissinot <bboissin+networkmanager@gmail.com>
|
||||
|
|
|
@ -83,12 +83,12 @@ update_default_route (NMPolicy *policy, NMDevice *new)
|
|||
a serial device with ppp interface, so route all the traffic to it. */
|
||||
ip_iface = nm_device_get_ip_iface (new);
|
||||
if (strcmp (ip_iface, nm_device_get_iface (new))) {
|
||||
nm_system_device_replace_default_route (ip_iface, 0, 0);
|
||||
nm_system_device_replace_default_ip4_route (ip_iface, 0, 0);
|
||||
} else {
|
||||
NMIP4Config *config;
|
||||
|
||||
config = nm_device_get_ip4_config (new);
|
||||
nm_system_device_replace_default_route (ip_iface, nm_ip4_config_get_gateway (config),
|
||||
nm_system_device_replace_default_ip4_route (ip_iface, nm_ip4_config_get_gateway (config),
|
||||
nm_ip4_config_get_mss (config));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -347,7 +347,7 @@ nm_system_vpn_device_set_from_ip4_config (NMDevice *active_device,
|
|||
nm_system_device_flush_ip4_routes_with_iface (iface);
|
||||
|
||||
if (g_slist_length (routes) == 0) {
|
||||
nm_system_device_replace_default_route (iface, 0, 0);
|
||||
nm_system_device_replace_default_ip4_route (iface, 0, 0);
|
||||
} else {
|
||||
GSList *iter;
|
||||
|
||||
|
@ -496,8 +496,61 @@ void nm_system_device_add_ip4_route_via_device_with_iface (const char *iface, co
|
|||
nl_addr_put (dst);
|
||||
|
||||
err = rtnl_route_add (nlh, route, 0);
|
||||
if (err)
|
||||
nm_warning ("rtnl_route_add() returned error %s (%d)", strerror (err), err);
|
||||
if (err) {
|
||||
nm_warning ("rtnl_route_add() returned error %s (%d)\n%s",
|
||||
strerror (err), err, nl_geterror());
|
||||
}
|
||||
|
||||
out:
|
||||
rtnl_route_put (route);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_replace_default_ip4_route
|
||||
*
|
||||
* Replace default IPv4 route with one via the current device
|
||||
*
|
||||
*/
|
||||
void
|
||||
nm_system_device_replace_default_ip4_route (const char *iface, guint32 gw, guint32 mss)
|
||||
{
|
||||
struct rtnl_route * route;
|
||||
struct nl_handle * nlh;
|
||||
struct nl_addr * gw_addr;
|
||||
int iface_idx, err;
|
||||
|
||||
nlh = nm_netlink_get_default_handle ();
|
||||
g_return_if_fail (nlh != NULL);
|
||||
|
||||
route = rtnl_route_alloc();
|
||||
g_return_if_fail (route != NULL);
|
||||
|
||||
rtnl_route_set_scope (route, RT_SCOPE_UNIVERSE);
|
||||
|
||||
iface_idx = nm_netlink_iface_to_index (iface);
|
||||
if (iface_idx < 0)
|
||||
goto out;
|
||||
rtnl_route_set_oif (route, iface_idx);
|
||||
|
||||
/* Build up gateway address; a gateway of 0 (used in e.g. PPP links) means
|
||||
* that all packets should be sent to the gateway since it's a point-to-point
|
||||
* link and has no broadcast segment really.
|
||||
*/
|
||||
if (!(gw_addr = nl_addr_build (AF_INET, &gw, sizeof (gw))))
|
||||
goto out;
|
||||
rtnl_route_set_gateway (route, gw_addr);
|
||||
nl_addr_put (gw_addr);
|
||||
|
||||
if (mss > 0) {
|
||||
if (rtnl_route_set_metric (route, RTAX_ADVMSS, mss) < 0)
|
||||
goto out;
|
||||
}
|
||||
|
||||
err = rtnl_route_add (nlh, route, NLM_F_REPLACE);
|
||||
if (err) {
|
||||
nm_warning ("rtnl_route_add() returned error %s (%d)\n%s",
|
||||
strerror (err), err, nl_geterror());
|
||||
}
|
||||
|
||||
out:
|
||||
rtnl_route_put (route);
|
||||
|
|
|
@ -38,7 +38,7 @@ gboolean nm_system_device_has_active_routes (NMDevice *dev);
|
|||
void nm_system_device_flush_ip4_routes (NMDevice *dev);
|
||||
void nm_system_device_flush_ip4_routes_with_iface (const char *iface);
|
||||
|
||||
void nm_system_device_replace_default_route (const char *iface,
|
||||
void nm_system_device_replace_default_ip4_route (const char *iface,
|
||||
guint32 gw,
|
||||
guint32 mss);
|
||||
|
||||
|
|
|
@ -67,20 +67,6 @@ void nm_system_init (void)
|
|||
nm_generic_init ();
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_replace_default_route
|
||||
*
|
||||
* Add default route to the given device
|
||||
*
|
||||
*/
|
||||
void
|
||||
nm_system_device_replace_default_route (const char *iface,
|
||||
guint32 gw,
|
||||
guint32 mss)
|
||||
{
|
||||
nm_generic_device_replace_default_route (iface, gw, mss);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_addresses
|
||||
*
|
||||
|
|
|
@ -56,20 +56,6 @@ void nm_system_init (void)
|
|||
nm_generic_init ();
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_replace_default_route
|
||||
*
|
||||
* Add default route to the given device
|
||||
*
|
||||
*/
|
||||
void
|
||||
nm_system_device_replace_default_route (const char *iface,
|
||||
guint32 gw,
|
||||
guint32 mss)
|
||||
{
|
||||
nm_generic_device_replace_default_route (iface, gw, mss);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_flush_ip4_addresses
|
||||
*
|
||||
|
|
|
@ -178,21 +178,6 @@ void nm_system_restart_mdns_responder (void)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_replace_default_route
|
||||
*
|
||||
* Add default route to the given device
|
||||
*
|
||||
*/
|
||||
void
|
||||
nm_system_device_replace_default_route (const char *iface,
|
||||
guint32 gw,
|
||||
guint32 mss)
|
||||
{
|
||||
nm_generic_device_replace_default_route (iface, gw, mss);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_system_flush_loopback_routes
|
||||
*
|
||||
|
|
|
@ -51,39 +51,6 @@ void nm_generic_init (void)
|
|||
nm_system_kill_all_dhcp_daemons ();
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_generic_replace_default_route
|
||||
*
|
||||
* Replace default route with one via the current device
|
||||
*
|
||||
*/
|
||||
void
|
||||
nm_generic_device_replace_default_route (const char *iface, guint32 gw, guint32 mss)
|
||||
{
|
||||
char *buf, *addr_str = NULL, *mss_str = NULL;
|
||||
|
||||
g_return_if_fail (iface != NULL);
|
||||
|
||||
if (gw > 0) {
|
||||
struct in_addr addr = { .s_addr = gw };
|
||||
char buf2[INET_ADDRSTRLEN + 1];
|
||||
|
||||
memset (buf2, 0, sizeof (buf2));
|
||||
inet_ntop (AF_INET, &addr, buf2, INET_ADDRSTRLEN);
|
||||
addr_str = g_strdup_printf ("via %s", buf2);
|
||||
}
|
||||
|
||||
if (mss > 0)
|
||||
mss_str = g_strdup_printf ("advmss %d", mss);
|
||||
|
||||
buf = g_strdup_printf (IP_BINARY_PATH" route replace default %s %s dev %s",
|
||||
addr_str ? addr_str : "",
|
||||
mss_str ? mss_str : "",
|
||||
iface);
|
||||
nm_spawn_process (buf);
|
||||
g_free (buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_generic_device_flush_ip4_addresses
|
||||
*
|
||||
|
|
|
@ -39,8 +39,6 @@ gboolean nm_generic_device_has_active_routes (NMDevice *dev);
|
|||
void nm_generic_device_flush_ip4_routes (NMDevice *dev);
|
||||
void nm_generic_device_flush_ip4_routes_with_iface (const char *iface);
|
||||
|
||||
void nm_generic_device_replace_default_route (const char *iface, guint32 gw, guint32 mss);
|
||||
|
||||
void nm_generic_device_flush_ip4_addresses (NMDevice *dev);
|
||||
void nm_generic_device_flush_ip4_addresses_with_iface (const char *iface);
|
||||
|
||||
|
|
|
@ -219,20 +219,6 @@ void nm_system_restart_mdns_responder (void)
|
|||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_replace_default_route
|
||||
*
|
||||
* Add default route to the given device
|
||||
*
|
||||
*/
|
||||
void
|
||||
nm_system_device_replace_default_route (const char *iface,
|
||||
guint32 gw,
|
||||
guint32 mss)
|
||||
{
|
||||
nm_generic_device_replace_default_route (iface, gw, mss);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_activate_nis
|
||||
*
|
||||
|
|
|
@ -76,21 +76,6 @@ void nm_system_device_flush_ip4_routes_with_iface (const char *iface)
|
|||
nm_generic_device_flush_ip4_routes_with_iface (iface);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_system_device_replace_default_route
|
||||
*
|
||||
* Add default route to the given device
|
||||
*
|
||||
*/
|
||||
void
|
||||
nm_system_device_replace_default_route (const char *iface,
|
||||
guint32 gw,
|
||||
guint32 mss)
|
||||
{
|
||||
nm_generic_device_replace_default_route (iface, gw, mss);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_has_active_routes
|
||||
*
|
||||
|
|
|
@ -77,21 +77,6 @@ void nm_system_device_flush_ip4_routes_with_iface (const char *iface)
|
|||
nm_generic_device_flush_ip4_routes_with_iface (iface);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_system_device_replace_default_route
|
||||
*
|
||||
* Add default route to the given device
|
||||
*
|
||||
*/
|
||||
void
|
||||
nm_system_device_replace_default_route (const char *iface,
|
||||
guint32 gw,
|
||||
guint32 mss)
|
||||
{
|
||||
nm_generic_device_replace_default_route (iface, gw, mss);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_has_active_routes
|
||||
*
|
||||
|
|
|
@ -74,21 +74,6 @@ void nm_system_device_flush_ip4_routes_with_iface (const char *iface)
|
|||
nm_generic_device_flush_ip4_routes_with_iface (iface);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_system_device_replace_default_route
|
||||
*
|
||||
* Add default route to the given device
|
||||
*
|
||||
*/
|
||||
void
|
||||
nm_system_device_replace_default_route (const char *iface,
|
||||
guint32 gw,
|
||||
guint32 mss)
|
||||
{
|
||||
nm_generic_device_replace_default_route (iface, gw, mss);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_has_active_routes
|
||||
*
|
||||
|
|
|
@ -158,22 +158,6 @@ void nm_system_restart_mdns_responder (void)
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_system_device_replace_default_route
|
||||
*
|
||||
* Add default route to the given device
|
||||
*
|
||||
*/
|
||||
void
|
||||
nm_system_device_replace_default_route (const char *iface,
|
||||
guint32 gw,
|
||||
guint32 mss)
|
||||
{
|
||||
nm_generic_device_replace_default_route (iface, gw, mss);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_system_flush_loopback_routes
|
||||
*
|
||||
|
|
|
@ -83,21 +83,6 @@ void nm_system_device_flush_ip4_routes_with_iface (const char *iface)
|
|||
nm_generic_device_flush_ip4_routes_with_iface (iface);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nm_system_device_replace_default_route
|
||||
*
|
||||
* Add default route to the given device
|
||||
*
|
||||
*/
|
||||
void
|
||||
nm_system_device_replace_default_route (const char *iface,
|
||||
guint32 gw,
|
||||
guint32 mss)
|
||||
{
|
||||
nm_generic_device_replace_default_route (iface, gw, mss);
|
||||
}
|
||||
|
||||
/*
|
||||
* nm_system_device_has_active_routes
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue