aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordingtianhong <dingtianhong@huawei.com>2014-05-15 07:11:36 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-15 23:35:16 -0400
commita188a54d11629bef2169052297e61f3767ca8ce5 (patch)
treeabf311bb54dbb685f4ef8543a1708211a0dc36f5
parent112a3513b51976111e5e4a3115485d3fc89410c1 (diff)
macvlan: simplify the structure port
The port->count was used to count the number of macvlan devs in the same port, but the list vlans could play the same role to do that, so free the port if the list vlans is empty and no need to use the parameter count. Signed-off-by: Ding Tianhong <dingtianhong@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/macvlan.c12
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
50struct macvlan_skb_cb { 51struct 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,
955unregister_netdev: 954unregister_netdev:
956 unregister_netdevice(dev); 955 unregister_netdevice(dev);
957destroy_port: 956destroy_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;