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

ndisc: Make ndisc_fill_xxx_option() for sk_buff.

Signed-off-by: default avatarYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2ce13576
...@@ -143,12 +143,12 @@ struct neigh_table nd_tbl = { ...@@ -143,12 +143,12 @@ struct neigh_table nd_tbl = {
.gc_thresh3 = 1024, .gc_thresh3 = 1024,
}; };
static u8 *ndisc_fill_addr_option(u8 *opt, int type, void *data, static void ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data)
struct net_device *dev)
{ {
int pad = ndisc_addr_option_pad(dev->type); int pad = ndisc_addr_option_pad(skb->dev->type);
int data_len = dev->addr_len; int data_len = skb->dev->addr_len;
int space = ndisc_opt_addr_space(dev); int space = ndisc_opt_addr_space(skb->dev);
u8 *opt = skb_put(skb, space);
opt[0] = type; opt[0] = type;
opt[1] = space>>3; opt[1] = space>>3;
...@@ -162,7 +162,6 @@ static u8 *ndisc_fill_addr_option(u8 *opt, int type, void *data, ...@@ -162,7 +162,6 @@ static u8 *ndisc_fill_addr_option(u8 *opt, int type, void *data,
opt += data_len; opt += data_len;
if ((space -= data_len) > 0) if ((space -= data_len) > 0)
memset(opt, 0, space); memset(opt, 0, space);
return opt + space;
} }
static struct nd_opt_hdr *ndisc_next_option(struct nd_opt_hdr *cur, static struct nd_opt_hdr *ndisc_next_option(struct nd_opt_hdr *cur,
...@@ -440,7 +439,7 @@ static struct sk_buff *ndisc_build_skb(struct net_device *dev, ...@@ -440,7 +439,7 @@ static struct sk_buff *ndisc_build_skb(struct net_device *dev,
if (!skb) if (!skb)
return NULL; return NULL;
skb_put(skb, len + optlen); skb_put(skb, len);
hdr = (struct icmp6hdr *)skb_transport_header(skb); hdr = (struct icmp6hdr *)skb_transport_header(skb);
memcpy(hdr, icmp6h, sizeof(*hdr)); memcpy(hdr, icmp6h, sizeof(*hdr));
...@@ -452,7 +451,7 @@ static struct sk_buff *ndisc_build_skb(struct net_device *dev, ...@@ -452,7 +451,7 @@ static struct sk_buff *ndisc_build_skb(struct net_device *dev,
} }
if (llinfo) if (llinfo)
ndisc_fill_addr_option(opt, llinfo, dev->dev_addr, dev); ndisc_fill_addr_option(skb, llinfo, dev->dev_addr);
hdr->icmp6_cksum = csum_ipv6_magic(saddr, daddr, skb->len, hdr->icmp6_cksum = csum_ipv6_magic(saddr, daddr, skb->len,
IPPROTO_ICMPV6, IPPROTO_ICMPV6,
...@@ -1379,17 +1378,18 @@ static void ndisc_redirect_rcv(struct sk_buff *skb) ...@@ -1379,17 +1378,18 @@ 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, static void ndisc_fill_redirect_hdr_option(struct sk_buff *skb,
int rd_len) struct sk_buff *orig_skb,
int rd_len)
{ {
u8 *opt = skb_put(skb, rd_len);
memset(opt, 0, 8); memset(opt, 0, 8);
*(opt++) = ND_OPT_REDIRECT_HDR; *(opt++) = ND_OPT_REDIRECT_HDR;
*(opt++) = (rd_len >> 3); *(opt++) = (rd_len >> 3);
opt += 6; opt += 6;
memcpy(opt, ipv6_hdr(orig_skb), rd_len - 8); 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)
...@@ -1406,7 +1406,6 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) ...@@ -1406,7 +1406,6 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
struct dst_entry *dst; struct dst_entry *dst;
struct inet6_dev *idev; struct inet6_dev *idev;
struct flowi6 fl6; struct flowi6 fl6;
u8 *opt;
int rd_len; int rd_len;
int err; int err;
u8 ha_buf[MAX_ADDR_LEN], *ha = NULL; u8 ha_buf[MAX_ADDR_LEN], *ha = NULL;
...@@ -1481,7 +1480,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) ...@@ -1481,7 +1480,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
if (!buff) if (!buff)
goto release; goto release;
skb_put(buff, sizeof(*msg) + optlen); skb_put(buff, sizeof(*msg));
msg = (struct rd_msg *)icmp6_hdr(buff); msg = (struct rd_msg *)icmp6_hdr(buff);
memset(&msg->icmph, 0, sizeof(struct icmp6hdr)); memset(&msg->icmph, 0, sizeof(struct icmp6hdr));
...@@ -1494,21 +1493,19 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) ...@@ -1494,21 +1493,19 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
msg->target = *target; msg->target = *target;
msg->dest = ipv6_hdr(skb)->daddr; msg->dest = ipv6_hdr(skb)->daddr;
opt = msg->opt;
/* /*
* include target_address option * include target_address option
*/ */
if (ha) if (ha)
opt = ndisc_fill_addr_option(opt, ND_OPT_TARGET_LL_ADDR, ha, dev); ndisc_fill_addr_option(skb, ND_OPT_TARGET_LL_ADDR, ha);
/* /*
* build redirect option and copy skb over to the new packet. * build redirect option and copy skb over to the new packet.
*/ */
if (rd_len) if (rd_len)
opt = ndisc_fill_redirect_hdr_option(opt, skb, rd_len); ndisc_fill_redirect_hdr_option(buff, skb, rd_len);
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,
buff->len, IPPROTO_ICMPV6, buff->len, IPPROTO_ICMPV6,
......
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