diff options
-rw-r--r-- | drivers/net/macvlan.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index e03707de1eee..f4701da19a02 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c | |||
@@ -44,9 +44,10 @@ struct macvlan_port { | |||
44 | struct sk_buff_head bc_queue; | 44 | struct sk_buff_head bc_queue; |
45 | struct work_struct bc_work; | 45 | struct work_struct bc_work; |
46 | bool passthru; | 46 | bool passthru; |
47 | int count; | ||
48 | }; | 47 | }; |
49 | 48 | ||
49 | #define MACVLAN_PORT_IS_EMPTY(port) list_empty(&port->vlans) | ||
50 | |||
50 | struct macvlan_skb_cb { | 51 | struct macvlan_skb_cb { |
51 | const struct macvlan_dev *src; | 52 | const struct macvlan_dev *src; |
52 | }; | 53 | }; |
@@ -628,8 +629,7 @@ static void macvlan_uninit(struct net_device *dev) | |||
628 | 629 | ||
629 | free_percpu(vlan->pcpu_stats); | 630 | free_percpu(vlan->pcpu_stats); |
630 | 631 | ||
631 | port->count -= 1; | 632 | if (MACVLAN_PORT_IS_EMPTY(port)) |
632 | if (!port->count) | ||
633 | macvlan_port_destroy(port->dev); | 633 | macvlan_port_destroy(port->dev); |
634 | } | 634 | } |
635 | 635 | ||
@@ -931,13 +931,12 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev, | |||
931 | vlan->flags = nla_get_u16(data[IFLA_MACVLAN_FLAGS]); | 931 | vlan->flags = nla_get_u16(data[IFLA_MACVLAN_FLAGS]); |
932 | 932 | ||
933 | if (vlan->mode == MACVLAN_MODE_PASSTHRU) { | 933 | if (vlan->mode == MACVLAN_MODE_PASSTHRU) { |
934 | if (port->count) | 934 | if (!MACVLAN_PORT_IS_EMPTY(port)) |
935 | return -EINVAL; | 935 | return -EINVAL; |
936 | port->passthru = true; | 936 | port->passthru = true; |
937 | eth_hw_addr_inherit(dev, lowerdev); | 937 | eth_hw_addr_inherit(dev, lowerdev); |
938 | } | 938 | } |
939 | 939 | ||
940 | port->count += 1; | ||
941 | err = register_netdevice(dev); | 940 | err = register_netdevice(dev); |
942 | if (err < 0) | 941 | if (err < 0) |
943 | goto destroy_port; | 942 | goto destroy_port; |
@@ -955,8 +954,7 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev, | |||
955 | unregister_netdev: | 954 | unregister_netdev: |
956 | unregister_netdevice(dev); | 955 | unregister_netdevice(dev); |
957 | destroy_port: | 956 | destroy_port: |
958 | port->count -= 1; | 957 | if (MACVLAN_PORT_IS_EMPTY(port)) |
959 | if (!port->count) | ||
960 | macvlan_port_destroy(lowerdev); | 958 | macvlan_port_destroy(lowerdev); |
961 | 959 | ||
962 | return err; | 960 | return err; |