sctp: Set source addresses on the association before adding transports
Recent commit 8da645e101
sctp: Get rid of an extra routing lookup when adding a transport
introduced a regression in the connection setup. The behavior was
different between IPv4 and IPv6. IPv4 case ended up working because the
route lookup routing returned a NULL route, which triggered another
route lookup later in the output patch that succeeded. In the IPv6 case,
a valid route was returned for first call, but we could not find a valid
source address at the time since the source addresses were not set on the
association yet. Thus resulted in a hung connection.
The solution is to set the source addresses on the association prior to
adding peers.
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
d792c1006f
commit
409b95aff3
@@ -1080,6 +1080,13 @@ static int __sctp_connect(struct sock* sk,
|
||||
err = -ENOMEM;
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
err = sctp_assoc_set_bind_addr_from_ep(asoc, scope,
|
||||
GFP_KERNEL);
|
||||
if (err < 0) {
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Prime the peer's transport structures. */
|
||||
@@ -1095,11 +1102,6 @@ static int __sctp_connect(struct sock* sk,
|
||||
walk_size += af->sockaddr_len;
|
||||
}
|
||||
|
||||
err = sctp_assoc_set_bind_addr_from_ep(asoc, GFP_KERNEL);
|
||||
if (err < 0) {
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
/* In case the user of sctp_connectx() wants an association
|
||||
* id back, assign one now.
|
||||
*/
|
||||
@@ -1689,6 +1691,11 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
|
||||
goto out_unlock;
|
||||
}
|
||||
asoc = new_asoc;
|
||||
err = sctp_assoc_set_bind_addr_from_ep(asoc, scope, GFP_KERNEL);
|
||||
if (err < 0) {
|
||||
err = -ENOMEM;
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
/* If the SCTP_INIT ancillary data is specified, set all
|
||||
* the association init values accordingly.
|
||||
@@ -1718,11 +1725,6 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
|
||||
err = -ENOMEM;
|
||||
goto out_free;
|
||||
}
|
||||
err = sctp_assoc_set_bind_addr_from_ep(asoc, GFP_KERNEL);
|
||||
if (err < 0) {
|
||||
err = -ENOMEM;
|
||||
goto out_free;
|
||||
}
|
||||
}
|
||||
|
||||
/* ASSERT: we have a valid association at this point. */
|
||||
|
Reference in New Issue
Block a user