diff options
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r-- | net/ipv4/route.c | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 2c9f73f3b7cc..7a4d724765e6 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -162,10 +162,7 @@ static u32 *ipv4_cow_metrics(struct dst_entry *dst, unsigned long old) | |||
162 | struct inet_peer *peer; | 162 | struct inet_peer *peer; |
163 | u32 *p = NULL; | 163 | u32 *p = NULL; |
164 | 164 | ||
165 | if (!rt->peer) | 165 | peer = rt_get_peer_create(rt, rt->rt_dst); |
166 | rt_bind_peer(rt, rt->rt_dst, 1); | ||
167 | |||
168 | peer = rt->peer; | ||
169 | if (peer) { | 166 | if (peer) { |
170 | u32 *old_p = __DST_METRICS_PTR(old); | 167 | u32 *old_p = __DST_METRICS_PTR(old); |
171 | unsigned long prev, new; | 168 | unsigned long prev, new; |
@@ -1364,14 +1361,13 @@ void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more) | |||
1364 | struct rtable *rt = (struct rtable *) dst; | 1361 | struct rtable *rt = (struct rtable *) dst; |
1365 | 1362 | ||
1366 | if (rt && !(rt->dst.flags & DST_NOPEER)) { | 1363 | if (rt && !(rt->dst.flags & DST_NOPEER)) { |
1367 | if (rt->peer == NULL) | 1364 | struct inet_peer *peer = rt_get_peer_create(rt, rt->rt_dst); |
1368 | rt_bind_peer(rt, rt->rt_dst, 1); | ||
1369 | 1365 | ||
1370 | /* If peer is attached to destination, it is never detached, | 1366 | /* If peer is attached to destination, it is never detached, |
1371 | so that we need not to grab a lock to dereference it. | 1367 | so that we need not to grab a lock to dereference it. |
1372 | */ | 1368 | */ |
1373 | if (rt->peer) { | 1369 | if (peer) { |
1374 | iph->id = htons(inet_getid(rt->peer, more)); | 1370 | iph->id = htons(inet_getid(peer, more)); |
1375 | return; | 1371 | return; |
1376 | } | 1372 | } |
1377 | } else if (!rt) | 1373 | } else if (!rt) |
@@ -1481,10 +1477,7 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw, | |||
1481 | rt->rt_gateway != old_gw) | 1477 | rt->rt_gateway != old_gw) |
1482 | continue; | 1478 | continue; |
1483 | 1479 | ||
1484 | if (!rt->peer) | 1480 | peer = rt_get_peer_create(rt, rt->rt_dst); |
1485 | rt_bind_peer(rt, rt->rt_dst, 1); | ||
1486 | |||
1487 | peer = rt->peer; | ||
1488 | if (peer) { | 1481 | if (peer) { |
1489 | if (peer->redirect_learned.a4 != new_gw) { | 1482 | if (peer->redirect_learned.a4 != new_gw) { |
1490 | peer->redirect_learned.a4 = new_gw; | 1483 | peer->redirect_learned.a4 = new_gw; |
@@ -1579,9 +1572,7 @@ void ip_rt_send_redirect(struct sk_buff *skb) | |||
1579 | log_martians = IN_DEV_LOG_MARTIANS(in_dev); | 1572 | log_martians = IN_DEV_LOG_MARTIANS(in_dev); |
1580 | rcu_read_unlock(); | 1573 | rcu_read_unlock(); |
1581 | 1574 | ||
1582 | if (!rt->peer) | 1575 | peer = rt_get_peer_create(rt, rt->rt_dst); |
1583 | rt_bind_peer(rt, rt->rt_dst, 1); | ||
1584 | peer = rt->peer; | ||
1585 | if (!peer) { | 1576 | if (!peer) { |
1586 | icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST, rt->rt_gateway); | 1577 | icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST, rt->rt_gateway); |
1587 | return; | 1578 | return; |
@@ -1646,9 +1637,7 @@ static int ip_error(struct sk_buff *skb) | |||
1646 | break; | 1637 | break; |
1647 | } | 1638 | } |
1648 | 1639 | ||
1649 | if (!rt->peer) | 1640 | peer = rt_get_peer_create(rt, rt->rt_dst); |
1650 | rt_bind_peer(rt, rt->rt_dst, 1); | ||
1651 | peer = rt->peer; | ||
1652 | 1641 | ||
1653 | send = true; | 1642 | send = true; |
1654 | if (peer) { | 1643 | if (peer) { |
@@ -1754,9 +1743,7 @@ static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu) | |||
1754 | 1743 | ||
1755 | dst_confirm(dst); | 1744 | dst_confirm(dst); |
1756 | 1745 | ||
1757 | if (!rt->peer) | 1746 | peer = rt_get_peer_create(rt, rt->rt_dst); |
1758 | rt_bind_peer(rt, rt->rt_dst, 1); | ||
1759 | peer = rt->peer; | ||
1760 | if (peer) { | 1747 | if (peer) { |
1761 | unsigned long pmtu_expires = ACCESS_ONCE(peer->pmtu_expires); | 1748 | unsigned long pmtu_expires = ACCESS_ONCE(peer->pmtu_expires); |
1762 | 1749 | ||
@@ -1782,12 +1769,8 @@ static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu) | |||
1782 | static void ipv4_validate_peer(struct rtable *rt) | 1769 | static void ipv4_validate_peer(struct rtable *rt) |
1783 | { | 1770 | { |
1784 | if (rt->rt_peer_genid != rt_peer_genid()) { | 1771 | if (rt->rt_peer_genid != rt_peer_genid()) { |
1785 | struct inet_peer *peer; | 1772 | struct inet_peer *peer = rt_get_peer(rt, rt->rt_dst); |
1786 | |||
1787 | if (!rt->peer) | ||
1788 | rt_bind_peer(rt, rt->rt_dst, 0); | ||
1789 | 1773 | ||
1790 | peer = rt->peer; | ||
1791 | if (peer) { | 1774 | if (peer) { |
1792 | check_peer_pmtu(&rt->dst, peer); | 1775 | check_peer_pmtu(&rt->dst, peer); |
1793 | 1776 | ||