From 0f9f4b1b234bdc12a2604225d8c6398a355b75a4 Mon Sep 17 00:00:00 2001 From: Amir Shehata Date: Wed, 17 Dec 2014 19:31:54 -0800 Subject: [PATCH] LU-6045 lnet: return appropriate errno when adding route When adding route it ignored specific scenarios, namely: 1. route already exists 2. route is on a local net 3. route is unreacheable This patch returns the appropriate return codes from the lower level function lnet_add_route(), and then ignores the above case from the calling function, lnet_parse_route(). This is needed so we don't halt processing routes in the module parameters. However, we can now add routes dynamically, and it should be returned to the user whether adding the requested route succeeded or failed. In userspace it is determined whether to continue adding routes or to halt processing. Currently "lnetctl import < config" continues adding the rest of the configuration and reports at the end which operations passed and which ones failed. Signed-off-by: Amir Shehata Change-Id: Ie5367cae74e2b30fc29c33c46d31e11a1629bb5a Reviewed-on: http://review.whamcloud.com/13116 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Doug Oucharek Reviewed-by: Isaac Huang Reviewed-by: Oleg Drokin --- lnet/lnet/config.c | 2 +- lnet/lnet/router.c | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lnet/lnet/config.c b/lnet/lnet/config.c index c5f7e96..dd1e2d0 100644 --- a/lnet/lnet/config.c +++ b/lnet/lnet/config.c @@ -792,7 +792,7 @@ lnet_parse_route (char *str, int *im_a_router) } rc = lnet_add_route(net, hops, nid, priority); - if (rc != 0) { + if (rc != 0 && rc != -EEXIST && rc != -EHOSTUNREACH) { CERROR("Can't create route " "to %s via %s\n", libcfs_net2str(net), diff --git a/lnet/lnet/router.c b/lnet/lnet/router.c index 015a2e4..d3eb33c 100644 --- a/lnet/lnet/router.c +++ b/lnet/lnet/router.c @@ -327,7 +327,7 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway, return -EINVAL; if (lnet_islocalnet(net)) /* it's a local network */ - return 0; /* ignore the route entry */ + return -EEXIST; /* Assume net, route, all new */ LIBCFS_ALLOC(route, sizeof(*route)); @@ -358,7 +358,7 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway, LIBCFS_FREE(rnet, sizeof(*rnet)); if (rc == -EHOSTUNREACH) /* gateway is not on a local net. */ - return 0; /* ignore the route entry */ + return rc; /* ignore the route entry */ CERROR("Error %d creating route %s %d %s\n", rc, libcfs_net2str(net), hops, libcfs_nid2str(gateway)); @@ -406,13 +406,17 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway, lnet_peer_decref_locked(route->lr_gateway); lnet_net_unlock(LNET_LOCK_EX); - if (!add_route) + rc = 0; + + if (!add_route) { + rc = -EEXIST; LIBCFS_FREE(route, sizeof(*route)); + } if (rnet != rnet2) LIBCFS_FREE(rnet, sizeof(*rnet)); - return 0; + return rc; } int -- 1.8.3.1