Commit 2c2910a4 authored by Dietmar Eggemann's avatar Dietmar Eggemann Committed by David S. Miller

[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: default avatarDietmar Eggemann <dietmar.eggemann@gmx.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ae9cda5d
...@@ -283,14 +283,18 @@ static inline int ip_rcv_finish(struct sk_buff *skb) ...@@ -283,14 +283,18 @@ static inline int ip_rcv_finish(struct sk_buff *skb)
{ {
struct net_device *dev = skb->dev; struct net_device *dev = skb->dev;
struct iphdr *iph = skb->nh.iph; struct iphdr *iph = skb->nh.iph;
int err;
/* /*
* Initialise the virtual path cache for the packet. It describes * Initialise the virtual path cache for the packet. It describes
* how the packet travels inside Linux networking. * how the packet travels inside Linux networking.
*/ */
if (skb->dst == NULL) { if (skb->dst == NULL) {
if (ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev)) if ((err = ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev))) {
if (err == -EHOSTUNREACH)
IP_INC_STATS_BH(IPSTATS_MIB_INADDRERRORS);
goto drop; goto drop;
}
} }
#ifdef CONFIG_NET_CLS_ROUTE #ifdef CONFIG_NET_CLS_ROUTE
......
...@@ -1909,7 +1909,7 @@ static int ip_route_input_slow(struct sk_buff *skb, u32 daddr, u32 saddr, ...@@ -1909,7 +1909,7 @@ static int ip_route_input_slow(struct sk_buff *skb, u32 daddr, u32 saddr,
*/ */
if ((err = fib_lookup(&fl, &res)) != 0) { if ((err = fib_lookup(&fl, &res)) != 0) {
if (!IN_DEV_FORWARD(in_dev)) if (!IN_DEV_FORWARD(in_dev))
goto e_inval; goto e_hostunreach;
goto no_route; goto no_route;
} }
free_res = 1; free_res = 1;
...@@ -1933,7 +1933,7 @@ static int ip_route_input_slow(struct sk_buff *skb, u32 daddr, u32 saddr, ...@@ -1933,7 +1933,7 @@ static int ip_route_input_slow(struct sk_buff *skb, u32 daddr, u32 saddr,
} }
if (!IN_DEV_FORWARD(in_dev)) if (!IN_DEV_FORWARD(in_dev))
goto e_inval; goto e_hostunreach;
if (res.type != RTN_UNICAST) if (res.type != RTN_UNICAST)
goto martian_destination; goto martian_destination;
...@@ -2025,6 +2025,11 @@ martian_destination: ...@@ -2025,6 +2025,11 @@ martian_destination:
"%u.%u.%u.%u, dev %s\n", "%u.%u.%u.%u, dev %s\n",
NIPQUAD(daddr), NIPQUAD(saddr), dev->name); NIPQUAD(daddr), NIPQUAD(saddr), dev->name);
#endif #endif
e_hostunreach:
err = -EHOSTUNREACH;
goto done;
e_inval: e_inval:
err = -EINVAL; err = -EINVAL;
goto done; goto done;
......
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