OSDN Git Service

xfrm: rate limit SA mapping change message to user space
authorAntony Antony <antony.antony@secunet.com>
Wed, 22 Dec 2021 13:11:18 +0000 (14:11 +0100)
committerSteffen Klassert <steffen.klassert@secunet.com>
Thu, 23 Dec 2021 08:32:51 +0000 (09:32 +0100)
commit4e484b3e969b52effd95c17f7a86f39208b2ccf4
tree813756c3b558d6f58ce1e828f59183ed6ab9417d
parent23b6a6df94c6ce434e7947cfad14b1640fb9f794
xfrm: rate limit SA mapping change message to user space

Kernel generates mapping change message, XFRM_MSG_MAPPING,
when a source port chage is detected on a input state with UDP
encapsulation set.  Kernel generates a message for each IPsec packet
with new source port.  For a high speed flow per packet mapping change
message can be excessive, and can overload the user space listener.

Introduce rate limiting for XFRM_MSG_MAPPING message to the user space.

The rate limiting is configurable via netlink, when adding a new SA or
updating it. Use the new attribute XFRMA_MTIMER_THRESH in seconds.

v1->v2 change:
update xfrm_sa_len()

v2->v3 changes:
use u32 insted unsigned long to reduce size of struct xfrm_state
fix xfrm_ompat size Reported-by: kernel test robot <lkp@intel.com>
accept XFRM_MSG_MAPPING only when XFRMA_ENCAP is present

Co-developed-by: Thomas Egerer <thomas.egerer@secunet.com>
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
Signed-off-by: Antony Antony <antony.antony@secunet.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
include/net/xfrm.h
include/uapi/linux/xfrm.h
net/xfrm/xfrm_compat.c
net/xfrm/xfrm_state.c
net/xfrm/xfrm_user.c