aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/route.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6/route.c')
-rw-r--r--net/ipv6/route.c55
1 files changed, 32 insertions, 23 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 3399dd326287..0e381bb94683 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -731,14 +731,14 @@ static struct rt6_info *rt6_alloc_cow(const struct rt6_info *ort,
731 if (rt->rt6i_dst.plen != 128 && 731 if (rt->rt6i_dst.plen != 128 &&
732 ipv6_addr_equal(&ort->rt6i_dst.addr, daddr)) 732 ipv6_addr_equal(&ort->rt6i_dst.addr, daddr))
733 rt->rt6i_flags |= RTF_ANYCAST; 733 rt->rt6i_flags |= RTF_ANYCAST;
734 ipv6_addr_copy(&rt->rt6i_gateway, daddr); 734 rt->rt6i_gateway = *daddr;
735 } 735 }
736 736
737 rt->rt6i_flags |= RTF_CACHE; 737 rt->rt6i_flags |= RTF_CACHE;
738 738
739#ifdef CONFIG_IPV6_SUBTREES 739#ifdef CONFIG_IPV6_SUBTREES
740 if (rt->rt6i_src.plen && saddr) { 740 if (rt->rt6i_src.plen && saddr) {
741 ipv6_addr_copy(&rt->rt6i_src.addr, saddr); 741 rt->rt6i_src.addr = *saddr;
742 rt->rt6i_src.plen = 128; 742 rt->rt6i_src.plen = 128;
743 } 743 }
744#endif 744#endif
@@ -934,7 +934,7 @@ struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_ori
934 in6_dev_hold(rt->rt6i_idev); 934 in6_dev_hold(rt->rt6i_idev);
935 rt->rt6i_expires = 0; 935 rt->rt6i_expires = 0;
936 936
937 ipv6_addr_copy(&rt->rt6i_gateway, &ort->rt6i_gateway); 937 rt->rt6i_gateway = ort->rt6i_gateway;
938 rt->rt6i_flags = ort->rt6i_flags & ~RTF_EXPIRES; 938 rt->rt6i_flags = ort->rt6i_flags & ~RTF_EXPIRES;
939 rt->rt6i_metric = 0; 939 rt->rt6i_metric = 0;
940 940
@@ -1094,7 +1094,7 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
1094 rt->dst.output = ip6_output; 1094 rt->dst.output = ip6_output;
1095 dst_set_neighbour(&rt->dst, neigh); 1095 dst_set_neighbour(&rt->dst, neigh);
1096 atomic_set(&rt->dst.__refcnt, 1); 1096 atomic_set(&rt->dst.__refcnt, 1);
1097 ipv6_addr_copy(&rt->rt6i_dst.addr, addr); 1097 rt->rt6i_dst.addr = *addr;
1098 rt->rt6i_dst.plen = 128; 1098 rt->rt6i_dst.plen = 128;
1099 rt->rt6i_idev = idev; 1099 rt->rt6i_idev = idev;
1100 dst_metric_set(&rt->dst, RTAX_HOPLIMIT, 255); 1100 dst_metric_set(&rt->dst, RTAX_HOPLIMIT, 255);
@@ -1237,9 +1237,18 @@ int ip6_route_add(struct fib6_config *cfg)
1237 if (cfg->fc_metric == 0) 1237 if (cfg->fc_metric == 0)
1238 cfg->fc_metric = IP6_RT_PRIO_USER; 1238 cfg->fc_metric = IP6_RT_PRIO_USER;
1239 1239
1240 table = fib6_new_table(net, cfg->fc_table); 1240 err = -ENOBUFS;
1241 if (NULL != cfg->fc_nlinfo.nlh &&
1242 !(cfg->fc_nlinfo.nlh->nlmsg_flags&NLM_F_CREATE)) {
1243 table = fib6_get_table(net, cfg->fc_table);
1244 if (table == NULL) {
1245 printk(KERN_WARNING "IPv6: NLM_F_CREATE should be specified when creating new route\n");
1246 table = fib6_new_table(net, cfg->fc_table);
1247 }
1248 } else {
1249 table = fib6_new_table(net, cfg->fc_table);
1250 }
1241 if (table == NULL) { 1251 if (table == NULL) {
1242 err = -ENOBUFS;
1243 goto out; 1252 goto out;
1244 } 1253 }
1245 1254
@@ -1322,7 +1331,7 @@ int ip6_route_add(struct fib6_config *cfg)
1322 int gwa_type; 1331 int gwa_type;
1323 1332
1324 gw_addr = &cfg->fc_gateway; 1333 gw_addr = &cfg->fc_gateway;
1325 ipv6_addr_copy(&rt->rt6i_gateway, gw_addr); 1334 rt->rt6i_gateway = *gw_addr;
1326 gwa_type = ipv6_addr_type(gw_addr); 1335 gwa_type = ipv6_addr_type(gw_addr);
1327 1336
1328 if (gwa_type != (IPV6_ADDR_LINKLOCAL|IPV6_ADDR_UNICAST)) { 1337 if (gwa_type != (IPV6_ADDR_LINKLOCAL|IPV6_ADDR_UNICAST)) {
@@ -1376,7 +1385,7 @@ int ip6_route_add(struct fib6_config *cfg)
1376 err = -EINVAL; 1385 err = -EINVAL;
1377 goto out; 1386 goto out;
1378 } 1387 }
1379 ipv6_addr_copy(&rt->rt6i_prefsrc.addr, &cfg->fc_prefsrc); 1388 rt->rt6i_prefsrc.addr = cfg->fc_prefsrc;
1380 rt->rt6i_prefsrc.plen = 128; 1389 rt->rt6i_prefsrc.plen = 128;
1381 } else 1390 } else
1382 rt->rt6i_prefsrc.plen = 0; 1391 rt->rt6i_prefsrc.plen = 0;
@@ -1573,7 +1582,7 @@ static struct rt6_info *ip6_route_redirect(const struct in6_addr *dest,
1573 }, 1582 },
1574 }; 1583 };
1575 1584
1576 ipv6_addr_copy(&rdfl.gateway, gateway); 1585 rdfl.gateway = *gateway;
1577 1586
1578 if (rt6_need_strict(dest)) 1587 if (rt6_need_strict(dest))
1579 flags |= RT6_LOOKUP_F_IFACE; 1588 flags |= RT6_LOOKUP_F_IFACE;
@@ -1629,7 +1638,7 @@ void rt6_redirect(const struct in6_addr *dest, const struct in6_addr *src,
1629 if (on_link) 1638 if (on_link)
1630 nrt->rt6i_flags &= ~RTF_GATEWAY; 1639 nrt->rt6i_flags &= ~RTF_GATEWAY;
1631 1640
1632 ipv6_addr_copy(&nrt->rt6i_gateway, (struct in6_addr*)neigh->primary_key); 1641 nrt->rt6i_gateway = *(struct in6_addr *)neigh->primary_key;
1633 dst_set_neighbour(&nrt->dst, neigh_clone(neigh)); 1642 dst_set_neighbour(&nrt->dst, neigh_clone(neigh));
1634 1643
1635 if (ip6_ins_rt(nrt)) 1644 if (ip6_ins_rt(nrt))
@@ -1775,7 +1784,7 @@ static struct rt6_info *ip6_rt_copy(const struct rt6_info *ort,
1775 rt->dst.output = ort->dst.output; 1784 rt->dst.output = ort->dst.output;
1776 rt->dst.flags |= DST_HOST; 1785 rt->dst.flags |= DST_HOST;
1777 1786
1778 ipv6_addr_copy(&rt->rt6i_dst.addr, dest); 1787 rt->rt6i_dst.addr = *dest;
1779 rt->rt6i_dst.plen = 128; 1788 rt->rt6i_dst.plen = 128;
1780 dst_copy_metrics(&rt->dst, &ort->dst); 1789 dst_copy_metrics(&rt->dst, &ort->dst);
1781 rt->dst.error = ort->dst.error; 1790 rt->dst.error = ort->dst.error;
@@ -1785,7 +1794,7 @@ static struct rt6_info *ip6_rt_copy(const struct rt6_info *ort,
1785 rt->dst.lastuse = jiffies; 1794 rt->dst.lastuse = jiffies;
1786 rt->rt6i_expires = 0; 1795 rt->rt6i_expires = 0;
1787 1796
1788 ipv6_addr_copy(&rt->rt6i_gateway, &ort->rt6i_gateway); 1797 rt->rt6i_gateway = ort->rt6i_gateway;
1789 rt->rt6i_flags = ort->rt6i_flags & ~RTF_EXPIRES; 1798 rt->rt6i_flags = ort->rt6i_flags & ~RTF_EXPIRES;
1790 rt->rt6i_metric = 0; 1799 rt->rt6i_metric = 0;
1791 1800
@@ -1848,8 +1857,8 @@ static struct rt6_info *rt6_add_route_info(struct net *net,
1848 .fc_nlinfo.nl_net = net, 1857 .fc_nlinfo.nl_net = net,
1849 }; 1858 };
1850 1859
1851 ipv6_addr_copy(&cfg.fc_dst, prefix); 1860 cfg.fc_dst = *prefix;
1852 ipv6_addr_copy(&cfg.fc_gateway, gwaddr); 1861 cfg.fc_gateway = *gwaddr;
1853 1862
1854 /* We should treat it as a default route if prefix length is 0. */ 1863 /* We should treat it as a default route if prefix length is 0. */
1855 if (!prefixlen) 1864 if (!prefixlen)
@@ -1898,7 +1907,7 @@ struct rt6_info *rt6_add_dflt_router(const struct in6_addr *gwaddr,
1898 .fc_nlinfo.nl_net = dev_net(dev), 1907 .fc_nlinfo.nl_net = dev_net(dev),
1899 }; 1908 };
1900 1909
1901 ipv6_addr_copy(&cfg.fc_gateway, gwaddr); 1910 cfg.fc_gateway = *gwaddr;
1902 1911
1903 ip6_route_add(&cfg); 1912 ip6_route_add(&cfg);
1904 1913
@@ -1944,9 +1953,9 @@ static void rtmsg_to_fib6_config(struct net *net,
1944 1953
1945 cfg->fc_nlinfo.nl_net = net; 1954 cfg->fc_nlinfo.nl_net = net;
1946 1955
1947 ipv6_addr_copy(&cfg->fc_dst, &rtmsg->rtmsg_dst); 1956 cfg->fc_dst = rtmsg->rtmsg_dst;
1948 ipv6_addr_copy(&cfg->fc_src, &rtmsg->rtmsg_src); 1957 cfg->fc_src = rtmsg->rtmsg_src;
1949 ipv6_addr_copy(&cfg->fc_gateway, &rtmsg->rtmsg_gateway); 1958 cfg->fc_gateway = rtmsg->rtmsg_gateway;
1950} 1959}
1951 1960
1952int ipv6_route_ioctl(struct net *net, unsigned int cmd, void __user *arg) 1961int ipv6_route_ioctl(struct net *net, unsigned int cmd, void __user *arg)
@@ -2080,7 +2089,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
2080 } 2089 }
2081 dst_set_neighbour(&rt->dst, neigh); 2090 dst_set_neighbour(&rt->dst, neigh);
2082 2091
2083 ipv6_addr_copy(&rt->rt6i_dst.addr, addr); 2092 rt->rt6i_dst.addr = *addr;
2084 rt->rt6i_dst.plen = 128; 2093 rt->rt6i_dst.plen = 128;
2085 rt->rt6i_table = fib6_get_table(net, RT6_TABLE_LOCAL); 2094 rt->rt6i_table = fib6_get_table(net, RT6_TABLE_LOCAL);
2086 2095
@@ -2098,7 +2107,7 @@ int ip6_route_get_saddr(struct net *net,
2098 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt); 2107 struct inet6_dev *idev = ip6_dst_idev((struct dst_entry*)rt);
2099 int err = 0; 2108 int err = 0;
2100 if (rt->rt6i_prefsrc.plen) 2109 if (rt->rt6i_prefsrc.plen)
2101 ipv6_addr_copy(saddr, &rt->rt6i_prefsrc.addr); 2110 *saddr = rt->rt6i_prefsrc.addr;
2102 else 2111 else
2103 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL, 2112 err = ipv6_dev_get_saddr(net, idev ? idev->dev : NULL,
2104 daddr, prefs, saddr); 2113 daddr, prefs, saddr);
@@ -2437,7 +2446,7 @@ static int rt6_fill_node(struct net *net,
2437 2446
2438 if (rt->rt6i_prefsrc.plen) { 2447 if (rt->rt6i_prefsrc.plen) {
2439 struct in6_addr saddr_buf; 2448 struct in6_addr saddr_buf;
2440 ipv6_addr_copy(&saddr_buf, &rt->rt6i_prefsrc.addr); 2449 saddr_buf = rt->rt6i_prefsrc.addr;
2441 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf); 2450 NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
2442 } 2451 }
2443 2452
@@ -2511,14 +2520,14 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
2511 if (nla_len(tb[RTA_SRC]) < sizeof(struct in6_addr)) 2520 if (nla_len(tb[RTA_SRC]) < sizeof(struct in6_addr))
2512 goto errout; 2521 goto errout;
2513 2522
2514 ipv6_addr_copy(&fl6.saddr, nla_data(tb[RTA_SRC])); 2523 fl6.saddr = *(struct in6_addr *)nla_data(tb[RTA_SRC]);
2515 } 2524 }
2516 2525
2517 if (tb[RTA_DST]) { 2526 if (tb[RTA_DST]) {
2518 if (nla_len(tb[RTA_DST]) < sizeof(struct in6_addr)) 2527 if (nla_len(tb[RTA_DST]) < sizeof(struct in6_addr))
2519 goto errout; 2528 goto errout;
2520 2529
2521 ipv6_addr_copy(&fl6.daddr, nla_data(tb[RTA_DST])); 2530 fl6.daddr = *(struct in6_addr *)nla_data(tb[RTA_DST]);
2522 } 2531 }
2523 2532
2524 if (tb[RTA_IIF]) 2533 if (tb[RTA_IIF])