Commit a8757147 authored by Xin Long's avatar Xin Long Committed by Steffen Klassert

ip6_vti: not register vti_ipv6_handler twice

An xfrm6_tunnel object is linked into the list when registering,
so vti_ipv6_handler can not be registered twice, otherwise its
next pointer will be overwritten on the second time.

So this patch is to define a new xfrm6_tunnel object to register
for AF_INET.

Fixes: 2ab110cb ("ip6_vti: support IP6IP tunnel processing")
Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
parent 55a48c7e
......@@ -1236,6 +1236,13 @@ static struct xfrm6_tunnel vti_ipv6_handler __read_mostly = {
.err_handler = vti6_err,
.priority = 0,
};
static struct xfrm6_tunnel vti_ip6ip_handler __read_mostly = {
.handler = vti6_rcv_tunnel,
.cb_handler = vti6_rcv_cb,
.err_handler = vti6_err,
.priority = 0,
};
#endif
/**
......@@ -1268,7 +1275,7 @@ static int __init vti6_tunnel_init(void)
err = xfrm6_tunnel_register(&vti_ipv6_handler, AF_INET6);
if (err < 0)
goto vti_tunnel_ipv6_failed;
err = xfrm6_tunnel_register(&vti_ipv6_handler, AF_INET);
err = xfrm6_tunnel_register(&vti_ip6ip_handler, AF_INET);
if (err < 0)
goto vti_tunnel_ip6ip_failed;
#endif
......@@ -1282,7 +1289,7 @@ static int __init vti6_tunnel_init(void)
rtnl_link_failed:
#if IS_ENABLED(CONFIG_INET6_XFRM_TUNNEL)
err = xfrm6_tunnel_deregister(&vti_ipv6_handler, AF_INET);
err = xfrm6_tunnel_deregister(&vti_ip6ip_handler, AF_INET);
vti_tunnel_ip6ip_failed:
err = xfrm6_tunnel_deregister(&vti_ipv6_handler, AF_INET6);
vti_tunnel_ipv6_failed:
......@@ -1306,7 +1313,7 @@ static void __exit vti6_tunnel_cleanup(void)
{
rtnl_link_unregister(&vti6_link_ops);
#if IS_ENABLED(CONFIG_INET6_XFRM_TUNNEL)
xfrm6_tunnel_deregister(&vti_ipv6_handler, AF_INET);
xfrm6_tunnel_deregister(&vti_ip6ip_handler, AF_INET);
xfrm6_tunnel_deregister(&vti_ipv6_handler, AF_INET6);
#endif
xfrm6_protocol_deregister(&vti_ipcomp6_protocol, IPPROTO_COMP);
......
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