提交 9c86dafe 编写于 作者: Y YOSHIFUJI Hideaki / 吉藤英明 提交者: David S. Miller

ndisc: Introduce ndisc_fill_redirect_hdr_option().

Signed-off-by: NYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 6bce6b4e
...@@ -1341,6 +1341,19 @@ static void ndisc_redirect_rcv(struct sk_buff *skb) ...@@ -1341,6 +1341,19 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
icmpv6_notify(skb, NDISC_REDIRECT, 0, 0); icmpv6_notify(skb, NDISC_REDIRECT, 0, 0);
} }
static u8 *ndisc_fill_redirect_hdr_option(u8 *opt, struct sk_buff *orig_skb,
int rd_len)
{
memset(opt, 0, 8);
*(opt++) = ND_OPT_REDIRECT_HDR;
*(opt++) = (rd_len >> 3);
opt += 6;
memcpy(opt, ipv6_hdr(orig_skb), rd_len - 8);
return opt + rd_len - 8;
}
void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
{ {
struct net_device *dev = skb->dev; struct net_device *dev = skb->dev;
...@@ -1470,12 +1483,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) ...@@ -1470,12 +1483,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
* build redirect option and copy skb over to the new packet. * build redirect option and copy skb over to the new packet.
*/ */
memset(opt, 0, 8); if (rd_len)
*(opt++) = ND_OPT_REDIRECT_HDR; opt = ndisc_fill_redirect_hdr_option(opt, skb, rd_len);
*(opt++) = (rd_len >> 3);
opt += 6;
memcpy(opt, ipv6_hdr(skb), rd_len - 8);
msg->icmph.icmp6_cksum = csum_ipv6_magic(&saddr_buf, &ipv6_hdr(skb)->saddr, msg->icmph.icmp6_cksum = csum_ipv6_magic(&saddr_buf, &ipv6_hdr(skb)->saddr,
len, IPPROTO_ICMPV6, len, IPPROTO_ICMPV6,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册