Commit fbda33b2 authored by Alexey Dobriyan's avatar Alexey Dobriyan Committed by David S. Miller

netns xfrm: ->get_saddr in netns

Signed-off-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c5b3cf46
...@@ -269,7 +269,7 @@ struct xfrm_policy_afinfo { ...@@ -269,7 +269,7 @@ struct xfrm_policy_afinfo {
struct dst_entry *(*dst_lookup)(struct net *net, int tos, struct dst_entry *(*dst_lookup)(struct net *net, int tos,
xfrm_address_t *saddr, xfrm_address_t *saddr,
xfrm_address_t *daddr); xfrm_address_t *daddr);
int (*get_saddr)(xfrm_address_t *saddr, xfrm_address_t *daddr); int (*get_saddr)(struct net *net, xfrm_address_t *saddr, xfrm_address_t *daddr);
struct dst_entry *(*find_bundle)(struct flowi *fl, struct xfrm_policy *policy); struct dst_entry *(*find_bundle)(struct flowi *fl, struct xfrm_policy *policy);
void (*decode_session)(struct sk_buff *skb, void (*decode_session)(struct sk_buff *skb,
struct flowi *fl, struct flowi *fl,
......
...@@ -44,12 +44,13 @@ static struct dst_entry *xfrm4_dst_lookup(struct net *net, int tos, ...@@ -44,12 +44,13 @@ static struct dst_entry *xfrm4_dst_lookup(struct net *net, int tos,
return dst; return dst;
} }
static int xfrm4_get_saddr(xfrm_address_t *saddr, xfrm_address_t *daddr) static int xfrm4_get_saddr(struct net *net,
xfrm_address_t *saddr, xfrm_address_t *daddr)
{ {
struct dst_entry *dst; struct dst_entry *dst;
struct rtable *rt; struct rtable *rt;
dst = xfrm4_dst_lookup(&init_net, 0, NULL, daddr); dst = xfrm4_dst_lookup(net, 0, NULL, daddr);
if (IS_ERR(dst)) if (IS_ERR(dst))
return -EHOSTUNREACH; return -EHOSTUNREACH;
......
...@@ -50,12 +50,13 @@ static struct dst_entry *xfrm6_dst_lookup(struct net *net, int tos, ...@@ -50,12 +50,13 @@ static struct dst_entry *xfrm6_dst_lookup(struct net *net, int tos,
return dst; return dst;
} }
static int xfrm6_get_saddr(xfrm_address_t *saddr, xfrm_address_t *daddr) static int xfrm6_get_saddr(struct net *net,
xfrm_address_t *saddr, xfrm_address_t *daddr)
{ {
struct dst_entry *dst; struct dst_entry *dst;
struct net_device *dev; struct net_device *dev;
dst = xfrm6_dst_lookup(&init_net, 0, NULL, daddr); dst = xfrm6_dst_lookup(net, 0, NULL, daddr);
if (IS_ERR(dst)) if (IS_ERR(dst))
return -EHOSTUNREACH; return -EHOSTUNREACH;
......
...@@ -1187,7 +1187,7 @@ int __xfrm_sk_clone_policy(struct sock *sk) ...@@ -1187,7 +1187,7 @@ int __xfrm_sk_clone_policy(struct sock *sk)
} }
static int static int
xfrm_get_saddr(xfrm_address_t *local, xfrm_address_t *remote, xfrm_get_saddr(struct net *net, xfrm_address_t *local, xfrm_address_t *remote,
unsigned short family) unsigned short family)
{ {
int err; int err;
...@@ -1195,7 +1195,7 @@ xfrm_get_saddr(xfrm_address_t *local, xfrm_address_t *remote, ...@@ -1195,7 +1195,7 @@ xfrm_get_saddr(xfrm_address_t *local, xfrm_address_t *remote,
if (unlikely(afinfo == NULL)) if (unlikely(afinfo == NULL))
return -EINVAL; return -EINVAL;
err = afinfo->get_saddr(local, remote); err = afinfo->get_saddr(net, local, remote);
xfrm_policy_put_afinfo(afinfo); xfrm_policy_put_afinfo(afinfo);
return err; return err;
} }
...@@ -1207,6 +1207,7 @@ xfrm_tmpl_resolve_one(struct xfrm_policy *policy, struct flowi *fl, ...@@ -1207,6 +1207,7 @@ xfrm_tmpl_resolve_one(struct xfrm_policy *policy, struct flowi *fl,
struct xfrm_state **xfrm, struct xfrm_state **xfrm,
unsigned short family) unsigned short family)
{ {
struct net *net = xp_net(policy);
int nx; int nx;
int i, error; int i, error;
xfrm_address_t *daddr = xfrm_flowi_daddr(fl, family); xfrm_address_t *daddr = xfrm_flowi_daddr(fl, family);
...@@ -1225,7 +1226,7 @@ xfrm_tmpl_resolve_one(struct xfrm_policy *policy, struct flowi *fl, ...@@ -1225,7 +1226,7 @@ xfrm_tmpl_resolve_one(struct xfrm_policy *policy, struct flowi *fl,
local = &tmpl->saddr; local = &tmpl->saddr;
family = tmpl->encap_family; family = tmpl->encap_family;
if (xfrm_addr_any(local, family)) { if (xfrm_addr_any(local, family)) {
error = xfrm_get_saddr(&tmp, remote, family); error = xfrm_get_saddr(net, &tmp, remote, family);
if (error) if (error)
goto fail; goto fail;
local = &tmp; local = &tmp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment