From 69a00f7a7a11e5829c8d1a80997a110bba1b8f43 Mon Sep 17 00:00:00 2001 From: Benedict Wong Date: Wed, 25 Jul 2018 13:45:29 -0700 Subject: [PATCH] UPSTREAM: xfrm: Return detailed errors from xfrmi_newlink Currently all failure modes of xfrm interface creation return EEXIST. This change improves the granularity of errnos provided by also returning ENODEV or EINVAL if failures happen in looking up the underlying interface, or a required parameter is not provided. This change has been tested against the Android Kernel Networking Tests, with additional xfrmi_newlink tests here: https://android-review.googlesource.com/c/kernel/tests/+/715755 Signed-off-by: Benedict Wong Signed-off-by: Steffen Klassert (cherry picked from commit 44e2b838c24d883dae8496dc7b6ddac7956ba53c) Bug: 113046120 Change-Id: Ic680bf1e4a828aaae01b289223d9396a551eefd2 --- net/xfrm/xfrm_interface.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c index 31acc6f33d98..481d7307ab51 100644 --- a/net/xfrm/xfrm_interface.c +++ b/net/xfrm/xfrm_interface.c @@ -689,7 +689,10 @@ static int xfrmi_newlink(struct net *src_net, struct net_device *dev, nla_strlcpy(p->name, tb[IFLA_IFNAME], IFNAMSIZ); xi = xfrmi_locate(net, p, 1); - return PTR_ERR_OR_ZERO(xi); + if (IS_ERR(xi)) + return PTR_ERR(xi); + + return 0; } static void xfrmi_dellink(struct net_device *dev, struct list_head *head) -- 2.20.1