From fd85ec45b92347efa38010e8b4a8f3abeae80b12 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Tue, 3 Sep 2013 14:02:59 -0400 Subject: [PATCH] platform: fix VLAN ingress/egress map setting --- src/platform/nm-linux-platform.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 6358489032..e512807446 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -1744,10 +1744,15 @@ vlan_get_info (NMPlatform *platform, int ifindex, int *parent, int *vlan_id) static gboolean vlan_set_ingress_map (NMPlatform *platform, int ifindex, int from, int to) { - auto_nl_object struct rtnl_link *change = rtnl_link_alloc (); + /* We have to use link_get() because a "blank" rtnl_link won't have the + * right data structures to be able to call rtnl_link_vlan_set_ingress_map() + * on it. (Likewise below in vlan_set_egress_map().) + */ + auto_nl_object struct rtnl_link *change = link_get (platform, ifindex); - g_assert (change); - rtnl_link_vlan_set_egress_map (change, from, to); + if (!change) + return FALSE; + rtnl_link_vlan_set_ingress_map (change, from, to); return link_change (platform, ifindex, change); } @@ -1755,9 +1760,10 @@ vlan_set_ingress_map (NMPlatform *platform, int ifindex, int from, int to) static gboolean vlan_set_egress_map (NMPlatform *platform, int ifindex, int from, int to) { - auto_nl_object struct rtnl_link *change = rtnl_link_alloc (); + auto_nl_object struct rtnl_link *change = link_get (platform, ifindex); - g_assert (change); + if (!change) + return FALSE; rtnl_link_vlan_set_egress_map (change, from, to); return link_change (platform, ifindex, change);