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

ndisc: Use struct rd_msg for redirect message.

Signed-off-by: default avatarYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9ca1b22d
...@@ -1355,12 +1355,11 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) ...@@ -1355,12 +1355,11 @@ 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;
struct net *net = dev_net(dev); struct net *net = dev_net(dev);
struct sock *sk = net->ipv6.ndisc_sk; struct sock *sk = net->ipv6.ndisc_sk;
int len = sizeof(struct icmp6hdr) + 2 * sizeof(struct in6_addr); int len = sizeof(struct rd_msg);
struct inet_peer *peer; struct inet_peer *peer;
struct sk_buff *buff; struct sk_buff *buff;
struct icmp6hdr *icmph; struct rd_msg *msg;
struct in6_addr saddr_buf; struct in6_addr saddr_buf;
struct in6_addr *addrp;
struct rt6_info *rt; struct rt6_info *rt;
struct dst_entry *dst; struct dst_entry *dst;
struct inet6_dev *idev; struct inet6_dev *idev;
...@@ -1455,21 +1454,19 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) ...@@ -1455,21 +1454,19 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
skb_set_transport_header(buff, skb_tail_pointer(buff) - buff->data); skb_set_transport_header(buff, skb_tail_pointer(buff) - buff->data);
skb_put(buff, len); skb_put(buff, len);
icmph = icmp6_hdr(buff); msg = (struct rd_msg *)icmp6_hdr(buff);
memset(icmph, 0, sizeof(struct icmp6hdr)); memset(&msg->icmph, 0, sizeof(struct icmp6hdr));
icmph->icmp6_type = NDISC_REDIRECT; msg->icmph.icmp6_type = NDISC_REDIRECT;
/* /*
* copy target and destination addresses * copy target and destination addresses
*/ */
addrp = (struct in6_addr *)(icmph + 1); msg->target = *target;
*addrp = *target; msg->dest = ipv6_hdr(skb)->daddr;
addrp++;
*addrp = ipv6_hdr(skb)->daddr;
opt = (u8*) (addrp + 1); opt = msg->opt;
/* /*
* include target_address option * include target_address option
...@@ -1490,9 +1487,9 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) ...@@ -1490,9 +1487,9 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
memcpy(opt, ipv6_hdr(skb), rd_len - 8); memcpy(opt, ipv6_hdr(skb), rd_len - 8);
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,
csum_partial(icmph, len, 0)); csum_partial(msg, len, 0));
skb_dst_set(buff, dst); skb_dst_set(buff, dst);
rcu_read_lock(); rcu_read_lock();
......
...@@ -1705,37 +1705,33 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu ...@@ -1705,37 +1705,33 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
struct net *net = dev_net(skb->dev); struct net *net = dev_net(skb->dev);
struct netevent_redirect netevent; struct netevent_redirect netevent;
struct rt6_info *rt, *nrt = NULL; struct rt6_info *rt, *nrt = NULL;
const struct in6_addr *target;
struct ndisc_options ndopts; struct ndisc_options ndopts;
const struct in6_addr *dest;
struct neighbour *old_neigh; struct neighbour *old_neigh;
struct inet6_dev *in6_dev; struct inet6_dev *in6_dev;
struct neighbour *neigh; struct neighbour *neigh;
struct icmp6hdr *icmph; struct rd_msg *msg;
int optlen, on_link; int optlen, on_link;
u8 *lladdr; u8 *lladdr;
optlen = skb->tail - skb->transport_header; optlen = skb->tail - skb->transport_header;
optlen -= sizeof(struct icmp6hdr) + 2 * sizeof(struct in6_addr); optlen -= sizeof(*msg);
if (optlen < 0) { if (optlen < 0) {
net_dbg_ratelimited("rt6_do_redirect: packet too short\n"); net_dbg_ratelimited("rt6_do_redirect: packet too short\n");
return; return;
} }
icmph = icmp6_hdr(skb); msg = (struct rd_msg *)icmp6_hdr(skb);
target = (const struct in6_addr *) (icmph + 1);
dest = target + 1;
if (ipv6_addr_is_multicast(dest)) { if (ipv6_addr_is_multicast(&msg->dest)) {
net_dbg_ratelimited("rt6_do_redirect: destination address is multicast\n"); net_dbg_ratelimited("rt6_do_redirect: destination address is multicast\n");
return; return;
} }
on_link = 0; on_link = 0;
if (ipv6_addr_equal(dest, target)) { if (ipv6_addr_equal(&msg->dest, &msg->target)) {
on_link = 1; on_link = 1;
} else if (ipv6_addr_type(target) != } else if (ipv6_addr_type(&msg->target) !=
(IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) { (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) {
net_dbg_ratelimited("rt6_do_redirect: target address is not link-local unicast\n"); net_dbg_ratelimited("rt6_do_redirect: target address is not link-local unicast\n");
return; return;
...@@ -1752,7 +1748,7 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu ...@@ -1752,7 +1748,7 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
* first-hop router for the specified ICMP Destination Address. * first-hop router for the specified ICMP Destination Address.
*/ */
if (!ndisc_parse_options((u8*)(dest + 1), optlen, &ndopts)) { if (!ndisc_parse_options(msg->opt, optlen, &ndopts)) {
net_dbg_ratelimited("rt6_redirect: invalid ND options\n"); net_dbg_ratelimited("rt6_redirect: invalid ND options\n");
return; return;
} }
...@@ -1779,7 +1775,7 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu ...@@ -1779,7 +1775,7 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
*/ */
dst_confirm(&rt->dst); dst_confirm(&rt->dst);
neigh = __neigh_lookup(&nd_tbl, target, skb->dev, 1); neigh = __neigh_lookup(&nd_tbl, &msg->target, skb->dev, 1);
if (!neigh) if (!neigh)
return; return;
...@@ -1799,7 +1795,7 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu ...@@ -1799,7 +1795,7 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
NEIGH_UPDATE_F_ISROUTER)) NEIGH_UPDATE_F_ISROUTER))
); );
nrt = ip6_rt_copy(rt, dest); nrt = ip6_rt_copy(rt, &msg->dest);
if (!nrt) if (!nrt)
goto out; goto out;
...@@ -1817,7 +1813,7 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu ...@@ -1817,7 +1813,7 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
netevent.old_neigh = old_neigh; netevent.old_neigh = old_neigh;
netevent.new = &nrt->dst; netevent.new = &nrt->dst;
netevent.new_neigh = neigh; netevent.new_neigh = neigh;
netevent.daddr = dest; netevent.daddr = &msg->dest;
call_netevent_notifiers(NETEVENT_REDIRECT, &netevent); call_netevent_notifiers(NETEVENT_REDIRECT, &netevent);
if (rt->rt6i_flags & RTF_CACHE) { if (rt->rt6i_flags & RTF_CACHE) {
......
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