aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
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
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')
-rw-r--r--net/ipv6/ndisc.c25
-rw-r--r--net/ipv6/route.c24
2 files changed, 21 insertions, 28 deletions
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 4c4ccf79d2c5..5733cd27f4a3 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1355,12 +1355,11 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
1355 struct net_device *dev = skb->dev; 1355 struct net_device *dev = skb->dev;
1356 struct net *net = dev_net(dev); 1356 struct net *net = dev_net(dev);
1357 struct sock *sk = net->ipv6.ndisc_sk; 1357 struct sock *sk = net->ipv6.ndisc_sk;
1358 int len = sizeof(struct icmp6hdr) + 2 * sizeof(struct in6_addr); 1358 int len = sizeof(struct rd_msg);
1359 struct inet_peer *peer; 1359 struct inet_peer *peer;
1360 struct sk_buff *buff; 1360 struct sk_buff *buff;
1361 struct icmp6hdr *icmph; 1361 struct rd_msg *msg;
1362 struct in6_addr saddr_buf; 1362 struct in6_addr saddr_buf;
1363 struct in6_addr *addrp;
1364 struct rt6_info *rt; 1363 struct rt6_info *rt;
1365 struct dst_entry *dst; 1364 struct dst_entry *dst;
1366 struct inet6_dev *idev; 1365 struct inet6_dev *idev;
@@ -1455,21 +1454,19 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
1455 1454
1456 skb_set_transport_header(buff, skb_tail_pointer(buff) - buff->data); 1455 skb_set_transport_header(buff, skb_tail_pointer(buff) - buff->data);
1457 skb_put(buff, len); 1456 skb_put(buff, len);
1458 icmph = icmp6_hdr(buff); 1457 msg = (struct rd_msg *)icmp6_hdr(buff);
1459 1458
1460 memset(icmph, 0, sizeof(struct icmp6hdr)); 1459 memset(&msg->icmph, 0, sizeof(struct icmp6hdr));
1461 icmph->icmp6_type = NDISC_REDIRECT; 1460 msg->icmph.icmp6_type = NDISC_REDIRECT;
1462 1461
1463 /* 1462 /*
1464 * copy target and destination addresses 1463 * copy target and destination addresses
1465 */ 1464 */
1466 1465
1467 addrp = (struct in6_addr *)(icmph + 1); 1466 msg->target = *target;
1468 *addrp = *target; 1467 msg->dest = ipv6_hdr(skb)->daddr;
1469 addrp++;
1470 *addrp = ipv6_hdr(skb)->daddr;
1471 1468
1472 opt = (u8*) (addrp + 1); 1469 opt = msg->opt;
1473 1470
1474 /* 1471 /*
1475 * include target_address option 1472 * include target_address option
@@ -1490,9 +1487,9 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
1490 1487
1491 memcpy(opt, ipv6_hdr(skb), rd_len - 8); 1488 memcpy(opt, ipv6_hdr(skb), rd_len - 8);
1492 1489
1493 icmph->icmp6_cksum = csum_ipv6_magic(&saddr_buf, &ipv6_hdr(skb)->saddr, 1490 msg->icmph.icmp6_cksum = csum_ipv6_magic(&saddr_buf, &ipv6_hdr(skb)->saddr,
1494 len, IPPROTO_ICMPV6, 1491 len, IPPROTO_ICMPV6,
1495 csum_partial(icmph, len, 0)); 1492 csum_partial(msg, len, 0));
1496 1493
1497 skb_dst_set(buff, dst); 1494 skb_dst_set(buff, dst);
1498 rcu_read_lock(); 1495 rcu_read_lock();
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) {