Commit a8779ec1 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller

netpoll: Remove gfp parameter from __netpoll_setup

The gfp parameter was added in:
commit 47be03a2
Author: Amerigo Wang <amwang@redhat.com>
Date:   Fri Aug 10 01:24:37 2012 +0000

    netpoll: use GFP_ATOMIC in slave_enable_netpoll() and __netpoll_setup()

    slave_enable_netpoll() and __netpoll_setup() may be called
    with read_lock() held, so should use GFP_ATOMIC to allocate
    memory. Eric suggested to pass gfp flags to __netpoll_setup().

    Cc: Eric Dumazet <eric.dumazet@gmail.com>
    Cc: "David S. Miller" <davem@davemloft.net>
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarCong Wang <amwang@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>

The reason for the gfp parameter was removed in:
commit c4cdef9b
Author: dingtianhong <dingtianhong@huawei.com>
Date:   Tue Jul 23 15:25:27 2013 +0800

    bonding: don't call slave_xxx_netpoll under spinlocks

    The slave_xxx_netpoll will call synchronize_rcu_bh(),
    so the function may schedule and sleep, it should't be
    called under spinlocks.

    bond_netpoll_setup() and bond_netpoll_cleanup() are always
    protected by rtnl lock, it is no need to take the read lock,
    as the slave list couldn't be changed outside rtnl lock.
Signed-off-by: default avatarDing Tianhong <dingtianhong@huawei.com>
    Cc: Jay Vosburgh <fubar@us.ibm.com>
    Cc: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>

