aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/route.c
diff options
context:
space:
mode:
authorDavid Miller <davem@davemloft.net>2012-06-30 22:02:56 -0400
committerDavid S. Miller <davem@davemloft.net>2012-07-20 16:30:59 -0400
commit1a00fee4ffb22312a0ac40045ecd6f222b55eb3d (patch)
treef1154e606c695a85ee810bb9332ebcd5049f359f /net/ipv4/route.c
parent38a424e4657462fe9f8b76f01a0e879abde99ab4 (diff)
ipv4: Remove rt_key_{src,dst,tos} from struct rtable.
They are always used in contexts where they can be reconstituted, or where the finally resolved rt->rt_{src,dst} is semantically equivalent. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r--net/ipv4/route.c39
1 files changed, 9 insertions, 30 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 55eb4634ed60..c89d690acdfa 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1268,12 +1268,9 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1268#endif 1268#endif
1269 rth->dst.output = ip_rt_bug; 1269 rth->dst.output = ip_rt_bug;
1270 1270
1271 rth->rt_key_dst = daddr;
1272 rth->rt_key_src = saddr;
1273 rth->rt_genid = rt_genid(dev_net(dev)); 1271 rth->rt_genid = rt_genid(dev_net(dev));
1274 rth->rt_flags = RTCF_MULTICAST; 1272 rth->rt_flags = RTCF_MULTICAST;
1275 rth->rt_type = RTN_MULTICAST; 1273 rth->rt_type = RTN_MULTICAST;
1276 rth->rt_key_tos = tos;
1277 rth->rt_dst = daddr; 1274 rth->rt_dst = daddr;
1278 rth->rt_src = saddr; 1275 rth->rt_src = saddr;
1279 rth->rt_route_iif = dev->ifindex; 1276 rth->rt_route_iif = dev->ifindex;
@@ -1392,12 +1389,9 @@ static int __mkroute_input(struct sk_buff *skb,
1392 goto cleanup; 1389 goto cleanup;
1393 } 1390 }
1394 1391
1395 rth->rt_key_dst = daddr;
1396 rth->rt_key_src = saddr;
1397 rth->rt_genid = rt_genid(dev_net(rth->dst.dev)); 1392 rth->rt_genid = rt_genid(dev_net(rth->dst.dev));
1398 rth->rt_flags = flags; 1393 rth->rt_flags = flags;
1399 rth->rt_type = res->type; 1394 rth->rt_type = res->type;
1400 rth->rt_key_tos = tos;
1401 rth->rt_dst = daddr; 1395 rth->rt_dst = daddr;
1402 rth->rt_src = saddr; 1396 rth->rt_src = saddr;
1403 rth->rt_route_iif = in_dev->dev->ifindex; 1397 rth->rt_route_iif = in_dev->dev->ifindex;
@@ -1563,12 +1557,9 @@ local_input:
1563 rth->dst.tclassid = itag; 1557 rth->dst.tclassid = itag;
1564#endif 1558#endif
1565 1559
1566 rth->rt_key_dst = daddr;
1567 rth->rt_key_src = saddr;
1568 rth->rt_genid = rt_genid(net); 1560 rth->rt_genid = rt_genid(net);
1569 rth->rt_flags = flags|RTCF_LOCAL; 1561 rth->rt_flags = flags|RTCF_LOCAL;
1570 rth->rt_type = res.type; 1562 rth->rt_type = res.type;
1571 rth->rt_key_tos = tos;
1572 rth->rt_dst = daddr; 1563 rth->rt_dst = daddr;
1573 rth->rt_src = saddr; 1564 rth->rt_src = saddr;
1574 rth->rt_route_iif = dev->ifindex; 1565 rth->rt_route_iif = dev->ifindex;
@@ -1668,9 +1659,7 @@ EXPORT_SYMBOL(ip_route_input);
1668 1659
1669/* called with rcu_read_lock() */ 1660/* called with rcu_read_lock() */
1670static struct rtable *__mkroute_output(const struct fib_result *res, 1661static struct rtable *__mkroute_output(const struct fib_result *res,
1671 const struct flowi4 *fl4, 1662 const struct flowi4 *fl4, int orig_oif,
1672 __be32 orig_daddr, __be32 orig_saddr,
1673 int orig_oif, __u8 orig_rtos,
1674 struct net_device *dev_out, 1663 struct net_device *dev_out,
1675 unsigned int flags) 1664 unsigned int flags)
1676{ 1665{
@@ -1721,12 +1710,9 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
1721 1710
1722 rth->dst.output = ip_output; 1711 rth->dst.output = ip_output;
1723 1712
1724 rth->rt_key_dst = orig_daddr;
1725 rth->rt_key_src = orig_saddr;
1726 rth->rt_genid = rt_genid(dev_net(dev_out)); 1713 rth->rt_genid = rt_genid(dev_net(dev_out));
1727 rth->rt_flags = flags; 1714 rth->rt_flags = flags;
1728 rth->rt_type = type; 1715 rth->rt_type = type;
1729 rth->rt_key_tos = orig_rtos;
1730 rth->rt_dst = fl4->daddr; 1716 rth->rt_dst = fl4->daddr;
1731 rth->rt_src = fl4->saddr; 1717 rth->rt_src = fl4->saddr;
1732 rth->rt_route_iif = 0; 1718 rth->rt_route_iif = 0;
@@ -1777,16 +1763,12 @@ struct rtable *__ip_route_output_key(struct net *net, struct flowi4 *fl4)
1777 unsigned int flags = 0; 1763 unsigned int flags = 0;
1778 struct fib_result res; 1764 struct fib_result res;
1779 struct rtable *rth; 1765 struct rtable *rth;
1780 __be32 orig_daddr;
1781 __be32 orig_saddr;
1782 int orig_oif; 1766 int orig_oif;
1783 1767
1784 res.tclassid = 0; 1768 res.tclassid = 0;
1785 res.fi = NULL; 1769 res.fi = NULL;
1786 res.table = NULL; 1770 res.table = NULL;
1787 1771
1788 orig_daddr = fl4->daddr;
1789 orig_saddr = fl4->saddr;
1790 orig_oif = fl4->flowi4_oif; 1772 orig_oif = fl4->flowi4_oif;
1791 1773
1792 fl4->flowi4_iif = net->loopback_dev->ifindex; 1774 fl4->flowi4_iif = net->loopback_dev->ifindex;
@@ -1948,8 +1930,7 @@ struct rtable *__ip_route_output_key(struct net *net, struct flowi4 *fl4)
1948 1930
1949 1931
1950make_route: 1932make_route:
1951 rth = __mkroute_output(&res, fl4, orig_daddr, orig_saddr, orig_oif, 1933 rth = __mkroute_output(&res, fl4, orig_oif, dev_out, flags);
1952 tos, dev_out, flags);
1953 1934
1954out: 1935out:
1955 rcu_read_unlock(); 1936 rcu_read_unlock();
@@ -2014,9 +1995,6 @@ struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_or
2014 if (new->dev) 1995 if (new->dev)
2015 dev_hold(new->dev); 1996 dev_hold(new->dev);
2016 1997
2017 rt->rt_key_dst = ort->rt_key_dst;
2018 rt->rt_key_src = ort->rt_key_src;
2019 rt->rt_key_tos = ort->rt_key_tos;
2020 rt->rt_route_iif = ort->rt_route_iif; 1998 rt->rt_route_iif = ort->rt_route_iif;
2021 rt->rt_iif = ort->rt_iif; 1999 rt->rt_iif = ort->rt_iif;
2022 rt->rt_oif = ort->rt_oif; 2000 rt->rt_oif = ort->rt_oif;
@@ -2058,7 +2036,7 @@ struct rtable *ip_route_output_flow(struct net *net, struct flowi4 *flp4,
2058} 2036}
2059EXPORT_SYMBOL_GPL(ip_route_output_flow); 2037EXPORT_SYMBOL_GPL(ip_route_output_flow);
2060 2038
2061static int rt_fill_info(struct net *net, 2039static int rt_fill_info(struct net *net, __be32 src, u8 tos,
2062 struct sk_buff *skb, u32 pid, u32 seq, int event, 2040 struct sk_buff *skb, u32 pid, u32 seq, int event,
2063 int nowait, unsigned int flags) 2041 int nowait, unsigned int flags)
2064{ 2042{
@@ -2077,7 +2055,7 @@ static int rt_fill_info(struct net *net,
2077 r->rtm_family = AF_INET; 2055 r->rtm_family = AF_INET;
2078 r->rtm_dst_len = 32; 2056 r->rtm_dst_len = 32;
2079 r->rtm_src_len = 0; 2057 r->rtm_src_len = 0;
2080 r->rtm_tos = rt->rt_key_tos; 2058 r->rtm_tos = tos;
2081 r->rtm_table = RT_TABLE_MAIN; 2059 r->rtm_table = RT_TABLE_MAIN;
2082 if (nla_put_u32(skb, RTA_TABLE, RT_TABLE_MAIN)) 2060 if (nla_put_u32(skb, RTA_TABLE, RT_TABLE_MAIN))
2083 goto nla_put_failure; 2061 goto nla_put_failure;
@@ -2090,9 +2068,9 @@ static int rt_fill_info(struct net *net,
2090 2068
2091 if (nla_put_be32(skb, RTA_DST, rt->rt_dst)) 2069 if (nla_put_be32(skb, RTA_DST, rt->rt_dst))
2092 goto nla_put_failure; 2070 goto nla_put_failure;
2093 if (rt->rt_key_src) { 2071 if (src) {
2094 r->rtm_src_len = 32; 2072 r->rtm_src_len = 32;
2095 if (nla_put_be32(skb, RTA_SRC, rt->rt_key_src)) 2073 if (nla_put_be32(skb, RTA_SRC, src))
2096 goto nla_put_failure; 2074 goto nla_put_failure;
2097 } 2075 }
2098 if (rt->dst.dev && 2076 if (rt->dst.dev &&
@@ -2104,7 +2082,7 @@ static int rt_fill_info(struct net *net,
2104 goto nla_put_failure; 2082 goto nla_put_failure;
2105#endif 2083#endif
2106 if (!rt_is_input_route(rt) && 2084 if (!rt_is_input_route(rt) &&
2107 rt->rt_src != rt->rt_key_src) { 2085 rt->rt_src != src) {
2108 if (nla_put_be32(skb, RTA_PREFSRC, rt->rt_src)) 2086 if (nla_put_be32(skb, RTA_PREFSRC, rt->rt_src))
2109 goto nla_put_failure; 2087 goto nla_put_failure;
2110 } 2088 }
@@ -2248,7 +2226,8 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, void
2248 if (rtm->rtm_flags & RTM_F_NOTIFY) 2226 if (rtm->rtm_flags & RTM_F_NOTIFY)
2249 rt->rt_flags |= RTCF_NOTIFY; 2227 rt->rt_flags |= RTCF_NOTIFY;
2250 2228
2251 err = rt_fill_info(net, skb, NETLINK_CB(in_skb).pid, nlh->nlmsg_seq, 2229 err = rt_fill_info(net, src, rtm->rtm_tos, skb,
2230 NETLINK_CB(in_skb).pid, nlh->nlmsg_seq,
2252 RTM_NEWROUTE, 0, 0); 2231 RTM_NEWROUTE, 0, 0);
2253 if (err <= 0) 2232 if (err <= 0)
2254 goto errout_free; 2233 goto errout_free;