All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] tst_rtnetlink: pass error codes using rtnl_errno variable
@ 2021-06-22 15:48 Martin Doucha
  2021-06-22 16:11 ` Richard Palethorpe
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Doucha @ 2021-06-22 15:48 UTC (permalink / raw)
  To: ltp

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 include/tst_rtnetlink.h |  2 ++
 lib/tst_netdevice.c     | 26 +++++++++++++++-----------
 lib/tst_rtnetlink.c     |  6 ++++--
 3 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/include/tst_rtnetlink.h b/include/tst_rtnetlink.h
index 12ec258f2..7c28f795d 100644
--- a/include/tst_rtnetlink.h
+++ b/include/tst_rtnetlink.h
@@ -21,6 +21,8 @@ struct tst_rtnl_message {
 	size_t payload_size;
 };
 
+extern int rtnl_errno;
+
 /* Open a netlink socket */
 struct tst_rtnl_context *tst_rtnl_create_context(const char *file,
 	const int lineno);
diff --git a/lib/tst_netdevice.c b/lib/tst_netdevice.c
index d098173d5..af57fba1e 100644
--- a/lib/tst_netdevice.c
+++ b/lib/tst_netdevice.c
@@ -149,9 +149,9 @@ int tst_create_veth_pair(const char *file, const int lineno,
 	tst_rtnl_destroy_context(file, lineno, ctx);
 
 	if (!ret) {
-		tst_brk_(file, lineno, TBROK | TTERRNO,
-			"Failed to create veth interfaces %s+%s", ifname1,
-			ifname2);
+		tst_brk_(file, lineno, TBROK,
+			"Failed to create veth interfaces %s+%s: %s", ifname1,
+			ifname2, tst_strerrno(rtnl_errno));
 	}
 
 	return ret;
@@ -183,8 +183,9 @@ int tst_remove_netdev(const char *file, const int lineno, const char *ifname)
 	tst_rtnl_destroy_context(file, lineno, ctx);
 
 	if (!ret) {
-		tst_brk_(file, lineno, TBROK | TTERRNO,
-			"Failed to remove netdevice %s", ifname);
+		tst_brk_(file, lineno, TBROK,
+			"Failed to remove netdevice %s: %s", ifname,
+			tst_strerrno(rtnl_errno));
 	}
 
 	return ret;
@@ -232,8 +233,9 @@ static int modify_address(const char *file, const int lineno,
 	tst_rtnl_destroy_context(file, lineno, ctx);
 
 	if (!ret) {
-		tst_brk_(file, lineno, TBROK | TTERRNO,
-			"Failed to modify %s network address", ifname);
+		tst_brk_(file, lineno, TBROK,
+			"Failed to modify %s network address: %s", ifname,
+			tst_strerrno(rtnl_errno));
 	}
 
 	return ret;
@@ -301,8 +303,9 @@ static int change_ns(const char *file, const int lineno, const char *ifname,
 	tst_rtnl_destroy_context(file, lineno, ctx);
 
 	if (!ret) {
-		tst_brk_(file, lineno, TBROK | TTERRNO,
-			"Failed to move %s to another namespace", ifname);
+		tst_brk_(file, lineno, TBROK,
+			"Failed to move %s to another namespace: %s", ifname,
+			tst_strerrno(rtnl_errno));
 	}
 
 	return ret;
@@ -392,8 +395,9 @@ static int modify_route(const char *file, const int lineno, unsigned int action,
 	tst_rtnl_destroy_context(file, lineno, ctx);
 
 	if (!ret) {
-		tst_brk_(file, lineno, TBROK | TTERRNO,
-			"Failed to modify network route");
+		tst_brk_(file, lineno, TBROK,
+			"Failed to modify network route: %s",
+			tst_strerrno(rtnl_errno));
 	}
 
 	return ret;
diff --git a/lib/tst_rtnetlink.c b/lib/tst_rtnetlink.c
index 1ecda3a9f..6f24b89fe 100644
--- a/lib/tst_rtnetlink.c
+++ b/lib/tst_rtnetlink.c
@@ -24,6 +24,8 @@ struct tst_rtnl_context {
 	struct nlmsghdr *curmsg;
 };
 
+int rtnl_errno;
+
 static int tst_rtnl_grow_buffer(const char *file, const int lineno,
 	struct tst_rtnl_context *ctx, size_t size)
 {
@@ -380,7 +382,7 @@ int tst_rtnl_check_acks(const char *file, const int lineno,
 		}
 
 		if (res->err->error) {
-			TST_ERR = -res->err->error;
+			rtnl_errno = -res->err->error;
 			return 0;
 		}
 	}
@@ -394,7 +396,7 @@ int tst_rtnl_send_validate(const char *file, const int lineno,
 	struct tst_rtnl_message *response;
 	int ret;
 
-	TST_ERR = 0;
+	rtnl_errno = 0;
 
 	if (tst_rtnl_send(file, lineno, ctx) <= 0)
 		return 0;
-- 
2.32.0


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

* [LTP] [PATCH] tst_rtnetlink: pass error codes using rtnl_errno variable
  2021-06-22 15:48 [LTP] [PATCH] tst_rtnetlink: pass error codes using rtnl_errno variable Martin Doucha
@ 2021-06-22 16:11 ` Richard Palethorpe
  2021-06-22 16:17   ` Martin Doucha
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Palethorpe @ 2021-06-22 16:11 UTC (permalink / raw)
  To: ltp

Hello Martin,

Martin Doucha <mdoucha@suse.cz> writes:

> Signed-off-by: Martin Doucha <mdoucha@suse.cz>
> ---
>  include/tst_rtnetlink.h |  2 ++
>  lib/tst_netdevice.c     | 26 +++++++++++++++-----------
>  lib/tst_rtnetlink.c     |  6 ++++--
>  3 files changed, 21 insertions(+), 13 deletions(-)
>
> diff --git a/include/tst_rtnetlink.h b/include/tst_rtnetlink.h
> index 12ec258f2..7c28f795d 100644
> --- a/include/tst_rtnetlink.h
> +++ b/include/tst_rtnetlink.h
> @@ -21,6 +21,8 @@ struct tst_rtnl_message {
>  	size_t payload_size;
>  };
>  
> +extern int rtnl_errno;

This is polluting the name space. I suppose it can be prepended
with tst_, but does the test author need to see this? Or you could even
just merge tst_netdevice and tst_rtnetlink.

Otherwise I think this approach is fine.

-- 
Thank you,
Richard.

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

* [LTP] [PATCH] tst_rtnetlink: pass error codes using rtnl_errno variable
  2021-06-22 16:11 ` Richard Palethorpe
@ 2021-06-22 16:17   ` Martin Doucha
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Doucha @ 2021-06-22 16:17 UTC (permalink / raw)
  To: ltp

On 22. 06. 21 18:11, Richard Palethorpe wrote:
> Hello Martin,
> 
> Martin Doucha <mdoucha@suse.cz> writes:
>> +extern int rtnl_errno;
> 
> This is polluting the name space. I suppose it can be prepended
> with tst_, but does the test author need to see this? Or you could even
> just merge tst_netdevice and tst_rtnetlink.
> 
> Otherwise I think this approach is fine.

You're right, I should have prefixed it with tst_. I'll send v2 in a moment.

Yes, test authors will need to access this variable if they want to use
RTNL_CHECK_ACKS() or RTNL_SEND_VALIDATE() in their tests.

-- 
Martin Doucha   mdoucha@suse.cz
QA Engineer for Software Maintenance
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic

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

end of thread, other threads:[~2021-06-22 16:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-22 15:48 [LTP] [PATCH] tst_rtnetlink: pass error codes using rtnl_errno variable Martin Doucha
2021-06-22 16:11 ` Richard Palethorpe
2021-06-22 16:17   ` Martin Doucha

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.