Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame^] | 1 | From cbcb848e6d4f4e8c4aa11c80f1f3dbb7fb2d397e Mon Sep 17 00:00:00 2001 |
| 2 | From: Beniamino Galvani <bgalvani@redhat.com> |
| 3 | Date: Mon, 4 Jan 2016 14:22:01 +0100 |
| 4 | Subject: [PATCH 3/7] device: update @ip_iface only if IP interface exists |
| 5 | |
| 6 | If @ip_ifindex is zero, the IP interface has disappeared and |
| 7 | there's no point in updating @ip_iface. |
| 8 | |
| 9 | Actually, unconditionally updating @ip_iface is dangerous because it |
| 10 | breaks the assumption used by other functions (as |
| 11 | nm_device_get_ip_ifindex()) that a non-NULL @ip_iface implies a valid |
| 12 | @ip_ifindex. This was causing the scary failure: |
| 13 | |
| 14 | devices/nm-device.c:666:get_ip_iface_identifier: assertion failed: (ifindex) |
| 15 | |
| 16 | https://bugzilla.redhat.com/show_bug.cgi?id=1268617 |
| 17 | (cherry picked from commit ed536998f9530698ff3082fc5587dbeb7d3a594f) |
| 18 | --- |
| 19 | src/devices/nm-device.c | 7 ++++--- |
| 20 | 1 file changed, 4 insertions(+), 3 deletions(-) |
| 21 | |
| 22 | diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c |
| 23 | index bb39ca5..4413e92 100644 |
| 24 | --- a/src/devices/nm-device.c |
| 25 | +++ b/src/devices/nm-device.c |
| 26 | @@ -1526,12 +1526,13 @@ device_ip_link_changed (NMDevice *self) |
| 27 | { |
| 28 | NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); |
| 29 | const NMPlatformLink *pllink; |
| 30 | - int ip_ifindex; |
| 31 | |
| 32 | priv->device_ip_link_changed_id = 0; |
| 33 | |
| 34 | - ip_ifindex = nm_device_get_ip_ifindex (self); |
| 35 | - pllink = nm_platform_link_get (NM_PLATFORM_GET, ip_ifindex); |
| 36 | + if (!priv->ip_ifindex) |
| 37 | + return G_SOURCE_REMOVE; |
| 38 | + |
| 39 | + pllink = nm_platform_link_get (NM_PLATFORM_GET, priv->ip_ifindex); |
| 40 | if (!pllink) |
| 41 | return G_SOURCE_REMOVE; |
| 42 | |
| 43 | -- |
| 44 | 2.5.0 |
| 45 | |