inet: Create and use rt{,6}_get_peer_create().
There's a lot of places that open-code rt{,6}_get_peer() only because they want to set 'create' to one. So add an rt{,6}_get_peer_create() for their sake. There were also a few spots open-coding plain rt{,6}_get_peer() and those are transformed here as well. Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
@@ -188,14 +188,14 @@ static inline bool icmpv6_xrlim_allow(struct sock *sk, u8 type,
|
||||
} else {
|
||||
struct rt6_info *rt = (struct rt6_info *)dst;
|
||||
int tmo = net->ipv6.sysctl.icmpv6_time;
|
||||
struct inet_peer *peer;
|
||||
|
||||
/* Give more bandwidth to wider prefixes. */
|
||||
if (rt->rt6i_dst.plen < 128)
|
||||
tmo >>= ((128 - rt->rt6i_dst.plen)>>5);
|
||||
|
||||
if (!rt->rt6i_peer)
|
||||
rt6_bind_peer(rt, 1);
|
||||
res = inet_peer_xrlim_allow(rt->rt6i_peer, tmo);
|
||||
peer = rt6_get_peer_create(rt);
|
||||
res = inet_peer_xrlim_allow(peer, tmo);
|
||||
}
|
||||
dst_release(dst);
|
||||
return res;
|
||||
|
@@ -463,6 +463,7 @@ int ip6_forward(struct sk_buff *skb)
|
||||
*/
|
||||
if (skb->dev == dst->dev && opt->srcrt == 0 && !skb_sec_path(skb)) {
|
||||
struct in6_addr *target = NULL;
|
||||
struct inet_peer *peer;
|
||||
struct rt6_info *rt;
|
||||
|
||||
/*
|
||||
@@ -476,13 +477,12 @@ int ip6_forward(struct sk_buff *skb)
|
||||
else
|
||||
target = &hdr->daddr;
|
||||
|
||||
if (!rt->rt6i_peer)
|
||||
rt6_bind_peer(rt, 1);
|
||||
peer = rt6_get_peer_create(rt);
|
||||
|
||||
/* Limit redirects both by destination (here)
|
||||
and by source (inside ndisc_send_redirect)
|
||||
*/
|
||||
if (inet_peer_xrlim_allow(rt->rt6i_peer, 1*HZ))
|
||||
if (inet_peer_xrlim_allow(peer, 1*HZ))
|
||||
ndisc_send_redirect(skb, target);
|
||||
} else {
|
||||
int addrtype = ipv6_addr_type(&hdr->saddr);
|
||||
@@ -602,11 +602,8 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
|
||||
int old, new;
|
||||
|
||||
if (rt && !(rt->dst.flags & DST_NOPEER)) {
|
||||
struct inet_peer *peer;
|
||||
struct inet_peer *peer = rt6_get_peer_create(rt);
|
||||
|
||||
if (!rt->rt6i_peer)
|
||||
rt6_bind_peer(rt, 1);
|
||||
peer = rt->rt6i_peer;
|
||||
if (peer) {
|
||||
fhdr->identification = htonl(inet_getid(peer, 0));
|
||||
return;
|
||||
|
@@ -1472,6 +1472,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
|
||||
struct net *net = dev_net(dev);
|
||||
struct sock *sk = net->ipv6.ndisc_sk;
|
||||
int len = sizeof(struct icmp6hdr) + 2 * sizeof(struct in6_addr);
|
||||
struct inet_peer *peer;
|
||||
struct sk_buff *buff;
|
||||
struct icmp6hdr *icmph;
|
||||
struct in6_addr saddr_buf;
|
||||
@@ -1518,9 +1519,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
|
||||
"Redirect: destination is not a neighbour\n");
|
||||
goto release;
|
||||
}
|
||||
if (!rt->rt6i_peer)
|
||||
rt6_bind_peer(rt, 1);
|
||||
if (!inet_peer_xrlim_allow(rt->rt6i_peer, 1*HZ))
|
||||
peer = rt6_get_peer_create(rt);
|
||||
if (!inet_peer_xrlim_allow(peer, 1*HZ))
|
||||
goto release;
|
||||
|
||||
if (dev->addr_len) {
|
||||
|
@@ -99,10 +99,7 @@ static u32 *ipv6_cow_metrics(struct dst_entry *dst, unsigned long old)
|
||||
if (!(rt->dst.flags & DST_HOST))
|
||||
return NULL;
|
||||
|
||||
if (!rt->rt6i_peer)
|
||||
rt6_bind_peer(rt, 1);
|
||||
|
||||
peer = rt->rt6i_peer;
|
||||
peer = rt6_get_peer_create(rt);
|
||||
if (peer) {
|
||||
u32 *old_p = __DST_METRICS_PTR(old);
|
||||
unsigned long prev, new;
|
||||
|
@@ -1744,9 +1744,7 @@ static struct inet_peer *tcp_v6_get_peer(struct sock *sk, bool *release_it)
|
||||
peer = inet_getpeer_v6(net, &np->daddr, 1);
|
||||
*release_it = true;
|
||||
} else {
|
||||
if (!rt->rt6i_peer)
|
||||
rt6_bind_peer(rt, 1);
|
||||
peer = rt->rt6i_peer;
|
||||
peer = rt6_get_peer_create(rt);
|
||||
*release_it = false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user