Commit d9904528 authored by David S. Miller's avatar David S. Miller

Merge branch 'rmnet-cleanups'

Taehee Yoo says:

====================
net: rmnet: several code cleanup for rmnet module

This patchset is to cleanup rmnet module code.

1. The first patch is to add module alias
rmnet module can not be loaded automatically because there is no
alias name.

2. The second patch is to add extack error message code.
When rmnet netlink command fails, it doesn't print any error message.
So, users couldn't know the exact reason.
In order to tell the exact reason to the user, the extack error message
is used in this patch.

3. The third patch is to use GFP_KERNEL instead of GFP_ATOMIC.
In the sleepable context, GFP_KERNEL can be used.
So, in this patch, GFP_KERNEL is used instead of GFP_ATOMIC.

Change log:
 - v1->v2: change error message in the second patch.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents aec128f9 9c9cc918
...@@ -57,7 +57,7 @@ static int rmnet_register_real_device(struct net_device *real_dev) ...@@ -57,7 +57,7 @@ static int rmnet_register_real_device(struct net_device *real_dev)
if (rmnet_is_real_dev_registered(real_dev)) if (rmnet_is_real_dev_registered(real_dev))
return 0; return 0;
port = kzalloc(sizeof(*port), GFP_ATOMIC); port = kzalloc(sizeof(*port), GFP_KERNEL);
if (!port) if (!port)
return -ENOMEM; return -ENOMEM;
...@@ -122,13 +122,12 @@ static int rmnet_newlink(struct net *src_net, struct net_device *dev, ...@@ -122,13 +122,12 @@ static int rmnet_newlink(struct net *src_net, struct net_device *dev,
} }
real_dev = __dev_get_by_index(src_net, nla_get_u32(tb[IFLA_LINK])); real_dev = __dev_get_by_index(src_net, nla_get_u32(tb[IFLA_LINK]));
if (!real_dev || !dev) if (!real_dev) {
NL_SET_ERR_MSG_MOD(extack, "link does not exist");
return -ENODEV; return -ENODEV;
}
if (!data[IFLA_RMNET_MUX_ID]) ep = kzalloc(sizeof(*ep), GFP_KERNEL);
return -EINVAL;
ep = kzalloc(sizeof(*ep), GFP_ATOMIC);
if (!ep) if (!ep)
return -ENOMEM; return -ENOMEM;
...@@ -139,7 +138,7 @@ static int rmnet_newlink(struct net *src_net, struct net_device *dev, ...@@ -139,7 +138,7 @@ static int rmnet_newlink(struct net *src_net, struct net_device *dev,
goto err0; goto err0;
port = rmnet_get_port_rtnl(real_dev); port = rmnet_get_port_rtnl(real_dev);
err = rmnet_vnd_newlink(mux_id, dev, port, real_dev, ep); err = rmnet_vnd_newlink(mux_id, dev, port, real_dev, ep, extack);
if (err) if (err)
goto err1; goto err1;
...@@ -263,12 +262,16 @@ static int rmnet_rtnl_validate(struct nlattr *tb[], struct nlattr *data[], ...@@ -263,12 +262,16 @@ static int rmnet_rtnl_validate(struct nlattr *tb[], struct nlattr *data[],
{ {
u16 mux_id; u16 mux_id;
if (!data || !data[IFLA_RMNET_MUX_ID]) if (!data || !data[IFLA_RMNET_MUX_ID]) {
NL_SET_ERR_MSG_MOD(extack, "MUX ID not specified");
return -EINVAL; return -EINVAL;
}
mux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]); mux_id = nla_get_u16(data[IFLA_RMNET_MUX_ID]);
if (mux_id > (RMNET_MAX_LOGICAL_EP - 1)) if (mux_id > (RMNET_MAX_LOGICAL_EP - 1)) {
NL_SET_ERR_MSG_MOD(extack, "invalid MUX ID");
return -ERANGE; return -ERANGE;
}
return 0; return 0;
} }
...@@ -406,14 +409,22 @@ int rmnet_add_bridge(struct net_device *rmnet_dev, ...@@ -406,14 +409,22 @@ int rmnet_add_bridge(struct net_device *rmnet_dev,
/* If there is more than one rmnet dev attached, its probably being /* If there is more than one rmnet dev attached, its probably being
* used for muxing. Skip the briding in that case * used for muxing. Skip the briding in that case
*/ */
if (port->nr_rmnet_devs > 1) if (port->nr_rmnet_devs > 1) {
NL_SET_ERR_MSG_MOD(extack, "more than one rmnet dev attached");
return -EINVAL; return -EINVAL;
}
if (port->rmnet_mode != RMNET_EPMODE_VND) if (port->rmnet_mode != RMNET_EPMODE_VND) {
NL_SET_ERR_MSG_MOD(extack, "bridge device already exists");
return -EINVAL; return -EINVAL;
}
if (rmnet_is_real_dev_registered(slave_dev)) {
NL_SET_ERR_MSG_MOD(extack,
"slave cannot be another rmnet dev");
if (rmnet_is_real_dev_registered(slave_dev))
return -EBUSY; return -EBUSY;
}
err = rmnet_register_real_device(slave_dev); err = rmnet_register_real_device(slave_dev);
if (err) if (err)
...@@ -475,4 +486,5 @@ static void __exit rmnet_exit(void) ...@@ -475,4 +486,5 @@ static void __exit rmnet_exit(void)
module_init(rmnet_init) module_init(rmnet_init)
module_exit(rmnet_exit) module_exit(rmnet_exit)
MODULE_ALIAS_RTNL_LINK("rmnet");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
...@@ -222,16 +222,17 @@ void rmnet_vnd_setup(struct net_device *rmnet_dev) ...@@ -222,16 +222,17 @@ void rmnet_vnd_setup(struct net_device *rmnet_dev)
int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev, int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
struct rmnet_port *port, struct rmnet_port *port,
struct net_device *real_dev, struct net_device *real_dev,
struct rmnet_endpoint *ep) struct rmnet_endpoint *ep,
struct netlink_ext_ack *extack)
{ {
struct rmnet_priv *priv = netdev_priv(rmnet_dev); struct rmnet_priv *priv = netdev_priv(rmnet_dev);
int rc; int rc;
if (ep->egress_dev) if (rmnet_get_endpoint(port, id)) {
return -EINVAL; NL_SET_ERR_MSG_MOD(extack, "MUX ID already exists");
if (rmnet_get_endpoint(port, id))
return -EBUSY; return -EBUSY;
}
rmnet_dev->hw_features = NETIF_F_RXCSUM; rmnet_dev->hw_features = NETIF_F_RXCSUM;
rmnet_dev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; rmnet_dev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
......
...@@ -11,7 +11,8 @@ int rmnet_vnd_do_flow_control(struct net_device *dev, int enable); ...@@ -11,7 +11,8 @@ int rmnet_vnd_do_flow_control(struct net_device *dev, int enable);
int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev, int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
struct rmnet_port *port, struct rmnet_port *port,
struct net_device *real_dev, struct net_device *real_dev,
struct rmnet_endpoint *ep); struct rmnet_endpoint *ep,
struct netlink_ext_ack *extack);
int rmnet_vnd_dellink(u8 id, struct rmnet_port *port, int rmnet_vnd_dellink(u8 id, struct rmnet_port *port,
struct rmnet_endpoint *ep); struct rmnet_endpoint *ep);
void rmnet_vnd_rx_fixup(struct sk_buff *skb, struct net_device *dev); void rmnet_vnd_rx_fixup(struct sk_buff *skb, struct net_device *dev);
......
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