net: fix the counter ICMP_MIB_INERRORS/ICMP6_MIB_INERRORS
When dealing with ICMPv[46] Error Message, function icmp_socket_deliver() and icmpv6_notify() do some valid checks on packet's length, but then some protocols check packet's length redaudantly. So remove those duplicated statements, and increase counter ICMP_MIB_INERRORS/ICMP6_MIB_INERRORS in function icmp_socket_deliver() and icmpv6_notify() respectively. In addition, add missed counter in udp6/udplite6 when socket is NULL. Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
299ee123e1
commit
7304fe4681
@@ -626,9 +626,10 @@ void icmpv6_notify(struct sk_buff *skb, u8 type, u8 code, __be32 info)
|
||||
int inner_offset;
|
||||
__be16 frag_off;
|
||||
u8 nexthdr;
|
||||
struct net *net = dev_net(skb->dev);
|
||||
|
||||
if (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))
|
||||
return;
|
||||
goto out;
|
||||
|
||||
nexthdr = ((struct ipv6hdr *)skb->data)->nexthdr;
|
||||
if (ipv6_ext_hdr(nexthdr)) {
|
||||
@@ -636,14 +637,14 @@ void icmpv6_notify(struct sk_buff *skb, u8 type, u8 code, __be32 info)
|
||||
inner_offset = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr),
|
||||
&nexthdr, &frag_off);
|
||||
if (inner_offset<0)
|
||||
return;
|
||||
goto out;
|
||||
} else {
|
||||
inner_offset = sizeof(struct ipv6hdr);
|
||||
}
|
||||
|
||||
/* Checkin header including 8 bytes of inner protocol header. */
|
||||
if (!pskb_may_pull(skb, inner_offset+8))
|
||||
return;
|
||||
goto out;
|
||||
|
||||
/* BUGGG_FUTURE: we should try to parse exthdrs in this packet.
|
||||
Without this we will not able f.e. to make source routed
|
||||
@@ -652,13 +653,15 @@ void icmpv6_notify(struct sk_buff *skb, u8 type, u8 code, __be32 info)
|
||||
--ANK (980726)
|
||||
*/
|
||||
|
||||
rcu_read_lock();
|
||||
ipprot = rcu_dereference(inet6_protos[nexthdr]);
|
||||
if (ipprot && ipprot->err_handler)
|
||||
ipprot->err_handler(skb, NULL, type, code, inner_offset, info);
|
||||
rcu_read_unlock();
|
||||
|
||||
raw6_icmp_error(skb, nexthdr, type, code, inner_offset, info);
|
||||
return;
|
||||
|
||||
out:
|
||||
ICMP6_INC_STATS_BH(net, __in6_dev_get(skb->dev), ICMP6_MIB_INERRORS);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user