Blob Blame History Raw
From: Taehee Yoo <ap420073@gmail.com>
Date: Sun, 8 Mar 2020 01:19:17 +0000
Subject: bareudp: print error message when command fails
Patch-mainline: v5.7-rc1
Git-commit: c46a49a45c865350d6051df555034b86a2ac72ff
References: jsc#SLE-15172

When bareudp 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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 drivers/net/bareudp.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

--- a/drivers/net/bareudp.c
+++ b/drivers/net/bareudp.c
@@ -556,10 +556,17 @@ static int bareudp_validate(struct nlatt
 	return 0;
 }
 
-static int bareudp2info(struct nlattr *data[], struct bareudp_conf *conf)
+static int bareudp2info(struct nlattr *data[], struct bareudp_conf *conf,
+			struct netlink_ext_ack *extack)
 {
-	if (!data[IFLA_BAREUDP_PORT] || !data[IFLA_BAREUDP_ETHERTYPE])
+	if (!data[IFLA_BAREUDP_PORT]) {
+		NL_SET_ERR_MSG(extack, "port not specified");
 		return -EINVAL;
+	}
+	if (!data[IFLA_BAREUDP_ETHERTYPE]) {
+		NL_SET_ERR_MSG(extack, "ethertype not specified");
+		return -EINVAL;
+	}
 
 	if (data[IFLA_BAREUDP_PORT])
 		conf->port =  nla_get_u16(data[IFLA_BAREUDP_PORT]);
@@ -635,7 +642,7 @@ static int bareudp_newlink(struct net *n
 	struct bareudp_conf conf;
 	int err;
 
-	err = bareudp2info(data, &conf);
+	err = bareudp2info(data, &conf, extack);
 	if (err)
 		return err;