aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-07-18 02:09:49 -0400
committerDavid S. Miller <davem@davemloft.net>2011-07-18 02:11:35 -0400
commit69cce1d1404968f78b177a0314f5822d5afdbbfb (patch)
tree26223264fd69ea8078d0013fd5a76eb7aeb04c12 /net/ipv6
parent9cbb7ecbcff85077bb12301aaf4c9b5a56c5993d (diff)
net: Abstract dst->neighbour accesses behind helpers.
dst_{get,set}_neighbour() Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/addrconf.c2
-rw-r--r--net/ipv6/ip6_fib.c2
-rw-r--r--net/ipv6/ip6_output.c16
-rw-r--r--net/ipv6/ndisc.c4
-rw-r--r--net/ipv6/route.c39
-rw-r--r--net/ipv6/sit.c4
6 files changed, 36 insertions, 31 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 48cd03df8954..a06c53c14d84 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -656,7 +656,7 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr, int pfxlen,
656 * layer address of our nexhop router 656 * layer address of our nexhop router
657 */ 657 */
658 658
659 if (rt->dst.neighbour == NULL) 659 if (dst_get_neighbour(&rt->dst) == NULL)
660 ifa->flags &= ~IFA_F_OPTIMISTIC; 660 ifa->flags &= ~IFA_F_OPTIMISTIC;
661 661
662 ifa->idev = idev; 662 ifa->idev = idev;
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
index 158df2365d5e..54a4678955bf 100644
--- a/net/ipv6/ip6_fib.c
+++ b/net/ipv6/ip6_fib.c
@@ -1455,7 +1455,7 @@ static int fib6_age(struct rt6_info *rt, void *arg)
1455 RT6_TRACE("aging clone %p\n", rt); 1455 RT6_TRACE("aging clone %p\n", rt);
1456 return -1; 1456 return -1;
1457 } else if ((rt->rt6i_flags & RTF_GATEWAY) && 1457 } else if ((rt->rt6i_flags & RTF_GATEWAY) &&
1458 (!(rt->dst.neighbour->flags & NTF_ROUTER))) { 1458 (!(dst_get_neighbour(&rt->dst)->flags & NTF_ROUTER))) {
1459 RT6_TRACE("purging route %p via non-router but gateway\n", 1459 RT6_TRACE("purging route %p via non-router but gateway\n",
1460 rt); 1460 rt);
1461 return -1; 1461 return -1;
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index eb50bb07ab2e..8db0e4875ad8 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -135,7 +135,7 @@ static int ip6_finish_output2(struct sk_buff *skb)
135 skb->len); 135 skb->len);
136 } 136 }
137 137
138 neigh = dst->neighbour; 138 neigh = dst_get_neighbour(dst);
139 if (neigh) 139 if (neigh)
140 return neigh_output(neigh, skb); 140 return neigh_output(neigh, skb);
141 141
@@ -385,6 +385,7 @@ int ip6_forward(struct sk_buff *skb)
385 struct ipv6hdr *hdr = ipv6_hdr(skb); 385 struct ipv6hdr *hdr = ipv6_hdr(skb);
386 struct inet6_skb_parm *opt = IP6CB(skb); 386 struct inet6_skb_parm *opt = IP6CB(skb);
387 struct net *net = dev_net(dst->dev); 387 struct net *net = dev_net(dst->dev);
388 struct neighbour *n;
388 u32 mtu; 389 u32 mtu;
389 390
390 if (net->ipv6.devconf_all->forwarding == 0) 391 if (net->ipv6.devconf_all->forwarding == 0)
@@ -459,11 +460,10 @@ int ip6_forward(struct sk_buff *skb)
459 send redirects to source routed frames. 460 send redirects to source routed frames.
460 We don't send redirects to frames decapsulated from IPsec. 461 We don't send redirects to frames decapsulated from IPsec.
461 */ 462 */
462 if (skb->dev == dst->dev && dst->neighbour && opt->srcrt == 0 && 463 n = dst_get_neighbour(dst);
463 !skb_sec_path(skb)) { 464 if (skb->dev == dst->dev && n && opt->srcrt == 0 && !skb_sec_path(skb)) {
464 struct in6_addr *target = NULL; 465 struct in6_addr *target = NULL;
465 struct rt6_info *rt; 466 struct rt6_info *rt;
466 struct neighbour *n = dst->neighbour;
467 467
468 /* 468 /*
469 * incoming and outgoing devices are the same 469 * incoming and outgoing devices are the same
@@ -920,8 +920,11 @@ out:
920static int ip6_dst_lookup_tail(struct sock *sk, 920static int ip6_dst_lookup_tail(struct sock *sk,
921 struct dst_entry **dst, struct flowi6 *fl6) 921 struct dst_entry **dst, struct flowi6 *fl6)
922{ 922{
923 int err;
924 struct net *net = sock_net(sk); 923 struct net *net = sock_net(sk);
924#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
925 struct neighbour *n;
926#endif
927 int err;
925 928
926 if (*dst == NULL) 929 if (*dst == NULL)
927 *dst = ip6_route_output(net, sk, fl6); 930 *dst = ip6_route_output(net, sk, fl6);
@@ -947,7 +950,8 @@ static int ip6_dst_lookup_tail(struct sock *sk,
947 * dst entry and replace it instead with the 950 * dst entry and replace it instead with the
948 * dst entry of the nexthop router 951 * dst entry of the nexthop router
949 */ 952 */
950 if ((*dst)->neighbour && !((*dst)->neighbour->nud_state & NUD_VALID)) { 953 n = dst_get_neighbour(*dst);
954 if (n && !(n->nud_state & NUD_VALID)) {
951 struct inet6_ifaddr *ifp; 955 struct inet6_ifaddr *ifp;
952 struct flowi6 fl_gw6; 956 struct flowi6 fl_gw6;
953 int redirect; 957 int redirect;
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index a997d414f525..9da6e02eaaeb 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1238,7 +1238,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1238 rt = rt6_get_dflt_router(&ipv6_hdr(skb)->saddr, skb->dev); 1238 rt = rt6_get_dflt_router(&ipv6_hdr(skb)->saddr, skb->dev);
1239 1239
1240 if (rt) 1240 if (rt)
1241 neigh = rt->dst.neighbour; 1241 neigh = dst_get_neighbour(&rt->dst);
1242 1242
1243 if (rt && lifetime == 0) { 1243 if (rt && lifetime == 0) {
1244 neigh_clone(neigh); 1244 neigh_clone(neigh);
@@ -1259,7 +1259,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1259 return; 1259 return;
1260 } 1260 }
1261 1261
1262 neigh = rt->dst.neighbour; 1262 neigh = dst_get_neighbour(&rt->dst);
1263 if (neigh == NULL) { 1263 if (neigh == NULL) {
1264 ND_PRINTK0(KERN_ERR 1264 ND_PRINTK0(KERN_ERR
1265 "ICMPv6 RA: %s() got default router without neighbour.\n", 1265 "ICMPv6 RA: %s() got default router without neighbour.\n",
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index c1515a3c1305..2998cb5be90b 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -356,7 +356,7 @@ out:
356#ifdef CONFIG_IPV6_ROUTER_PREF 356#ifdef CONFIG_IPV6_ROUTER_PREF
357static void rt6_probe(struct rt6_info *rt) 357static void rt6_probe(struct rt6_info *rt)
358{ 358{
359 struct neighbour *neigh = rt ? rt->dst.neighbour : NULL; 359 struct neighbour *neigh = rt ? dst_get_neighbour(&rt->dst) : NULL;
360 /* 360 /*
361 * Okay, this does not seem to be appropriate 361 * Okay, this does not seem to be appropriate
362 * for now, however, we need to check if it 362 * for now, however, we need to check if it
@@ -404,7 +404,7 @@ static inline int rt6_check_dev(struct rt6_info *rt, int oif)
404 404
405static inline int rt6_check_neigh(struct rt6_info *rt) 405static inline int rt6_check_neigh(struct rt6_info *rt)
406{ 406{
407 struct neighbour *neigh = rt->dst.neighbour; 407 struct neighbour *neigh = dst_get_neighbour(&rt->dst);
408 int m; 408 int m;
409 if (rt->rt6i_flags & RTF_NONEXTHOP || 409 if (rt->rt6i_flags & RTF_NONEXTHOP ||
410 !(rt->rt6i_flags & RTF_GATEWAY)) 410 !(rt->rt6i_flags & RTF_GATEWAY))
@@ -745,7 +745,7 @@ static struct rt6_info *rt6_alloc_cow(struct rt6_info *ort, const struct in6_add
745 dst_free(&rt->dst); 745 dst_free(&rt->dst);
746 return NULL; 746 return NULL;
747 } 747 }
748 rt->dst.neighbour = neigh; 748 dst_set_neighbour(&rt->dst, neigh);
749 749
750 } 750 }
751 751
@@ -760,7 +760,7 @@ static struct rt6_info *rt6_alloc_clone(struct rt6_info *ort, const struct in6_a
760 rt->rt6i_dst.plen = 128; 760 rt->rt6i_dst.plen = 128;
761 rt->rt6i_flags |= RTF_CACHE; 761 rt->rt6i_flags |= RTF_CACHE;
762 rt->dst.flags |= DST_HOST; 762 rt->dst.flags |= DST_HOST;
763 rt->dst.neighbour = neigh_clone(ort->dst.neighbour); 763 dst_set_neighbour(&rt->dst, neigh_clone(dst_get_neighbour(&ort->dst)));
764 } 764 }
765 return rt; 765 return rt;
766} 766}
@@ -794,7 +794,7 @@ restart:
794 dst_hold(&rt->dst); 794 dst_hold(&rt->dst);
795 read_unlock_bh(&table->tb6_lock); 795 read_unlock_bh(&table->tb6_lock);
796 796
797 if (!rt->dst.neighbour && !(rt->rt6i_flags & RTF_NONEXTHOP)) 797 if (!dst_get_neighbour(&rt->dst) && !(rt->rt6i_flags & RTF_NONEXTHOP))
798 nrt = rt6_alloc_cow(rt, &fl6->daddr, &fl6->saddr); 798 nrt = rt6_alloc_cow(rt, &fl6->daddr, &fl6->saddr);
799 else if (!(rt->dst.flags & DST_HOST)) 799 else if (!(rt->dst.flags & DST_HOST))
800 nrt = rt6_alloc_clone(rt, &fl6->daddr); 800 nrt = rt6_alloc_clone(rt, &fl6->daddr);
@@ -1058,7 +1058,7 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
1058 } 1058 }
1059 1059
1060 rt->rt6i_idev = idev; 1060 rt->rt6i_idev = idev;
1061 rt->dst.neighbour = neigh; 1061 dst_set_neighbour(&rt->dst, neigh);
1062 atomic_set(&rt->dst.__refcnt, 1); 1062 atomic_set(&rt->dst.__refcnt, 1);
1063 dst_metric_set(&rt->dst, RTAX_HOPLIMIT, 255); 1063 dst_metric_set(&rt->dst, RTAX_HOPLIMIT, 255);
1064 rt->dst.output = ip6_output; 1064 rt->dst.output = ip6_output;
@@ -1338,12 +1338,12 @@ int ip6_route_add(struct fib6_config *cfg)
1338 rt->rt6i_prefsrc.plen = 0; 1338 rt->rt6i_prefsrc.plen = 0;
1339 1339
1340 if (cfg->fc_flags & (RTF_GATEWAY | RTF_NONEXTHOP)) { 1340 if (cfg->fc_flags & (RTF_GATEWAY | RTF_NONEXTHOP)) {
1341 rt->dst.neighbour = __neigh_lookup_errno(&nd_tbl, &rt->rt6i_gateway, dev); 1341 struct neighbour *n = __neigh_lookup_errno(&nd_tbl, &rt->rt6i_gateway, dev);
1342 if (IS_ERR(rt->dst.neighbour)) { 1342 if (IS_ERR(n)) {
1343 err = PTR_ERR(rt->dst.neighbour); 1343 err = PTR_ERR(n);
1344 rt->dst.neighbour = NULL;
1345 goto out; 1344 goto out;
1346 } 1345 }
1346 dst_set_neighbour(&rt->dst, n);
1347 } 1347 }
1348 1348
1349 rt->rt6i_flags = cfg->fc_flags; 1349 rt->rt6i_flags = cfg->fc_flags;
@@ -1574,7 +1574,7 @@ void rt6_redirect(const struct in6_addr *dest, const struct in6_addr *src,
1574 dst_confirm(&rt->dst); 1574 dst_confirm(&rt->dst);
1575 1575
1576 /* Duplicate redirect: silently ignore. */ 1576 /* Duplicate redirect: silently ignore. */
1577 if (neigh == rt->dst.neighbour) 1577 if (neigh == dst_get_neighbour(&rt->dst))
1578 goto out; 1578 goto out;
1579 1579
1580 nrt = ip6_rt_copy(rt); 1580 nrt = ip6_rt_copy(rt);
@@ -1590,7 +1590,7 @@ void rt6_redirect(const struct in6_addr *dest, const struct in6_addr *src,
1590 nrt->dst.flags |= DST_HOST; 1590 nrt->dst.flags |= DST_HOST;
1591 1591
1592 ipv6_addr_copy(&nrt->rt6i_gateway, (struct in6_addr*)neigh->primary_key); 1592 ipv6_addr_copy(&nrt->rt6i_gateway, (struct in6_addr*)neigh->primary_key);
1593 nrt->dst.neighbour = neigh_clone(neigh); 1593 dst_set_neighbour(&nrt->dst, neigh_clone(neigh));
1594 1594
1595 if (ip6_ins_rt(nrt)) 1595 if (ip6_ins_rt(nrt))
1596 goto out; 1596 goto out;
@@ -1670,7 +1670,7 @@ again:
1670 1. It is connected route. Action: COW 1670 1. It is connected route. Action: COW
1671 2. It is gatewayed route or NONEXTHOP route. Action: clone it. 1671 2. It is gatewayed route or NONEXTHOP route. Action: clone it.
1672 */ 1672 */
1673 if (!rt->dst.neighbour && !(rt->rt6i_flags & RTF_NONEXTHOP)) 1673 if (!dst_get_neighbour(&rt->dst) && !(rt->rt6i_flags & RTF_NONEXTHOP))
1674 nrt = rt6_alloc_cow(rt, daddr, saddr); 1674 nrt = rt6_alloc_cow(rt, daddr, saddr);
1675 else 1675 else
1676 nrt = rt6_alloc_clone(rt, daddr); 1676 nrt = rt6_alloc_clone(rt, daddr);
@@ -2035,7 +2035,7 @@ struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
2035 2035
2036 return ERR_CAST(neigh); 2036 return ERR_CAST(neigh);
2037 } 2037 }
2038 rt->dst.neighbour = neigh; 2038 dst_set_neighbour(&rt->dst, neigh);
2039 2039
2040 ipv6_addr_copy(&rt->rt6i_dst.addr, addr); 2040 ipv6_addr_copy(&rt->rt6i_dst.addr, addr);
2041 rt->rt6i_dst.plen = 128; 2041 rt->rt6i_dst.plen = 128;
@@ -2400,8 +2400,8 @@ static int rt6_fill_node(struct net *net,
2400 if (rtnetlink_put_metrics(skb, dst_metrics_ptr(&rt->dst)) < 0) 2400 if (rtnetlink_put_metrics(skb, dst_metrics_ptr(&rt->dst)) < 0)
2401 goto nla_put_failure; 2401 goto nla_put_failure;
2402 2402
2403 if (rt->dst.neighbour) 2403 if (dst_get_neighbour(&rt->dst))
2404 NLA_PUT(skb, RTA_GATEWAY, 16, &rt->dst.neighbour->primary_key); 2404 NLA_PUT(skb, RTA_GATEWAY, 16, &dst_get_neighbour(&rt->dst)->primary_key);
2405 2405
2406 if (rt->dst.dev) 2406 if (rt->dst.dev)
2407 NLA_PUT_U32(skb, RTA_OIF, rt->rt6i_dev->ifindex); 2407 NLA_PUT_U32(skb, RTA_OIF, rt->rt6i_dev->ifindex);
@@ -2585,6 +2585,7 @@ struct rt6_proc_arg
2585static int rt6_info_route(struct rt6_info *rt, void *p_arg) 2585static int rt6_info_route(struct rt6_info *rt, void *p_arg)
2586{ 2586{
2587 struct seq_file *m = p_arg; 2587 struct seq_file *m = p_arg;
2588 struct neighbour *n;
2588 2589
2589 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen); 2590 seq_printf(m, "%pi6 %02x ", &rt->rt6i_dst.addr, rt->rt6i_dst.plen);
2590 2591
@@ -2593,9 +2594,9 @@ static int rt6_info_route(struct rt6_info *rt, void *p_arg)
2593#else 2594#else
2594 seq_puts(m, "00000000000000000000000000000000 00 "); 2595 seq_puts(m, "00000000000000000000000000000000 00 ");
2595#endif 2596#endif
2596 2597 n = dst_get_neighbour(&rt->dst);
2597 if (rt->dst.neighbour) { 2598 if (n) {
2598 seq_printf(m, "%pi6", rt->dst.neighbour->primary_key); 2599 seq_printf(m, "%pi6", n->primary_key);
2599 } else { 2600 } else {
2600 seq_puts(m, "00000000000000000000000000000000"); 2601 seq_puts(m, "00000000000000000000000000000000");
2601 } 2602 }
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 1cca5761aea9..07bf1085458f 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -677,7 +677,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
677 struct neighbour *neigh = NULL; 677 struct neighbour *neigh = NULL;
678 678
679 if (skb_dst(skb)) 679 if (skb_dst(skb))
680 neigh = skb_dst(skb)->neighbour; 680 neigh = dst_get_neighbour(skb_dst(skb));
681 681
682 if (neigh == NULL) { 682 if (neigh == NULL) {
683 if (net_ratelimit()) 683 if (net_ratelimit())
@@ -702,7 +702,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
702 struct neighbour *neigh = NULL; 702 struct neighbour *neigh = NULL;
703 703
704 if (skb_dst(skb)) 704 if (skb_dst(skb))
705 neigh = skb_dst(skb)->neighbour; 705 neigh = dst_get_neighbour(skb_dst(skb));
706 706
707 if (neigh == NULL) { 707 if (neigh == NULL) {
708 if (net_ratelimit()) 708 if (net_ratelimit())