From: Pavel Emelyanov <xemul@openvz.org>
To: David Miller <davem@davemloft.net>
Cc: Linux Netdev List <netdev@vger.kernel.org>
Subject: [PATCH net-next 2/7] INET: toss struct net initialization around
Date: Mon, 07 Jul 2008 14:47:16 +0400 [thread overview]
Message-ID: <4871F434.3000104@openvz.org> (raw)
In-Reply-To: <4871F2D8.8030502@openvz.org>
Some places, that deal with ICMP statistics already have where
to get a struct net from, but use it directly, without declaring
a separate variable on the stack.
Since I will need this net soon, I declare a struct net on the
stack and use it in the existing places in a separate patch not
to spoil the future ones.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/dccp/ipv4.c | 3 ++-
net/ipv4/icmp.c | 4 +---
net/ipv4/tcp_ipv4.c | 3 ++-
net/ipv4/udp.c | 3 ++-
4 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 37d27bc..cc4f334 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -205,13 +205,14 @@ static void dccp_v4_err(struct sk_buff *skb, u32 info)
struct sock *sk;
__u64 seq;
int err;
+ struct net *net = dev_net(skb->dev);
if (skb->len < (iph->ihl << 2) + 8) {
ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
return;
}
- sk = inet_lookup(dev_net(skb->dev), &dccp_hashinfo,
+ sk = inet_lookup(net, &dccp_hashinfo,
iph->daddr, dh->dccph_dport,
iph->saddr, dh->dccph_sport, inet_iif(skb));
if (sk == NULL) {
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 1ffe7ad..56d6b94 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -973,6 +973,7 @@ int icmp_rcv(struct sk_buff *skb)
{
struct icmphdr *icmph;
struct rtable *rt = skb->rtable;
+ struct net *net = dev_net(rt->u.dst.dev);
if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
int nh;
@@ -1027,9 +1028,6 @@ int icmp_rcv(struct sk_buff *skb)
*/
if (rt->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) {
- struct net *net;
-
- net = dev_net(rt->u.dst.dev);
/*
* RFC 1122: 3.2.2.6 An ICMP_ECHO to broadcast MAY be
* silently ignored (we let user decide with a sysctl).
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 4300bcf..ca41b77 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -343,13 +343,14 @@ void tcp_v4_err(struct sk_buff *skb, u32 info)
struct sock *sk;
__u32 seq;
int err;
+ struct net *net = dev_net(skb->dev);
if (skb->len < (iph->ihl << 2) + 8) {
ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
return;
}
- sk = inet_lookup(dev_net(skb->dev), &tcp_hashinfo, iph->daddr, th->dest,
+ sk = inet_lookup(net, &tcp_hashinfo, iph->daddr, th->dest,
iph->saddr, th->source, inet_iif(skb));
if (!sk) {
ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 7187121..9342cfd 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -354,8 +354,9 @@ void __udp4_lib_err(struct sk_buff *skb, u32 info, struct hlist_head udptable[])
struct sock *sk;
int harderr;
int err;
+ struct net *net = dev_net(skb->dev);
- sk = __udp4_lib_lookup(dev_net(skb->dev), iph->daddr, uh->dest,
+ sk = __udp4_lib_lookup(net, iph->daddr, uh->dest,
iph->saddr, uh->source, skb->dev->ifindex, udptable);
if (sk == NULL) {
ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
--
1.5.3.4
next prev parent reply other threads:[~2008-07-07 10:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-07 10:41 [PATCH net-next 0/7] MIB: add struct net to ICMP accounting macros Pavel Emelyanov
2008-07-07 10:44 ` [PATCH net-next 1/7] ICMP: add struct net argument to icmp_out_count Pavel Emelyanov
2008-07-15 6:01 ` David Miller
2008-07-07 10:47 ` Pavel Emelyanov [this message]
2008-07-15 6:01 ` [PATCH net-next 2/7] INET: toss struct net initialization around David Miller
2008-07-07 10:50 ` [PATCH net-next 3/7] ICMP: drop unused MIB accounting wrappers Pavel Emelyanov
2008-07-15 6:02 ` David Miller
2008-07-07 10:51 ` [PATCH net-next 4/7] MIB: add struct net to ICMP_INC_STATS Pavel Emelyanov
2008-07-15 6:02 ` David Miller
2008-07-07 10:52 ` [PATCH net-next 5/7] MIB: add struct net to ICMP_INC_STATS_BH Pavel Emelyanov
2008-07-15 6:03 ` David Miller
2008-07-07 10:53 ` [PATCH net-next 6/7] MIB: add struct net to ICMPMSGOUT_INC_STATS Pavel Emelyanov
2008-07-15 6:03 ` David Miller
2008-07-07 10:53 ` [PATCH net-next 7/7] MIB: add struct net to ICMPMSGIN_INC_STATS_BH Pavel Emelyanov
2008-07-15 6:04 ` 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=4871F434.3000104@openvz.org \
--to=xemul@openvz.org \
--cc=davem@davemloft.net \
--cc=netdev@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).