[IPV4/IPV6]: Always wait for IPSEC SA resolution in socket contexts.
authorDavid S. Miller <davem@sunset.davemloft.net>
Thu, 8 Feb 2007 10:09:21 +0000 (02:09 -0800)
committerDavid S. Miller <davem@sunset.davemloft.net>
Thu, 8 Feb 2007 20:38:45 +0000 (12:38 -0800)
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: David S. Miller <davem@davemloft.net>
12 files changed:
include/net/route.h
net/dccp/ipv4.c
net/dccp/ipv6.c
net/ipv4/af_inet.c
net/ipv4/datagram.c
net/ipv4/raw.c
net/ipv4/tcp_ipv4.c
net/ipv4/udp.c
net/ipv6/datagram.c
net/ipv6/raw.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c

index 486e37aff06ca28751e2a4a1cbf645b52cd3ebee..1440bdb5a27d2ac818c65abcae431f9ae6bf7753 100644 (file)
@@ -146,7 +146,8 @@ static inline char rt_tos2priority(u8 tos)
 
 static inline int ip_route_connect(struct rtable **rp, __be32 dst,
                                   __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,
                            .nl_u = { .ip4_u = { .daddr = dst,
@@ -168,7 +169,7 @@ static inline int ip_route_connect(struct rtable **rp, __be32 dst,
                *rp = NULL;
        }
        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,
index 90c74b4adb7396443a36d8124633e2d22abd5551..fa2c982d43095f78022fbbef0f234fd47c489690 100644 (file)
@@ -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,
                               RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
                               IPPROTO_DCCP,
-                              inet->sport, usin->sin_port, sk);
+                              inet->sport, usin->sin_port, sk, 1);
        if (tmp < 0)
                return tmp;
 
index 6b91a9dd04111298c96127ea49e18d864602e9f9..79140b3e592e40231585357ba045454af64308ee 100644 (file)
@@ -1041,7 +1041,7 @@ static int dccp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
        if (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)
                goto failure;
 
index 864009643675fe195be002f09e50bfeb69b0e417..5750a2b2a0d6f38e8a6cf2874b560cc50ebfa8f2 100644 (file)
@@ -1007,7 +1007,7 @@ static int inet_sk_reselect_saddr(struct sock *sk)
                               RT_CONN_FLAGS(sk),
                               sk->sk_bound_dev_if,
                               sk->sk_protocol,
-                              inet->sport, inet->dport, sk);
+                              inet->sport, inet->dport, sk, 0);
        if (err)
                return err;
 
index 7b068a891953aae4d9e377438319815c3439259b..0072d79f0c2a0018cad97f12930cf8b4adde5b78 100644 (file)
@@ -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,
                               RT_CONN_FLAGS(sk), oif,
                               sk->sk_protocol,
-                              inet->sport, usin->sin_port, sk);
+                              inet->sport, usin->sin_port, sk, 1);
        if (err)
                return err;
        if ((rt->rt_flags & RTCF_BROADCAST) && !sock_flag(sk, SOCK_BROADCAST)) {
index a6c63bbd9ddb198dd77e88f9c8ee22002382516c..fed6a1e7af9e0aab861e4dddac537b7e8a19c561 100644 (file)
@@ -489,7 +489,7 @@ static int raw_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
                }
 
                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)
                goto done;
index f061ec50d8bcc81d8de1b0baa0e3b7d1df24d2fd..383e4b52dbde402e8bad91da376a8b612eef19e4 100644 (file)
@@ -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,
                               RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
                               IPPROTO_TCP,
-                              inet->sport, usin->sin_port, sk);
+                              inet->sport, usin->sin_port, sk, 1);
        if (tmp < 0)
                return tmp;
 
index cfff930f2bafc78039908c1ab728d2340e4dc26d..8b54c68a0d12d987596f5edca96699dcc8c9c348 100644 (file)
@@ -629,7 +629,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
                                               { .sport = inet->sport,
                                                 .dport = dport } } };
                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)
                        goto out;
 
index 5c94fea90e97467f683b5ee64d4caf7c9ca214a9..ecde30140f4a59bbd475218c052adb9d26e9935f 100644 (file)
@@ -178,7 +178,7 @@ ipv4_connected:
        if (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;
 
        /* source address lookup done in ip6_dst_lookup */
index 4ae1b19ada5d3eb9e3c3c7f0b1b7a8030002eacb..f2e883c9368a7bbea22537cb87fde2bf2465323e 100644 (file)
@@ -815,7 +815,7 @@ static int rawv6_sendmsg(struct kiocb *iocb, struct sock *sk,
        if (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;
 
        if (hlimit < 0) {
index c25e930c2c6963d8e5d8aac4053e505cb83eedcf..dcb7b00a737dc9c801dd6c406337e2b1ee5d03f9 100644 (file)
@@ -265,7 +265,7 @@ static int tcp_v6_connect(struct sock *sk, struct sockaddr *uaddr,
        if (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;
 
        if (saddr == NULL) {
index f52a5c3cc0a36d5a4f64956b2d57bd4720067894..15e5195549cb337728739605b842e23b2ae3160e 100644 (file)
@@ -736,7 +736,7 @@ do_udp_sendmsg:
        if (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;
 
        if (hlimit < 0) {