xfrm: remove xfrm_state_put_afinfo

commit 44abdc3047
("xfrm: replace rwlock on xfrm_state_afinfo with rcu") made
xfrm_state_put_afinfo equivalent to rcu_read_unlock.

Use spatch to replace it with direct calls to rcu_read_unlock:

@@
struct xfrm_state_afinfo *a;
@@

-  xfrm_state_put_afinfo(a);
+  rcu_read_unlock();

old:
 text    data     bss     dec     hex filename
22570      72     424   23066    5a1a xfrm_state.o
 1612       0       0    1612     64c xfrm_output.o
new:
22554      72     424   23050    5a0a xfrm_state.o
 1596       0       0    1596     63c xfrm_output.o

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
This commit is contained in:
Florian Westphal 2017-01-09 14:20:47 +01:00 коммит произвёл Steffen Klassert
Родитель 423826a7b1
Коммит af5d27c4e1
3 изменённых файлов: 16 добавлений и 24 удалений

Просмотреть файл

@ -343,7 +343,6 @@ struct xfrm_state_afinfo {
int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo); int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo); int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned int family); struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned int family);
void xfrm_state_put_afinfo(struct xfrm_state_afinfo *afinfo);
struct xfrm_input_afinfo { struct xfrm_input_afinfo {
unsigned int family; unsigned int family;

Просмотреть файл

@ -246,10 +246,8 @@ void xfrm_local_error(struct sk_buff *skb, int mtu)
return; return;
afinfo = xfrm_state_get_afinfo(proto); afinfo = xfrm_state_get_afinfo(proto);
if (!afinfo) if (afinfo)
return; afinfo->local_error(skb, mtu);
rcu_read_unlock();
afinfo->local_error(skb, mtu);
xfrm_state_put_afinfo(afinfo);
} }
EXPORT_SYMBOL_GPL(xfrm_local_error); EXPORT_SYMBOL_GPL(xfrm_local_error);

Просмотреть файл

