netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 2/3] net: rmnet: print error message when command fails
@ 2020-03-04  7:51 Taehee Yoo
  2020-03-04 20:01 ` Jakub Kicinski
  2020-03-04 20:47 ` subashab
  0 siblings, 2 replies; 5+ messages in thread
From: Taehee Yoo @ 2020-03-04  7:51 UTC (permalink / raw)
  To: davem, kuba, subashab, stranche, netdev; +Cc: ap420073

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.

Signed-off-by: Taehee Yoo <ap420073@gmail.com>
---
 .../ethernet/qualcomm/rmnet/rmnet_config.c    | 31 +++++++++++++------
 .../net/ethernet/qualcomm/rmnet/rmnet_vnd.c   | 11 ++++---
 .../net/ethernet/qualcomm/rmnet/rmnet_vnd.h   |  3 +-
 3 files changed, 29 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
index d846a0ccea8f..c2fee2b1e8e4 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c
@@ -122,11 +122,10 @@ 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]));
-	if (!real_dev || !dev)
+	if (!real_dev) {
+		NL_SET_ERR_MSG_MOD(extack, "link does not exist");
 		return -ENODEV;
-
-	if (!data[IFLA_RMNET_MUX_ID])
-		return -EINVAL;
+	}
 
 	ep = kzalloc(sizeof(*ep), GFP_ATOMIC);
 	if (!ep)
@@ -139,7 +138,7 @@ static int rmnet_newlink(struct net *src_net, struct net_device *dev,
 		goto err0;
 
 	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)
 		goto err1;
 
@@ -263,12 +262,16 @@ static int rmnet_rtnl_validate(struct nlattr *tb[], struct nlattr *data[],
 {
 	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 specifies");
 		return -EINVAL;
+	}
 
 	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 0;
 }
@@ -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
 	 * 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;
+	}
 
-	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;
+	}
+
+	if (rmnet_is_real_dev_registered(slave_dev)) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "dev is already attached another rmnet dev");
 
-	if (rmnet_is_real_dev_registered(slave_dev))
 		return -EBUSY;
+	}
 
 	err = rmnet_register_real_device(slave_dev);
 	if (err)
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
index 26ad40f19c64..d7c52e398e4a 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c
@@ -222,16 +222,17 @@ void rmnet_vnd_setup(struct net_device *rmnet_dev)
 int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev,
 		      struct rmnet_port *port,
 		      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);
 	int rc;
 
-	if (ep->egress_dev)
-		return -EINVAL;
-
-	if (rmnet_get_endpoint(port, id))
+	if (rmnet_get_endpoint(port, id)) {
+		NL_SET_ERR_MSG_MOD(extack, "MUX ID already exists");
 		return -EBUSY;
+	}
 
 	rmnet_dev->hw_features = NETIF_F_RXCSUM;
 	rmnet_dev->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h
index 14d77c709d4a..4967f3461ed1 100644
--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h
+++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h
@@ -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,
 		      struct rmnet_port *port,
 		      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,
 		      struct rmnet_endpoint *ep);
 void rmnet_vnd_rx_fixup(struct sk_buff *skb, struct net_device *dev);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next 2/3] net: rmnet: print error message when command fails
  2020-03-04  7:51 [PATCH net-next 2/3] net: rmnet: print error message when command fails Taehee Yoo
@ 2020-03-04 20:01 ` Jakub Kicinski
  2020-03-04 22:56   ` Taehee Yoo
  2020-03-04 20:47 ` subashab
  1 sibling, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2020-03-04 20:01 UTC (permalink / raw)
  To: Taehee Yoo; +Cc: davem, subashab, stranche, netdev

On Wed,  4 Mar 2020 07:51:02 +0000 Taehee Yoo wrote:
> @@ -263,12 +262,16 @@ static int rmnet_rtnl_validate(struct nlattr *tb[], struct nlattr *data[],
>  {
>  	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 specifies");
>  		return -EINVAL;
> +	}

nit: typo in specified ?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next 2/3] net: rmnet: print error message when command fails
  2020-03-04  7:51 [PATCH net-next 2/3] net: rmnet: print error message when command fails Taehee Yoo
  2020-03-04 20:01 ` Jakub Kicinski
@ 2020-03-04 20:47 ` subashab
  2020-03-04 22:57   ` Taehee Yoo
  1 sibling, 1 reply; 5+ messages in thread
From: subashab @ 2020-03-04 20:47 UTC (permalink / raw)
  To: Taehee Yoo; +Cc: davem, kuba, stranche, netdev

> +	if (rmnet_is_real_dev_registered(slave_dev)) {
> +		NL_SET_ERR_MSG_MOD(extack,
> +				   "dev is already attached another rmnet dev");
> 
Hi Taehee

Can you make this change as well-
"slave cannot be another rmnet dev"



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next 2/3] net: rmnet: print error message when command fails
  2020-03-04 20:01 ` Jakub Kicinski
@ 2020-03-04 22:56   ` Taehee Yoo
  0 siblings, 0 replies; 5+ messages in thread
From: Taehee Yoo @ 2020-03-04 22:56 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: David Miller, subashab, stranche, Netdev

On Thu, 5 Mar 2020 at 05:01, Jakub Kicinski <kuba@kernel.org> wrote:
>

Hi Jakub,
Thank you for the review

> On Wed,  4 Mar 2020 07:51:02 +0000 Taehee Yoo wrote:
> > @@ -263,12 +262,16 @@ static int rmnet_rtnl_validate(struct nlattr *tb[], struct nlattr *data[],
> >  {
> >       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 specifies");
> >               return -EINVAL;
> > +     }
>
> nit: typo in specified ?

Okay, I will change this message.

Thank you!
Taehee Yoo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next 2/3] net: rmnet: print error message when command fails
  2020-03-04 20:47 ` subashab
@ 2020-03-04 22:57   ` Taehee Yoo
  0 siblings, 0 replies; 5+ messages in thread
From: Taehee Yoo @ 2020-03-04 22:57 UTC (permalink / raw)
  To: subashab; +Cc: David Miller, Jakub Kicinski, stranche, Netdev

On Thu, 5 Mar 2020 at 05:47, <subashab@codeaurora.org> wrote:
>

Hi Subash,
Thank you for your review

> > +     if (rmnet_is_real_dev_registered(slave_dev)) {
> > +             NL_SET_ERR_MSG_MOD(extack,
> > +                                "dev is already attached another rmnet dev");
> >
> Hi Taehee
>
> Can you make this change as well-
> "slave cannot be another rmnet dev"

Okay, I will change this message too.

Thank you!
Taehee Yoo

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-04 22:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-04  7:51 [PATCH net-next 2/3] net: rmnet: print error message when command fails Taehee Yoo
2020-03-04 20:01 ` Jakub Kicinski
2020-03-04 22:56   ` Taehee Yoo
2020-03-04 20:47 ` subashab
2020-03-04 22:57   ` Taehee Yoo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).