diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2017-11-20 11:45:26 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2017-12-11 10:52:23 +0100 |
commit | e4bdb219091004f751706aadc39e4fed21e86368 (patch) | |
tree | e476878ef16e5379fd3f5eaa5db6189fe0510811 | |
parent | 92f8f30d47d706a8a3166a7a672d7294c6280f02 (diff) | |
download | NetworkManager-e4bdb219091004f751706aadc39e4fed21e86368.tar.gz |
device: set qdiscs when device comes up
-rw-r--r-- | src/devices/nm-device.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 8b68761fc9..b26ec4939f 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -5324,6 +5324,50 @@ lldp_init (NMDevice *self, gboolean restart) } } +static gboolean +tc_commit (NMDevice *self) +{ + NMConnection *connection = NULL; + gs_unref_ptrarray GPtrArray *qdiscs = NULL; + NMSettingTCConfig *s_tc = NULL; + int ip_ifindex; + guint nqdiscs; + int i; + + connection = nm_device_get_applied_connection (self); + if (connection) + s_tc = nm_connection_get_setting_tc_config (connection); + + ip_ifindex = nm_device_get_ip_ifindex (self); + if (!ip_ifindex) + return s_tc == NULL; + + if (s_tc) { + nqdiscs = nm_setting_tc_config_get_num_qdiscs (s_tc); + qdiscs = g_ptr_array_new_full (nqdiscs, (GDestroyNotify) nmp_object_unref); + + for (i = 0; i < nqdiscs; i++) { + NMTCQdisc *s_qdisc = nm_setting_tc_config_get_qdisc (s_tc, i); + NMPObject *q = nmp_object_new (NMP_OBJECT_TYPE_QDISC, NULL); + NMPlatformQdisc *qdisc = NMP_OBJECT_CAST_QDISC (q); + + qdisc->ifindex = ip_ifindex; + qdisc->kind = nm_tc_qdisc_get_kind (s_qdisc); + qdisc->addr_family = AF_UNSPEC; + qdisc->handle = nm_tc_qdisc_get_handle (s_qdisc); + qdisc->parent = nm_tc_qdisc_get_parent (s_qdisc); + qdisc->info = 0; + + g_ptr_array_add (qdiscs, q); + } + } + + if (!nm_platform_qdisc_sync (nm_device_get_platform (self), ip_ifindex, qdiscs)) + return FALSE; + + return TRUE; +} + /* * activate_stage2_device_config * @@ -5345,6 +5389,11 @@ activate_stage2_device_config (NMDevice *self) if (!nm_device_sys_iface_state_is_external_or_assume (self)) { NMDeviceStateReason failure_reason = NM_DEVICE_STATE_REASON_NONE; + if (!tc_commit (self)) { + _LOGW (LOGD_IP6, "failed applying traffic control rules"); + nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_CONFIG_FAILED); + } + if (!nm_device_bring_up (self, FALSE, &no_firmware)) { if (no_firmware) nm_device_state_changed (self, NM_DEVICE_STATE_FAILED, NM_DEVICE_STATE_REASON_FIRMWARE_MISSING); @@ -12663,6 +12712,8 @@ nm_device_cleanup (NMDevice *self, NMDeviceStateReason reason, CleanupType clean nm_platform_ip_route_flush (platform, AF_UNSPEC, ifindex); nm_platform_ip_address_flush (platform, AF_UNSPEC, ifindex); + nm_platform_tfilter_sync (platform, ifindex, NULL); + nm_platform_qdisc_sync (platform, ifindex, NULL); } } |