summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDmitry Safonov <dima@arista.com>2020-09-21 15:36:51 +0100
committerAlistair Delva <adelva@google.com>2020-11-02 16:36:55 +0000
commitdf6415dcd498a7f33b2d50a1d85ddb43b4a3640a (patch)
tree9dc5de2ea4e490eab013769896e0026195992896 /include
parent6f21bc2d227453f2aa3baebdc7b2200dd91ef041 (diff)
BACKPORT: xfrm: Provide API to register translator module
Add a skeleton for xfrm_compat module and provide API to register it in xfrm_state.ko. struct xfrm_translator will have function pointers to translate messages received from 32-bit userspace or to be sent to it from 64-bit kernel. module_get()/module_put() are used instead of rcu_read_lock() as the module will vmalloc() memory for translation. The new API is registered with xfrm_state module, not with xfrm_user as the former needs translator for user_policy set by setsockopt() and xfrm_user already uses functions from xfrm_state. Signed-off-by: Dmitry Safonov <dima@arista.com> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> (cherry picked from commit c9e7c76d70fa50582ca96759829c93d0dd024662) [adelva: Edited around some context changes] Bug: 163141236 Signed-off-by: Alistair Delva <adelva@google.com> Change-Id: Ic825c6a0367fa192cc3f7af6b7d2682ef8f9d58b
Diffstat (limited to 'include')
-rw-r--r--include/net/xfrm.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 2a63f7e30506..1e7174c152cf 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -1825,4 +1825,24 @@ static inline int xfrm_tunnel_check(struct sk_buff *skb, struct xfrm_state *x,
return 0;
}
+
+struct xfrm_translator {
+ struct module *owner;
+};
+
+#if IS_ENABLED(CONFIG_XFRM_USER_COMPAT)
+extern int xfrm_register_translator(struct xfrm_translator *xtr);
+extern int xfrm_unregister_translator(struct xfrm_translator *xtr);
+extern struct xfrm_translator *xfrm_get_translator(void);
+extern void xfrm_put_translator(struct xfrm_translator *xtr);
+#else
+static inline struct xfrm_translator *xfrm_get_translator(void)
+{
+ return NULL;
+}
+static inline void xfrm_put_translator(struct xfrm_translator *xtr)
+{
+}
+#endif
+
#endif /* _NET_XFRM_H */