mirror of
https://github.com/S3NEO/android_kernel_samsung_msm8226.git
synced 2024-11-07 03:47:13 +00:00
net: Loopback ifindex is constant now
As pointed out, there are places, that access net->loopback_dev->ifindex and after ifindex generation is made per-net this value becomes constant equals 1. So go ahead and introduce the LOOPBACK_IFINDEX constant and use it where appropriate. Change-Id: I29fd08fa01a9522240ab654d436b02a577bb610c Signed-off-by: Pavel Emelyanov <xemul@parallels.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Kevin F. Haggerty <haggertk@lineageos.org>
This commit is contained in:
parent
0a869bcb58
commit
dfa1494b31
4 changed files with 8 additions and 7 deletions
|
@ -202,6 +202,7 @@ static __net_init int loopback_net_init(struct net *net)
|
|||
if (err)
|
||||
goto out_free_netdev;
|
||||
|
||||
BUG_ON(dev->ifindex != LOOPBACK_IFINDEX);
|
||||
net->loopback_dev = dev;
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -928,7 +928,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowidn *o
|
|||
.saddr = oldflp->saddr,
|
||||
.flowidn_scope = RT_SCOPE_UNIVERSE,
|
||||
.flowidn_mark = oldflp->flowidn_mark,
|
||||
.flowidn_iif = init_net.loopback_dev->ifindex,
|
||||
.flowidn_iif = LOOPBACK_IFINDEX,
|
||||
.flowidn_oif = oldflp->flowidn_oif,
|
||||
};
|
||||
struct dn_route *rt = NULL;
|
||||
|
@ -946,7 +946,7 @@ static int dn_route_output_slow(struct dst_entry **pprt, const struct flowidn *o
|
|||
"dn_route_output_slow: dst=%04x src=%04x mark=%d"
|
||||
" iif=%d oif=%d\n", le16_to_cpu(oldflp->daddr),
|
||||
le16_to_cpu(oldflp->saddr),
|
||||
oldflp->flowidn_mark, init_net.loopback_dev->ifindex,
|
||||
oldflp->flowidn_mark, LOOPBACK_IFINDEX,
|
||||
oldflp->flowidn_oif);
|
||||
|
||||
/* If we have an output interface, verify its a DECnet device */
|
||||
|
@ -1009,7 +1009,7 @@ source_ok:
|
|||
if (!fld.daddr)
|
||||
goto out;
|
||||
}
|
||||
fld.flowidn_oif = init_net.loopback_dev->ifindex;
|
||||
fld.flowidn_oif = LOOPBACK_IFINDEX;
|
||||
res.type = RTN_LOCAL;
|
||||
goto make_route;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
|
|||
if (ipv4_is_zeronet(iph->saddr))
|
||||
return ipv4_is_local_multicast(iph->daddr) ^ invert;
|
||||
}
|
||||
flow.flowi4_iif = dev_net(par->in)->loopback_dev->ifindex;
|
||||
flow.flowi4_iif = LOOPBACK_IFINDEX;
|
||||
flow.daddr = iph->saddr;
|
||||
flow.saddr = rpfilter_get_saddr(iph->daddr);
|
||||
flow.flowi4_oif = 0;
|
||||
|
|
|
@ -2347,7 +2347,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
|
|||
|
||||
if (res.type == RTN_LOCAL) {
|
||||
err = fib_validate_source(skb, saddr, daddr, tos,
|
||||
net->loopback_dev->ifindex,
|
||||
LOOPBACK_IFINDEX,
|
||||
dev, &spec_dst, &itag);
|
||||
if (err < 0)
|
||||
goto martian_source_keep_err;
|
||||
|
@ -2674,7 +2674,7 @@ static struct rtable *ip_route_output_slow(struct net *net, struct flowi4 *fl4)
|
|||
orig_saddr = fl4->saddr;
|
||||
orig_oif = fl4->flowi4_oif;
|
||||
|
||||
fl4->flowi4_iif = net->loopback_dev->ifindex;
|
||||
fl4->flowi4_iif = LOOPBACK_IFINDEX;
|
||||
fl4->flowi4_tos = tos & IPTOS_RT_MASK;
|
||||
fl4->flowi4_scope = ((tos & RTO_ONLINK) ?
|
||||
RT_SCOPE_LINK : RT_SCOPE_UNIVERSE);
|
||||
|
@ -2763,7 +2763,7 @@ static struct rtable *ip_route_output_slow(struct net *net, struct flowi4 *fl4)
|
|||
if (!fl4->daddr)
|
||||
fl4->daddr = fl4->saddr = htonl(INADDR_LOOPBACK);
|
||||
dev_out = net->loopback_dev;
|
||||
fl4->flowi4_oif = net->loopback_dev->ifindex;
|
||||
fl4->flowi4_oif = LOOPBACK_IFINDEX;
|
||||
res.type = RTN_LOCAL;
|
||||
flags |= RTCF_LOCAL;
|
||||
goto make_route;
|
||||
|
|
Loading…
Reference in a new issue