aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/route.c
diff options
context:
space:
mode:
authorYOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org>2013-01-05 11:34:51 -0500
committerDavid S. Miller <davem@davemloft.net>2013-01-07 00:08:38 -0500
commit71bcdba06db91ceaaffe019b6c958b5faf06012a (patch)
tree1db3be752e5d6a40619f1366bbcbae8008487d19 /net/ipv6/route.c
parent9ca1b22d6d228177e6f929f6818a1cd3d5e30c4a (diff)
ndisc: Use struct rd_msg for redirect message.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/route.c')
-rw-r--r--net/ipv6/route.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index e229a3bc345d..621b68ecf16f 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1705,37 +1705,33 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
1705 struct net *net = dev_net(skb->dev); 1705 struct net *net = dev_net(skb->dev);
1706 struct netevent_redirect netevent; 1706 struct netevent_redirect netevent;
1707 struct rt6_info *rt, *nrt = NULL; 1707 struct rt6_info *rt, *nrt = NULL;
1708 const struct in6_addr *target;
1709 struct ndisc_options ndopts; 1708 struct ndisc_options ndopts;
1710 const struct in6_addr *dest;
1711 struct neighbour *old_neigh; 1709 struct neighbour *old_neigh;
1712 struct inet6_dev *in6_dev; 1710 struct inet6_dev *in6_dev;
1713 struct neighbour *neigh; 1711 struct neighbour *neigh;
1714 struct icmp6hdr *icmph; 1712 struct rd_msg *msg;
1715 int optlen, on_link; 1713 int optlen, on_link;
1716 u8 *lladdr; 1714 u8 *lladdr;
1717 1715
1718 optlen = skb->tail - skb->transport_header; 1716 optlen = skb->tail - skb->transport_header;
1719 optlen -= sizeof(struct icmp6hdr) + 2 * sizeof(struct in6_addr); 1717 optlen -= sizeof(*msg);
1720 1718
1721 if (optlen < 0) { 1719 if (optlen < 0) {
1722 net_dbg_ratelimited("rt6_do_redirect: packet too short\n"); 1720 net_dbg_ratelimited("rt6_do_redirect: packet too short\n");
1723 return; 1721 return;
1724 } 1722 }
1725 1723
1726 icmph = icmp6_hdr(skb); 1724 msg = (struct rd_msg *)icmp6_hdr(skb);
1727 target = (const struct in6_addr *) (icmph + 1);
1728 dest = target + 1;
1729 1725
1730 if (ipv6_addr_is_multicast(dest)) { 1726 if (ipv6_addr_is_multicast(&msg->dest)) {
1731 net_dbg_ratelimited("rt6_do_redirect: destination address is multicast\n"); 1727 net_dbg_ratelimited("rt6_do_redirect: destination address is multicast\n");
1732 return; 1728 return;
1733 } 1729 }
1734 1730
1735 on_link = 0; 1731 on_link = 0;
1736 if (ipv6_addr_equal(dest, target)) { 1732 if (ipv6_addr_equal(&msg->dest, &msg->target)) {
1737 on_link = 1; 1733 on_link = 1;
1738 } else if (ipv6_addr_type(target) != 1734 } else if (ipv6_addr_type(&msg->target) !=
1739 (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) { 1735 (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) {
1740 net_dbg_ratelimited("rt6_do_redirect: target address is not link-local unicast\n"); 1736 net_dbg_ratelimited("rt6_do_redirect: target address is not link-local unicast\n");
1741 return; 1737 return;
@@ -1752,7 +1748,7 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
1752 * first-hop router for the specified ICMP Destination Address. 1748 * first-hop router for the specified ICMP Destination Address.
1753 */ 1749 */
1754 1750
1755 if (!ndisc_parse_options((u8*)(dest + 1), optlen, &ndopts)) { 1751 if (!ndisc_parse_options(msg->opt, optlen, &ndopts)) {
1756 net_dbg_ratelimited("rt6_redirect: invalid ND options\n"); 1752 net_dbg_ratelimited("rt6_redirect: invalid ND options\n");
1757 return; 1753 return;
1758 } 1754 }
@@ -1779,7 +1775,7 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
1779 */ 1775 */
1780 dst_confirm(&rt->dst); 1776 dst_confirm(&rt->dst);
1781 1777
1782 neigh = __neigh_lookup(&nd_tbl, target, skb->dev, 1); 1778 neigh = __neigh_lookup(&nd_tbl, &msg->target, skb->dev, 1);
1783 if (!neigh) 1779 if (!neigh)
1784 return; 1780 return;
1785 1781
@@ -1799,7 +1795,7 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
1799 NEIGH_UPDATE_F_ISROUTER)) 1795 NEIGH_UPDATE_F_ISROUTER))
1800 ); 1796 );
1801 1797
1802 nrt = ip6_rt_copy(rt, dest); 1798 nrt = ip6_rt_copy(rt, &msg->dest);
1803 if (!nrt) 1799 if (!nrt)
1804 goto out; 1800 goto out;
1805 1801
@@ -1817,7 +1813,7 @@ static void rt6_do_redirect(struct dst_entry *dst, struct sock *sk, struct sk_bu
1817 netevent.old_neigh = old_neigh; 1813 netevent.old_neigh = old_neigh;
1818 netevent.new = &nrt->dst; 1814 netevent.new = &nrt->dst;
1819 netevent.new_neigh = neigh; 1815 netevent.new_neigh = neigh;
1820 netevent.daddr = dest; 1816 netevent.daddr = &msg->dest;
1821 call_netevent_notifiers(NETEVENT_REDIRECT, &netevent); 1817 call_netevent_notifiers(NETEVENT_REDIRECT, &netevent);
1822 1818
1823 if (rt->rt6i_flags & RTF_CACHE) { 1819 if (rt->rt6i_flags & RTF_CACHE) {