From: Florian Westphal <fw@strlen.de>
To: netfilter-devel@vger.kernel.org
Cc: netdev@vger.kernel.org, Florian Westphal <fw@strlen.de>
Subject: [RFC PATCH 2/5] net: ipv4: move ip_rcv route error counter handling into helper function
Date: Mon, 12 Sep 2011 21:42:29 +0200 [thread overview]
Message-ID: <1315856552-1422-3-git-send-email-fw@strlen.de> (raw)
In-Reply-To: <1315856552-1422-1-git-send-email-fw@strlen.de>
This will avoid code duplication and messing with mib counters
in the planned netfilter reverse path filter match.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
include/net/ip.h | 1 +
net/ipv4/ip_input.c | 21 ++++++++++++---------
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/include/net/ip.h b/include/net/ip.h
index e9ea7c7..0001633 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -95,6 +95,7 @@ extern int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk,
struct ip_options_rcu *opt);
extern int ip_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev);
+extern void ip_rcv_inc_route_err_stats(struct net *net, int err);
extern int ip_local_deliver(struct sk_buff *skb);
extern int ip_mr_input(struct sk_buff *skb);
extern int ip_output(struct sk_buff *skb);
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index c8f48ef..43679f4 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -314,6 +314,17 @@ drop:
return -1;
}
+void ip_rcv_inc_route_err_stats(struct net *net, int err)
+{
+ if (err == -EHOSTUNREACH)
+ IP_INC_STATS_BH(net, IPSTATS_MIB_INADDRERRORS);
+ else if (err == -ENETUNREACH)
+ IP_INC_STATS_BH(net, IPSTATS_MIB_INNOROUTES);
+ else if (err == -EXDEV)
+ NET_INC_STATS_BH(net, LINUX_MIB_IPRPFILTER);
+}
+EXPORT_SYMBOL_GPL(ip_rcv_inc_route_err_stats);
+
static int ip_rcv_finish(struct sk_buff *skb)
{
const struct iphdr *iph = ip_hdr(skb);
@@ -327,15 +338,7 @@ static int ip_rcv_finish(struct sk_buff *skb)
int err = ip_route_input_noref(skb, iph->daddr, iph->saddr,
iph->tos, skb->dev);
if (unlikely(err)) {
- if (err == -EHOSTUNREACH)
- IP_INC_STATS_BH(dev_net(skb->dev),
- IPSTATS_MIB_INADDRERRORS);
- else if (err == -ENETUNREACH)
- IP_INC_STATS_BH(dev_net(skb->dev),
- IPSTATS_MIB_INNOROUTES);
- else if (err == -EXDEV)
- NET_INC_STATS_BH(dev_net(skb->dev),
- LINUX_MIB_IPRPFILTER);
+ ip_rcv_inc_route_err_stats(dev_net(skb->dev), err);
goto drop;
}
}
--
1.7.3.4
next prev parent reply other threads:[~2011-09-12 19:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-12 19:42 [PATCH RFC v2 0/5] netfilter reverse path filter matches Florian Westphal
2011-09-12 19:42 ` [RFC PATCH 1/5] net: ipv4: export fib_table_lookup Florian Westphal
2011-09-12 19:42 ` Florian Westphal [this message]
2011-09-12 19:42 ` [RFC PATCH 3/5] netfilter: add ipv4 reverse path filter match Florian Westphal
2011-09-12 19:42 ` [RFC PATCH 4/5] ipv6: add ip6_route_lookup Florian Westphal
2011-09-12 19:42 ` [RFC PATCH 5/5] netfilter: add ipv6 reverse path filter match Florian Westphal
2011-09-28 21:18 ` [PATCH RFC v2 0/5] netfilter reverse path filter matches Pablo Neira Ayuso
2011-09-28 21:23 ` Florian Westphal
2011-09-28 22:39 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1315856552-1422-3-git-send-email-fw@strlen.de \
--to=fw@strlen.de \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.