From: Pavel Emelyanov <xemul@openvz.org>
To: David Miller <davem@davemloft.net>
Cc: Linux Netdev List <netdev@vger.kernel.org>
Subject: [PATCH 1/20] ipv4: prepare net initialization for IP accounting
Date: Wed, 16 Jul 2008 12:08:22 +0400 [thread overview]
Message-ID: <487DAC76.20708@openvz.org> (raw)
In-Reply-To: <487DABB6.5080905@openvz.org>
Some places, that deal with IP statistics already have where to
get a struct net from, but use it directly, without declaring
a separate variable on the stack.
So, save this net on the stack for future IP_XXX_STATS macros.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
net/ipv4/inet_connection_sock.c | 3 ++-
net/ipv4/ip_fragment.c | 6 +++---
net/ipv4/udp.c | 4 +++-
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 5bbf000..8338e10 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -338,9 +338,10 @@ struct dst_entry* inet_csk_route_req(struct sock *sk,
.uli_u = { .ports =
{ .sport = inet_sk(sk)->sport,
.dport = ireq->rmt_port } } };
+ struct net *net = sock_net(sk);
security_req_classify_flow(req, &fl);
- if (ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 0)) {
+ if (ip_route_output_flow(net, &rt, &fl, sk, 0)) {
IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
return NULL;
}
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index fbd5804..e23be5b 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -187,8 +187,10 @@ static void ip_evictor(struct net *net)
static void ip_expire(unsigned long arg)
{
struct ipq *qp;
+ struct net *net;
qp = container_of((struct inet_frag_queue *) arg, struct ipq, q);
+ net = container_of(qp->q.net, struct net, ipv4.frags);
spin_lock(&qp->q.lock);
@@ -202,9 +204,7 @@ static void ip_expire(unsigned long arg)
if ((qp->q.last_in & INET_FRAG_FIRST_IN) && qp->q.fragments != NULL) {
struct sk_buff *head = qp->q.fragments;
- struct net *net;
- net = container_of(qp->q.net, struct net, ipv4.frags);
/* Send an ICMP "Fragment Reassembly Timeout" message. */
if ((head->dev = dev_get_by_index(net, qp->iif)) != NULL) {
icmp_send(head, ICMP_TIME_EXCEEDED, ICMP_EXC_FRAGTIME, 0);
@@ -570,9 +570,9 @@ int ip_defrag(struct sk_buff *skb, u32 user)
struct ipq *qp;
struct net *net;
+ net = skb->dev ? dev_net(skb->dev) : dev_net(skb->dst->dev);
IP_INC_STATS_BH(IPSTATS_MIB_REASMREQDS);
- net = skb->dev ? dev_net(skb->dev) : dev_net(skb->dst->dev);
/* Start by cleaning up the memory. */
if (atomic_read(&net->ipv4.frags.mem) > net->ipv4.frags.high_thresh)
ip_evictor(net);
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index fdd4faa..048ef57 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -656,8 +656,10 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
.uli_u = { .ports =
{ .sport = inet->sport,
.dport = dport } } };
+ struct net *net = sock_net(sk);
+
security_sk_classify_flow(sk, &fl);
- err = ip_route_output_flow(sock_net(sk), &rt, &fl, sk, 1);
+ err = ip_route_output_flow(net, &rt, &fl, sk, 1);
if (err) {
if (err == -ENETUNREACH)
IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
--
1.5.5.1
next prev parent reply other threads:[~2008-07-16 8:08 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-16 8:05 [PATCH 0/20] mib: add struct net to IP, TCP and NET macros Pavel Emelyanov
2008-07-16 8:08 ` Pavel Emelyanov [this message]
2008-07-16 8:09 ` [PATCH 2/20] mib: drop unused IP_INC_STATS_USER Pavel Emelyanov
2008-07-16 8:10 ` [PATCH 3/20] mib: add net to IP_INC_STATS Pavel Emelyanov
2008-07-16 8:12 ` [PATCH 4/20] mib: add net to IP_INC_STATS_BH Pavel Emelyanov
2008-07-16 8:14 ` [PATCH 5/20] mib: add net to IP_ADD_STATS_BH Pavel Emelyanov
2008-07-16 8:16 ` [PATCH 6/20] inet: prepare struct net for TCP MIB accounting Pavel Emelyanov
2008-07-16 8:19 ` [PATCH 8/20] tcp: add net to tcp_mib_init Pavel Emelyanov
2008-07-16 8:21 ` [PATCH 9/20] mib: add net to TCP_INC_STATS Pavel Emelyanov
2008-07-16 8:22 ` [PATCH 10/20] mib: add net to TCP_INC_STATS_BH Pavel Emelyanov
2008-07-16 8:23 ` [PATCH 11/20] mib: add net to TCP_DEC_STATS Pavel Emelyanov
2008-07-16 8:24 ` [PATCH 12/20] mib: add net to TCP_ADD_STATS_USER Pavel Emelyanov
2008-07-16 8:27 ` [PATCH 13/20] sock: add net to prot->enter_memory_pressure callback Pavel Emelyanov
2008-07-16 8:29 ` [PATCH 14/20] inet: prepare net on the stack for NET accounting macros Pavel Emelyanov
2008-07-16 8:31 ` [PATCH 15/20] tcp: replace tcp_sock argument with sock in some places Pavel Emelyanov
2008-07-16 8:32 ` [PATCH 16/20] mib: add net to NET_INC_STATS Pavel Emelyanov
2008-07-16 8:33 ` [PATCH 17/20] mib: add net to NET_INC_STATS_BH Pavel Emelyanov
2008-07-16 8:34 ` [PATCH 18/20] mib: add net to NET_INC_STATS_USER Pavel Emelyanov
2008-07-16 8:37 ` [PATCH 19/20] mib: add net to NET_ADD_STATS_BH Pavel Emelyanov
2008-07-16 8:38 ` [PATCH 20/20] mib: add net to NET_ADD_STATS_USER Pavel Emelyanov
[not found] ` <487DAE95.4090608@openvz.org>
2008-07-16 8:43 ` [PATCH (resend) 7/20] mib: drop unused TCP MIB accounting macros Pavel Emelyanov
2008-07-17 3:38 ` [PATCH 0/20] mib: add struct net to IP, TCP and NET macros 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=487DAC76.20708@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).