static int xfrm6_get_saddr(struct net *net, xfrm_address_t *saddr, xfrm_address_t *daddr) { struct dst_entry *dst; struct net_device *dev; dst = xfrm6_dst_lookup(net, 0, NULL, daddr); if (IS_ERR(dst)) return -EHOSTUNREACH; dev = ip6_dst_idev(dst)->dev; ipv6_dev_get_saddr(dev_net(dev), dev, &daddr->in6, 0, &saddr->in6); dst_release(dst); return 0; }
static int xfrm6_get_saddr(xfrm_address_t *saddr, xfrm_address_t *daddr) { struct rt6_info *rt; struct flowi fl_tunnel = { .nl_u = { .ip6_u = { .daddr = *(struct in6_addr *)&daddr->a6, }, }, }; if (!xfrm6_dst_lookup((struct xfrm_dst **)&rt, &fl_tunnel)) { ipv6_get_saddr(&rt->u.dst, (struct in6_addr *)&daddr->a6, (struct in6_addr *)&saddr->a6); dst_release(&rt->u.dst); return 0; } return -EHOSTUNREACH; }