diff options
| -rw-r--r-- | include/net/route.h | 57 | ||||
| -rw-r--r-- | net/ipv4/route.c | 60 | ||||
| -rw-r--r-- | net/ipv4/xfrm4_policy.c | 7 |
3 files changed, 6 insertions, 118 deletions
diff --git a/include/net/route.h b/include/net/route.h index c27449466d18..52362368af09 100644 --- a/include/net/route.h +++ b/include/net/route.h | |||
| @@ -40,7 +40,6 @@ | |||
| 40 | #define RT_CONN_FLAGS(sk) (RT_TOS(inet_sk(sk)->tos) | sock_flag(sk, SOCK_LOCALROUTE)) | 40 | #define RT_CONN_FLAGS(sk) (RT_TOS(inet_sk(sk)->tos) | sock_flag(sk, SOCK_LOCALROUTE)) |
| 41 | 41 | ||
| 42 | struct fib_nh; | 42 | struct fib_nh; |
| 43 | struct inet_peer; | ||
| 44 | struct fib_info; | 43 | struct fib_info; |
| 45 | struct rtable { | 44 | struct rtable { |
| 46 | struct dst_entry dst; | 45 | struct dst_entry dst; |
| @@ -66,44 +65,9 @@ struct rtable { | |||
| 66 | 65 | ||
| 67 | /* Miscellaneous cached information */ | 66 | /* Miscellaneous cached information */ |
| 68 | u32 rt_pmtu; | 67 | u32 rt_pmtu; |
| 69 | unsigned long _peer; /* long-living peer info */ | ||
| 70 | struct fib_info *fi; /* for client ref to shared metrics */ | 68 | struct fib_info *fi; /* for client ref to shared metrics */ |
| 71 | }; | 69 | }; |
| 72 | 70 | ||
| 73 | static inline struct inet_peer *rt_peer_ptr(struct rtable *rt) | ||
| 74 | { | ||
| 75 | return inetpeer_ptr(rt->_peer); | ||
| 76 | } | ||
| 77 | |||
| 78 | static inline bool rt_has_peer(struct rtable *rt) | ||
| 79 | { | ||
| 80 | return inetpeer_ptr_is_peer(rt->_peer); | ||
| 81 | } | ||
| 82 | |||
| 83 | static inline void __rt_set_peer(struct rtable *rt, struct inet_peer *peer) | ||
| 84 | { | ||
| 85 | __inetpeer_ptr_set_peer(&rt->_peer, peer); | ||
| 86 | } | ||
| 87 | |||
| 88 | static inline bool rt_set_peer(struct rtable *rt, struct inet_peer *peer) | ||
| 89 | { | ||
| 90 | return inetpeer_ptr_set_peer(&rt->_peer, peer); | ||
| 91 | } | ||
| 92 | |||
| 93 | static inline void rt_init_peer(struct rtable *rt, struct inet_peer_base *base) | ||
| 94 | { | ||
| 95 | inetpeer_init_ptr(&rt->_peer, base); | ||
| 96 | } | ||
| 97 | |||
| 98 | static inline void rt_transfer_peer(struct rtable *rt, struct rtable *ort) | ||
| 99 | { | ||
| 100 | rt->_peer = ort->_peer; | ||
| 101 | if (rt_has_peer(ort)) { | ||
| 102 | struct inet_peer *peer = rt_peer_ptr(ort); | ||
| 103 | atomic_inc(&peer->refcnt); | ||
| 104 | } | ||
| 105 | } | ||
| 106 | |||
| 107 | static inline bool rt_is_input_route(const struct rtable *rt) | 71 | static inline bool rt_is_input_route(const struct rtable *rt) |
| 108 | { | 72 | { |
| 109 | return rt->rt_route_iif != 0; | 73 | return rt->rt_route_iif != 0; |
| @@ -326,27 +290,6 @@ static inline struct rtable *ip_route_newports(struct flowi4 *fl4, struct rtable | |||
| 326 | return rt; | 290 | return rt; |
| 327 | } | 291 | } |
| 328 | 292 | ||
| 329 | extern void rt_bind_peer(struct rtable *rt, __be32 daddr, int create); | ||
| 330 | |||
| 331 | static inline struct inet_peer *__rt_get_peer(struct rtable *rt, __be32 daddr, int create) | ||
| 332 | { | ||
| 333 | if (rt_has_peer(rt)) | ||
| 334 | return rt_peer_ptr(rt); | ||
| 335 | |||
| 336 | rt_bind_peer(rt, daddr, create); | ||
| 337 | return (rt_has_peer(rt) ? rt_peer_ptr(rt) : NULL); | ||
| 338 | } | ||
| 339 | |||
| 340 | static inline struct inet_peer *rt_get_peer(struct rtable *rt, __be32 daddr) | ||
| 341 | { | ||
| 342 | return __rt_get_peer(rt, daddr, 0); | ||
| 343 | } | ||
| 344 | |||
| 345 | static inline struct inet_peer *rt_get_peer_create(struct rtable *rt, __be32 daddr) | ||
| 346 | { | ||
| 347 | return __rt_get_peer(rt, daddr, 1); | ||
| 348 | } | ||
| 349 | |||
| 350 | static inline int inet_iif(const struct sk_buff *skb) | 293 | static inline int inet_iif(const struct sk_buff *skb) |
| 351 | { | 294 | { |
| 352 | return skb_rtable(skb)->rt_iif; | 295 | return skb_rtable(skb)->rt_iif; |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 9cc00f8a6ee5..95bfa1ba5b28 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
| @@ -889,7 +889,6 @@ static void rt_cache_invalidate(struct net *net) | |||
| 889 | 889 | ||
| 890 | get_random_bytes(&shuffle, sizeof(shuffle)); | 890 | get_random_bytes(&shuffle, sizeof(shuffle)); |
| 891 | atomic_add(shuffle + 1U, &net->ipv4.rt_genid); | 891 | atomic_add(shuffle + 1U, &net->ipv4.rt_genid); |
| 892 | inetpeer_invalidate_family(AF_INET); | ||
| 893 | } | 892 | } |
| 894 | 893 | ||
| 895 | /* | 894 | /* |
| @@ -1216,22 +1215,6 @@ skip_hashing: | |||
| 1216 | return rt; | 1215 | return rt; |
| 1217 | } | 1216 | } |
| 1218 | 1217 | ||
| 1219 | void rt_bind_peer(struct rtable *rt, __be32 daddr, int create) | ||
| 1220 | { | ||
| 1221 | struct inet_peer_base *base; | ||
| 1222 | struct inet_peer *peer; | ||
| 1223 | |||
| 1224 | base = inetpeer_base_ptr(rt->_peer); | ||
| 1225 | if (!base) | ||
| 1226 | return; | ||
| 1227 | |||
| 1228 | peer = inet_getpeer_v4(base, daddr, create); | ||
| 1229 | if (peer) { | ||
| 1230 | if (!rt_set_peer(rt, peer)) | ||
| 1231 | inet_putpeer(peer); | ||
| 1232 | } | ||
| 1233 | } | ||
| 1234 | |||
| 1235 | /* | 1218 | /* |
| 1236 | * Peer allocation may fail only in serious out-of-memory conditions. However | 1219 | * Peer allocation may fail only in serious out-of-memory conditions. However |
| 1237 | * we still can generate some output. | 1220 | * we still can generate some output. |
| @@ -1588,10 +1571,6 @@ static void ipv4_dst_destroy(struct dst_entry *dst) | |||
| 1588 | fib_info_put(rt->fi); | 1571 | fib_info_put(rt->fi); |
| 1589 | rt->fi = NULL; | 1572 | rt->fi = NULL; |
| 1590 | } | 1573 | } |
| 1591 | if (rt_has_peer(rt)) { | ||
| 1592 | struct inet_peer *peer = rt_peer_ptr(rt); | ||
| 1593 | inet_putpeer(peer); | ||
| 1594 | } | ||
| 1595 | } | 1574 | } |
| 1596 | 1575 | ||
| 1597 | 1576 | ||
| @@ -1711,26 +1690,11 @@ static unsigned int ipv4_mtu(const struct dst_entry *dst) | |||
| 1711 | static void rt_init_metrics(struct rtable *rt, const struct flowi4 *fl4, | 1690 | static void rt_init_metrics(struct rtable *rt, const struct flowi4 *fl4, |
| 1712 | struct fib_info *fi) | 1691 | struct fib_info *fi) |
| 1713 | { | 1692 | { |
| 1714 | struct inet_peer_base *base; | 1693 | if (fi->fib_metrics != (u32 *) dst_default_metrics) { |
| 1715 | struct inet_peer *peer; | 1694 | rt->fi = fi; |
| 1716 | 1695 | atomic_inc(&fi->fib_clntref); | |
| 1717 | base = inetpeer_base_ptr(rt->_peer); | ||
| 1718 | BUG_ON(!base); | ||
| 1719 | |||
| 1720 | peer = inet_getpeer_v4(base, rt->rt_dst, 0); | ||
| 1721 | if (peer) { | ||
| 1722 | __rt_set_peer(rt, peer); | ||
| 1723 | if (inet_metrics_new(peer)) | ||
| 1724 | memcpy(peer->metrics, fi->fib_metrics, | ||
| 1725 | sizeof(u32) * RTAX_MAX); | ||
| 1726 | dst_init_metrics(&rt->dst, peer->metrics, false); | ||
| 1727 | } else { | ||
| 1728 | if (fi->fib_metrics != (u32 *) dst_default_metrics) { | ||
| 1729 | rt->fi = fi; | ||
| 1730 | atomic_inc(&fi->fib_clntref); | ||
| 1731 | } | ||
| 1732 | dst_init_metrics(&rt->dst, fi->fib_metrics, true); | ||
| 1733 | } | 1696 | } |
| 1697 | dst_init_metrics(&rt->dst, fi->fib_metrics, true); | ||
| 1734 | } | 1698 | } |
| 1735 | 1699 | ||
| 1736 | static void rt_set_nexthop(struct rtable *rt, const struct flowi4 *fl4, | 1700 | static void rt_set_nexthop(struct rtable *rt, const struct flowi4 *fl4, |
| @@ -1820,7 +1784,6 @@ static int ip_route_input_mc(struct sk_buff *skb, __be32 daddr, __be32 saddr, | |||
| 1820 | rth->rt_mark = skb->mark; | 1784 | rth->rt_mark = skb->mark; |
| 1821 | rth->rt_pmtu = 0; | 1785 | rth->rt_pmtu = 0; |
| 1822 | rth->rt_gateway = daddr; | 1786 | rth->rt_gateway = daddr; |
| 1823 | rt_init_peer(rth, dev_net(dev)->ipv4.peers); | ||
| 1824 | rth->fi = NULL; | 1787 | rth->fi = NULL; |
| 1825 | if (our) { | 1788 | if (our) { |
| 1826 | rth->dst.input= ip_local_deliver; | 1789 | rth->dst.input= ip_local_deliver; |
| @@ -1946,7 +1909,6 @@ static int __mkroute_input(struct sk_buff *skb, | |||
| 1946 | rth->rt_mark = skb->mark; | 1909 | rth->rt_mark = skb->mark; |
| 1947 | rth->rt_pmtu = 0; | 1910 | rth->rt_pmtu = 0; |
| 1948 | rth->rt_gateway = daddr; | 1911 | rth->rt_gateway = daddr; |
| 1949 | rt_init_peer(rth, &res->table->tb_peers); | ||
| 1950 | rth->fi = NULL; | 1912 | rth->fi = NULL; |
| 1951 | 1913 | ||
| 1952 | rth->dst.input = ip_forward; | 1914 | rth->dst.input = ip_forward; |
| @@ -2125,7 +2087,6 @@ local_input: | |||
| 2125 | rth->rt_mark = skb->mark; | 2087 | rth->rt_mark = skb->mark; |
| 2126 | rth->rt_pmtu = 0; | 2088 | rth->rt_pmtu = 0; |
| 2127 | rth->rt_gateway = daddr; | 2089 | rth->rt_gateway = daddr; |
| 2128 | rt_init_peer(rth, net->ipv4.peers); | ||
| 2129 | rth->fi = NULL; | 2090 | rth->fi = NULL; |
| 2130 | if (res.type == RTN_UNREACHABLE) { | 2091 | if (res.type == RTN_UNREACHABLE) { |
| 2131 | rth->dst.input= ip_error; | 2092 | rth->dst.input= ip_error; |
| @@ -2323,9 +2284,6 @@ static struct rtable *__mkroute_output(const struct fib_result *res, | |||
| 2323 | rth->rt_mark = fl4->flowi4_mark; | 2284 | rth->rt_mark = fl4->flowi4_mark; |
| 2324 | rth->rt_pmtu = 0; | 2285 | rth->rt_pmtu = 0; |
| 2325 | rth->rt_gateway = fl4->daddr; | 2286 | rth->rt_gateway = fl4->daddr; |
| 2326 | rt_init_peer(rth, (res->table ? | ||
| 2327 | &res->table->tb_peers : | ||
| 2328 | dev_net(dev_out)->ipv4.peers)); | ||
| 2329 | rth->fi = NULL; | 2287 | rth->fi = NULL; |
| 2330 | 2288 | ||
| 2331 | RT_CACHE_STAT_INC(out_slow_tot); | 2289 | RT_CACHE_STAT_INC(out_slow_tot); |
| @@ -2662,7 +2620,6 @@ struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_or | |||
| 2662 | rt->rt_dst = ort->rt_dst; | 2620 | rt->rt_dst = ort->rt_dst; |
| 2663 | rt->rt_src = ort->rt_src; | 2621 | rt->rt_src = ort->rt_src; |
| 2664 | rt->rt_gateway = ort->rt_gateway; | 2622 | rt->rt_gateway = ort->rt_gateway; |
| 2665 | rt_transfer_peer(rt, ort); | ||
| 2666 | rt->fi = ort->fi; | 2623 | rt->fi = ort->fi; |
| 2667 | if (rt->fi) | 2624 | if (rt->fi) |
| 2668 | atomic_inc(&rt->fi->fib_clntref); | 2625 | atomic_inc(&rt->fi->fib_clntref); |
| @@ -2700,7 +2657,7 @@ static int rt_fill_info(struct net *net, | |||
| 2700 | struct rtmsg *r; | 2657 | struct rtmsg *r; |
| 2701 | struct nlmsghdr *nlh; | 2658 | struct nlmsghdr *nlh; |
| 2702 | unsigned long expires = 0; | 2659 | unsigned long expires = 0; |
| 2703 | u32 id = 0, error; | 2660 | u32 error; |
| 2704 | 2661 | ||
| 2705 | nlh = nlmsg_put(skb, pid, seq, event, sizeof(*r), flags); | 2662 | nlh = nlmsg_put(skb, pid, seq, event, sizeof(*r), flags); |
| 2706 | if (nlh == NULL) | 2663 | if (nlh == NULL) |
| @@ -2753,11 +2710,6 @@ static int rt_fill_info(struct net *net, | |||
| 2753 | goto nla_put_failure; | 2710 | goto nla_put_failure; |
| 2754 | 2711 | ||
| 2755 | error = rt->dst.error; | 2712 | error = rt->dst.error; |
| 2756 | if (rt_has_peer(rt)) { | ||
| 2757 | const struct inet_peer *peer = rt_peer_ptr(rt); | ||
| 2758 | inet_peer_refcheck(peer); | ||
| 2759 | id = atomic_read(&peer->ip_id_count) & 0xffff; | ||
| 2760 | } | ||
| 2761 | expires = rt->dst.expires; | 2713 | expires = rt->dst.expires; |
| 2762 | if (expires) { | 2714 | if (expires) { |
| 2763 | if (time_before(jiffies, expires)) | 2715 | if (time_before(jiffies, expires)) |
| @@ -2792,7 +2744,7 @@ static int rt_fill_info(struct net *net, | |||
| 2792 | goto nla_put_failure; | 2744 | goto nla_put_failure; |
| 2793 | } | 2745 | } |
| 2794 | 2746 | ||
| 2795 | if (rtnl_put_cacheinfo(skb, &rt->dst, id, expires, error) < 0) | 2747 | if (rtnl_put_cacheinfo(skb, &rt->dst, 0, expires, error) < 0) |
| 2796 | goto nla_put_failure; | 2748 | goto nla_put_failure; |
| 2797 | 2749 | ||
| 2798 | return nlmsg_end(skb, nlh); | 2750 | return nlmsg_end(skb, nlh); |
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index 951bcf35b21c..87d3fcc302d4 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c | |||
| @@ -90,8 +90,6 @@ static int xfrm4_fill_dst(struct xfrm_dst *xdst, struct net_device *dev, | |||
| 90 | xdst->u.dst.dev = dev; | 90 | xdst->u.dst.dev = dev; |
| 91 | dev_hold(dev); | 91 | dev_hold(dev); |
| 92 | 92 | ||
| 93 | rt_transfer_peer(&xdst->u.rt, rt); | ||
| 94 | |||
| 95 | /* Sheit... I remember I did this right. Apparently, | 93 | /* Sheit... I remember I did this right. Apparently, |
| 96 | * it was magically lost, so this code needs audit */ | 94 | * it was magically lost, so this code needs audit */ |
| 97 | xdst->u.rt.rt_flags = rt->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST | | 95 | xdst->u.rt.rt_flags = rt->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST | |
| @@ -210,11 +208,6 @@ static void xfrm4_dst_destroy(struct dst_entry *dst) | |||
| 210 | 208 | ||
| 211 | dst_destroy_metrics_generic(dst); | 209 | dst_destroy_metrics_generic(dst); |
| 212 | 210 | ||
| 213 | if (rt_has_peer(&xdst->u.rt)) { | ||
| 214 | struct inet_peer *peer = rt_peer_ptr(&xdst->u.rt); | ||
| 215 | inet_putpeer(peer); | ||
| 216 | } | ||
| 217 | |||
| 218 | xfrm_dst_destroy(xdst); | 211 | xfrm_dst_destroy(xdst); |
| 219 | } | 212 | } |
| 220 | 213 | ||
