Commit f4de84c6 authored by YOSHIFUJI Hideaki / 吉藤英明's avatar YOSHIFUJI Hideaki / 吉藤英明 Committed by David S. Miller

ndisc: Use ndisc_send_skb() for redirect.

Reuse dst if one is attached with skb.
Signed-off-by: default avatarYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent aa4bdd4b
...@@ -467,10 +467,8 @@ static void ndisc_send_skb(struct sk_buff *skb, ...@@ -467,10 +467,8 @@ static void ndisc_send_skb(struct sk_buff *skb,
const struct in6_addr *daddr, const struct in6_addr *daddr,
const struct in6_addr *saddr) const struct in6_addr *saddr)
{ {
struct flowi6 fl6; struct dst_entry *dst = skb_dst(skb);
struct dst_entry *dst;
struct net *net = dev_net(skb->dev); struct net *net = dev_net(skb->dev);
struct sock *sk = net->ipv6.ndisc_sk;
struct inet6_dev *idev; struct inet6_dev *idev;
int err; int err;
struct icmp6hdr *icmp6h = icmp6_hdr(skb); struct icmp6hdr *icmp6h = icmp6_hdr(skb);
...@@ -478,6 +476,10 @@ static void ndisc_send_skb(struct sk_buff *skb, ...@@ -478,6 +476,10 @@ static void ndisc_send_skb(struct sk_buff *skb,
type = icmp6h->icmp6_type; type = icmp6h->icmp6_type;
if (!dst) {
struct sock *sk = net->ipv6.ndisc_sk;
struct flowi6 fl6;
icmpv6_flow_init(sk, &fl6, type, saddr, daddr, skb->dev->ifindex); icmpv6_flow_init(sk, &fl6, type, saddr, daddr, skb->dev->ifindex);
dst = icmp6_dst_alloc(skb->dev, &fl6); dst = icmp6_dst_alloc(skb->dev, &fl6);
if (IS_ERR(dst)) { if (IS_ERR(dst)) {
...@@ -486,6 +488,7 @@ static void ndisc_send_skb(struct sk_buff *skb, ...@@ -486,6 +488,7 @@ static void ndisc_send_skb(struct sk_buff *skb,
} }
skb_dst_set(skb, dst); skb_dst_set(skb, dst);
}
rcu_read_lock(); rcu_read_lock();
idev = __in6_dev_get(dst->dev); idev = __in6_dev_get(dst->dev);
...@@ -1404,10 +1407,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) ...@@ -1404,10 +1407,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
struct in6_addr saddr_buf; struct in6_addr saddr_buf;
struct rt6_info *rt; struct rt6_info *rt;
struct dst_entry *dst; struct dst_entry *dst;
struct inet6_dev *idev;
struct flowi6 fl6; struct flowi6 fl6;
int rd_len; int rd_len;
int err;
u8 ha_buf[MAX_ADDR_LEN], *ha = NULL; u8 ha_buf[MAX_ADDR_LEN], *ha = NULL;
bool ret; bool ret;
...@@ -1515,17 +1516,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) ...@@ -1515,17 +1516,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
inet6_sk(sk)->hop_limit, buff->len); inet6_sk(sk)->hop_limit, buff->len);
skb_dst_set(buff, dst); skb_dst_set(buff, dst);
rcu_read_lock(); ndisc_send_skb(buff, &ipv6_hdr(skb)->saddr, &saddr_buf);
idev = __in6_dev_get(dst->dev);
IP6_UPD_PO_STATS(net, idev, IPSTATS_MIB_OUT, skb->len);
err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, buff, NULL, dst->dev,
dst_output);
if (!err) {
ICMP6MSGOUT_INC_STATS(net, idev, NDISC_REDIRECT);
ICMP6_INC_STATS(net, idev, ICMP6_MIB_OUTMSGS);
}
rcu_read_unlock();
return; return;
release: release:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment