aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ip_tunnel.c
diff options
context:
space:
mode:
authorstephen hemminger <stephen@networkplumber.org>2013-08-06 01:51:37 -0400
committerDavid S. Miller <davem@davemloft.net>2013-08-07 19:47:52 -0400
commit6261d983f226f0a6a8d4d32b57a032bc23a5ebb6 (patch)
tree4bed875ac9758214183ebbed0e9b0f62afba617b /net/ipv4/ip_tunnel.c
parent8a56d243ca60c92c0b80307422ae75676873a715 (diff)
ip_tunnel: embed hash list head
The IP tunnel hash heads can be embedded in the per-net structure since it is a fixed size. Reduce the size so that the total structure fits in a page size. The original size was overly large, even NETDEV_HASHBITS is only 8 bits! Also, add some white space for readability. Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> Acked-by: Pravin B Shelar <pshelar@nicira.com>. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ip_tunnel.c')
-rw-r--r--net/ipv4/ip_tunnel.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index ca1cb2d5f6e2..9fdf8a6d95f3 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -838,15 +838,16 @@ int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id,
838{ 838{
839 struct ip_tunnel_net *itn = net_generic(net, ip_tnl_net_id); 839 struct ip_tunnel_net *itn = net_generic(net, ip_tnl_net_id);
840 struct ip_tunnel_parm parms; 840 struct ip_tunnel_parm parms;
841 unsigned int i;
841 842
842 itn->tunnels = kzalloc(IP_TNL_HASH_SIZE * sizeof(struct hlist_head), GFP_KERNEL); 843 for (i = 0; i < IP_TNL_HASH_SIZE; i++)
843 if (!itn->tunnels) 844 INIT_HLIST_HEAD(&itn->tunnels[i]);
844 return -ENOMEM;
845 845
846 if (!ops) { 846 if (!ops) {
847 itn->fb_tunnel_dev = NULL; 847 itn->fb_tunnel_dev = NULL;
848 return 0; 848 return 0;
849 } 849 }
850
850 memset(&parms, 0, sizeof(parms)); 851 memset(&parms, 0, sizeof(parms));
851 if (devname) 852 if (devname)
852 strlcpy(parms.name, devname, IFNAMSIZ); 853 strlcpy(parms.name, devname, IFNAMSIZ);
@@ -854,10 +855,9 @@ int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id,
854 rtnl_lock(); 855 rtnl_lock();
855 itn->fb_tunnel_dev = __ip_tunnel_create(net, ops, &parms); 856 itn->fb_tunnel_dev = __ip_tunnel_create(net, ops, &parms);
856 rtnl_unlock(); 857 rtnl_unlock();
857 if (IS_ERR(itn->fb_tunnel_dev)) { 858
858 kfree(itn->tunnels); 859 if (IS_ERR(itn->fb_tunnel_dev))
859 return PTR_ERR(itn->fb_tunnel_dev); 860 return PTR_ERR(itn->fb_tunnel_dev);
860 }
861 861
862 return 0; 862 return 0;
863} 863}
@@ -887,7 +887,6 @@ void ip_tunnel_delete_net(struct ip_tunnel_net *itn)
887 ip_tunnel_destroy(itn, &list); 887 ip_tunnel_destroy(itn, &list);
888 unregister_netdevice_many(&list); 888 unregister_netdevice_many(&list);
889 rtnl_unlock(); 889 rtnl_unlock();
890 kfree(itn->tunnels);
891} 890}
892EXPORT_SYMBOL_GPL(ip_tunnel_delete_net); 891EXPORT_SYMBOL_GPL(ip_tunnel_delete_net);
893 892