Commit 8eb9086f authored by David S. Miller's avatar David S. Miller

[IPV4/IPV6]: Always wait for IPSEC SA resolution in socket contexts.

Do this even for non-blocking sockets.  This avoids the silly -EAGAIN
that applications can see now, even for non-blocking sockets in some
cases (f.e. connect()).

With help from Venkat Tekkirala.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ba7808ea
...@@ -146,7 +146,8 @@ static inline char rt_tos2priority(u8 tos) ...@@ -146,7 +146,8 @@ static inline char rt_tos2priority(u8 tos)
static inline int ip_route_connect(struct rtable **rp, __be32 dst, static inline int ip_route_connect(struct rtable **rp, __be32 dst,
__be32 src, u32 tos, int oif, u8 protocol, __be32 src, u32 tos, int oif, u8 protocol,
__be16 sport, __be16 dport, struct sock *sk) __be16 sport, __be16 dport, struct sock *sk,
int flags)
{ {
struct flowi fl = { .oif = oif, struct flowi fl = { .oif = oif,
.nl_u = { .ip4_u = { .daddr = dst, .nl_u = { .ip4_u = { .daddr = dst,
...@@ -168,7 +169,7 @@ static inline int ip_route_connect(struct rtable **rp, __be32 dst, ...@@ -168,7 +169,7 @@ static inline int ip_route_connect(struct rtable **rp, __be32 dst,
*rp = NULL; *rp = NULL;
} }
security_sk_classify_flow(sk, &fl); security_sk_classify_flow(sk, &fl);
return ip_route_output_flow(rp, &fl, sk, 0); return ip_route_output_flow(rp, &fl, sk, flags);
} }
static inline int ip_route_newports(struct rtable **rp, u8 protocol, static inline int ip_route_newports(struct rtable **rp, u8 protocol,
......
...@@ -72,7 +72,7 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) ...@@ -72,7 +72,7 @@ int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
tmp = ip_route_connect(&rt, nexthop, inet->saddr, tmp = ip_route_connect(&rt, nexthop, inet->saddr,
RT_CONN_FLAGS(sk), sk->sk_bound_dev_if, RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
IPPROTO_DCCP, IPPROTO_DCCP,
inet->sport, usin->sin_port, sk); inet->sport, usin->sin_port, sk, 1);
if (tmp < 0) if (tmp < 0)
return tmp; return tmp;
......
...@@ -1041,7 +1041,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr, ...@@ -1041,7 +1041,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
if (final_p) if (final_p)
ipv6_addr_copy(&fl.fl6_dst, final_p); ipv6_addr_copy(&fl.fl6_dst, final_p);
err = xfrm_lookup(&dst, &fl, sk, 0); err = xfrm_lookup(&dst, &fl, sk, 1);
if (err < 0) if (err < 0)
goto failure; goto failure;
......
...@@ -1007,7 +1007,7 @@ static int inet_sk_reselect_saddr(struct sock *sk) ...@@ -1007,7 +1007,7 @@ static int inet_sk_reselect_saddr(struct sock *sk)
RT_CONN_FLAGS(sk), RT_CONN_FLAGS(sk),
sk->sk_bound_dev_if, sk->sk_bound_dev_if,
sk->sk_protocol, sk->sk_protocol,
inet->sport, inet->dport, sk); inet->sport, inet->dport, sk, 0);
if (err) if (err)
return err; return err;
......
...@@ -49,7 +49,7 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) ...@@ -49,7 +49,7 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
err = ip_route_connect(&rt, usin->sin_addr.s_addr, saddr, err = ip_route_connect(&rt, usin->sin_addr.s_addr, saddr,
RT_CONN_FLAGS(sk), oif, RT_CONN_FLAGS(sk), oif,
sk->sk_protocol, sk->sk_protocol,
inet->sport, usin->sin_port, sk); inet->sport, usin->sin_port, sk, 1);
if (err) if (err)
return err; return err;
if ((rt->rt_flags & RTCF_BROADCAST) && !sock_flag(sk, SOCK_BROADCAST)) { if ((rt->rt_flags & RTCF_BROADCAST) && !sock_flag(sk, SOCK_BROADCAST)) {
......
...@@ -489,7 +489,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -489,7 +489,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
} }
security_sk_classify_flow(sk, &fl); security_sk_classify_flow(sk, &fl);
err = ip_route_output_flow(&rt, &fl, sk, !(msg->msg_flags&MSG_DONTWAIT)); err = ip_route_output_flow(&rt, &fl, sk, 1);
} }
if (err) if (err)
goto done; goto done;
......
...@@ -191,7 +191,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) ...@@ -191,7 +191,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
tmp = ip_route_connect(&rt, nexthop, inet->saddr, tmp = ip_route_connect(&rt, nexthop, inet->saddr,
RT_CONN_FLAGS(sk), sk->sk_bound_dev_if, RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
IPPROTO_TCP, IPPROTO_TCP,
inet->sport, usin->sin_port, sk); inet->sport, usin->sin_port, sk, 1);
if (tmp < 0) if (tmp < 0)
return tmp; return tmp;
......
...@@ -629,7 +629,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -629,7 +629,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
{ .sport = inet->sport, { .sport = inet->sport,
.dport = dport } } }; .dport = dport } } };
security_sk_classify_flow(sk, &fl); security_sk_classify_flow(sk, &fl);
err = ip_route_output_flow(&rt, &fl, sk, !(msg->msg_flags&MSG_DONTWAIT)); err = ip_route_output_flow(&rt, &fl, sk, 1);
if (err) if (err)
goto out; goto out;
......
...@@ -178,7 +178,7 @@ ipv4_connected: ...@@ -178,7 +178,7 @@ ipv4_connected:
if (final_p) if (final_p)
ipv6_addr_copy(&fl.fl6_dst, final_p); ipv6_addr_copy(&fl.fl6_dst, final_p);
if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) if ((err = xfrm_lookup(&dst, &fl, sk, 1)) < 0)
goto out; goto out;
/* source address lookup done in ip6_dst_lookup */ /* source address lookup done in ip6_dst_lookup */
......
...@@ -815,7 +815,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -815,7 +815,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
if (final_p) if (final_p)
ipv6_addr_copy(&fl.fl6_dst, final_p); ipv6_addr_copy(&fl.fl6_dst, final_p);
if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) if ((err = xfrm_lookup(&dst, &fl, sk, 1)) < 0)
goto out; goto out;
if (hlimit < 0) { if (hlimit < 0) {
......
...@@ -265,7 +265,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr, ...@@ -265,7 +265,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
if (final_p) if (final_p)
ipv6_addr_copy(&fl.fl6_dst, final_p); ipv6_addr_copy(&fl.fl6_dst, final_p);
if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) if ((err = xfrm_lookup(&dst, &fl, sk, 1)) < 0)
goto failure; goto failure;
if (saddr == NULL) { if (saddr == NULL) {
......
...@@ -736,7 +736,7 @@ do_udp_sendmsg: ...@@ -736,7 +736,7 @@ do_udp_sendmsg:
if (final_p) if (final_p)
ipv6_addr_copy(&fl.fl6_dst, final_p); ipv6_addr_copy(&fl.fl6_dst, final_p);
if ((err = xfrm_lookup(&dst, &fl, sk, 0)) < 0) if ((err = xfrm_lookup(&dst, &fl, sk, 1)) < 0)
goto out; goto out;
if (hlimit < 0) { if (hlimit < 0) {
......
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