Skip to content

Commit

Permalink
inet: toss struct net initialization around
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
xemul authored and davem330 committed Jul 15, 2008
1 parent 0388b00 commit fd54d71
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion net/dccp/ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 1 addition & 3 deletions net/ipv4/icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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).
Expand Down
3 changes: 2 additions & 1 deletion net/ipv4/tcp_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion net/ipv4/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fd54d71

Please sign in to comment.