Commit 87a115783eca7a424eef599d6f10a499f85f59c8

Authored by David S. Miller
1 parent 8f0315190d

ipv6: Move xfrm_lookup() call down into icmp6_dst_alloc().

And return error pointers.

Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 4 changed files with 12 additions and 29 deletions Side-by-side Diff

include/net/ip6_route.h
... ... @@ -95,7 +95,7 @@
95 95  
96 96 extern struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
97 97 struct neighbour *neigh,
98   - const struct in6_addr *addr);
  98 + struct flowi6 *fl6);
99 99 extern int icmp6_dst_gc(void);
100 100  
101 101 extern void fib6_force_start_gc(struct net *net);
... ... @@ -1410,18 +1410,11 @@
1410 1410 csum_partial(skb_transport_header(skb),
1411 1411 mldlen, 0));
1412 1412  
1413   - dst = icmp6_dst_alloc(skb->dev, NULL, &ipv6_hdr(skb)->daddr);
1414   -
1415   - if (!dst) {
1416   - err = -ENOMEM;
1417   - goto err_out;
1418   - }
1419   -
1420 1413 icmpv6_flow_init(net->ipv6.igmp_sk, &fl6, ICMPV6_MLD2_REPORT,
1421 1414 &ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr,
1422 1415 skb->dev->ifindex);
  1416 + dst = icmp6_dst_alloc(skb->dev, NULL, &fl6);
1423 1417  
1424   - dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
1425 1418 err = 0;
1426 1419 if (IS_ERR(dst)) {
1427 1420 err = PTR_ERR(dst);
1428 1421  
... ... @@ -1785,17 +1778,10 @@
1785 1778 rcu_read_lock();
1786 1779 idev = __in6_dev_get(skb->dev);
1787 1780  
1788   - dst = icmp6_dst_alloc(skb->dev, NULL, &ipv6_hdr(skb)->daddr);
1789   - if (!dst) {
1790   - err = -ENOMEM;
1791   - goto err_out;
1792   - }
1793   -
1794 1781 icmpv6_flow_init(sk, &fl6, type,
1795 1782 &ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr,
1796 1783 skb->dev->ifindex);
1797   -
1798   - dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
  1784 + dst = icmp6_dst_alloc(skb->dev, NULL, &fl6);
1799 1785 if (IS_ERR(dst)) {
1800 1786 err = PTR_ERR(dst);
1801 1787 goto err_out;
... ... @@ -516,14 +516,7 @@
516 516 type = icmp6h->icmp6_type;
517 517  
518 518 icmpv6_flow_init(sk, &fl6, type, saddr, daddr, dev->ifindex);
519   -
520   - dst = icmp6_dst_alloc(dev, neigh, daddr);
521   - if (!dst) {
522   - kfree_skb(skb);
523   - return;
524   - }
525   -
526   - dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
  519 + dst = icmp6_dst_alloc(dev, neigh, &fl6);
527 520 if (IS_ERR(dst)) {
528 521 kfree_skb(skb);
529 522 return;
... ... @@ -1068,8 +1068,9 @@
1068 1068  
1069 1069 struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
1070 1070 struct neighbour *neigh,
1071   - const struct in6_addr *addr)
  1071 + struct flowi6 *fl6)
1072 1072 {
  1073 + struct dst_entry *dst;
1073 1074 struct rt6_info *rt;
1074 1075 struct inet6_dev *idev = in6_dev_get(dev);
1075 1076 struct net *net = dev_net(dev);
1076 1077  
... ... @@ -1080,13 +1081,14 @@
1080 1081 rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, dev, 0);
1081 1082 if (unlikely(!rt)) {
1082 1083 in6_dev_put(idev);
  1084 + dst = ERR_PTR(-ENOMEM);
1083 1085 goto out;
1084 1086 }
1085 1087  
1086 1088 if (neigh)
1087 1089 neigh_hold(neigh);
1088 1090 else {
1089   - neigh = __neigh_lookup_errno(&nd_tbl, addr, dev);
  1091 + neigh = __neigh_lookup_errno(&nd_tbl, &fl6->daddr, dev);
1090 1092 if (IS_ERR(neigh))
1091 1093 neigh = NULL;
1092 1094 }
... ... @@ -1095,7 +1097,7 @@
1095 1097 rt->dst.output = ip6_output;
1096 1098 dst_set_neighbour(&rt->dst, neigh);
1097 1099 atomic_set(&rt->dst.__refcnt, 1);
1098   - rt->rt6i_dst.addr = *addr;
  1100 + rt->rt6i_dst.addr = fl6->daddr;
1099 1101 rt->rt6i_dst.plen = 128;
1100 1102 rt->rt6i_idev = idev;
1101 1103 dst_metric_set(&rt->dst, RTAX_HOPLIMIT, 255);
1102 1104  
... ... @@ -1107,8 +1109,10 @@
1107 1109  
1108 1110 fib6_force_start_gc(net);
1109 1111  
  1112 + dst = xfrm_lookup(net, &rt->dst, flowi6_to_flowi(fl6), NULL, 0);
  1113 +
1110 1114 out:
1111   - return &rt->dst;
  1115 + return dst;
1112 1116 }
1113 1117  
1114 1118 int icmp6_dst_gc(void)