c9e7c76d70
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>
30 lines
699 B
C
30 lines
699 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* XFRM compat layer
|
|
* Author: Dmitry Safonov <dima@arista.com>
|
|
* Based on code and translator idea by: Florian Westphal <fw@strlen.de>
|
|
*/
|
|
#include <linux/compat.h>
|
|
#include <linux/xfrm.h>
|
|
#include <net/xfrm.h>
|
|
|
|
static struct xfrm_translator xfrm_translator = {
|
|
.owner = THIS_MODULE,
|
|
};
|
|
|
|
static int __init xfrm_compat_init(void)
|
|
{
|
|
return xfrm_register_translator(&xfrm_translator);
|
|
}
|
|
|
|
static void __exit xfrm_compat_exit(void)
|
|
{
|
|
xfrm_unregister_translator(&xfrm_translator);
|
|
}
|
|
|
|
module_init(xfrm_compat_init);
|
|
module_exit(xfrm_compat_exit);
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_AUTHOR("Dmitry Safonov");
|
|
MODULE_DESCRIPTION("XFRM 32-bit compatibility layer");
|