[IPV4]: Snmpv2 Mib IP counter ipInAddrErrors support

I followed Thomas' proposal to see every martian destination as a case
where the ipInAddrErrors counter has to be incremented. There are
two advantages by doing so: (1) The relation between the ipInReceive
counter and all the other ipInXXX counters is more accurate in the
case the RTN_UNICAST code check fails and (2) it makes the code in
ip_route_input_slow easier.

Signed-off-by: Dietmar Eggemann <dietmar.eggemann@gmx.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Dietmar Eggemann and committed by David S. Miller 2c2910a4 ae9cda5d

+12 -3
+5 -1
net/ipv4/ip_input.c
··· 283 283 { 284 284 struct net_device *dev = skb->dev; 285 285 struct iphdr *iph = skb->nh.iph; 286 + int err; 286 287 287 288 /* 288 289 * Initialise the virtual path cache for the packet. It describes 289 290 * how the packet travels inside Linux networking. 290 291 */ 291 292 if (skb->dst == NULL) { 292 - if (ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev)) 293 + if ((err = ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev))) { 294 + if (err == -EHOSTUNREACH) 295 + IP_INC_STATS_BH(IPSTATS_MIB_INADDRERRORS); 293 296 goto drop; 297 + } 294 298 } 295 299 296 300 #ifdef CONFIG_NET_CLS_ROUTE
+7 -2
net/ipv4/route.c
··· 1909 1909 */ 1910 1910 if ((err = fib_lookup(&fl, &res)) != 0) { 1911 1911 if (!IN_DEV_FORWARD(in_dev)) 1912 - goto e_inval; 1912 + goto e_hostunreach; 1913 1913 goto no_route; 1914 1914 } 1915 1915 free_res = 1; ··· 1933 1933 } 1934 1934 1935 1935 if (!IN_DEV_FORWARD(in_dev)) 1936 - goto e_inval; 1936 + goto e_hostunreach; 1937 1937 if (res.type != RTN_UNICAST) 1938 1938 goto martian_destination; 1939 1939 ··· 2025 2025 "%u.%u.%u.%u, dev %s\n", 2026 2026 NIPQUAD(daddr), NIPQUAD(saddr), dev->name); 2027 2027 #endif 2028 + 2029 + e_hostunreach: 2030 + err = -EHOSTUNREACH; 2031 + goto done; 2032 + 2028 2033 e_inval: 2029 2034 err = -EINVAL; 2030 2035 goto done;