Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 321963
b: refs/heads/master
c: 38e6bc1
h: refs/heads/master
i:
  321961: 6e26479
  321959: 9383ddb
v: v3
  • Loading branch information
Amerigo Wang authored and David S. Miller committed Aug 14, 2012
1 parent 7d54d40 commit 9af3959
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 47be03a28cc6c80e3aa2b3e8ed6d960ff0c5c0af
refs/heads/master: 38e6bc185d9544dfad1774b3f8902a0b061aea25
4 changes: 1 addition & 3 deletions trunk/drivers/net/bonding/bond_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1257,9 +1257,7 @@ static inline void slave_disable_netpoll(struct slave *slave)
return;

slave->np = NULL;
synchronize_rcu_bh();
__netpoll_cleanup(np);
kfree(np);
__netpoll_free_rcu(np);
}
static inline bool slave_dev_support_netpoll(struct net_device *slave_dev)
{
Expand Down
3 changes: 3 additions & 0 deletions trunk/include/linux/netpoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct netpoll {
u8 remote_mac[ETH_ALEN];

struct list_head rx; /* rx_np list element */
struct rcu_head rcu;
};

struct netpoll_info {
Expand All @@ -38,6 +39,7 @@ struct netpoll_info {
struct delayed_work tx_work;

struct netpoll *netpoll;
struct rcu_head rcu;
};

void netpoll_send_udp(struct netpoll *np, const char *msg, int len);
Expand All @@ -48,6 +50,7 @@ int netpoll_setup(struct netpoll *np);
int netpoll_trap(void);
void netpoll_set_trap(int trap);
void __netpoll_cleanup(struct netpoll *np);
void __netpoll_free_rcu(struct netpoll *np);
void netpoll_cleanup(struct netpoll *np);
int __netpoll_rx(struct sk_buff *skb);
void netpoll_send_skb_on_dev(struct netpoll *np, struct sk_buff *skb,
Expand Down
6 changes: 1 addition & 5 deletions trunk/net/8021q/vlan_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,11 +704,7 @@ static void vlan_dev_netpoll_cleanup(struct net_device *dev)

info->netpoll = NULL;

/* Wait for transmitting packets to finish before freeing. */
synchronize_rcu_bh();

__netpoll_cleanup(netpoll);
kfree(netpoll);
__netpoll_free_rcu(netpoll);
}
#endif /* CONFIG_NET_POLL_CONTROLLER */

Expand Down
6 changes: 1 addition & 5 deletions trunk/net/bridge/br_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,7 @@ void br_netpoll_disable(struct net_bridge_port *p)

p->np = NULL;

/* Wait for transmitting packets to finish before freeing. */
synchronize_rcu_bh();

__netpoll_cleanup(np);
kfree(np);
__netpoll_free_rcu(np);
}

#endif
Expand Down
42 changes: 32 additions & 10 deletions trunk/net/core/netpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,24 @@ static int __init netpoll_init(void)
}
core_initcall(netpoll_init);

static void rcu_cleanup_netpoll_info(struct rcu_head *rcu_head)
{
struct netpoll_info *npinfo =
container_of(rcu_head, struct netpoll_info, rcu);

skb_queue_purge(&npinfo->arp_tx);
skb_queue_purge(&npinfo->txq);

/* we can't call cancel_delayed_work_sync here, as we are in softirq */
cancel_delayed_work(&npinfo->tx_work);

/* clean after last, unfinished work */
__skb_queue_purge(&npinfo->txq);
/* now cancel it again */
cancel_delayed_work(&npinfo->tx_work);
kfree(npinfo);
}

void __netpoll_cleanup(struct netpoll *np)
{
struct netpoll_info *npinfo;
Expand All @@ -903,20 +921,24 @@ void __netpoll_cleanup(struct netpoll *np)
ops->ndo_netpoll_cleanup(np->dev);

RCU_INIT_POINTER(np->dev->npinfo, NULL);
call_rcu_bh(&npinfo->rcu, rcu_cleanup_netpoll_info);
}
}
EXPORT_SYMBOL_GPL(__netpoll_cleanup);

/* avoid racing with NAPI reading npinfo */
synchronize_rcu_bh();
static void rcu_cleanup_netpoll(struct rcu_head *rcu_head)
{
struct netpoll *np = container_of(rcu_head, struct netpoll, rcu);

skb_queue_purge(&npinfo->arp_tx);
skb_queue_purge(&npinfo->txq);
cancel_delayed_work_sync(&npinfo->tx_work);
__netpoll_cleanup(np);
kfree(np);
}

/* clean after last, unfinished work */
__skb_queue_purge(&npinfo->txq);
kfree(npinfo);
}
void __netpoll_free_rcu(struct netpoll *np)
{
call_rcu_bh(&np->rcu, rcu_cleanup_netpoll);
}
EXPORT_SYMBOL_GPL(__netpoll_cleanup);
EXPORT_SYMBOL_GPL(__netpoll_free_rcu);

void netpoll_cleanup(struct netpoll *np)
{
Expand Down

0 comments on commit 9af3959

Please sign in to comment.