* [PATCH net-next v2] tunnels: correct conditional build of MPLS and IPv6
@ 2016-07-10 1:20 Simon Horman
2016-07-11 20:27 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Simon Horman @ 2016-07-10 1:20 UTC (permalink / raw)
To: David Miller; +Cc: netdev, Simon Horman
Using a combination if #if conditionals and goto labels to unwind
tunnel4_init seems unwieldy. This patch takes a simpler approach of
directly unregistering previously registered protocols when an error
occurs.
This fixes a number of problems with the current implementation
including the potential presence of labels when they are unused
and the potential absence of unregister code when it is needed.
Fixes: 8afe97e5d416 ("tunnels: support MPLS over IPv4 tunnels")
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
net/ipv4/tunnel4.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/net/ipv4/tunnel4.c b/net/ipv4/tunnel4.c
index 45cd4253583a..ec35eaa5c029 100644
--- a/net/ipv4/tunnel4.c
+++ b/net/ipv4/tunnel4.c
@@ -208,24 +208,25 @@ static const struct net_protocol tunnelmpls4_protocol = {
static int __init tunnel4_init(void)
{
if (inet_add_protocol(&tunnel4_protocol, IPPROTO_IPIP))
- goto err_ipip;
+ goto err;
#if IS_ENABLED(CONFIG_IPV6)
- if (inet_add_protocol(&tunnel64_protocol, IPPROTO_IPV6))
- goto err_ipv6;
+ if (inet_add_protocol(&tunnel64_protocol, IPPROTO_IPV6)) {
+ inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP);
+ goto err;
+ }
#endif
#if IS_ENABLED(CONFIG_MPLS)
- if (inet_add_protocol(&tunnelmpls4_protocol, IPPROTO_MPLS))
- goto err_mpls;
+ if (inet_add_protocol(&tunnelmpls4_protocol, IPPROTO_MPLS)) {
+ inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP);
+#if IS_ENABLED(CONFIG_IPV6)
+ inet_del_protocol(&tunnel64_protocol, IPPROTO_IPV6);
+#endif
+ goto err;
+ }
#endif
return 0;
-#if IS_ENABLED(CONFIG_IPV6)
-err_mpls:
- inet_del_protocol(&tunnel4_protocol, IPPROTO_IPV6);
-#endif
-err_ipv6:
- inet_del_protocol(&tunnel4_protocol, IPPROTO_IPIP);
-err_ipip:
+err:
pr_err("%s: can't add protocol\n", __func__);
return -EAGAIN;
}
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next v2] tunnels: correct conditional build of MPLS and IPv6
2016-07-10 1:20 [PATCH net-next v2] tunnels: correct conditional build of MPLS and IPv6 Simon Horman
@ 2016-07-11 20:27 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-07-11 20:27 UTC (permalink / raw)
To: simon.horman; +Cc: netdev
From: Simon Horman <simon.horman@netronome.com>
Date: Sun, 10 Jul 2016 10:20:11 +0900
> Using a combination if #if conditionals and goto labels to unwind
> tunnel4_init seems unwieldy. This patch takes a simpler approach of
> directly unregistering previously registered protocols when an error
> occurs.
>
> This fixes a number of problems with the current implementation
> including the potential presence of labels when they are unused
> and the potential absence of unregister code when it is needed.
>
> Fixes: 8afe97e5d416 ("tunnels: support MPLS over IPv4 tunnels")
> Signed-off-by: Simon Horman <simon.horman@netronome.com>
Applied, thanks Simon.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-07-11 20:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-10 1:20 [PATCH net-next v2] tunnels: correct conditional build of MPLS and IPv6 Simon Horman
2016-07-11 20:27 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).