summaryrefslogtreecommitdiff
path: root/net/xfrm
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2019-03-29 23:16:22 +0300
committerSteffen Klassert <steffen.klassert@secunet.com>2019-04-08 10:13:46 +0300
commitb262a69582a4676c7378a73077b7bb186c7c5b2a (patch)
tree5c71243107e5f14023de503aeb2acd2214f01d25 /net/xfrm
parentf981c57ffd2d7cf2dd4b6d6f8fcb3965df42f54c (diff)
downloadlinux-b262a69582a4676c7378a73077b7bb186c7c5b2a.tar.xz
xfrm: place af number into xfrm_mode struct
This will be useful to know if we're supposed to decode ipv4 or ipv6. While at it, make the unregister function return void, all module_exit functions did just BUG(); there is never a point in doing error checks if there is no way to handle such error. Signed-off-by: Florian Westphal <fw@strlen.de> Reviewed-by: Sabrina Dubroca <sd@queasysnail.net> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/xfrm')
-rw-r--r--net/xfrm/xfrm_state.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 1bb971f46fc6..c32394b59776 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -331,7 +331,7 @@ static void xfrm_put_type_offload(const struct xfrm_type_offload *type)
}
static DEFINE_SPINLOCK(xfrm_mode_lock);
-int xfrm_register_mode(struct xfrm_mode *mode, int family)
+int xfrm_register_mode(struct xfrm_mode *mode)
{
struct xfrm_state_afinfo *afinfo;
struct xfrm_mode **modemap;
@@ -340,7 +340,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
if (unlikely(mode->encap >= XFRM_MODE_MAX))
return -EINVAL;
- afinfo = xfrm_state_get_afinfo(family);
+ afinfo = xfrm_state_get_afinfo(mode->family);
if (unlikely(afinfo == NULL))
return -EAFNOSUPPORT;
@@ -365,31 +365,24 @@ out:
}
EXPORT_SYMBOL(xfrm_register_mode);
-int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
+void xfrm_unregister_mode(struct xfrm_mode *mode)
{
struct xfrm_state_afinfo *afinfo;
struct xfrm_mode **modemap;
- int err;
-
- if (unlikely(mode->encap >= XFRM_MODE_MAX))
- return -EINVAL;
- afinfo = xfrm_state_get_afinfo(family);
- if (unlikely(afinfo == NULL))
- return -EAFNOSUPPORT;
+ afinfo = xfrm_state_get_afinfo(mode->family);
+ if (WARN_ON_ONCE(!afinfo))
+ return;
- err = -ENOENT;
modemap = afinfo->mode_map;
spin_lock_bh(&xfrm_mode_lock);
if (likely(modemap[mode->encap] == mode)) {
modemap[mode->encap] = NULL;
module_put(mode->afinfo->owner);
- err = 0;
}
spin_unlock_bh(&xfrm_mode_lock);
rcu_read_unlock();
- return err;
}
EXPORT_SYMBOL(xfrm_unregister_mode);