Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 109082
b: refs/heads/master
c: fdc0bde
h: refs/heads/master
v: v3
  • Loading branch information
Denis V. Lunev authored and David S. Miller committed Aug 23, 2008
1 parent 8c83174 commit 72fc3f9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f6e0b239a2657ea8cb67f0d83d0bfdbfd19a481b
refs/heads/master: fdc0bde90a689b9145f2b6f271c03f4c99d09667
22 changes: 14 additions & 8 deletions trunk/net/ipv4/icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,22 @@ static struct sock *icmp_sk(struct net *net)
return net->ipv4.icmp_sk[smp_processor_id()];
}

static inline int icmp_xmit_lock(struct sock *sk)
static inline struct sock *icmp_xmit_lock(struct net *net)
{
struct sock *sk;

local_bh_disable();

sk = icmp_sk(net);

if (unlikely(!spin_trylock(&sk->sk_lock.slock))) {
/* This can happen if the output path signals a
* dst_link_failure() for an outgoing ICMP packet.
*/
local_bh_enable();
return 1;
return NULL;
}
return 0;
return sk;
}

static inline void icmp_xmit_unlock(struct sock *sk)
Expand Down Expand Up @@ -354,15 +358,17 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
struct ipcm_cookie ipc;
struct rtable *rt = skb->rtable;
struct net *net = dev_net(rt->u.dst.dev);
struct sock *sk = icmp_sk(net);
struct inet_sock *inet = inet_sk(sk);
struct sock *sk;
struct inet_sock *inet;
__be32 daddr;

if (ip_options_echo(&icmp_param->replyopts, skb))
return;

if (icmp_xmit_lock(sk))
sk = icmp_xmit_lock(net);
if (sk == NULL)
return;
inet = inet_sk(sk);

icmp_param->data.icmph.checksum = 0;

Expand Down Expand Up @@ -419,7 +425,6 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
if (!rt)
goto out;
net = dev_net(rt->u.dst.dev);
sk = icmp_sk(net);

/*
* Find the original header. It is expected to be valid, of course.
Expand Down Expand Up @@ -483,7 +488,8 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
}
}

if (icmp_xmit_lock(sk))
sk = icmp_xmit_lock(net);
if (sk == NULL)
return;

/*
Expand Down
23 changes: 12 additions & 11 deletions trunk/net/ipv6/icmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,22 @@ static struct inet6_protocol icmpv6_protocol = {
.flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
};

static __inline__ int icmpv6_xmit_lock(struct sock *sk)
static __inline__ struct sock *icmpv6_xmit_lock(struct net *net)
{
struct sock *sk;

local_bh_disable();

sk = icmpv6_sk(net);
if (unlikely(!spin_trylock(&sk->sk_lock.slock))) {
/* This can happen if the output path (f.e. SIT or
* ip6ip6 tunnel) signals dst_link_failure() for an
* outgoing ICMP6 packet.
*/
local_bh_enable();
return 1;
return NULL;
}
return 0;
return sk;
}

static __inline__ void icmpv6_xmit_unlock(struct sock *sk)
Expand Down Expand Up @@ -392,11 +395,10 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
fl.fl_icmp_code = code;
security_skb_classify_flow(skb, &fl);

sk = icmpv6_sk(net);
np = inet6_sk(sk);

if (icmpv6_xmit_lock(sk))
sk = icmpv6_xmit_lock(net);
if (sk == NULL)
return;
np = inet6_sk(sk);

if (!icmpv6_xrlim_allow(sk, type, &fl))
goto out;
Expand Down Expand Up @@ -539,11 +541,10 @@ static void icmpv6_echo_reply(struct sk_buff *skb)
fl.fl_icmp_type = ICMPV6_ECHO_REPLY;
security_skb_classify_flow(skb, &fl);

sk = icmpv6_sk(net);
np = inet6_sk(sk);

if (icmpv6_xmit_lock(sk))
sk = icmpv6_xmit_lock(net);
if (sk == NULL)
return;
np = inet6_sk(sk);

if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst))
fl.oif = np->mcast_oif;
Expand Down

0 comments on commit 72fc3f9

Please sign in to comment.