summaryrefslogtreecommitdiff
path: root/src/devices/nm-device.c
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2019-12-05 10:36:54 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2020-01-13 11:33:54 +0100
commit2e21fbc1fea0db4188ae4170e2113e5babeb215d (patch)
tree5f5778860de9e82edafb00126ab74c50e39b921f /src/devices/nm-device.c
parent583f5f35026e74ab6e06cb8ddec686418a7c9ddd (diff)
downloadNetworkManager-2e21fbc1fea0db4188ae4170e2113e5babeb215d.tar.gz
core,libnm: add VRF supportbg/vrf
Add VRF support to the daemon. When the device we are activating is a VRF or a VRF's slave, put routes in the table specified by the VRF connection. Also, introduce a VRF device type in libnm.
Diffstat (limited to 'src/devices/nm-device.c')
-rw-r--r--src/devices/nm-device.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 3898d1565a..22ab17c8fb 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -2109,6 +2109,8 @@ nm_device_get_route_metric_default (NMDeviceType device_type)
return 450;
case NM_DEVICE_TYPE_PPP:
return 460;
+ case NM_DEVICE_TYPE_VRF:
+ return 470;
case NM_DEVICE_TYPE_VXLAN:
return 500;
case NM_DEVICE_TYPE_DUMMY:
@@ -2274,6 +2276,8 @@ _get_route_table (NMDevice *self,
NMSettingIPConfig *s_ip;
guint32 route_table = 0;
gboolean is_user_config = TRUE;
+ NMSettingConnection *s_con;
+ NMSettingVrf *s_vrf;
nm_assert_addr_family (addr_family);
@@ -2310,6 +2314,28 @@ _get_route_table (NMDevice *self,
}
}
+ if ( route_table == 0u
+ && connection
+ && (s_con = nm_connection_get_setting_connection (connection))
+ && (nm_streq0 (nm_setting_connection_get_slave_type (s_con), NM_SETTING_VRF_SETTING_NAME)
+ && priv->master
+ && nm_device_get_device_type (priv->master) == NM_DEVICE_TYPE_VRF)) {
+ const NMPlatformLnkVrf *lnk;
+
+ lnk = nm_platform_link_get_lnk_vrf (nm_device_get_platform (self),
+ nm_device_get_ifindex (priv->master),
+ NULL);
+
+ if (lnk)
+ route_table = lnk->table;
+ }
+
+ if ( route_table == 0u
+ && connection
+ && (s_vrf = (NMSettingVrf *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VRF))) {
+ route_table = nm_setting_vrf_get_table (s_vrf);
+ }
+
klass = NM_DEVICE_GET_CLASS (self);
if (klass->coerce_route_table)
route_table = klass->coerce_route_table (self, addr_family, route_table, is_user_config);
@@ -17152,7 +17178,7 @@ set_property (GObject *object, guint prop_id,
nm_assert (priv->type == NM_DEVICE_TYPE_UNKNOWN);
priv->type = g_value_get_uint (value);
nm_assert (priv->type > NM_DEVICE_TYPE_UNKNOWN);
- nm_assert (priv->type <= NM_DEVICE_TYPE_WIFI_P2P);
+ nm_assert (priv->type <= NM_DEVICE_TYPE_VRF);
break;
case PROP_LINK_TYPE:
/* construct-only */