Commit 51f65e3c authored by David S. Miller's avatar David S. Miller

Merge branch 'ipvlan'

Konstantin Khlebnikov says:

====================
ipvlan: cleanups and fixes

v1: http://comments.gmane.org/gmane.linux.network/363346
v2: http://comments.gmane.org/gmane.linux.network/369086

v3 has reduced set of patches from "ipvlan: fix ipv6 autoconfiguration".
Here just cleanups and patch which ignores ipv6 notifications from RA.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 20b953ed 23a5a49c
...@@ -67,8 +67,6 @@ struct ipvl_dev { ...@@ -67,8 +67,6 @@ struct ipvl_dev {
struct ipvl_port *port; struct ipvl_port *port;
struct net_device *phy_dev; struct net_device *phy_dev;
struct list_head addrs; struct list_head addrs;
int ipv4cnt;
int ipv6cnt;
struct ipvl_pcpu_stats __percpu *pcpu_stats; struct ipvl_pcpu_stats __percpu *pcpu_stats;
DECLARE_BITMAP(mac_filters, IPVLAN_MAC_FILTER_SIZE); DECLARE_BITMAP(mac_filters, IPVLAN_MAC_FILTER_SIZE);
netdev_features_t sfeatures; netdev_features_t sfeatures;
...@@ -106,6 +104,11 @@ static inline struct ipvl_port *ipvlan_port_get_rcu(const struct net_device *d) ...@@ -106,6 +104,11 @@ static inline struct ipvl_port *ipvlan_port_get_rcu(const struct net_device *d)
return rcu_dereference(d->rx_handler_data); return rcu_dereference(d->rx_handler_data);
} }
static inline struct ipvl_port *ipvlan_port_get_rcu_bh(const struct net_device *d)
{
return rcu_dereference_bh(d->rx_handler_data);
}
static inline struct ipvl_port *ipvlan_port_get_rtnl(const struct net_device *d) static inline struct ipvl_port *ipvlan_port_get_rtnl(const struct net_device *d)
{ {
return rtnl_dereference(d->rx_handler_data); return rtnl_dereference(d->rx_handler_data);
...@@ -124,5 +127,5 @@ struct ipvl_addr *ipvlan_find_addr(const struct ipvl_dev *ipvlan, ...@@ -124,5 +127,5 @@ struct ipvl_addr *ipvlan_find_addr(const struct ipvl_dev *ipvlan,
bool ipvlan_addr_busy(struct ipvl_port *port, void *iaddr, bool is_v6); bool ipvlan_addr_busy(struct ipvl_port *port, void *iaddr, bool is_v6);
struct ipvl_addr *ipvlan_ht_addr_lookup(const struct ipvl_port *port, struct ipvl_addr *ipvlan_ht_addr_lookup(const struct ipvl_port *port,
const void *iaddr, bool is_v6); const void *iaddr, bool is_v6);
void ipvlan_ht_addr_del(struct ipvl_addr *addr, bool sync); void ipvlan_ht_addr_del(struct ipvl_addr *addr);
#endif /* __IPVLAN_H */ #endif /* __IPVLAN_H */
...@@ -85,11 +85,9 @@ void ipvlan_ht_addr_add(struct ipvl_dev *ipvlan, struct ipvl_addr *addr) ...@@ -85,11 +85,9 @@ void ipvlan_ht_addr_add(struct ipvl_dev *ipvlan, struct ipvl_addr *addr)
hlist_add_head_rcu(&addr->hlnode, &port->hlhead[hash]); hlist_add_head_rcu(&addr->hlnode, &port->hlhead[hash]);
} }
void ipvlan_ht_addr_del(struct ipvl_addr *addr, bool sync) void ipvlan_ht_addr_del(struct ipvl_addr *addr)
{ {
hlist_del_init_rcu(&addr->hlnode); hlist_del_init_rcu(&addr->hlnode);
if (sync)
synchronize_rcu();
} }
struct ipvl_addr *ipvlan_find_addr(const struct ipvl_dev *ipvlan, struct ipvl_addr *ipvlan_find_addr(const struct ipvl_dev *ipvlan,
...@@ -531,7 +529,7 @@ static int ipvlan_xmit_mode_l2(struct sk_buff *skb, struct net_device *dev) ...@@ -531,7 +529,7 @@ static int ipvlan_xmit_mode_l2(struct sk_buff *skb, struct net_device *dev)
int ipvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev) int ipvlan_queue_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
struct ipvl_dev *ipvlan = netdev_priv(dev); struct ipvl_dev *ipvlan = netdev_priv(dev);
struct ipvl_port *port = ipvlan_port_get_rcu(ipvlan->phy_dev); struct ipvl_port *port = ipvlan_port_get_rcu_bh(ipvlan->phy_dev);
if (!port) if (!port)
goto out; goto out;
......
...@@ -153,10 +153,9 @@ static int ipvlan_open(struct net_device *dev) ...@@ -153,10 +153,9 @@ static int ipvlan_open(struct net_device *dev)
else else
dev->flags &= ~IFF_NOARP; dev->flags &= ~IFF_NOARP;
if (ipvlan->ipv6cnt > 0 || ipvlan->ipv4cnt > 0) { list_for_each_entry(addr, &ipvlan->addrs, anode)
list_for_each_entry(addr, &ipvlan->addrs, anode) ipvlan_ht_addr_add(ipvlan, addr);
ipvlan_ht_addr_add(ipvlan, addr);
}
return dev_uc_add(phy_dev, phy_dev->dev_addr); return dev_uc_add(phy_dev, phy_dev->dev_addr);
} }
...@@ -171,10 +170,9 @@ static int ipvlan_stop(struct net_device *dev) ...@@ -171,10 +170,9 @@ static int ipvlan_stop(struct net_device *dev)
dev_uc_del(phy_dev, phy_dev->dev_addr); dev_uc_del(phy_dev, phy_dev->dev_addr);
if (ipvlan->ipv6cnt > 0 || ipvlan->ipv4cnt > 0) { list_for_each_entry(addr, &ipvlan->addrs, anode)
list_for_each_entry(addr, &ipvlan->addrs, anode) ipvlan_ht_addr_del(addr);
ipvlan_ht_addr_del(addr, !dev->dismantle);
}
return 0; return 0;
} }
...@@ -471,8 +469,6 @@ static int ipvlan_link_new(struct net *src_net, struct net_device *dev, ...@@ -471,8 +469,6 @@ static int ipvlan_link_new(struct net *src_net, struct net_device *dev,
ipvlan->port = port; ipvlan->port = port;
ipvlan->sfeatures = IPVLAN_FEATURES; ipvlan->sfeatures = IPVLAN_FEATURES;
INIT_LIST_HEAD(&ipvlan->addrs); INIT_LIST_HEAD(&ipvlan->addrs);
ipvlan->ipv4cnt = 0;
ipvlan->ipv6cnt = 0;
/* TODO Probably put random address here to be presented to the /* TODO Probably put random address here to be presented to the
* world but keep using the physical-dev address for the outgoing * world but keep using the physical-dev address for the outgoing
...@@ -508,12 +504,12 @@ static void ipvlan_link_delete(struct net_device *dev, struct list_head *head) ...@@ -508,12 +504,12 @@ static void ipvlan_link_delete(struct net_device *dev, struct list_head *head)
struct ipvl_dev *ipvlan = netdev_priv(dev); struct ipvl_dev *ipvlan = netdev_priv(dev);
struct ipvl_addr *addr, *next; struct ipvl_addr *addr, *next;
if (ipvlan->ipv6cnt > 0 || ipvlan->ipv4cnt > 0) { list_for_each_entry_safe(addr, next, &ipvlan->addrs, anode) {
list_for_each_entry_safe(addr, next, &ipvlan->addrs, anode) { ipvlan_ht_addr_del(addr);
ipvlan_ht_addr_del(addr, !dev->dismantle); list_del(&addr->anode);
list_del(&addr->anode); kfree_rcu(addr, rcu);
}
} }
list_del_rcu(&ipvlan->pnode); list_del_rcu(&ipvlan->pnode);
unregister_netdevice_queue(dev, head); unregister_netdevice_queue(dev, head);
netdev_upper_dev_unlink(ipvlan->phy_dev, dev); netdev_upper_dev_unlink(ipvlan->phy_dev, dev);
...@@ -627,7 +623,7 @@ static int ipvlan_add_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr) ...@@ -627,7 +623,7 @@ static int ipvlan_add_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr)
memcpy(&addr->ip6addr, ip6_addr, sizeof(struct in6_addr)); memcpy(&addr->ip6addr, ip6_addr, sizeof(struct in6_addr));
addr->atype = IPVL_IPV6; addr->atype = IPVL_IPV6;
list_add_tail(&addr->anode, &ipvlan->addrs); list_add_tail(&addr->anode, &ipvlan->addrs);
ipvlan->ipv6cnt++;
/* If the interface is not up, the address will be added to the hash /* If the interface is not up, the address will be added to the hash
* list by ipvlan_open. * list by ipvlan_open.
*/ */
...@@ -645,10 +641,8 @@ static void ipvlan_del_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr) ...@@ -645,10 +641,8 @@ static void ipvlan_del_addr6(struct ipvl_dev *ipvlan, struct in6_addr *ip6_addr)
if (!addr) if (!addr)
return; return;
ipvlan_ht_addr_del(addr, true); ipvlan_ht_addr_del(addr);
list_del(&addr->anode); list_del(&addr->anode);
ipvlan->ipv6cnt--;
WARN_ON(ipvlan->ipv6cnt < 0);
kfree_rcu(addr, rcu); kfree_rcu(addr, rcu);
return; return;
...@@ -661,6 +655,10 @@ static int ipvlan_addr6_event(struct notifier_block *unused, ...@@ -661,6 +655,10 @@ static int ipvlan_addr6_event(struct notifier_block *unused,
struct net_device *dev = (struct net_device *)if6->idev->dev; struct net_device *dev = (struct net_device *)if6->idev->dev;
struct ipvl_dev *ipvlan = netdev_priv(dev); struct ipvl_dev *ipvlan = netdev_priv(dev);
/* FIXME IPv6 autoconf calls us from bh without RTNL */
if (in_softirq())
return NOTIFY_DONE;
if (!netif_is_ipvlan(dev)) if (!netif_is_ipvlan(dev))
return NOTIFY_DONE; return NOTIFY_DONE;
...@@ -699,7 +697,7 @@ static int ipvlan_add_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr) ...@@ -699,7 +697,7 @@ static int ipvlan_add_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr)
memcpy(&addr->ip4addr, ip4_addr, sizeof(struct in_addr)); memcpy(&addr->ip4addr, ip4_addr, sizeof(struct in_addr));
addr->atype = IPVL_IPV4; addr->atype = IPVL_IPV4;
list_add_tail(&addr->anode, &ipvlan->addrs); list_add_tail(&addr->anode, &ipvlan->addrs);
ipvlan->ipv4cnt++;
/* If the interface is not up, the address will be added to the hash /* If the interface is not up, the address will be added to the hash
* list by ipvlan_open. * list by ipvlan_open.
*/ */
...@@ -717,10 +715,8 @@ static void ipvlan_del_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr) ...@@ -717,10 +715,8 @@ static void ipvlan_del_addr4(struct ipvl_dev *ipvlan, struct in_addr *ip4_addr)
if (!addr) if (!addr)
return; return;
ipvlan_ht_addr_del(addr, true); ipvlan_ht_addr_del(addr);
list_del(&addr->anode); list_del(&addr->anode);
ipvlan->ipv4cnt--;
WARN_ON(ipvlan->ipv4cnt < 0);
kfree_rcu(addr, rcu); kfree_rcu(addr, rcu);
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment