From 02b30e7871410e54d1adfa7deb4943493d0a020e Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 3 Aug 2023 17:19:56 +1000 Subject: netlink: Propagate errors for "dup" operations We now detect errors on netlink "set" operations while configuring the pasta namespace with --config-net. However in many cases rather than a simple "set" we use a more complex "dup" function to copy configuration from the host to the namespace. We're not yet properly detecting and reporting netlink errors for that case. Change the "dup" operations to propagate netlink errors to their caller, pasta_ns_conf() and report them there. Link: https://bugs.passt.top/show_bug.cgi?id=60 Signed-off-by: David Gibson [sbrivio: Minor formatting changes in pasta_ns_conf()] Signed-off-by: Stefano Brivio --- pasta.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'pasta.c') diff --git a/pasta.c b/pasta.c index 02635b3..1e84680 100644 --- a/pasta.c +++ b/pasta.c @@ -298,8 +298,9 @@ void pasta_ns_conf(struct ctx *c) &c->ip4.addr, c->ip4.prefix_len); } else { - nl_addr_dup(nl_sock, c->ifi4, - nl_sock_ns, c->pasta_ifi, AF_INET); + rc = nl_addr_dup(nl_sock, c->ifi4, + nl_sock_ns, c->pasta_ifi, + AF_INET); } if (rc < 0) { @@ -311,8 +312,8 @@ void pasta_ns_conf(struct ctx *c) rc = nl_route_set_def(nl_sock_ns, c->pasta_ifi, AF_INET, &c->ip4.gw); } else { - nl_route_dup(nl_sock, c->ifi4, nl_sock_ns, - c->pasta_ifi, AF_INET); + rc = nl_route_dup(nl_sock, c->ifi4, nl_sock_ns, + c->pasta_ifi, AF_INET); } if (rc < 0) { @@ -326,9 +327,9 @@ void pasta_ns_conf(struct ctx *c) rc = nl_addr_set(nl_sock_ns, c->pasta_ifi, AF_INET6, &c->ip6.addr, 64); } else { - nl_addr_dup(nl_sock, c->ifi6, - nl_sock_ns, c->pasta_ifi, - AF_INET6); + rc = nl_addr_dup(nl_sock, c->ifi6, + nl_sock_ns, c->pasta_ifi, + AF_INET6); } if (rc < 0) { @@ -340,9 +341,9 @@ void pasta_ns_conf(struct ctx *c) rc = nl_route_set_def(nl_sock_ns, c->pasta_ifi, AF_INET6, &c->ip6.gw); } else { - nl_route_dup(nl_sock, c->ifi6, - nl_sock_ns, c->pasta_ifi, - AF_INET6); + rc = nl_route_dup(nl_sock, c->ifi6, + nl_sock_ns, c->pasta_ifi, + AF_INET6); } if (rc < 0) { -- cgit v1.2.3