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>
This commit is contained in:
committed by
David S. Miller
parent
8a56d243ca
commit
6261d983f2
@@ -86,12 +86,12 @@ struct tnl_ptk_info {
|
|||||||
#define PACKET_RCVD 0
|
#define PACKET_RCVD 0
|
||||||
#define PACKET_REJECT 1
|
#define PACKET_REJECT 1
|
||||||
|
|
||||||
#define IP_TNL_HASH_BITS 10
|
#define IP_TNL_HASH_BITS 7
|
||||||
#define IP_TNL_HASH_SIZE (1 << IP_TNL_HASH_BITS)
|
#define IP_TNL_HASH_SIZE (1 << IP_TNL_HASH_BITS)
|
||||||
|
|
||||||
struct ip_tunnel_net {
|
struct ip_tunnel_net {
|
||||||
struct hlist_head *tunnels;
|
|
||||||
struct net_device *fb_tunnel_dev;
|
struct net_device *fb_tunnel_dev;
|
||||||
|
struct hlist_head tunnels[IP_TNL_HASH_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_INET
|
#ifdef CONFIG_INET
|
||||||
|
@@ -838,15 +838,16 @@ int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id,
|
|||||||
{
|
{
|
||||||
struct ip_tunnel_net *itn = net_generic(net, ip_tnl_net_id);
|
struct ip_tunnel_net *itn = net_generic(net, ip_tnl_net_id);
|
||||||
struct ip_tunnel_parm parms;
|
struct ip_tunnel_parm parms;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
itn->tunnels = kzalloc(IP_TNL_HASH_SIZE * sizeof(struct hlist_head), GFP_KERNEL);
|
for (i = 0; i < IP_TNL_HASH_SIZE; i++)
|
||||||
if (!itn->tunnels)
|
INIT_HLIST_HEAD(&itn->tunnels[i]);
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
if (!ops) {
|
if (!ops) {
|
||||||
itn->fb_tunnel_dev = NULL;
|
itn->fb_tunnel_dev = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&parms, 0, sizeof(parms));
|
memset(&parms, 0, sizeof(parms));
|
||||||
if (devname)
|
if (devname)
|
||||||
strlcpy(parms.name, devname, IFNAMSIZ);
|
strlcpy(parms.name, devname, IFNAMSIZ);
|
||||||
@@ -854,10 +855,9 @@ int ip_tunnel_init_net(struct net *net, int ip_tnl_net_id,
|
|||||||
rtnl_lock();
|
rtnl_lock();
|
||||||
itn->fb_tunnel_dev = __ip_tunnel_create(net, ops, &parms);
|
itn->fb_tunnel_dev = __ip_tunnel_create(net, ops, &parms);
|
||||||
rtnl_unlock();
|
rtnl_unlock();
|
||||||
if (IS_ERR(itn->fb_tunnel_dev)) {
|
|
||||||
kfree(itn->tunnels);
|
if (IS_ERR(itn->fb_tunnel_dev))
|
||||||
return PTR_ERR(itn->fb_tunnel_dev);
|
return PTR_ERR(itn->fb_tunnel_dev);
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -887,7 +887,6 @@ void ip_tunnel_delete_net(struct ip_tunnel_net *itn)
|
|||||||
ip_tunnel_destroy(itn, &list);
|
ip_tunnel_destroy(itn, &list);
|
||||||
unregister_netdevice_many(&list);
|
unregister_netdevice_many(&list);
|
||||||
rtnl_unlock();
|
rtnl_unlock();
|
||||||
kfree(itn->tunnels);
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(ip_tunnel_delete_net);
|
EXPORT_SYMBOL_GPL(ip_tunnel_delete_net);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user