aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-05-18 18:42:43 -0400
committerDavid S. Miller <davem@davemloft.net>2011-05-18 18:42:43 -0400
commita48eff128865aa20520fa6e0e0c5fbd2ac50d712 (patch)
treec60e376c3fca23bb215c977e42661187076dccbf /net/ipv4
parented2361e66eec60645f8e4715fe39a42235ef43ae (diff)
ipv4: Pass explicit destination address to rt_bind_peer().
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/icmp.c8
-rw-r--r--net/ipv4/route.c16
-rw-r--r--net/ipv4/tcp_ipv4.c2
3 files changed, 13 insertions, 13 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 3f47585aad68..5395e45dcce6 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -234,7 +234,7 @@ static inline void icmp_xmit_unlock(struct sock *sk)
234 */ 234 */
235 235
236static inline bool icmpv4_xrlim_allow(struct net *net, struct rtable *rt, 236static inline bool icmpv4_xrlim_allow(struct net *net, struct rtable *rt,
237 int type, int code) 237 struct flowi4 *fl4, int type, int code)
238{ 238{
239 struct dst_entry *dst = &rt->dst; 239 struct dst_entry *dst = &rt->dst;
240 bool rc = true; 240 bool rc = true;
@@ -253,7 +253,7 @@ static inline bool icmpv4_xrlim_allow(struct net *net, struct rtable *rt,
253 /* Limit if icmp type is enabled in ratemask. */ 253 /* Limit if icmp type is enabled in ratemask. */
254 if ((1 << type) & net->ipv4.sysctl_icmp_ratemask) { 254 if ((1 << type) & net->ipv4.sysctl_icmp_ratemask) {
255 if (!rt->peer) 255 if (!rt->peer)
256 rt_bind_peer(rt, 1); 256 rt_bind_peer(rt, fl4->daddr, 1);
257 rc = inet_peer_xrlim_allow(rt->peer, 257 rc = inet_peer_xrlim_allow(rt->peer,
258 net->ipv4.sysctl_icmp_ratelimit); 258 net->ipv4.sysctl_icmp_ratelimit);
259 } 259 }
@@ -363,7 +363,7 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb)
363 rt = ip_route_output_key(net, &fl4); 363 rt = ip_route_output_key(net, &fl4);
364 if (IS_ERR(rt)) 364 if (IS_ERR(rt))
365 goto out_unlock; 365 goto out_unlock;
366 if (icmpv4_xrlim_allow(net, rt, icmp_param->data.icmph.type, 366 if (icmpv4_xrlim_allow(net, rt, &fl4, icmp_param->data.icmph.type,
367 icmp_param->data.icmph.code)) 367 icmp_param->data.icmph.code))
368 icmp_push_reply(icmp_param, &fl4, &ipc, &rt); 368 icmp_push_reply(icmp_param, &fl4, &ipc, &rt);
369 ip_rt_put(rt); 369 ip_rt_put(rt);
@@ -603,7 +603,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
603 if (IS_ERR(rt)) 603 if (IS_ERR(rt))
604 goto out_unlock; 604 goto out_unlock;
605 605
606 if (!icmpv4_xrlim_allow(net, rt, type, code)) 606 if (!icmpv4_xrlim_allow(net, rt, &fl4, type, code))
607 goto ende; 607 goto ende;
608 608
609 /* RFC says return as much as we can without exceeding 576 bytes. */ 609 /* RFC says return as much as we can without exceeding 576 bytes. */
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 9c5ad86bc783..b24d58e6bbcd 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -156,7 +156,7 @@ static u32 *ipv4_cow_metrics(struct dst_entry *dst, unsigned long old)
156 u32 *p = NULL; 156 u32 *p = NULL;
157 157
158 if (!rt->peer) 158 if (!rt->peer)
159 rt_bind_peer(rt, 1); 159 rt_bind_peer(rt, rt->rt_dst, 1);
160 160
161 peer = rt->peer; 161 peer = rt->peer;
162 if (peer) { 162 if (peer) {
@@ -1193,11 +1193,11 @@ static u32 rt_peer_genid(void)
1193 return atomic_read(&__rt_peer_genid); 1193 return atomic_read(&__rt_peer_genid);
1194} 1194}
1195 1195
1196void rt_bind_peer(struct rtable *rt, int create) 1196void rt_bind_peer(struct rtable *rt, __be32 daddr, int create)
1197{ 1197{
1198 struct inet_peer *peer; 1198 struct inet_peer *peer;
1199 1199
1200 peer = inet_getpeer_v4(rt->rt_dst, create); 1200 peer = inet_getpeer_v4(daddr, create);
1201 1201
1202 if (peer && cmpxchg(&rt->peer, NULL, peer) != NULL) 1202 if (peer && cmpxchg(&rt->peer, NULL, peer) != NULL)
1203 inet_putpeer(peer); 1203 inet_putpeer(peer);
@@ -1231,7 +1231,7 @@ void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more)
1231 1231
1232 if (rt) { 1232 if (rt) {
1233 if (rt->peer == NULL) 1233 if (rt->peer == NULL)
1234 rt_bind_peer(rt, 1); 1234 rt_bind_peer(rt, rt->rt_dst, 1);
1235 1235
1236 /* If peer is attached to destination, it is never detached, 1236 /* If peer is attached to destination, it is never detached,
1237 so that we need not to grab a lock to dereference it. 1237 so that we need not to grab a lock to dereference it.
@@ -1377,7 +1377,7 @@ void ip_rt_send_redirect(struct sk_buff *skb)
1377 rcu_read_unlock(); 1377 rcu_read_unlock();
1378 1378
1379 if (!rt->peer) 1379 if (!rt->peer)
1380 rt_bind_peer(rt, 1); 1380 rt_bind_peer(rt, rt->rt_dst, 1);
1381 peer = rt->peer; 1381 peer = rt->peer;
1382 if (!peer) { 1382 if (!peer) {
1383 icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST, rt->rt_gateway); 1383 icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST, rt->rt_gateway);
@@ -1445,7 +1445,7 @@ static int ip_error(struct sk_buff *skb)
1445 } 1445 }
1446 1446
1447 if (!rt->peer) 1447 if (!rt->peer)
1448 rt_bind_peer(rt, 1); 1448 rt_bind_peer(rt, rt->rt_dst, 1);
1449 peer = rt->peer; 1449 peer = rt->peer;
1450 1450
1451 send = true; 1451 send = true;
@@ -1552,7 +1552,7 @@ static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu)
1552 dst_confirm(dst); 1552 dst_confirm(dst);
1553 1553
1554 if (!rt->peer) 1554 if (!rt->peer)
1555 rt_bind_peer(rt, 1); 1555 rt_bind_peer(rt, rt->rt_dst, 1);
1556 peer = rt->peer; 1556 peer = rt->peer;
1557 if (peer) { 1557 if (peer) {
1558 if (mtu < ip_rt_min_pmtu) 1558 if (mtu < ip_rt_min_pmtu)
@@ -1609,7 +1609,7 @@ static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie)
1609 struct inet_peer *peer; 1609 struct inet_peer *peer;
1610 1610
1611 if (!rt->peer) 1611 if (!rt->peer)
1612 rt_bind_peer(rt, 0); 1612 rt_bind_peer(rt, rt->rt_dst, 0);
1613 1613
1614 peer = rt->peer; 1614 peer = rt->peer;
1615 if (peer && peer->pmtu_expires) 1615 if (peer && peer->pmtu_expires)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 1d290acdcb27..3c8d9b6f1ea4 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1781,7 +1781,7 @@ struct inet_peer *tcp_v4_get_peer(struct sock *sk, bool *release_it)
1781 *release_it = true; 1781 *release_it = true;
1782 } else { 1782 } else {
1783 if (!rt->peer) 1783 if (!rt->peer)
1784 rt_bind_peer(rt, 1); 1784 rt_bind_peer(rt, inet->inet_daddr, 1);
1785 peer = rt->peer; 1785 peer = rt->peer;
1786 *release_it = false; 1786 *release_it = false;
1787 } 1787 }