diff options
author | David S. Miller <davem@davemloft.net> | 2012-07-10 06:58:16 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-07-11 01:40:11 -0400 |
commit | 1d861aa4b3fb08822055345f480850205ffe6170 (patch) | |
tree | 072c23dcde7766274464c75e51e820649301ad82 /net/ipv6 | |
parent | 16d1839907e695387654901995f9286b65fbbc6a (diff) |
inet: Minimize use of cached route inetpeer.
Only use it in the absolutely required cases:
1) COW'ing metrics
2) ipv4 PMTU
3) ipv4 redirects
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/icmp.c | 4 | ||||
-rw-r--r-- | net/ipv6/ip6_output.c | 10 | ||||
-rw-r--r-- | net/ipv6/ndisc.c | 8 |
3 files changed, 17 insertions, 5 deletions
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index c7da1422cbde..a113f7d7e938 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c | |||
@@ -194,8 +194,10 @@ static inline bool icmpv6_xrlim_allow(struct sock *sk, u8 type, | |||
194 | if (rt->rt6i_dst.plen < 128) | 194 | if (rt->rt6i_dst.plen < 128) |
195 | tmo >>= ((128 - rt->rt6i_dst.plen)>>5); | 195 | tmo >>= ((128 - rt->rt6i_dst.plen)>>5); |
196 | 196 | ||
197 | peer = rt6_get_peer_create(rt); | 197 | peer = inet_getpeer_v6(net->ipv6.peers, &rt->rt6i_dst.addr, 1); |
198 | res = inet_peer_xrlim_allow(peer, tmo); | 198 | res = inet_peer_xrlim_allow(peer, tmo); |
199 | if (peer) | ||
200 | inet_putpeer(peer); | ||
199 | } | 201 | } |
200 | dst_release(dst); | 202 | dst_release(dst); |
201 | return res; | 203 | return res; |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index c6af5963a202..5b2d63ed793e 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -466,13 +466,15 @@ int ip6_forward(struct sk_buff *skb) | |||
466 | else | 466 | else |
467 | target = &hdr->daddr; | 467 | target = &hdr->daddr; |
468 | 468 | ||
469 | peer = rt6_get_peer_create(rt); | 469 | peer = inet_getpeer_v6(net->ipv6.peers, &rt->rt6i_dst.addr, 1); |
470 | 470 | ||
471 | /* Limit redirects both by destination (here) | 471 | /* Limit redirects both by destination (here) |
472 | and by source (inside ndisc_send_redirect) | 472 | and by source (inside ndisc_send_redirect) |
473 | */ | 473 | */ |
474 | if (inet_peer_xrlim_allow(peer, 1*HZ)) | 474 | if (inet_peer_xrlim_allow(peer, 1*HZ)) |
475 | ndisc_send_redirect(skb, target); | 475 | ndisc_send_redirect(skb, target); |
476 | if (peer) | ||
477 | inet_putpeer(peer); | ||
476 | } else { | 478 | } else { |
477 | int addrtype = ipv6_addr_type(&hdr->saddr); | 479 | int addrtype = ipv6_addr_type(&hdr->saddr); |
478 | 480 | ||
@@ -592,10 +594,14 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt) | |||
592 | int old, new; | 594 | int old, new; |
593 | 595 | ||
594 | if (rt && !(rt->dst.flags & DST_NOPEER)) { | 596 | if (rt && !(rt->dst.flags & DST_NOPEER)) { |
595 | struct inet_peer *peer = rt6_get_peer_create(rt); | 597 | struct inet_peer *peer; |
598 | struct net *net; | ||
596 | 599 | ||
600 | net = dev_net(rt->dst.dev); | ||
601 | peer = inet_getpeer_v6(net->ipv6.peers, &rt->rt6i_dst.addr, 1); | ||
597 | if (peer) { | 602 | if (peer) { |
598 | fhdr->identification = htonl(inet_getid(peer, 0)); | 603 | fhdr->identification = htonl(inet_getid(peer, 0)); |
604 | inet_putpeer(peer); | ||
599 | return; | 605 | return; |
600 | } | 606 | } |
601 | } | 607 | } |
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 69a6330dea91..0fddd571400d 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c | |||
@@ -1486,6 +1486,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) | |||
1486 | int rd_len; | 1486 | int rd_len; |
1487 | int err; | 1487 | int err; |
1488 | u8 ha_buf[MAX_ADDR_LEN], *ha = NULL; | 1488 | u8 ha_buf[MAX_ADDR_LEN], *ha = NULL; |
1489 | bool ret; | ||
1489 | 1490 | ||
1490 | if (ipv6_get_lladdr(dev, &saddr_buf, IFA_F_TENTATIVE)) { | 1491 | if (ipv6_get_lladdr(dev, &saddr_buf, IFA_F_TENTATIVE)) { |
1491 | ND_PRINTK(2, warn, "Redirect: no link-local address on %s\n", | 1492 | ND_PRINTK(2, warn, "Redirect: no link-local address on %s\n", |
@@ -1519,8 +1520,11 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) | |||
1519 | "Redirect: destination is not a neighbour\n"); | 1520 | "Redirect: destination is not a neighbour\n"); |
1520 | goto release; | 1521 | goto release; |
1521 | } | 1522 | } |
1522 | peer = rt6_get_peer_create(rt); | 1523 | peer = inet_getpeer_v6(net->ipv6.peers, &rt->rt6i_dst.addr, 1); |
1523 | if (!inet_peer_xrlim_allow(peer, 1*HZ)) | 1524 | ret = inet_peer_xrlim_allow(peer, 1*HZ); |
1525 | if (peer) | ||
1526 | inet_putpeer(peer); | ||
1527 | if (!ret) | ||
1524 | goto release; | 1528 | goto release; |
1525 | 1529 | ||
1526 | if (dev->addr_len) { | 1530 | if (dev->addr_len) { |