Skip to content

Commit 99c6f60

Browse files
Jamal Hadi Salimdavem330
authored andcommitted
ipsec: pfkey should ignore events when no listeners
When pfkey has no km listeners, it still does a lot of work before finding out there aint nobody out there. If a tree falls in a forest and no one is around to hear it, does it make a sound? In this case it makes a lot of noise: With this short-circuit adding 10s of thousands of SAs using netlink improves performance by ~10%. Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent bc6cffd commit 99c6f60

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/key/af_key.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3030,6 +3030,9 @@ static int key_notify_sa_expire(struct xfrm_state *x, struct km_event *c)
30303030

30313031
static int pfkey_send_notify(struct xfrm_state *x, struct km_event *c)
30323032
{
3033+
if (atomic_read(&pfkey_socks_nr) == 0)
3034+
return 0;
3035+
30333036
switch (c->event) {
30343037
case XFRM_MSG_EXPIRE:
30353038
return key_notify_sa_expire(x, c);

0 commit comments

Comments
 (0)