Nothing else that calls __netpoll_setup or ndo_netpoll_setup
requires a gfp paramter, so remove the gfp parameter from both
of these functions making the code clearer.
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3f705f73
...@@ -922,12 +922,12 @@ static inline int slave_enable_netpoll(struct slave *slave) ...@@ -922,12 +922,12 @@ static inline int slave_enable_netpoll(struct slave *slave)
struct netpoll *np; struct netpoll *np;
int err = 0; int err = 0;
np = kzalloc(sizeof(*np), GFP_ATOMIC); np = kzalloc(sizeof(*np), GFP_KERNEL);
err = -ENOMEM; err = -ENOMEM;
if (!np) if (!np)
goto out; goto out;
err = __netpoll_setup(np, slave->dev, GFP_ATOMIC); err = __netpoll_setup(np, slave->dev);
if (err) { if (err) {
kfree(np); kfree(np);
goto out; goto out;
...@@ -962,7 +962,7 @@ static void bond_netpoll_cleanup(struct net_device *bond_dev) ...@@ -962,7 +962,7 @@ static void bond_netpoll_cleanup(struct net_device *bond_dev)
slave_disable_netpoll(slave); slave_disable_netpoll(slave);
} }
static int bond_netpoll_setup(struct net_device *dev, struct netpoll_info *ni, gfp_t gfp) static int bond_netpoll_setup(struct net_device *dev, struct netpoll_info *ni)
{ {
struct bonding *bond = netdev_priv(dev); struct bonding *bond = netdev_priv(dev);
struct list_head *iter; struct list_head *iter;
......
...@@ -1031,8 +1031,7 @@ static void team_port_leave(struct team *team, struct team_port *port) ...@@ -1031,8 +1031,7 @@ static void team_port_leave(struct team *team, struct team_port *port)
} }
#ifdef CONFIG_NET_POLL_CONTROLLER #ifdef CONFIG_NET_POLL_CONTROLLER
static int team_port_enable_netpoll(struct team *team, struct team_port *port, static int team_port_enable_netpoll(struct team *team, struct team_port *port)
gfp_t gfp)
{ {
struct netpoll *np; struct netpoll *np;
int err; int err;
...@@ -1040,11 +1039,11 @@ static int team_port_enable_netpoll(struct team *team, struct team_port *port, ...@@ -1040,11 +1039,11 @@ static int team_port_enable_netpoll(struct team *team, struct team_port *port,
if (!team->dev->npinfo) if (!team->dev->npinfo)
return 0; return 0;
np = kzalloc(sizeof(*np), gfp); np = kzalloc(sizeof(*np), GFP_KERNEL);
if (!np) if (!np)
return -ENOMEM; return -ENOMEM;
err = __netpoll_setup(np, port->dev, gfp); err = __netpoll_setup(np, port->dev);
if (err) { if (err) {
kfree(np); kfree(np);
return err; return err;
...@@ -1067,8 +1066,7 @@ static void team_port_disable_netpoll(struct team_port *port) ...@@ -1067,8 +1066,7 @@ static void team_port_disable_netpoll(struct team_port *port)
kfree(np); kfree(np);
} }
#else #else
static int team_port_enable_netpoll(struct team *team, struct team_port *port, static int team_port_enable_netpoll(struct team *team, struct team_port *port)
gfp_t gfp)
{ {
return 0; return 0;
} }
...@@ -1156,7 +1154,7 @@ static int team_port_add(struct team *team, struct net_device *port_dev) ...@@ -1156,7 +1154,7 @@ static int team_port_add(struct team *team, struct net_device *port_dev)
goto err_vids_add; goto err_vids_add;
} }
err = team_port_enable_netpoll(team, port, GFP_KERNEL); err = team_port_enable_netpoll(team, port);
if (err) { if (err) {
netdev_err(dev, "Failed to enable netpoll on device %s\n", netdev_err(dev, "Failed to enable netpoll on device %s\n",
portname); portname);
...@@ -1850,7 +1848,7 @@ static void team_netpoll_cleanup(struct net_device *dev) ...@@ -1850,7 +1848,7 @@ static void team_netpoll_cleanup(struct net_device *dev)
} }
static int team_netpoll_setup(struct net_device *dev, static int team_netpoll_setup(struct net_device *dev,
struct netpoll_info *npifo, gfp_t gfp) struct netpoll_info *npifo)
{ {
struct team *team = netdev_priv(dev); struct team *team = netdev_priv(dev);
struct team_port *port; struct team_port *port;
...@@ -1858,7 +1856,7 @@ static int team_netpoll_setup(struct net_device *dev, ...@@ -1858,7 +1856,7 @@ static int team_netpoll_setup(struct net_device *dev,
mutex_lock(&team->lock); mutex_lock(&team->lock);
list_for_each_entry(port, &team->port_list, list) { list_for_each_entry(port, &team->port_list, list) {
err = team_port_enable_netpoll(team, port, gfp); err = team_port_enable_netpoll(team, port);
if (err) { if (err) {
__team_netpoll_cleanup(team); __team_netpoll_cleanup(team);
break; break;
......
...@@ -1037,8 +1037,7 @@ struct net_device_ops { ...@@ -1037,8 +1037,7 @@ struct net_device_ops {
#ifdef CONFIG_NET_POLL_CONTROLLER #ifdef CONFIG_NET_POLL_CONTROLLER
void (*ndo_poll_controller)(struct net_device *dev); void (*ndo_poll_controller)(struct net_device *dev);
int (*ndo_netpoll_setup)(struct net_device *dev, int (*ndo_netpoll_setup)(struct net_device *dev,
struct netpoll_info *info, struct netpoll_info *info);
gfp_t gfp);
void (*ndo_netpoll_cleanup)(struct net_device *dev); void (*ndo_netpoll_cleanup)(struct net_device *dev);
#endif #endif
#ifdef CONFIG_NET_RX_BUSY_POLL #ifdef CONFIG_NET_RX_BUSY_POLL
......
...@@ -57,7 +57,7 @@ static inline void netpoll_rx_enable(struct net_device *dev) { return; } ...@@ -57,7 +57,7 @@ static inline void netpoll_rx_enable(struct net_device *dev) { return; }
void netpoll_send_udp(struct netpoll *np, const char *msg, int len); void netpoll_send_udp(struct netpoll *np, const char *msg, int len);
void netpoll_print_options(struct netpoll *np); void netpoll_print_options(struct netpoll *np);
int netpoll_parse_options(struct netpoll *np, char *opt); int netpoll_parse_options(struct netpoll *np, char *opt);
int __netpoll_setup(struct netpoll *np, struct net_device *ndev, gfp_t gfp); int __netpoll_setup(struct netpoll *np, struct net_device *ndev);
int netpoll_setup(struct netpoll *np); int netpoll_setup(struct netpoll *np);
void __netpoll_cleanup(struct netpoll *np); void __netpoll_cleanup(struct netpoll *np);
void __netpoll_free_async(struct netpoll *np); void __netpoll_free_async(struct netpoll *np);
......
...@@ -707,20 +707,19 @@ static void vlan_dev_poll_controller(struct net_device *dev) ...@@ -707,20 +707,19 @@ static void vlan_dev_poll_controller(struct net_device *dev)
return; return;
} }
static int vlan_dev_netpoll_setup(struct net_device *dev, struct netpoll_info *npinfo, static int vlan_dev_netpoll_setup(struct net_device *dev, struct netpoll_info *npinfo)
gfp_t gfp)
{ {
struct vlan_dev_priv *vlan = vlan_dev_priv(dev); struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
struct net_device *real_dev = vlan->real_dev; struct net_device *real_dev = vlan->real_dev;
struct netpoll *netpoll; struct netpoll *netpoll;
int err = 0; int err = 0;
netpoll = kzalloc(sizeof(*netpoll), gfp); netpoll = kzalloc(sizeof(*netpoll), GFP_KERNEL);
err = -ENOMEM; err = -ENOMEM;
if (!netpoll) if (!netpoll)
goto out; goto out;
err = __netpoll_setup(netpoll, real_dev, gfp); err = __netpoll_setup(netpoll, real_dev);
if (err) { if (err) {
kfree(netpoll); kfree(netpoll);
goto out; goto out;
......
...@@ -218,16 +218,16 @@ static void br_netpoll_cleanup(struct net_device *dev) ...@@ -218,16 +218,16 @@ static void br_netpoll_cleanup(struct net_device *dev)
br_netpoll_disable(p); br_netpoll_disable(p);
} }
static int __br_netpoll_enable(struct net_bridge_port *p, gfp_t gfp) static int __br_netpoll_enable(struct net_bridge_port *p)
{ {
struct netpoll *np; struct netpoll *np;
int err; int err;
np = kzalloc(sizeof(*p->np), gfp); np = kzalloc(sizeof(*p->np), GFP_KERNEL);
if (!np) if (!np)
return -ENOMEM; return -ENOMEM;
err = __netpoll_setup(np, p->dev, gfp); err = __netpoll_setup(np, p->dev);
if (err) { if (err) {
kfree(np); kfree(np);
return err; return err;
...@@ -237,16 +237,15 @@ static int __br_netpoll_enable(struct net_bridge_port *p, gfp_t gfp) ...@@ -237,16 +237,15 @@ static int __br_netpoll_enable(struct net_bridge_port *p, gfp_t gfp)
return err; return err;
} }
int br_netpoll_enable(struct net_bridge_port *p, gfp_t gfp) int br_netpoll_enable(struct net_bridge_port *p)
{ {
if (!p->br->dev->npinfo) if (!p->br->dev->npinfo)
return 0; return 0;
return __br_netpoll_enable(p, gfp); return __br_netpoll_enable(p);
} }
static int br_netpoll_setup(struct net_device *dev, struct netpoll_info *ni, static int br_netpoll_setup(struct net_device *dev, struct netpoll_info *ni)
gfp_t gfp)
{ {
struct net_bridge *br = netdev_priv(dev); struct net_bridge *br = netdev_priv(dev);
struct net_bridge_port *p; struct net_bridge_port *p;
...@@ -255,7 +254,7 @@ static int br_netpoll_setup(struct net_device *dev, struct netpoll_info *ni, ...@@ -255,7 +254,7 @@ static int br_netpoll_setup(struct net_device *dev, struct netpoll_info *ni,
list_for_each_entry(p, &br->port_list, list) { list_for_each_entry(p, &br->port_list, list) {
if (!p->dev) if (!p->dev)
continue; continue;
err = __br_netpoll_enable(p, gfp); err = __br_netpoll_enable(p);
if (err) if (err)
goto fail; goto fail;
} }
......
...@@ -366,7 +366,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev) ...@@ -366,7 +366,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
if (err) if (err)
goto err2; goto err2;
err = br_netpoll_enable(p, GFP_KERNEL); err = br_netpoll_enable(p);
if (err) if (err)
goto err3; goto err3;
......
...@@ -349,7 +349,7 @@ static inline void br_netpoll_send_skb(const struct net_bridge_port *p, ...@@ -349,7 +349,7 @@ static inline void br_netpoll_send_skb(const struct net_bridge_port *p,
netpoll_send_skb(np, skb); netpoll_send_skb(np, skb);
} }
int br_netpoll_enable(struct net_bridge_port *p, gfp_t gfp); int br_netpoll_enable(struct net_bridge_port *p);
void br_netpoll_disable(struct net_bridge_port *p); void br_netpoll_disable(struct net_bridge_port *p);
#else #else
static inline void br_netpoll_send_skb(const struct net_bridge_port *p, static inline void br_netpoll_send_skb(const struct net_bridge_port *p,
...@@ -357,7 +357,7 @@ static inline void br_netpoll_send_skb(const struct net_bridge_port *p, ...@@ -357,7 +357,7 @@ static inline void br_netpoll_send_skb(const struct net_bridge_port *p,
{ {
} }
static inline int br_netpoll_enable(struct net_bridge_port *p, gfp_t gfp) static inline int br_netpoll_enable(struct net_bridge_port *p)
{ {
return 0; return 0;
} }
......
...@@ -584,7 +584,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt) ...@@ -584,7 +584,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
} }
EXPORT_SYMBOL(netpoll_parse_options); EXPORT_SYMBOL(netpoll_parse_options);
int __netpoll_setup(struct netpoll *np, struct net_device *ndev, gfp_t gfp) int __netpoll_setup(struct netpoll *np, struct net_device *ndev)
{ {
struct netpoll_info *npinfo; struct netpoll_info *npinfo;
const struct net_device_ops *ops; const struct net_device_ops *ops;
...@@ -603,7 +603,7 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev, gfp_t gfp) ...@@ -603,7 +603,7 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev, gfp_t gfp)
} }
if (!ndev->npinfo) { if (!ndev->npinfo) {
npinfo = kmalloc(sizeof(*npinfo), gfp); npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL);
if (!npinfo) { if (!npinfo) {
err = -ENOMEM; err = -ENOMEM;
goto out; goto out;
...@@ -617,7 +617,7 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev, gfp_t gfp) ...@@ -617,7 +617,7 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev, gfp_t gfp)
ops = np->dev->netdev_ops; ops = np->dev->netdev_ops;
if (ops->ndo_netpoll_setup) { if (ops->ndo_netpoll_setup) {
err = ops->ndo_netpoll_setup(ndev, npinfo, gfp); err = ops->ndo_netpoll_setup(ndev, npinfo);
if (err) if (err)
goto free_npinfo; goto free_npinfo;
} }
...@@ -749,7 +749,7 @@ int netpoll_setup(struct netpoll *np) ...@@ -749,7 +749,7 @@ int netpoll_setup(struct netpoll *np)
/* fill up the skb queue */ /* fill up the skb queue */
refill_skbs(); refill_skbs();
err = __netpoll_setup(np, ndev, GFP_KERNEL); err = __netpoll_setup(np, ndev);
if (err) if (err)
goto put; goto put;
......
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