diff options
-rw-r--r-- | net/ipv4/ip_gre.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 7631b20490f5..a2a5983dbf03 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -1665,14 +1665,15 @@ static int __init ipgre_init(void) | |||
1665 | 1665 | ||
1666 | printk(KERN_INFO "GRE over IPv4 tunneling driver\n"); | 1666 | printk(KERN_INFO "GRE over IPv4 tunneling driver\n"); |
1667 | 1667 | ||
1668 | if (inet_add_protocol(&ipgre_protocol, IPPROTO_GRE) < 0) { | ||
1669 | printk(KERN_INFO "ipgre init: can't add protocol\n"); | ||
1670 | return -EAGAIN; | ||
1671 | } | ||
1672 | |||
1673 | err = register_pernet_device(&ipgre_net_ops); | 1668 | err = register_pernet_device(&ipgre_net_ops); |
1674 | if (err < 0) | 1669 | if (err < 0) |
1675 | goto gen_device_failed; | 1670 | return err; |
1671 | |||
1672 | err = inet_add_protocol(&ipgre_protocol, IPPROTO_GRE); | ||
1673 | if (err < 0) { | ||
1674 | printk(KERN_INFO "ipgre init: can't add protocol\n"); | ||
1675 | goto add_proto_failed; | ||
1676 | } | ||
1676 | 1677 | ||
1677 | err = rtnl_link_register(&ipgre_link_ops); | 1678 | err = rtnl_link_register(&ipgre_link_ops); |
1678 | if (err < 0) | 1679 | if (err < 0) |
@@ -1688,9 +1689,9 @@ out: | |||
1688 | tap_ops_failed: | 1689 | tap_ops_failed: |
1689 | rtnl_link_unregister(&ipgre_link_ops); | 1690 | rtnl_link_unregister(&ipgre_link_ops); |
1690 | rtnl_link_failed: | 1691 | rtnl_link_failed: |
1691 | unregister_pernet_device(&ipgre_net_ops); | ||
1692 | gen_device_failed: | ||
1693 | inet_del_protocol(&ipgre_protocol, IPPROTO_GRE); | 1692 | inet_del_protocol(&ipgre_protocol, IPPROTO_GRE); |
1693 | add_proto_failed: | ||
1694 | unregister_pernet_device(&ipgre_net_ops); | ||
1694 | goto out; | 1695 | goto out; |
1695 | } | 1696 | } |
1696 | 1697 | ||
@@ -1698,9 +1699,9 @@ static void __exit ipgre_fini(void) | |||
1698 | { | 1699 | { |
1699 | rtnl_link_unregister(&ipgre_tap_ops); | 1700 | rtnl_link_unregister(&ipgre_tap_ops); |
1700 | rtnl_link_unregister(&ipgre_link_ops); | 1701 | rtnl_link_unregister(&ipgre_link_ops); |
1701 | unregister_pernet_device(&ipgre_net_ops); | ||
1702 | if (inet_del_protocol(&ipgre_protocol, IPPROTO_GRE) < 0) | 1702 | if (inet_del_protocol(&ipgre_protocol, IPPROTO_GRE) < 0) |
1703 | printk(KERN_INFO "ipgre close: can't remove protocol\n"); | 1703 | printk(KERN_INFO "ipgre close: can't remove protocol\n"); |
1704 | unregister_pernet_device(&ipgre_net_ops); | ||
1704 | } | 1705 | } |
1705 | 1706 | ||
1706 | module_init(ipgre_init); | 1707 | module_init(ipgre_init); |