提交 a86b1e30 编写于 作者: P Pavel Emelyanov 提交者: David S. Miller

inet: prepare struct net for TCP MIB accounting

This is the same as the first patch in the set, but preparing
the net for TCP_XXX_STATS - save the struct net on the stack
where required and possible.
Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 c5346fe3
...@@ -544,6 +544,7 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) ...@@ -544,6 +544,7 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
#ifdef CONFIG_TCP_MD5SIG #ifdef CONFIG_TCP_MD5SIG
struct tcp_md5sig_key *key; struct tcp_md5sig_key *key;
#endif #endif
struct net *net;
/* Never send a reset in response to a reset. */ /* Never send a reset in response to a reset. */
if (th->rst) if (th->rst)
...@@ -594,7 +595,8 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) ...@@ -594,7 +595,8 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
sizeof(struct tcphdr), IPPROTO_TCP, 0); sizeof(struct tcphdr), IPPROTO_TCP, 0);
arg.csumoffset = offsetof(struct tcphdr, check) / 2; arg.csumoffset = offsetof(struct tcphdr, check) / 2;
ip_send_reply(dev_net(skb->dst->dev)->ipv4.tcp_sock, skb, net = dev_net(skb->dst->dev);
ip_send_reply(net->ipv4.tcp_sock, skb,
&arg, arg.iov[0].iov_len); &arg, arg.iov[0].iov_len);
TCP_INC_STATS_BH(TCP_MIB_OUTSEGS); TCP_INC_STATS_BH(TCP_MIB_OUTSEGS);
...@@ -619,6 +621,7 @@ static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack, ...@@ -619,6 +621,7 @@ static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack,
]; ];
} rep; } rep;
struct ip_reply_arg arg; struct ip_reply_arg arg;
struct net *net = dev_net(skb->dev);
memset(&rep.th, 0, sizeof(struct tcphdr)); memset(&rep.th, 0, sizeof(struct tcphdr));
memset(&arg, 0, sizeof(arg)); memset(&arg, 0, sizeof(arg));
...@@ -668,7 +671,7 @@ static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack, ...@@ -668,7 +671,7 @@ static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack,
if (oif) if (oif)
arg.bound_dev_if = oif; arg.bound_dev_if = oif;
ip_send_reply(dev_net(skb->dev)->ipv4.tcp_sock, skb, ip_send_reply(net->ipv4.tcp_sock, skb,
&arg, arg.iov[0].iov_len); &arg, arg.iov[0].iov_len);
TCP_INC_STATS_BH(TCP_MIB_OUTSEGS); TCP_INC_STATS_BH(TCP_MIB_OUTSEGS);
...@@ -1505,6 +1508,7 @@ int tcp_v4_rcv(struct sk_buff *skb) ...@@ -1505,6 +1508,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
struct tcphdr *th; struct tcphdr *th;
struct sock *sk; struct sock *sk;
int ret; int ret;
struct net *net = dev_net(skb->dev);
if (skb->pkt_type != PACKET_HOST) if (skb->pkt_type != PACKET_HOST)
goto discard_it; goto discard_it;
...@@ -1539,7 +1543,7 @@ int tcp_v4_rcv(struct sk_buff *skb) ...@@ -1539,7 +1543,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
TCP_SKB_CB(skb)->flags = iph->tos; TCP_SKB_CB(skb)->flags = iph->tos;
TCP_SKB_CB(skb)->sacked = 0; TCP_SKB_CB(skb)->sacked = 0;
sk = __inet_lookup(dev_net(skb->dev), &tcp_hashinfo, iph->saddr, sk = __inet_lookup(net, &tcp_hashinfo, iph->saddr,
th->source, iph->daddr, th->dest, inet_iif(skb)); th->source, iph->daddr, th->dest, inet_iif(skb));
if (!sk) if (!sk)
goto no_tcp_socket; goto no_tcp_socket;
......
...@@ -1617,6 +1617,7 @@ static int tcp_v6_rcv(struct sk_buff *skb) ...@@ -1617,6 +1617,7 @@ static int tcp_v6_rcv(struct sk_buff *skb)
struct tcphdr *th; struct tcphdr *th;
struct sock *sk; struct sock *sk;
int ret; int ret;
struct net *net = dev_net(skb->dev);
if (skb->pkt_type != PACKET_HOST) if (skb->pkt_type != PACKET_HOST)
goto discard_it; goto discard_it;
...@@ -1648,7 +1649,7 @@ static int tcp_v6_rcv(struct sk_buff *skb) ...@@ -1648,7 +1649,7 @@ static int tcp_v6_rcv(struct sk_buff *skb)
TCP_SKB_CB(skb)->flags = ipv6_get_dsfield(ipv6_hdr(skb)); TCP_SKB_CB(skb)->flags = ipv6_get_dsfield(ipv6_hdr(skb));
TCP_SKB_CB(skb)->sacked = 0; TCP_SKB_CB(skb)->sacked = 0;
sk = __inet6_lookup(dev_net(skb->dev), &tcp_hashinfo, sk = __inet6_lookup(net, &tcp_hashinfo,
&ipv6_hdr(skb)->saddr, th->source, &ipv6_hdr(skb)->saddr, th->source,
&ipv6_hdr(skb)->daddr, ntohs(th->dest), &ipv6_hdr(skb)->daddr, ntohs(th->dest),
inet6_iif(skb)); inet6_iif(skb));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册