Skip to content

Commit 87a1157

Browse files
committed
ipv6: Move xfrm_lookup() call down into icmp6_dst_alloc().
And return error pointers. Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8f03151 commit 87a1157

4 files changed

Lines changed: 12 additions & 29 deletions

File tree

‎include/net/ip6_route.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ extern struct rt6_info *rt6_lookup(struct net *net,
9595

9696
extern struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
9797
struct neighbour *neigh,
98-
const struct in6_addr *addr);
98+
struct flowi6 *fl6);
9999
extern int icmp6_dst_gc(void);
100100

101101
extern void fib6_force_start_gc(struct net *net);

‎net/ipv6/mcast.c‎

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,18 +1410,11 @@ static void mld_sendpack(struct sk_buff *skb)
14101410
csum_partial(skb_transport_header(skb),
14111411
mldlen, 0));
14121412

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-
14201413
icmpv6_flow_init(net->ipv6.igmp_sk, &fl6, ICMPV6_MLD2_REPORT,
14211414
&ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr,
14221415
skb->dev->ifindex);
1416+
dst = icmp6_dst_alloc(skb->dev, NULL, &fl6);
14231417

1424-
dst = xfrm_lookup(net, dst, flowi6_to_flowi(&fl6), NULL, 0);
14251418
err = 0;
14261419
if (IS_ERR(dst)) {
14271420
err = PTR_ERR(dst);
@@ -1785,17 +1778,10 @@ static void igmp6_send(struct in6_addr *addr, struct net_device *dev, int type)
17851778
rcu_read_lock();
17861779
idev = __in6_dev_get(skb->dev);
17871780

1788-
dst = icmp6_dst_alloc(skb->dev, NULL, &ipv6_hdr(skb)->daddr);
1789-
if (!dst) {
1790-
err = -ENOMEM;
1791-
goto err_out;
1792-
}
1793-
17941781
icmpv6_flow_init(sk, &fl6, type,
17951782
&ipv6_hdr(skb)->saddr, &ipv6_hdr(skb)->daddr,
17961783
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);
17991785
if (IS_ERR(dst)) {
18001786
err = PTR_ERR(dst);
18011787
goto err_out;

‎net/ipv6/ndisc.c‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -516,14 +516,7 @@ void ndisc_send_skb(struct sk_buff *skb,
516516
type = icmp6h->icmp6_type;
517517

518518
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);
527520
if (IS_ERR(dst)) {
528521
kfree_skb(skb);
529522
return;

‎net/ipv6/route.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,8 +1068,9 @@ static DEFINE_SPINLOCK(icmp6_dst_lock);
10681068

10691069
struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
10701070
struct neighbour *neigh,
1071-
const struct in6_addr *addr)
1071+
struct flowi6 *fl6)
10721072
{
1073+
struct dst_entry *dst;
10731074
struct rt6_info *rt;
10741075
struct inet6_dev *idev = in6_dev_get(dev);
10751076
struct net *net = dev_net(dev);
@@ -1080,13 +1081,14 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
10801081
rt = ip6_dst_alloc(&net->ipv6.ip6_dst_ops, dev, 0);
10811082
if (unlikely(!rt)) {
10821083
in6_dev_put(idev);
1084+
dst = ERR_PTR(-ENOMEM);
10831085
goto out;
10841086
}
10851087

10861088
if (neigh)
10871089
neigh_hold(neigh);
10881090
else {
1089-
neigh = __neigh_lookup_errno(&nd_tbl, addr, dev);
1091+
neigh = __neigh_lookup_errno(&nd_tbl, &fl6->daddr, dev);
10901092
if (IS_ERR(neigh))
10911093
neigh = NULL;
10921094
}
@@ -1095,7 +1097,7 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
10951097
rt->dst.output = ip6_output;
10961098
dst_set_neighbour(&rt->dst, neigh);
10971099
atomic_set(&rt->dst.__refcnt, 1);
1098-
rt->rt6i_dst.addr = *addr;
1100+
rt->rt6i_dst.addr = fl6->daddr;
10991101
rt->rt6i_dst.plen = 128;
11001102
rt->rt6i_idev = idev;
11011103
dst_metric_set(&rt->dst, RTAX_HOPLIMIT, 255);
@@ -1107,8 +1109,10 @@ struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
11071109

11081110
fib6_force_start_gc(net);
11091111

1112+
dst = xfrm_lookup(net, &rt->dst, flowi6_to_flowi(fl6), NULL, 0);
1113+
11101114
out:
1111-
return &rt->dst;
1115+
return dst;
11121116
}
11131117

11141118
int icmp6_dst_gc(void)

0 commit comments

Comments
 (0)