Skip to content

Commit 1a1ccc9

Browse files
committed
xfrm: Remove caching of xfrm_policy_sk_bundles
We currently cache socket policy bundles at xfrm_policy_sk_bundles. These cached bundles are never used. Instead we create and cache a new one whenever xfrm_lookup() is called on a socket policy. Most protocols cache the used routes to the socket, so let's remove the unused caching of socket policy bundles in xfrm. Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
1 parent d362309 commit 1a1ccc9

2 files changed

Lines changed: 0 additions & 29 deletions

File tree

‎include/net/netns/xfrm.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ struct netns_xfrm {
5959
struct dst_ops xfrm6_dst_ops;
6060
#endif
6161
spinlock_t xfrm_state_lock;
62-
spinlock_t xfrm_policy_sk_bundle_lock;
6362
rwlock_t xfrm_policy_lock;
6463
struct mutex xfrm_cfg_mutex;
6564

‎net/xfrm/xfrm_policy.c‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
#define XFRM_QUEUE_TMO_MAX ((unsigned)(60*HZ))
4040
#define XFRM_MAX_QUEUE_LEN 100
4141

42-
static struct dst_entry *xfrm_policy_sk_bundles;
43-
4442
static DEFINE_SPINLOCK(xfrm_policy_afinfo_lock);
4543
static struct xfrm_policy_afinfo __rcu *xfrm_policy_afinfo[NPROTO]
4644
__read_mostly;
@@ -2109,13 +2107,6 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
21092107
goto no_transform;
21102108
}
21112109

2112-
dst_hold(&xdst->u.dst);
2113-
2114-
spin_lock_bh(&net->xfrm.xfrm_policy_sk_bundle_lock);
2115-
xdst->u.dst.next = xfrm_policy_sk_bundles;
2116-
xfrm_policy_sk_bundles = &xdst->u.dst;
2117-
spin_unlock_bh(&net->xfrm.xfrm_policy_sk_bundle_lock);
2118-
21192110
route = xdst->route;
21202111
}
21212112
}
@@ -2549,33 +2540,15 @@ static struct dst_entry *xfrm_negative_advice(struct dst_entry *dst)
25492540
return dst;
25502541
}
25512542

2552-
static void __xfrm_garbage_collect(struct net *net)
2553-
{
2554-
struct dst_entry *head, *next;
2555-
2556-
spin_lock_bh(&net->xfrm.xfrm_policy_sk_bundle_lock);
2557-
head = xfrm_policy_sk_bundles;
2558-
xfrm_policy_sk_bundles = NULL;
2559-
spin_unlock_bh(&net->xfrm.xfrm_policy_sk_bundle_lock);
2560-
2561-
while (head) {
2562-
next = head->next;
2563-
dst_free(head);
2564-
head = next;
2565-
}
2566-
}
2567-
25682543
void xfrm_garbage_collect(struct net *net)
25692544
{
25702545
flow_cache_flush(net);
2571-
__xfrm_garbage_collect(net);
25722546
}
25732547
EXPORT_SYMBOL(xfrm_garbage_collect);
25742548

25752549
static void xfrm_garbage_collect_deferred(struct net *net)
25762550
{
25772551
flow_cache_flush_deferred(net);
2578-
__xfrm_garbage_collect(net);
25792552
}
25802553

25812554
static void xfrm_init_pmtu(struct dst_entry *dst)
@@ -2944,7 +2917,6 @@ static int __net_init xfrm_net_init(struct net *net)
29442917
/* Initialize the per-net locks here */
29452918
spin_lock_init(&net->xfrm.xfrm_state_lock);
29462919
rwlock_init(&net->xfrm.xfrm_policy_lock);
2947-
spin_lock_init(&net->xfrm.xfrm_policy_sk_bundle_lock);
29482920
mutex_init(&net->xfrm.xfrm_cfg_mutex);
29492921

29502922
flow_cache_init(net);

0 commit comments

Comments
 (0)