diff options
author | David S. Miller <davem@davemloft.net> | 2012-06-19 21:56:21 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-06-19 21:56:21 -0400 |
commit | f9242b6b28d61295f2bf7e8adfb1060b382e5381 (patch) | |
tree | b395670bd6ae832e9f6f87f47a1840baf3a06d0d /net/ipv4/icmp.c | |
parent | 677a3d60fb3153f786a0d28fcf0287670e7bd3c2 (diff) |
inet: Sanitize inet{,6} protocol demux.
Don't pretend that inet_protos[] and inet6_protos[] are hashes, thay
are just a straight arrays. Remove all unnecessary hash masking.
Document MAX_INET_PROTOS.
Use RAW_HTABLE_SIZE when appropriate.
Reported-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/icmp.c')
-rw-r--r-- | net/ipv4/icmp.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index e1caa1abe5d1..49a74cc79dc8 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
@@ -637,12 +637,12 @@ EXPORT_SYMBOL(icmp_send); | |||
637 | 637 | ||
638 | static void icmp_unreach(struct sk_buff *skb) | 638 | static void icmp_unreach(struct sk_buff *skb) |
639 | { | 639 | { |
640 | const struct net_protocol *ipprot; | ||
640 | const struct iphdr *iph; | 641 | const struct iphdr *iph; |
641 | struct icmphdr *icmph; | 642 | struct icmphdr *icmph; |
642 | int hash, protocol; | ||
643 | const struct net_protocol *ipprot; | ||
644 | u32 info = 0; | ||
645 | struct net *net; | 643 | struct net *net; |
644 | u32 info = 0; | ||
645 | int protocol; | ||
646 | 646 | ||
647 | net = dev_net(skb_dst(skb)->dev); | 647 | net = dev_net(skb_dst(skb)->dev); |
648 | 648 | ||
@@ -731,9 +731,8 @@ static void icmp_unreach(struct sk_buff *skb) | |||
731 | */ | 731 | */ |
732 | raw_icmp_error(skb, protocol, info); | 732 | raw_icmp_error(skb, protocol, info); |
733 | 733 | ||
734 | hash = protocol & (MAX_INET_PROTOS - 1); | ||
735 | rcu_read_lock(); | 734 | rcu_read_lock(); |
736 | ipprot = rcu_dereference(inet_protos[hash]); | 735 | ipprot = rcu_dereference(inet_protos[protocol]); |
737 | if (ipprot && ipprot->err_handler) | 736 | if (ipprot && ipprot->err_handler) |
738 | ipprot->err_handler(skb, info); | 737 | ipprot->err_handler(skb, info); |
739 | rcu_read_unlock(); | 738 | rcu_read_unlock(); |