From: Dax Kelson Date: Sat, 4 Feb 2012 06:40:25 +0000 (-0700) Subject: iscsi: use IP_FREEBIND socket option X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=9f9ef6d3c08319defc29e4cf6ef2868d15ed0cc3;p=linux-beck.git iscsi: use IP_FREEBIND socket option Use IP_FREEBIND socket option so that iscsi portal configuration with explicit IP addresses can happen during boot, before network interfaces have been assigned IPs. This is especially important on systemd based Linux boxes where system boot happens asynchronously and non-trivial configuration must be done to get targetcli.service to start synchronously after the network is configured. Reference: http://lists.fedoraproject.org/pipermail/devel/2011-October/158025.html Signed-off-by: Dax Kelson Cc: "Nicholas A. Bellinger" Cc: "Andy Grover" Cc: "Lennart Poettering" Signed-off-by: Nicholas Bellinger --- diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c index ec47a7c5966e..38cb7ce8469e 100644 --- a/drivers/target/iscsi/iscsi_target_login.c +++ b/drivers/target/iscsi/iscsi_target_login.c @@ -842,6 +842,14 @@ int iscsi_target_setup_login_socket( goto fail; } + ret = kernel_setsockopt(sock, IPPROTO_IP, IP_FREEBIND, + (char *)&opt, sizeof(opt)); + if (ret < 0) { + pr_err("kernel_setsockopt() for IP_FREEBIND" + " failed\n"); + goto fail; + } + ret = kernel_bind(sock, (struct sockaddr *)&np->np_sockaddr, len); if (ret < 0) { pr_err("kernel_bind() failed: %d\n", ret);