Skip to content

Commit

Permalink
ipsec: pfkey should ignore events when no listeners
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jamal Hadi Salim authored and David S. Miller committed Jun 10, 2008
1 parent bc6cffd commit 99c6f60
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/key/af_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -3030,6 +3030,9 @@ static int key_notify_sa_expire(struct xfrm_state *x, struct km_event *c)

static int pfkey_send_notify(struct xfrm_state *x, struct km_event *c)
{
if (atomic_read(&pfkey_socks_nr) == 0)
return 0;

switch (c->event) {
case XFRM_MSG_EXPIRE:
return key_notify_sa_expire(x, c);
Expand Down

0 comments on commit 99c6f60

Please sign in to comment.