}
}
-static struct socket *drbd_try_connect(struct drbd_conf *mdev)
+static struct socket *drbd_try_connect(struct drbd_tconn *tconn)
{
const char *what;
struct socket *sock;
int err;
int disconnect_on_error = 1;
- if (!get_net_conf(mdev->tconn))
+ if (!get_net_conf(tconn))
return NULL;
what = "sock_create_kern";
- err = sock_create_kern(((struct sockaddr *)mdev->tconn->net_conf->my_addr)->sa_family,
+ err = sock_create_kern(((struct sockaddr *)tconn->net_conf->my_addr)->sa_family,
SOCK_STREAM, IPPROTO_TCP, &sock);
if (err < 0) {
sock = NULL;
}
sock->sk->sk_rcvtimeo =
- sock->sk->sk_sndtimeo = mdev->tconn->net_conf->try_connect_int*HZ;
- drbd_setbufsize(sock, mdev->tconn->net_conf->sndbuf_size,
- mdev->tconn->net_conf->rcvbuf_size);
+ sock->sk->sk_sndtimeo = tconn->net_conf->try_connect_int*HZ;
+ drbd_setbufsize(sock, tconn->net_conf->sndbuf_size,
+ tconn->net_conf->rcvbuf_size);
/* explicitly bind to the configured IP as source IP
* for the outgoing connections.
* Make sure to use 0 as port number, so linux selects
* a free one dynamically.
*/
- memcpy(&src_in6, mdev->tconn->net_conf->my_addr,
- min_t(int, mdev->tconn->net_conf->my_addr_len, sizeof(src_in6)));
- if (((struct sockaddr *)mdev->tconn->net_conf->my_addr)->sa_family == AF_INET6)
+ memcpy(&src_in6, tconn->net_conf->my_addr,
+ min_t(int, tconn->net_conf->my_addr_len, sizeof(src_in6)));
+ if (((struct sockaddr *)tconn->net_conf->my_addr)->sa_family == AF_INET6)
src_in6.sin6_port = 0;
else
((struct sockaddr_in *)&src_in6)->sin_port = 0; /* AF_INET & AF_SCI */
what = "bind before connect";
err = sock->ops->bind(sock,
(struct sockaddr *) &src_in6,
- mdev->tconn->net_conf->my_addr_len);
+ tconn->net_conf->my_addr_len);
if (err < 0)
goto out;
disconnect_on_error = 0;
what = "connect";
err = sock->ops->connect(sock,
- (struct sockaddr *)mdev->tconn->net_conf->peer_addr,
- mdev->tconn->net_conf->peer_addr_len, 0);
+ (struct sockaddr *)tconn->net_conf->peer_addr,
+ tconn->net_conf->peer_addr_len, 0);
out:
if (err < 0) {
disconnect_on_error = 0;
break;
default:
- dev_err(DEV, "%s failed, err = %d\n", what, err);
+ conn_err(tconn, "%s failed, err = %d\n", what, err);
}
if (disconnect_on_error)
- drbd_force_state(mdev, NS(conn, C_DISCONNECTING));
+ drbd_force_state(tconn->volume0, NS(conn, C_DISCONNECTING));
}
- put_net_conf(mdev->tconn);
+ put_net_conf(tconn);
return sock;
}
do {
for (try = 0;;) {
/* 3 tries, this should take less than a second! */
- s = drbd_try_connect(mdev);
+ s = drbd_try_connect(mdev->tconn);
if (s || ++try >= 3)
break;
/* give the other side time to call bind() & listen() */