Commit 8d9ba388 authored by Jesper Dangaard Brouer's avatar Jesper Dangaard Brouer Committed by David S. Miller

Revert "icmp: avoid allocating large struct on stack"

This reverts commit 9a99d4a5 ("icmp: avoid allocating large struct
on stack"), because struct icmp_bxm no really a large struct, and
allocating and free of this small 112 bytes hurts performance.

Fixes: 9a99d4a5 ("icmp: avoid allocating large struct on stack")
Signed-off-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
Acked-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent aaa9c107
...@@ -571,7 +571,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) ...@@ -571,7 +571,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
{ {
struct iphdr *iph; struct iphdr *iph;
int room; int room;
struct icmp_bxm *icmp_param; struct icmp_bxm icmp_param;
struct rtable *rt = skb_rtable(skb_in); struct rtable *rt = skb_rtable(skb_in);
struct ipcm_cookie ipc; struct ipcm_cookie ipc;
struct flowi4 fl4; struct flowi4 fl4;
...@@ -648,13 +648,9 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) ...@@ -648,13 +648,9 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
} }
} }
icmp_param = kmalloc(sizeof(*icmp_param), GFP_ATOMIC);
if (!icmp_param)
return;
sk = icmp_xmit_lock(net); sk = icmp_xmit_lock(net);
if (!sk) if (!sk)
goto out_free; return;
/* /*
* Construct source address and options. * Construct source address and options.
...@@ -681,7 +677,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) ...@@ -681,7 +677,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
iph->tos; iph->tos;
mark = IP4_REPLY_MARK(net, skb_in->mark); mark = IP4_REPLY_MARK(net, skb_in->mark);
if (ip_options_echo(&icmp_param->replyopts.opt.opt, skb_in)) if (ip_options_echo(&icmp_param.replyopts.opt.opt, skb_in))
goto out_unlock; goto out_unlock;
...@@ -689,22 +685,22 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) ...@@ -689,22 +685,22 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
* Prepare data for ICMP header. * Prepare data for ICMP header.
*/ */
icmp_param->data.icmph.type = type; icmp_param.data.icmph.type = type;
icmp_param->data.icmph.code = code; icmp_param.data.icmph.code = code;
icmp_param->data.icmph.un.gateway = info; icmp_param.data.icmph.un.gateway = info;
icmp_param->data.icmph.checksum = 0; icmp_param.data.icmph.checksum = 0;
icmp_param->skb = skb_in; icmp_param.skb = skb_in;
icmp_param->offset = skb_network_offset(skb_in); icmp_param.offset = skb_network_offset(skb_in);
inet_sk(sk)->tos = tos; inet_sk(sk)->tos = tos;
sk->sk_mark = mark; sk->sk_mark = mark;
ipc.addr = iph->saddr; ipc.addr = iph->saddr;
ipc.opt = &icmp_param->replyopts.opt; ipc.opt = &icmp_param.replyopts.opt;
ipc.tx_flags = 0; ipc.tx_flags = 0;
ipc.ttl = 0; ipc.ttl = 0;
ipc.tos = -1; ipc.tos = -1;
rt = icmp_route_lookup(net, &fl4, skb_in, iph, saddr, tos, mark, rt = icmp_route_lookup(net, &fl4, skb_in, iph, saddr, tos, mark,
type, code, icmp_param); type, code, &icmp_param);
if (IS_ERR(rt)) if (IS_ERR(rt))
goto out_unlock; goto out_unlock;
...@@ -716,21 +712,19 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) ...@@ -716,21 +712,19 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
room = dst_mtu(&rt->dst); room = dst_mtu(&rt->dst);
if (room > 576) if (room > 576)
room = 576; room = 576;
room -= sizeof(struct iphdr) + icmp_param->replyopts.opt.opt.optlen; room -= sizeof(struct iphdr) + icmp_param.replyopts.opt.opt.optlen;
room -= sizeof(struct icmphdr); room -= sizeof(struct icmphdr);
icmp_param->data_len = skb_in->len - icmp_param->offset; icmp_param.data_len = skb_in->len - icmp_param.offset;
if (icmp_param->data_len > room) if (icmp_param.data_len > room)
icmp_param->data_len = room; icmp_param.data_len = room;
icmp_param->head_len = sizeof(struct icmphdr); icmp_param.head_len = sizeof(struct icmphdr);
icmp_push_reply(icmp_param, &fl4, &ipc, &rt); icmp_push_reply(&icmp_param, &fl4, &ipc, &rt);
ende: ende:
ip_rt_put(rt); ip_rt_put(rt);
out_unlock: out_unlock:
icmp_xmit_unlock(sk); icmp_xmit_unlock(sk);
out_free:
kfree(icmp_param);
out:; out:;
} }
EXPORT_SYMBOL(icmp_send); EXPORT_SYMBOL(icmp_send);
......
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