ipv4: Only compute net once in ip_call_ra_chain
ip_call_ra_chain is called early in the forwarding chain from ip_forward and ip_mr_input, which makes skb->dev the correct expression to get the input network device and dev_net(skb->dev) a correct expression for the network namespace the packet is being processed in. Compute the network namespace and store it in a variable to make the code clearer. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
161642e24f
commit
37fcbab61b
@ -157,6 +157,7 @@ bool ip_call_ra_chain(struct sk_buff *skb)
|
|||||||
u8 protocol = ip_hdr(skb)->protocol;
|
u8 protocol = ip_hdr(skb)->protocol;
|
||||||
struct sock *last = NULL;
|
struct sock *last = NULL;
|
||||||
struct net_device *dev = skb->dev;
|
struct net_device *dev = skb->dev;
|
||||||
|
struct net *net = dev_net(dev);
|
||||||
|
|
||||||
for (ra = rcu_dereference(ip_ra_chain); ra; ra = rcu_dereference(ra->next)) {
|
for (ra = rcu_dereference(ip_ra_chain); ra; ra = rcu_dereference(ra->next)) {
|
||||||
struct sock *sk = ra->sk;
|
struct sock *sk = ra->sk;
|
||||||
@ -167,7 +168,7 @@ bool ip_call_ra_chain(struct sk_buff *skb)
|
|||||||
if (sk && inet_sk(sk)->inet_num == protocol &&
|
if (sk && inet_sk(sk)->inet_num == protocol &&
|
||||||
(!sk->sk_bound_dev_if ||
|
(!sk->sk_bound_dev_if ||
|
||||||
sk->sk_bound_dev_if == dev->ifindex) &&
|
sk->sk_bound_dev_if == dev->ifindex) &&
|
||||||
net_eq(sock_net(sk), dev_net(dev))) {
|
net_eq(sock_net(sk), net)) {
|
||||||
if (ip_is_fragment(ip_hdr(skb))) {
|
if (ip_is_fragment(ip_hdr(skb))) {
|
||||||
if (ip_defrag(skb, IP_DEFRAG_CALL_RA_CHAIN))
|
if (ip_defrag(skb, IP_DEFRAG_CALL_RA_CHAIN))
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user