@ -192,7 +192,7 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
else else
err = -EEXIST; err = -EEXIST;
spin_unlock_bh(&xfrm_type_lock); spin_unlock_bh(&xfrm_type_lock);
xfrm_state_put_afinfo(afinfo); rcu_read_unlock();
return err; return err;
} }
EXPORT_SYMBOL(xfrm_register_type); EXPORT_SYMBOL(xfrm_register_type);
@ -213,7 +213,7 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
else else
typemap[type->proto] = NULL; typemap[type->proto] = NULL;
spin_unlock_bh(&xfrm_type_lock); spin_unlock_bh(&xfrm_type_lock);
xfrm_state_put_afinfo(afinfo); rcu_read_unlock();
return err; return err;
} }
EXPORT_SYMBOL(xfrm_unregister_type); EXPORT_SYMBOL(xfrm_unregister_type);
@ -235,13 +235,13 @@ retry:
if (unlikely(type && !try_module_get(type->owner))) if (unlikely(type && !try_module_get(type->owner)))
type = NULL; type = NULL;
if (!type && !modload_attempted) { if (!type && !modload_attempted) {
xfrm_state_put_afinfo(afinfo); rcu_read_unlock();
request_module("xfrm-type-%d-%d", family, proto); request_module("xfrm-type-%d-%d", family, proto);
modload_attempted = 1; modload_attempted = 1;
goto retry; goto retry;
} }
xfrm_state_put_afinfo(afinfo); rcu_read_unlock();
return type; return type;
} }
@ -280,7 +280,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
out: out:
spin_unlock_bh(&xfrm_mode_lock); spin_unlock_bh(&xfrm_mode_lock);
xfrm_state_put_afinfo(afinfo); rcu_read_unlock();
return err; return err;
} }
EXPORT_SYMBOL(xfrm_register_mode); EXPORT_SYMBOL(xfrm_register_mode);
@ -308,7 +308,7 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
} }
spin_unlock_bh(&xfrm_mode_lock); spin_unlock_bh(&xfrm_mode_lock);
xfrm_state_put_afinfo(afinfo); rcu_read_unlock();
return err; return err;
} }
EXPORT_SYMBOL(xfrm_unregister_mode); EXPORT_SYMBOL(xfrm_unregister_mode);
@ -331,13 +331,13 @@ retry:
if (unlikely(mode && !try_module_get(mode->owner))) if (unlikely(mode && !try_module_get(mode->owner)))
mode = NULL; mode = NULL;
if (!mode && !modload_attempted) { if (!mode && !modload_attempted) {
xfrm_state_put_afinfo(afinfo); rcu_read_unlock();
request_module("xfrm-mode-%d-%d", family, encap); request_module("xfrm-mode-%d-%d", family, encap);
modload_attempted = 1; modload_attempted = 1;
goto retry; goto retry;
} }
xfrm_state_put_afinfo(afinfo); rcu_read_unlock();
return mode; return mode;
} }
@ -651,13 +651,13 @@ xfrm_init_tempstate(struct xfrm_state *x, const struct flowi *fl,
afinfo->init_tempsel(&x->sel, fl); afinfo->init_tempsel(&x->sel, fl);
if (family != tmpl->encap_family) { if (family != tmpl->encap_family) {
xfrm_state_put_afinfo(afinfo); rcu_read_unlock();
afinfo = xfrm_state_get_afinfo(tmpl->encap_family); afinfo = xfrm_state_get_afinfo(tmpl->encap_family);
if (!afinfo) if (!afinfo)
return -1; return -1;
} }
afinfo->init_temprop(x, tmpl, daddr, saddr); afinfo->init_temprop(x, tmpl, daddr, saddr);
xfrm_state_put_afinfo(afinfo); rcu_read_unlock();
return 0; return 0;
} }
@ -1474,7 +1474,7 @@ xfrm_tmpl_sort(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n,
if (afinfo->tmpl_sort) if (afinfo->tmpl_sort)
err = afinfo->tmpl_sort(dst, src, n); err = afinfo->tmpl_sort(dst, src, n);
spin_unlock_bh(&net->xfrm.xfrm_state_lock); spin_unlock_bh(&net->xfrm.xfrm_state_lock);
xfrm_state_put_afinfo(afinfo); rcu_read_unlock();
return err; return err;
} }
EXPORT_SYMBOL(xfrm_tmpl_sort); EXPORT_SYMBOL(xfrm_tmpl_sort);
@ -1494,7 +1494,7 @@ xfrm_state_sort(struct xfrm_state **dst, struct xfrm_state **src, int n,
if (afinfo->state_sort) if (afinfo->state_sort)
err = afinfo->state_sort(dst, src, n); err = afinfo->state_sort(dst, src, n);
spin_unlock_bh(&net->xfrm.xfrm_state_lock); spin_unlock_bh(&net->xfrm.xfrm_state_lock);
xfrm_state_put_afinfo(afinfo); rcu_read_unlock();
return err; return err;
} }
EXPORT_SYMBOL(xfrm_state_sort); EXPORT_SYMBOL(xfrm_state_sort);
@ -1978,11 +1978,6 @@ struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned int family)
return afinfo; return afinfo;
} }
void xfrm_state_put_afinfo(struct xfrm_state_afinfo *afinfo)
{
rcu_read_unlock();
}
/* Temporarily located here until net/xfrm/xfrm_tunnel.c is created */ /* Temporarily located here until net/xfrm/xfrm_tunnel.c is created */
void xfrm_state_delete_tunnel(struct xfrm_state *x) void xfrm_state_delete_tunnel(struct xfrm_state *x)
{ {
@ -2025,7 +2020,7 @@ int __xfrm_init_state(struct xfrm_state *x, bool init_replay)
if (afinfo->init_flags) if (afinfo->init_flags)
err = afinfo->init_flags(x); err = afinfo->init_flags(x);
xfrm_state_put_afinfo(afinfo); rcu_read_unlock();
if (err) if (err)
goto error; goto error;