2004-11-16 02:41:53 +00:00
|
|
|
/* NetworkManager -- Network link manager
|
|
|
|
|
*
|
|
|
|
|
* Dan Williams <dcbw@redhat.com>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2004 Red Hat, Inc.
|
|
|
|
|
* Copyright (C) 1996 - 1997 Yoichi Hariguchi <yoichi@fore.com>
|
|
|
|
|
* Copyright (C) January, 1998 Sergei Viznyuk <sv@phystech.com>
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
#include <net/route.h>
|
|
|
|
|
#include <arpa/nameser.h>
|
2005-04-15 15:43:42 +00:00
|
|
|
#include <arpa/inet.h>
|
2004-11-16 02:41:53 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <syslog.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <resolv.h>
|
|
|
|
|
#include <netdb.h>
|
|
|
|
|
#include <glib.h>
|
2005-10-28 03:16:02 +00:00
|
|
|
#include <pthread.h>
|
2004-11-16 02:41:53 +00:00
|
|
|
#include "NetworkManagerSystem.h"
|
2005-12-31 08:21:24 +00:00
|
|
|
#include "nm-device.h"
|
2005-04-06 16:45:48 +00:00
|
|
|
#include "NetworkManagerUtils.h"
|
2005-03-14 Ray Strode <rstrode@redhat.com>
Fourth (probably working) cut at porting to
dbus 0.30 api and new hal. This cut adds
some new logging macros to make debugging
easier.
* dispatcher-daemon/NetworkManagerDispatcher.c:
* info-daemon/NetworkmanagerInfo.c:
* info-daemon/NetworkManagerInfoPassphraseDialog.c:
* info-daemon/NetworkManagerInfoVPN.c:
* src/NetworkManager.c:
* src/NetworkManagerAP.c:
* src/NetworkManagerAPList.c:
* src/NetworkManagerDHCP.c:
* src/NetworkManagerDbus.c:
* src/NetworkManagerDevice.c:
* src/NetworkManagerPolicy.c:
* src/NetworkManagerSystem.c:
* src/NetworkManagerUtils.c:
* src/NetworkManagerWireless.c:
* src/autoip.c:
* src/nm-dbus-nm.c:
* src/backends/NetworkManagerDebian.c:
* src/backends/NetworkManagerGentoo.c:
* src/backends/NetworkManagerRedHat.c:
* src/backends/NetworkManagerSlackware.c:
use new logging macros.
* dispatcher-daemon/NetworkManagerDispatcher.c:
(nmd_dbus_filter): s/dbus_free/g_free/
* info-daemon/Makefile.am: link in utils library.
* info-daemon/NetworkmanagerInfo.c: use new logging
macros.
(nmi_dbus_get_network): don't assume enumerations
are 32-bit.
(nmi_dbus_nmi_message_handler): don't free what
doesn't belong to us.
* libnm_glib/libnm_glib.c:
(libnm_glib_get_nm_status):
(libnm_glib_init): don't free what doesn't
belong to us.
(libnm_glib_dbus): strdup result, so it doesn't get
lost when message is unref'd.
* panel-applet/NMWirelessAppletDbus.c:
(nmwa_dbus_update_devices): s/dbus_free/g_free/
* src/NetworkManager.c:
(nm_monitor_wired_link_state): request initial status
dump of all cards when we start up, instead of relying
on /sys/.../carrier.
(nm_info_handler), (nm_set_up_log_handlers):
log handlers to specify what syslog priorites
the logging macros default to.
* src/NetworkManagerAPList.c:
(nm_ap_list_populate_from_nmi):
s/dbus_free_string_array/g_strfreev/
* src/NetworkManagerDbus.c:
(nm_dbus_get_network_object):
validate d-bus message argument types.
Advance message iterator after reading argument,
prepend instead of append to GSList.
* src/NetworkManagerDevice.c:
(nm_device_probe_wired_link_status):
remove redundant /sys in /sys path. remove wrong
contents == NULL means has carrier assumption.
* src/nm-netlink-monitor.c
(nm_netlink_monitor_request_status): implement
function to ask kernel to dump interface link
status over netlink socket.
* test/*.c: s/dbus_free/g_free/
* utils/nm-utils.h:
(nm_print_backtrace): new macro to print backtrace.
(nm_get_timestamp): new macro to get sub-second precise
unix timestamp.
(nm_info), (nm_debug), (nm_warning), (nm_error):
new logging functions. nm_info just prints,
nm_debug includes timestamp and function,
nm_warning includes function, nm_error includes
backtrace and sigtrap.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@497 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2005-03-15 05:30:15 +00:00
|
|
|
#include "nm-utils.h"
|
2004-11-16 02:41:53 +00:00
|
|
|
|
2005-10-28 03:16:02 +00:00
|
|
|
#include <netlink/route/addr.h>
|
|
|
|
|
#include <netlink/netlink.h>
|
|
|
|
|
#include <netlink/utils.h>
|
|
|
|
|
#include <netlink/route/link.h>
|
2005-04-15 15:43:42 +00:00
|
|
|
|
|
|
|
|
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
/*
|
|
|
|
|
* nm_system_device_set_ip4_route
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static gboolean nm_system_device_set_ip4_route (NMDevice *dev, int ip4_gateway, int ip4_dest, int ip4_netmask, int mss)
|
|
|
|
|
{
|
|
|
|
|
NMSock * sk;
|
|
|
|
|
gboolean success = FALSE;
|
|
|
|
|
struct rtentry rtent;
|
|
|
|
|
struct sockaddr_in *p;
|
|
|
|
|
const char * iface;
|
|
|
|
|
int err;
|
|
|
|
|
|
|
|
|
|
iface = nm_device_get_iface (dev);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Zero is not a legal gateway and the ioctl will fail. But zero is a
|
|
|
|
|
* way of saying "no route" so we just return here. Hopefully the
|
|
|
|
|
* caller flushed the routes, first.
|
|
|
|
|
*/
|
|
|
|
|
if (ip4_gateway == 0)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
if ((sk = nm_dev_sock_open (dev, NETWORK_CONTROL, __FUNCTION__, NULL)) == NULL)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
memset (&rtent, 0, sizeof (struct rtentry));
|
|
|
|
|
p = (struct sockaddr_in *) &rtent.rt_dst;
|
|
|
|
|
p->sin_family = AF_INET;
|
|
|
|
|
p->sin_addr.s_addr = ip4_dest;
|
|
|
|
|
p = (struct sockaddr_in *) &rtent.rt_gateway;
|
|
|
|
|
p->sin_family = AF_INET;
|
|
|
|
|
p->sin_addr.s_addr = ip4_gateway;
|
|
|
|
|
p = (struct sockaddr_in *) &rtent.rt_genmask;
|
|
|
|
|
p->sin_family = AF_INET;
|
|
|
|
|
p->sin_addr.s_addr = ip4_netmask;
|
|
|
|
|
rtent.rt_dev = (char *)iface;
|
|
|
|
|
rtent.rt_metric = 1;
|
|
|
|
|
rtent.rt_window = 0;
|
|
|
|
|
rtent.rt_flags = RTF_UP | RTF_GATEWAY | (rtent.rt_window ? RTF_WINDOW : 0);
|
|
|
|
|
|
|
|
|
|
if (mss)
|
|
|
|
|
{
|
|
|
|
|
rtent.rt_flags |= RTF_MTU;
|
|
|
|
|
rtent.rt_mtu = mss;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-25 22:37:41 +00:00
|
|
|
nm_ioctl_info ("%s: About to CADDRT\n", nm_device_get_iface (dev));
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
err = ioctl (nm_dev_sock_get_fd (sk), SIOCADDRT, &rtent);
|
2006-05-25 22:37:41 +00:00
|
|
|
nm_ioctl_info ("%s: About to CADDRT\n", nm_device_get_iface (dev));
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
|
|
|
|
|
if (err == -1)
|
|
|
|
|
{
|
|
|
|
|
if (errno == ENETUNREACH) /* possibly gateway is over the bridge */
|
|
|
|
|
{ /* try adding a route to gateway first */
|
|
|
|
|
struct rtentry rtent2;
|
|
|
|
|
|
|
|
|
|
memset (&rtent2, 0, sizeof(struct rtentry));
|
|
|
|
|
p = (struct sockaddr_in *)&rtent2.rt_dst;
|
|
|
|
|
p->sin_family = AF_INET;
|
|
|
|
|
p = (struct sockaddr_in *)&rtent2.rt_gateway;
|
|
|
|
|
p->sin_family = AF_INET;
|
|
|
|
|
p->sin_addr.s_addr = ip4_gateway;
|
|
|
|
|
p = (struct sockaddr_in *)&rtent2.rt_genmask;
|
|
|
|
|
p->sin_family = AF_INET;
|
|
|
|
|
p->sin_addr.s_addr = 0xffffffff;
|
|
|
|
|
rtent2.rt_dev = (char *)iface;
|
|
|
|
|
rtent2.rt_metric = 0;
|
|
|
|
|
rtent2.rt_flags = RTF_UP | RTF_HOST;
|
|
|
|
|
|
|
|
|
|
if (mss)
|
|
|
|
|
{
|
|
|
|
|
rtent2.rt_flags |= RTF_MTU;
|
|
|
|
|
rtent2.rt_mtu = mss;
|
|
|
|
|
}
|
|
|
|
|
|
2006-05-25 22:37:41 +00:00
|
|
|
nm_ioctl_info ("%s: About to CADDRT (2)\n", nm_device_get_iface (dev));
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
err = ioctl (nm_dev_sock_get_fd (sk), SIOCADDRT, &rtent2);
|
2006-05-25 22:37:41 +00:00
|
|
|
nm_ioctl_info ("%s: About to CADDRT (2)\n", nm_device_get_iface (dev));
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
|
|
|
|
|
if (!err)
|
|
|
|
|
{
|
2006-05-25 22:37:41 +00:00
|
|
|
nm_ioctl_info ("%s: About to CADDRT (3)\n", nm_device_get_iface (dev));
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
err = ioctl (nm_dev_sock_get_fd (sk), SIOCADDRT, &rtent);
|
2006-05-25 22:37:41 +00:00
|
|
|
nm_ioctl_info ("%s: About to CADDRT (3)\n", nm_device_get_iface (dev));
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
|
|
|
|
|
if (!err)
|
|
|
|
|
success = TRUE;
|
|
|
|
|
else
|
|
|
|
|
nm_warning ("Failed to set IPv4 default route on '%s': %s", iface, strerror (errno));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
nm_warning ("Failed to set IPv4 default route on '%s': %s", iface, strerror (errno));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
success = TRUE;
|
|
|
|
|
|
|
|
|
|
nm_dev_sock_close (sk);
|
|
|
|
|
return success;
|
|
|
|
|
}
|
2005-04-15 15:43:42 +00:00
|
|
|
|
|
|
|
|
|
2005-10-28 03:16:02 +00:00
|
|
|
static struct nl_cache * get_link_cache (struct nl_handle *nlh)
|
|
|
|
|
{
|
|
|
|
|
static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
|
|
|
|
|
static struct nl_cache * link_cache = NULL;
|
|
|
|
|
|
|
|
|
|
g_static_mutex_lock (&mutex);
|
|
|
|
|
if (!link_cache)
|
|
|
|
|
link_cache = rtnl_link_alloc_cache (nlh);
|
|
|
|
|
if (!link_cache)
|
|
|
|
|
nm_warning ("ERROR: couldn't allocate rtnl link cache!");
|
|
|
|
|
else
|
|
|
|
|
nl_cache_update (nlh, link_cache);
|
|
|
|
|
g_static_mutex_unlock (&mutex);
|
2005-04-15 15:43:42 +00:00
|
|
|
|
2005-10-28 03:16:02 +00:00
|
|
|
return link_cache;
|
|
|
|
|
}
|
2005-04-15 15:43:42 +00:00
|
|
|
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
|
2005-10-28 03:16:02 +00:00
|
|
|
static void iface_to_rtnl_index (const char *iface, struct nl_handle *nlh, struct rtnl_addr *addr)
|
|
|
|
|
{
|
|
|
|
|
struct nl_cache * cache = NULL;
|
|
|
|
|
int i;
|
2005-05-04 21:23:09 +00:00
|
|
|
|
2005-10-28 03:16:02 +00:00
|
|
|
g_return_if_fail (iface != NULL);
|
|
|
|
|
g_return_if_fail (nlh != NULL);
|
|
|
|
|
g_return_if_fail (addr != NULL);
|
|
|
|
|
|
|
|
|
|
if ((cache = get_link_cache (nlh)))
|
|
|
|
|
{
|
|
|
|
|
i = rtnl_link_name2i (cache, iface);
|
|
|
|
|
if (RTNL_LINK_NOT_FOUND != i)
|
|
|
|
|
rtnl_addr_set_ifindex (addr, i);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
nm_warning ("iface_to_rtnl_link() couldn't allocate link cache.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct rtnl_link * iface_to_rtnl_link (const char *iface, struct nl_handle *nlh)
|
|
|
|
|
{
|
|
|
|
|
struct nl_cache * cache = NULL;
|
2006-01-11 Robert Love <rml@novell.com>
* configure.in: Add the gcc flags '-Wshadow' and '-Wfloat-equal'.
* gnome/applet/applet.c, gnome/vpn-properties/nm-vpn-properties.c,
src/NetworkManagerAPList.c, src/NetworkManagerDbus.c,
src/NetworkManagerPolicy.c, src/NetworkManagerSystem.c,
src/nm-dbus-device.c, src/nm-device-802-3-ethernet.c,
src/nm-ip4-config.c, src/vpn-manager/nm-vpn-manager.c,
test/nmtestdevices.c: Fix shadowed variable usage as appropriate.
* src/nm-device-802-11-wireless.c: Fix floating point comparison by
comparing values within DBL_EPSILON. Also fix shadowed variable
usage.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1318 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-01-11 21:07:29 +00:00
|
|
|
struct rtnl_link * have_link = NULL;
|
2005-10-28 03:16:02 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (iface != NULL, NULL);
|
|
|
|
|
g_return_val_if_fail (nlh != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
if ((cache = get_link_cache (nlh)))
|
2006-01-11 Robert Love <rml@novell.com>
* configure.in: Add the gcc flags '-Wshadow' and '-Wfloat-equal'.
* gnome/applet/applet.c, gnome/vpn-properties/nm-vpn-properties.c,
src/NetworkManagerAPList.c, src/NetworkManagerDbus.c,
src/NetworkManagerPolicy.c, src/NetworkManagerSystem.c,
src/nm-dbus-device.c, src/nm-device-802-3-ethernet.c,
src/nm-ip4-config.c, src/vpn-manager/nm-vpn-manager.c,
test/nmtestdevices.c: Fix shadowed variable usage as appropriate.
* src/nm-device-802-11-wireless.c: Fix floating point comparison by
comparing values within DBL_EPSILON. Also fix shadowed variable
usage.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1318 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-01-11 21:07:29 +00:00
|
|
|
have_link = rtnl_link_get_by_name (cache, iface);
|
2005-10-28 03:16:02 +00:00
|
|
|
else
|
|
|
|
|
nm_warning ("iface_to_rtnl_link() couldn't allocate link cache.");
|
|
|
|
|
|
2006-01-11 Robert Love <rml@novell.com>
* configure.in: Add the gcc flags '-Wshadow' and '-Wfloat-equal'.
* gnome/applet/applet.c, gnome/vpn-properties/nm-vpn-properties.c,
src/NetworkManagerAPList.c, src/NetworkManagerDbus.c,
src/NetworkManagerPolicy.c, src/NetworkManagerSystem.c,
src/nm-dbus-device.c, src/nm-device-802-3-ethernet.c,
src/nm-ip4-config.c, src/vpn-manager/nm-vpn-manager.c,
test/nmtestdevices.c: Fix shadowed variable usage as appropriate.
* src/nm-device-802-11-wireless.c: Fix floating point comparison by
comparing values within DBL_EPSILON. Also fix shadowed variable
usage.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1318 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-01-11 21:07:29 +00:00
|
|
|
return have_link;
|
2005-10-28 03:16:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static struct nl_handle * new_nl_handle (void)
|
|
|
|
|
{
|
|
|
|
|
struct nl_handle * nlh = NULL;
|
|
|
|
|
|
|
|
|
|
nlh = nl_handle_alloc_nondefault(NL_CB_VERBOSE);
|
|
|
|
|
nl_handle_set_pid (nlh, (pthread_self() << 16 | getpid()));
|
|
|
|
|
if (nl_connect(nlh, NETLINK_ROUTE) < 0)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "new_nl_handle: couldn't connecto to netlink: %s\n", nl_geterror());
|
|
|
|
|
nl_handle_destroy (nlh);
|
|
|
|
|
nlh = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nlh;
|
|
|
|
|
}
|
2005-04-15 15:43:42 +00:00
|
|
|
|
|
|
|
|
|
2006-03-05 Dan Williams <dcbw@redhat.com>
Process netlink messages in device subclasses rather than in
NetworkManager.c. Also add support for recognizing Wireless Events.
* configure.in
- Find GLIB_GENMARSHAL
* src/Makefile.am
- Since we're marshalling custom types for wireless event signals,
we get to create our own marshallers using GLIB_GENMARSHAL
* src/NetworkManager.c
- (nm_monitor_wired_link_state): renamed to nm_monitor_setup
- (nm_monitor_setup): renamed from nm_monitor_wired_link_state, and
cut down somewhat. We no longer process signals here.
- (nm_data_new): create the netlink monitor here, and remove a
useless call to nm_policy_schedule_device_change_check()
- (nm_data_free): get rid of the netlink monitor here
- (nm_device_link_activated, nm_device_link_deactivated): removed
- (main): don't create the netlink monitor here, let nm_data_new
do that. Call nm_policy_schedule_device_change_check() right
before we jump to the mainloop to figure out which device
to use first
* src/NetworkManagerSystem.[ch]
- (nm_system_get_rtnl_index_from_iface, nm_system_get_iface_from_rtnl_index):
convert back and forth from interface names to interface
indexes
* src/nm-device-802-11-wireless.c
- (real_init): connect to wireless-event signals from the netlink
monitor object
- (nm_device_802_11_wireless_event): new function, schedule handler
for wireless event signals from the netlink monitor object. We
want the handler to run in the device's context
- (wireless_event_helper): handle wireless-event signals from netlink
- (nm_device_802_11_wireless_dispose): disconnect wireless-event
signal handler
* src/nm-device-802-11-wireless.h
- remove unused prototype for nm_device_802_11_wireless_new
* src/nm-device-802-3-ethernet.c
- (real_init): new function; set up signal handlers for link events
- (nm_device_802_3_ethernet_link_activated): new function, schedule
handler for netlink link activated events on device's main loop
- (link_activated_helper): when we get a link activated event, set
the device's link to be active
- (nm_device_802_3_ethernet_link_deactivated): new function; schedule
handler for netlink link deactivated events on device's main loop
- (link_deactivated_helper): when we get a link deactivated event, set
the device's link to be inactive
- (nm_device_802_3_ethernet_dispose): disconnect signal handler on
dispose
* src/nm-device-802-3-ethernet.h
- remove unused prototype for nm_device_802_3_ethernet_new
* src/nm-device.[ch]
- (nm_get_device_by_iface_locked): variant of nm_get_device_by_iface
but locks the device list
- (nm_device_set_active_link): a little bit of cleanup and de-indenting
* src/nm-netlink-monitor.[ch]
- (nm_netlink_monitor_class_install_signals): New signal
"wireless-event"
- (nm_netlink_monitor_new): keep reference to NMData so we can get
at the device list
- (nm_netlink_monitor_event_handler): expand for wireless events too
* src/nm-marshal-main.c
- Include generated nm-marshal.c and nm-marshal.h
* src/nm-marshal.list
- List of custom marshal functions
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1555 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-06 01:10:58 +00:00
|
|
|
int
|
|
|
|
|
nm_system_get_rtnl_index_from_iface (const char *iface)
|
|
|
|
|
{
|
|
|
|
|
struct nl_handle * nlh = NULL;
|
|
|
|
|
struct nl_cache * cache = NULL;
|
|
|
|
|
int i = RTNL_LINK_NOT_FOUND;
|
|
|
|
|
|
|
|
|
|
nlh = new_nl_handle ();
|
|
|
|
|
if (nlh && (cache = get_link_cache (nlh)))
|
|
|
|
|
i = rtnl_link_name2i (cache, iface);
|
|
|
|
|
nl_close (nlh);
|
|
|
|
|
nl_handle_destroy (nlh);
|
|
|
|
|
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define MAX_IFACE_LEN 32
|
|
|
|
|
char *
|
|
|
|
|
nm_system_get_iface_from_rtnl_index (int rtnl_index)
|
|
|
|
|
{
|
|
|
|
|
struct nl_handle * nlh = NULL;
|
|
|
|
|
struct nl_cache * cache = NULL;
|
|
|
|
|
char * buf = NULL;
|
|
|
|
|
|
|
|
|
|
nlh = new_nl_handle ();
|
|
|
|
|
if (nlh && (cache = get_link_cache (nlh)))
|
|
|
|
|
{
|
|
|
|
|
buf = g_malloc0 (MAX_IFACE_LEN);
|
|
|
|
|
if (!rtnl_link_i2name (cache, rtnl_index, buf, MAX_IFACE_LEN - 1))
|
|
|
|
|
{
|
|
|
|
|
g_free (buf);
|
|
|
|
|
buf = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
nl_close (nlh);
|
|
|
|
|
nl_handle_destroy (nlh);
|
|
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-04-15 15:43:42 +00:00
|
|
|
/*
|
|
|
|
|
* nm_system_device_set_from_ip4_config
|
|
|
|
|
*
|
|
|
|
|
* Set IPv4 configuration of the device from an NMIP4Config object.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
gboolean nm_system_device_set_from_ip4_config (NMDevice *dev)
|
|
|
|
|
{
|
2005-10-28 03:16:02 +00:00
|
|
|
NMData * app_data;
|
|
|
|
|
NMIP4Config * config;
|
|
|
|
|
struct nl_handle * nlh = NULL;
|
|
|
|
|
struct rtnl_addr * addr = NULL;
|
|
|
|
|
int err;
|
2005-04-15 15:43:42 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (dev != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
app_data = nm_device_get_app_data (dev);
|
|
|
|
|
g_return_val_if_fail (app_data != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
config = nm_device_get_ip4_config (dev);
|
|
|
|
|
g_return_val_if_fail (config != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
nm_system_delete_default_route ();
|
|
|
|
|
nm_system_device_flush_addresses (dev);
|
|
|
|
|
nm_system_device_flush_routes (dev);
|
|
|
|
|
nm_system_flush_arp_cache ();
|
|
|
|
|
|
2005-10-28 03:16:02 +00:00
|
|
|
nlh = new_nl_handle ();
|
|
|
|
|
|
|
|
|
|
if ((addr = nm_ip4_config_to_rtnl_addr (config, NM_RTNL_ADDR_DEFAULT)))
|
|
|
|
|
{
|
|
|
|
|
iface_to_rtnl_index (nm_device_get_iface (dev), nlh, addr);
|
|
|
|
|
if ((err = rtnl_addr_add (nlh, addr, 0)) < 0)
|
|
|
|
|
nm_warning ("nm_system_device_set_from_ip4_config(%s): error %d returned from rtnl_addr_add():\n%s", nm_device_get_iface (dev), err, nl_geterror());
|
|
|
|
|
rtnl_addr_put (addr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
nm_warning ("nm_system_device_set_from_ip4_config(): couldn't create rtnl address!\n");
|
|
|
|
|
|
|
|
|
|
nl_close (nlh);
|
|
|
|
|
nl_handle_destroy (nlh);
|
|
|
|
|
|
2005-04-15 15:43:42 +00:00
|
|
|
sleep (1);
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
nm_system_device_set_ip4_route (dev, nm_ip4_config_get_gateway (config), 0, 0, nm_ip4_config_get_mss (config));
|
2005-04-15 15:43:42 +00:00
|
|
|
|
2005-09-28 14:42:57 +00:00
|
|
|
nm_named_manager_add_ip4_config (app_data->named_manager, config);
|
2005-04-15 15:43:42 +00:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-05-16 12:57:08 +00:00
|
|
|
/*
|
|
|
|
|
* validate_ip4_route
|
|
|
|
|
*
|
|
|
|
|
* Ensure that IP4 routes are in the correct format
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
static char *validate_ip4_route (const char *route)
|
|
|
|
|
{
|
|
|
|
|
char * ret = NULL;
|
|
|
|
|
char * temp = NULL;
|
|
|
|
|
int slash_pos = -1;
|
|
|
|
|
char * p = NULL;
|
|
|
|
|
int len, i;
|
|
|
|
|
int dot_count = 0;
|
|
|
|
|
gboolean have_slash = FALSE;
|
|
|
|
|
struct in_addr addr;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (route != NULL, NULL);
|
|
|
|
|
|
|
|
|
|
len = strlen (route);
|
|
|
|
|
/* Minimum length, ie 1.1.1.1/8 */
|
|
|
|
|
if (len < 9)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
|
{
|
|
|
|
|
/* Ensure there is only one slash */
|
|
|
|
|
if (route[i] == '/')
|
|
|
|
|
{
|
|
|
|
|
if (have_slash)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
have_slash = TRUE;
|
|
|
|
|
slash_pos = i;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (route[i] == '.')
|
|
|
|
|
{
|
|
|
|
|
if (dot_count >= 4)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
dot_count++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!isdigit (route[i]))
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Make sure there is at least one slash and 3 dots */
|
|
|
|
|
if (!have_slash || !slash_pos || (dot_count != 3))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
/* Valid IP address part */
|
|
|
|
|
temp = g_strdup (route);
|
|
|
|
|
temp[slash_pos] = '\0';
|
|
|
|
|
memset (&addr, 0, sizeof (struct in_addr));
|
|
|
|
|
if (inet_aton (temp, &addr) == 0)
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
/* Ensure the network # is valid */
|
|
|
|
|
p = temp + slash_pos + 1;
|
|
|
|
|
i = (int) strtol (p, NULL, 10);
|
|
|
|
|
if ((i < 0) || (i > 32))
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
|
|
/* Success! */
|
|
|
|
|
ret = g_strdup (route);
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
g_free (temp);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-04-15 15:43:42 +00:00
|
|
|
/*
|
|
|
|
|
* nm_system_vpn_device_set_from_ip4_config
|
|
|
|
|
*
|
|
|
|
|
* Set IPv4 configuration of a VPN device from an NMIP4Config object.
|
|
|
|
|
*
|
|
|
|
|
*/
|
2005-05-16 12:57:08 +00:00
|
|
|
gboolean nm_system_vpn_device_set_from_ip4_config (NMNamedManager *named, NMDevice *active_device, const char *iface, NMIP4Config *config, char **routes, int num_routes)
|
2005-04-15 15:43:42 +00:00
|
|
|
{
|
2005-10-28 03:16:02 +00:00
|
|
|
NMIP4Config * ad_config = NULL;
|
|
|
|
|
struct nl_handle * nlh = NULL;
|
|
|
|
|
struct rtnl_addr * addr = NULL;
|
|
|
|
|
struct rtnl_link * request = NULL;
|
2005-04-15 15:43:42 +00:00
|
|
|
|
|
|
|
|
g_return_val_if_fail (config != NULL, FALSE);
|
|
|
|
|
|
2005-09-28 14:42:57 +00:00
|
|
|
/* Set up a route to the VPN gateway through the real network device */
|
2005-04-15 15:43:42 +00:00
|
|
|
if (active_device && (ad_config = nm_device_get_ip4_config (active_device)))
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
nm_system_device_set_ip4_route (active_device, nm_ip4_config_get_gateway (ad_config), nm_ip4_config_get_gateway (config), 0xFFFFFFFF, nm_ip4_config_get_mss (config));
|
2005-04-15 15:43:42 +00:00
|
|
|
|
2006-02-02 15:07:35 +00:00
|
|
|
if (iface != NULL && strlen (iface))
|
2006-01-03 20:58:07 +00:00
|
|
|
{
|
2006-06-09 14:24:19 +00:00
|
|
|
nm_system_device_set_up_down_with_iface (iface, TRUE);
|
2005-04-15 15:43:42 +00:00
|
|
|
|
2006-01-03 20:58:07 +00:00
|
|
|
nlh = new_nl_handle ();
|
2005-10-28 03:16:02 +00:00
|
|
|
|
2006-01-03 20:58:07 +00:00
|
|
|
if ((addr = nm_ip4_config_to_rtnl_addr (config, NM_RTNL_ADDR_PTP_DEFAULT)))
|
|
|
|
|
{
|
|
|
|
|
int err = 0;
|
|
|
|
|
iface_to_rtnl_index (iface, nlh, addr);
|
|
|
|
|
if ((err = rtnl_addr_add (nlh, addr, 0)) < 0)
|
2006-01-16 21:02:16 +00:00
|
|
|
nm_warning ("nm_system_device_set_from_ip4_config(): error %d returned from rtnl_addr_add():\n%s", err, nl_geterror());
|
2006-01-03 20:58:07 +00:00
|
|
|
rtnl_addr_put (addr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
nm_warning ("nm_system_vpn_device_set_from_ip4_config(): couldn't create rtnl address!\n");
|
2005-10-28 03:16:02 +00:00
|
|
|
|
2006-01-03 20:58:07 +00:00
|
|
|
/* Set the MTU */
|
|
|
|
|
if ((request = rtnl_link_alloc ()))
|
|
|
|
|
{
|
|
|
|
|
struct rtnl_link * old;
|
2005-10-28 03:16:02 +00:00
|
|
|
|
2006-01-03 20:58:07 +00:00
|
|
|
old = iface_to_rtnl_link (iface, nlh);
|
|
|
|
|
rtnl_link_set_mtu (request, 1412);
|
|
|
|
|
rtnl_link_change (nlh, old, request, 0);
|
2005-10-28 03:16:02 +00:00
|
|
|
|
2006-01-03 20:58:07 +00:00
|
|
|
rtnl_link_put (old);
|
|
|
|
|
rtnl_link_put (request);
|
|
|
|
|
}
|
2005-10-28 03:16:02 +00:00
|
|
|
|
2006-01-03 20:58:07 +00:00
|
|
|
nl_close (nlh);
|
|
|
|
|
nl_handle_destroy (nlh);
|
2005-10-28 03:16:02 +00:00
|
|
|
|
2006-01-03 20:58:07 +00:00
|
|
|
sleep (1);
|
2005-10-28 03:16:02 +00:00
|
|
|
|
2006-01-03 20:58:07 +00:00
|
|
|
nm_system_device_flush_routes_with_iface (iface);
|
|
|
|
|
if (num_routes <= 0)
|
|
|
|
|
{
|
|
|
|
|
nm_system_delete_default_route ();
|
|
|
|
|
nm_system_device_add_default_route_via_device_with_iface (iface);
|
|
|
|
|
}
|
|
|
|
|
else
|
2005-05-16 12:57:08 +00:00
|
|
|
{
|
2006-01-03 20:58:07 +00:00
|
|
|
int i;
|
|
|
|
|
for (i = 0; i < num_routes; i++)
|
2005-05-16 12:57:08 +00:00
|
|
|
{
|
2006-01-03 20:58:07 +00:00
|
|
|
char *valid_ip4_route;
|
|
|
|
|
|
|
|
|
|
/* Make sure the route is valid, otherwise it's a security risk as the route
|
|
|
|
|
* text is simply taken from the user, and passed directly to system(). If
|
|
|
|
|
* we did not check the route, think of:
|
|
|
|
|
*
|
|
|
|
|
* system("/sbin/ip route add `rm -rf /` dev eth0")
|
|
|
|
|
*
|
|
|
|
|
* where `rm -rf /` was the route text. As UID 0 (root), we have to be careful.
|
|
|
|
|
*/
|
|
|
|
|
if ((valid_ip4_route = validate_ip4_route (routes[i])))
|
|
|
|
|
{
|
|
|
|
|
nm_system_device_add_route_via_device_with_iface (iface, valid_ip4_route);
|
|
|
|
|
g_free (valid_ip4_route);
|
|
|
|
|
}
|
2005-05-16 12:57:08 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-04-15 15:43:42 +00:00
|
|
|
|
2005-09-28 14:42:57 +00:00
|
|
|
nm_named_manager_add_ip4_config (named, config);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_system_vpn_device_unset_from_ip4_config
|
|
|
|
|
*
|
|
|
|
|
* Unset an IPv4 configuration of a VPN device from an NMIP4Config object.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
gboolean nm_system_vpn_device_unset_from_ip4_config (NMNamedManager *named, NMDevice *active_device, const char *iface, NMIP4Config *config)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (named != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (active_device != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (config != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
nm_named_manager_remove_ip4_config (named, config);
|
2005-04-15 15:43:42 +00:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* nm_system_device_set_up_down
|
|
|
|
|
*
|
|
|
|
|
* Mark the device as up or down.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
gboolean nm_system_device_set_up_down (NMDevice *dev, gboolean up)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (dev != NULL, FALSE);
|
|
|
|
|
|
2006-06-09 14:24:19 +00:00
|
|
|
return nm_system_device_set_up_down_with_iface (nm_device_get_iface (dev), up);
|
2005-04-15 15:43:42 +00:00
|
|
|
}
|
|
|
|
|
|
2006-06-09 14:24:19 +00:00
|
|
|
gboolean nm_system_device_set_up_down_with_iface (const char *iface, gboolean up)
|
2005-04-15 15:43:42 +00:00
|
|
|
{
|
2005-10-28 03:16:02 +00:00
|
|
|
gboolean success = FALSE;
|
|
|
|
|
struct nl_handle * nlh = NULL;
|
|
|
|
|
struct rtnl_link * request = NULL;
|
|
|
|
|
struct rtnl_link * old = NULL;
|
2004-11-16 02:41:53 +00:00
|
|
|
|
2005-04-15 15:43:42 +00:00
|
|
|
g_return_val_if_fail (iface != NULL, FALSE);
|
2004-11-16 02:41:53 +00:00
|
|
|
|
2005-10-28 03:16:02 +00:00
|
|
|
if (!(nlh = new_nl_handle ()))
|
2004-11-16 02:41:53 +00:00
|
|
|
return FALSE;
|
|
|
|
|
|
2005-10-28 03:16:02 +00:00
|
|
|
if (!(request = rtnl_link_alloc ()))
|
|
|
|
|
goto out;
|
2004-11-16 02:41:53 +00:00
|
|
|
|
2005-12-01 21:42:41 +00:00
|
|
|
if (up)
|
|
|
|
|
rtnl_link_set_flags (request, IFF_UP);
|
|
|
|
|
else
|
|
|
|
|
rtnl_link_unset_flags (request, IFF_UP);
|
|
|
|
|
|
2005-10-28 03:16:02 +00:00
|
|
|
old = iface_to_rtnl_link (iface, nlh);
|
2005-12-01 21:42:41 +00:00
|
|
|
if (old)
|
|
|
|
|
rtnl_link_change (nlh, old, request, 0);
|
2004-11-16 02:41:53 +00:00
|
|
|
|
2005-10-28 03:16:02 +00:00
|
|
|
rtnl_link_put (old);
|
|
|
|
|
rtnl_link_put (request);
|
2004-11-16 02:41:53 +00:00
|
|
|
|
2005-10-28 03:16:02 +00:00
|
|
|
success = TRUE;
|
2005-06-19 19:07:47 +00:00
|
|
|
|
2005-10-28 03:16:02 +00:00
|
|
|
out:
|
|
|
|
|
nl_close (nlh);
|
|
|
|
|
nl_handle_destroy (nlh);
|
2004-11-16 02:41:53 +00:00
|
|
|
|
2005-06-19 19:07:47 +00:00
|
|
|
return success;
|
2004-11-16 02:41:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-04-15 15:43:42 +00:00
|
|
|
/*
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
* nm_system_set_mtu
|
2005-04-15 15:43:42 +00:00
|
|
|
*
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
* Set the MTU for a given device.
|
2005-04-15 15:43:42 +00:00
|
|
|
*/
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
void nm_system_set_mtu (NMDevice *dev)
|
2005-04-15 15:43:42 +00:00
|
|
|
{
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
struct rtnl_link * request;
|
|
|
|
|
struct rtnl_link * old;
|
|
|
|
|
unsigned long mtu;
|
|
|
|
|
struct nl_handle * nlh;
|
|
|
|
|
const char * iface;
|
2004-11-16 02:41:53 +00:00
|
|
|
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
mtu = nm_system_get_mtu (dev);
|
|
|
|
|
if (!mtu)
|
|
|
|
|
return;
|
2005-06-19 19:07:47 +00:00
|
|
|
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
nlh = new_nl_handle ();
|
|
|
|
|
if (!nlh)
|
|
|
|
|
return;
|
2004-11-16 02:41:53 +00:00
|
|
|
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
request = rtnl_link_alloc ();
|
|
|
|
|
if (!request)
|
|
|
|
|
goto out_nl_close;
|
2005-06-19 19:07:47 +00:00
|
|
|
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
iface = nm_device_get_iface (dev);
|
|
|
|
|
old = iface_to_rtnl_link (iface, nlh);
|
|
|
|
|
if (!old)
|
|
|
|
|
goto out_request;
|
2005-06-19 19:07:47 +00:00
|
|
|
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
nm_info ("Setting MTU of interface '%s' to %ld", iface, mtu);
|
|
|
|
|
rtnl_link_set_mtu (request, mtu);
|
|
|
|
|
rtnl_link_change (nlh, old, request, 0);
|
2004-11-16 02:41:53 +00:00
|
|
|
|
2006-03-29 Robert Love <rml@novell.com>
Patch by Vinay R <rvinay@novell.com> and Robert Love <rml@novell.com>,
to add support for per-route MSS and improve support for per-interface
MTU:
* src/NetworkManagerSystem.c: Modify nm_system_device_set_ip4_route to
optionally take an MSS parameter and set it for the given route.
Remove nm_system_device_set_ip4_route_with_iface. Pass in the
NMIP4Config's stored MSS, if any.
* src/nm-ip4-config.c: Add 'mtu' and 'mss' to NMIP4Config, representing
the interface's MTU and the route's MSS, respectively. Add functions
nm_ip4_config_get_mtu, nm_ip4_config_set_mtu, nm_ip4_config_get_mss,
and nm_ip4_config_set_mss for retrieving and setting the MTU and the
MSS.
* src/nm-ip4-config.h: Add prototypes for nm_ip4_config_get_mtu,
nm_ip4_config_set_mtu, nm_ip4_config_get_mss, and
nm_ip4_config_set_mss.
* src/vpn-manager/nm-vpn-service.c: Modify to receive the MSS from the
VPN daemon.
* src/backends/NetworkManager{Arch,Debian,Gentoo,RedHat,Slackware,SUSE}.c:
Change the retval of nm_system_get_mtu to guint32.
* src/dhcp-manager/nm-dhcp-manager.c: Set the MTU on the new DHCP-given
NMIP4Config to the MTU provided by the system, if any. TODO: If DHCP
servers can specify MTU's, we should set it here if the MTU was not
provided.
git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1660 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2006-03-29 19:26:53 +00:00
|
|
|
rtnl_link_put (old);
|
|
|
|
|
out_request:
|
|
|
|
|
rtnl_link_put (request);
|
|
|
|
|
out_nl_close:
|
|
|
|
|
nl_close (nlh);
|
|
|
|
|
nl_handle_destroy (nlh);
|
2004-11-16 02:41:53 +00:00
|
|
|
}
|