提交 358352b8 编写于 作者: P Pavel Emelyanov 提交者: David S. Miller

[INET]: Cleanup the xfrm4_tunnel_(un)register

Both check for the family to select an appropriate tunnel list.
Consolidate this check and make the for() loop more readable.
Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 99f93326
...@@ -17,6 +17,11 @@ static struct xfrm_tunnel *tunnel4_handlers; ...@@ -17,6 +17,11 @@ static struct xfrm_tunnel *tunnel4_handlers;
static struct xfrm_tunnel *tunnel64_handlers; static struct xfrm_tunnel *tunnel64_handlers;
static DEFINE_MUTEX(tunnel4_mutex); static DEFINE_MUTEX(tunnel4_mutex);
static inline struct xfrm_tunnel **fam_handlers(unsigned short family)
{
return (family == AF_INET) ? &tunnel4_handlers : &tunnel64_handlers;
}
int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family) int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family)
{ {
struct xfrm_tunnel **pprev; struct xfrm_tunnel **pprev;
...@@ -25,8 +30,7 @@ int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family) ...@@ -25,8 +30,7 @@ int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family)
mutex_lock(&tunnel4_mutex); mutex_lock(&tunnel4_mutex);
for (pprev = (family == AF_INET) ? &tunnel4_handlers : &tunnel64_handlers; for (pprev = fam_handlers(family); *pprev; pprev = &(*pprev)->next) {
*pprev; pprev = &(*pprev)->next) {
if ((*pprev)->priority > priority) if ((*pprev)->priority > priority)
break; break;
if ((*pprev)->priority == priority) if ((*pprev)->priority == priority)
...@@ -53,8 +57,7 @@ int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family) ...@@ -53,8 +57,7 @@ int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family)
mutex_lock(&tunnel4_mutex); mutex_lock(&tunnel4_mutex);
for (pprev = (family == AF_INET) ? &tunnel4_handlers : &tunnel64_handlers; for (pprev = fam_handlers(family); *pprev; pprev = &(*pprev)->next) {
*pprev; pprev = &(*pprev)->next) {
if (*pprev == handler) { if (*pprev == handler) {
*pprev = handler->next; *pprev = handler->next;
ret = 0; ret = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册