summaryrefslogtreecommitdiff
path: root/src/nm-default-route-manager.h
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-08-29 00:03:47 +0200
committerThomas Haller <thaller@redhat.com>2014-11-07 15:23:12 +0100
commite8824f6a5205ffcf761abd3e0897a22b254c7797 (patch)
treeaf9ee1d6a9d0988b2ba6e845a88e027da65a2c99 /src/nm-default-route-manager.h
parentcc9fad612e4885cee7099bda8c4ff21ef661ebaa (diff)
downloadNetworkManager-e8824f6a5205ffcf761abd3e0897a22b254c7797.tar.gz
policy: add manager for default routes and support multiple default routes
Up to now, NMPolicy would iterate over all devices to find the "best" device and assign the default route to that device. A better approach is to add a default route to *all* devices that are never-default=no. The relative priority is choosen according to the route metrics. If two devices receive the same metric, we want to prefer the device that activates first. That way, the default route sticks to the same device until a better device activates or the device deactivates. Hence, the order of activation is imporant in this case (as it is already now). Also, if several devices have identical metrics, increment their metrics so that every metric is unique. This makes the routing deterministic according to what we choose as best device. A special case is assumed devices. In this case we cannot adjust the metric in face of equal metrics. Add a new singleton class NMDefaultRouteManager that has a list of all devices and their default routes. The manager will order the devices by their priority and configure the routes using platform. Also update the metric for VPN connections. Later we will track VPN routes also via NMDefaultRouteManager. For now, fix the VPN metric because otherwise VPNs would always get metric 1024 (which is usually much larger then the device metrics). https://bugzilla.gnome.org/show_bug.cgi?id=735512 Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'src/nm-default-route-manager.h')
-rw-r--r--src/nm-default-route-manager.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/nm-default-route-manager.h b/src/nm-default-route-manager.h
new file mode 100644
index 0000000000..d60a2f86d4
--- /dev/null
+++ b/src/nm-default-route-manager.h
@@ -0,0 +1,64 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager -- Network link manager
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Copyright (C) 2014 Red Hat, Inc.
+ */
+
+#include <glib-object.h>
+
+#include "nm-connection.h"
+#include "nm-types.h"
+
+#ifndef __NETWORKMANAGER_DEFAULT_ROUTE_MANAGER_H__
+#define __NETWORKMANAGER_DEFAULT_ROUTE_MANAGER_H__
+
+
+#define NM_TYPE_DEFAULT_ROUTE_MANAGER (nm_default_route_manager_get_type ())
+#define NM_DEFAULT_ROUTE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEFAULT_ROUTE_MANAGER, NMDefaultRouteManager))
+#define NM_DEFAULT_ROUTE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEFAULT_ROUTE_MANAGER, NMDefaultRouteManagerClass))
+#define NM_IS_DEFAULT_ROUTE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DEFAULT_ROUTE_MANAGER))
+#define NM_IS_DEFAULT_ROUTE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEFAULT_ROUTE_MANAGER))
+#define NM_DEFAULT_ROUTE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEFAULT_ROUTE_MANAGER, NMDefaultRouteManagerClass))
+
+
+
+struct _NMDefaultRouteManager {
+ GObject parent;
+};
+
+typedef struct {
+ GObjectClass parent;
+} NMDefaultRouteManagerClass;
+
+GType nm_default_route_manager_get_type (void);
+
+NMDefaultRouteManager *nm_default_route_manager_get (void);
+
+void nm_default_route_manager_ip4_update_default_route (NMDefaultRouteManager *manager, gpointer source);
+void nm_default_route_manager_ip6_update_default_route (NMDefaultRouteManager *manager, gpointer source);
+
+void nm_default_route_manager_ip4_remove_default_route (NMDefaultRouteManager *manager, gpointer source);
+void nm_default_route_manager_ip6_remove_default_route (NMDefaultRouteManager *manager, gpointer source);
+
+gint64 nm_default_route_manager_ip4_get_effective_metric (NMDefaultRouteManager *manager, NMDevice *device);
+gint64 nm_default_route_manager_ip6_get_effective_metric (NMDefaultRouteManager *manager, NMDevice *device);
+
+gboolean nm_default_route_manager_ip4_connection_has_default_route (NMDefaultRouteManager *manager, NMConnection *connection);
+gboolean nm_default_route_manager_ip6_connection_has_default_route (NMDefaultRouteManager *manager, NMConnection *connection);
+
+#endif /* NM_DEFAULT_ROUTE_MANAGER_H */
+