Commit c0ed1c14 authored by Steffen Klassert's avatar Steffen Klassert Committed by David S. Miller

net: Add a flow_cache_flush_deferred function

flow_cach_flush() might sleep but can be called from
atomic context via the xfrm garbage collector. So add
a flow_cache_flush_deferred() function and use this if
the xfrm garbage colector is invoked from within the
packet path.
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
Acked-by: default avatarTimo Teräs <timo.teras@iki.fi>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9f28a2fc
...@@ -207,6 +207,7 @@ extern struct flow_cache_object *flow_cache_lookup( ...@@ -207,6 +207,7 @@ extern struct flow_cache_object *flow_cache_lookup(
u8 dir, flow_resolve_t resolver, void *ctx); u8 dir, flow_resolve_t resolver, void *ctx);
extern void flow_cache_flush(void); extern void flow_cache_flush(void);
extern void flow_cache_flush_deferred(void);
extern atomic_t flow_cache_genid; extern atomic_t flow_cache_genid;
#endif #endif
...@@ -358,6 +358,18 @@ void flow_cache_flush(void) ...@@ -358,6 +358,18 @@ void flow_cache_flush(void)
put_online_cpus(); put_online_cpus();
} }
static void flow_cache_flush_task(struct work_struct *work)
{
flow_cache_flush();
}
static DECLARE_WORK(flow_cache_flush_work, flow_cache_flush_task);
void flow_cache_flush_deferred(void)
{
schedule_work(&flow_cache_flush_work);
}
static int __cpuinit flow_cache_cpu_prepare(struct flow_cache *fc, int cpu) static int __cpuinit flow_cache_cpu_prepare(struct flow_cache *fc, int cpu)
{ {
struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, cpu); struct flow_cache_percpu *fcp = per_cpu_ptr(fc->percpu, cpu);
......
...@@ -2276,8 +2276,6 @@ static void __xfrm_garbage_collect(struct net *net) ...@@ -2276,8 +2276,6 @@ static void __xfrm_garbage_collect(struct net *net)
{ {
struct dst_entry *head, *next; struct dst_entry *head, *next;
flow_cache_flush();
spin_lock_bh(&xfrm_policy_sk_bundle_lock); spin_lock_bh(&xfrm_policy_sk_bundle_lock);
head = xfrm_policy_sk_bundles; head = xfrm_policy_sk_bundles;
xfrm_policy_sk_bundles = NULL; xfrm_policy_sk_bundles = NULL;
...@@ -2290,6 +2288,18 @@ static void __xfrm_garbage_collect(struct net *net) ...@@ -2290,6 +2288,18 @@ static void __xfrm_garbage_collect(struct net *net)
} }
} }
static void xfrm_garbage_collect(struct net *net)
{
flow_cache_flush();
__xfrm_garbage_collect(net);
}
static void xfrm_garbage_collect_deferred(struct net *net)
{
flow_cache_flush_deferred();
__xfrm_garbage_collect(net);
}
static void xfrm_init_pmtu(struct dst_entry *dst) static void xfrm_init_pmtu(struct dst_entry *dst)
{ {
do { do {
...@@ -2422,7 +2432,7 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo) ...@@ -2422,7 +2432,7 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
if (likely(dst_ops->neigh_lookup == NULL)) if (likely(dst_ops->neigh_lookup == NULL))
dst_ops->neigh_lookup = xfrm_neigh_lookup; dst_ops->neigh_lookup = xfrm_neigh_lookup;
if (likely(afinfo->garbage_collect == NULL)) if (likely(afinfo->garbage_collect == NULL))
afinfo->garbage_collect = __xfrm_garbage_collect; afinfo->garbage_collect = xfrm_garbage_collect_deferred;
xfrm_policy_afinfo[afinfo->family] = afinfo; xfrm_policy_afinfo[afinfo->family] = afinfo;
} }
write_unlock_bh(&xfrm_policy_afinfo_lock); write_unlock_bh(&xfrm_policy_afinfo_lock);
...@@ -2516,7 +2526,7 @@ static int xfrm_dev_event(struct notifier_block *this, unsigned long event, void ...@@ -2516,7 +2526,7 @@ static int xfrm_dev_event(struct notifier_block *this, unsigned long event, void
switch (event) { switch (event) {
case NETDEV_DOWN: case NETDEV_DOWN:
__xfrm_garbage_collect(dev_net(dev)); xfrm_garbage_collect(dev_net(dev));
} }
return NOTIFY_DONE; return NOTIFY_DONE;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment