aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@parallels.com>2012-08-08 17:53:36 -0400
committerDavid S. Miller <davem@davemloft.net>2012-08-09 19:18:07 -0400
commit1fb9489bf190ce2b3fc03891f3de4b2d30600e28 (patch)
treeda4e17036949e72ae0b1f0fc3b6b31557de18353 /net/ipv4
parentaa79e66eee5d525e2fcbd2a5fcb87ae3dd4aa9e9 (diff)
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. Signed-off-by: Pavel Emelyanov <xemul@parallels.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/fib_frontend.c2
-rw-r--r--net/ipv4/ipmr.c2
-rw-r--r--net/ipv4/netfilter/ipt_rpfilter.c2
-rw-r--r--net/ipv4/route.c6
4 files changed, 6 insertions, 6 deletions
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index c43ae3fba792..7f073a38c87d 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -218,7 +218,7 @@ __be32 fib_compute_spec_dst(struct sk_buff *skb)
218 scope = RT_SCOPE_UNIVERSE; 218 scope = RT_SCOPE_UNIVERSE;
219 if (!ipv4_is_zeronet(ip_hdr(skb)->saddr)) { 219 if (!ipv4_is_zeronet(ip_hdr(skb)->saddr)) {
220 fl4.flowi4_oif = 0; 220 fl4.flowi4_oif = 0;
221 fl4.flowi4_iif = net->loopback_dev->ifindex; 221 fl4.flowi4_iif = LOOPBACK_IFINDEX;
222 fl4.daddr = ip_hdr(skb)->saddr; 222 fl4.daddr = ip_hdr(skb)->saddr;
223 fl4.saddr = 0; 223 fl4.saddr = 0;
224 fl4.flowi4_tos = RT_TOS(ip_hdr(skb)->tos); 224 fl4.flowi4_tos = RT_TOS(ip_hdr(skb)->tos);
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 8eec8f4a0536..3a57570c8ee5 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1798,7 +1798,7 @@ static struct mr_table *ipmr_rt_fib_lookup(struct net *net, struct sk_buff *skb)
1798 .flowi4_oif = (rt_is_output_route(rt) ? 1798 .flowi4_oif = (rt_is_output_route(rt) ?
1799 skb->dev->ifindex : 0), 1799 skb->dev->ifindex : 0),
1800 .flowi4_iif = (rt_is_output_route(rt) ? 1800 .flowi4_iif = (rt_is_output_route(rt) ?
1801 net->loopback_dev->ifindex : 1801 LOOPBACK_IFINDEX :
1802 skb->dev->ifindex), 1802 skb->dev->ifindex),
1803 .flowi4_mark = skb->mark, 1803 .flowi4_mark = skb->mark,
1804 }; 1804 };
diff --git a/net/ipv4/netfilter/ipt_rpfilter.c b/net/ipv4/netfilter/ipt_rpfilter.c
index 31371be8174b..c30130062cd6 100644
--- a/net/ipv4/netfilter/ipt_rpfilter.c
+++ b/net/ipv4/netfilter/ipt_rpfilter.c
@@ -85,7 +85,7 @@ static bool rpfilter_mt(const struct sk_buff *skb, struct xt_action_param *par)
85 return ipv4_is_local_multicast(iph->daddr) ^ invert; 85 return ipv4_is_local_multicast(iph->daddr) ^ invert;
86 flow.flowi4_iif = 0; 86 flow.flowi4_iif = 0;
87 } else { 87 } else {
88 flow.flowi4_iif = dev_net(par->in)->loopback_dev->ifindex; 88 flow.flowi4_iif = LOOPBACK_IFINDEX;
89 } 89 }
90 90
91 flow.daddr = iph->saddr; 91 flow.daddr = iph->saddr;
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 21ad369014c0..c58137391a3d 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1619,7 +1619,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1619 1619
1620 if (res.type == RTN_LOCAL) { 1620 if (res.type == RTN_LOCAL) {
1621 err = fib_validate_source(skb, saddr, daddr, tos, 1621 err = fib_validate_source(skb, saddr, daddr, tos,
1622 net->loopback_dev->ifindex, 1622 LOOPBACK_IFINDEX,
1623 dev, in_dev, &itag); 1623 dev, in_dev, &itag);
1624 if (err < 0) 1624 if (err < 0)
1625 goto martian_source_keep_err; 1625 goto martian_source_keep_err;
@@ -1895,7 +1895,7 @@ struct rtable *__ip_route_output_key(struct net *net, struct flowi4 *fl4)
1895 1895
1896 orig_oif = fl4->flowi4_oif; 1896 orig_oif = fl4->flowi4_oif;
1897 1897
1898 fl4->flowi4_iif = net->loopback_dev->ifindex; 1898 fl4->flowi4_iif = LOOPBACK_IFINDEX;
1899 fl4->flowi4_tos = tos & IPTOS_RT_MASK; 1899 fl4->flowi4_tos = tos & IPTOS_RT_MASK;
1900 fl4->flowi4_scope = ((tos & RTO_ONLINK) ? 1900 fl4->flowi4_scope = ((tos & RTO_ONLINK) ?
1901 RT_SCOPE_LINK : RT_SCOPE_UNIVERSE); 1901 RT_SCOPE_LINK : RT_SCOPE_UNIVERSE);
@@ -1984,7 +1984,7 @@ struct rtable *__ip_route_output_key(struct net *net, struct flowi4 *fl4)
1984 if (!fl4->daddr) 1984 if (!fl4->daddr)
1985 fl4->daddr = fl4->saddr = htonl(INADDR_LOOPBACK); 1985 fl4->daddr = fl4->saddr = htonl(INADDR_LOOPBACK);
1986 dev_out = net->loopback_dev; 1986 dev_out = net->loopback_dev;
1987 fl4->flowi4_oif = net->loopback_dev->ifindex; 1987 fl4->flowi4_oif = LOOPBACK_IFINDEX;
1988 res.type = RTN_LOCAL; 1988 res.type = RTN_LOCAL;
1989 flags |= RTCF_LOCAL; 1989 flags |= RTCF_LOCAL;
1990 goto make_route; 1990 goto make_route;