diff options
Diffstat (limited to 'drivers/target/iscsi/iscsi_target.c')
-rw-r--r-- | drivers/target/iscsi/iscsi_target.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index ac44af165b27..44262908def5 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c | |||
@@ -1061,7 +1061,7 @@ attach_cmd: | |||
1061 | if (ret < 0) | 1061 | if (ret < 0) |
1062 | return iscsit_add_reject_from_cmd( | 1062 | return iscsit_add_reject_from_cmd( |
1063 | ISCSI_REASON_BOOKMARK_NO_RESOURCES, | 1063 | ISCSI_REASON_BOOKMARK_NO_RESOURCES, |
1064 | 1, 1, buf, cmd); | 1064 | 1, 0, buf, cmd); |
1065 | /* | 1065 | /* |
1066 | * Check the CmdSN against ExpCmdSN/MaxCmdSN here if | 1066 | * Check the CmdSN against ExpCmdSN/MaxCmdSN here if |
1067 | * the Immediate Bit is not set, and no Immediate | 1067 | * the Immediate Bit is not set, and no Immediate |
@@ -3164,6 +3164,30 @@ static int iscsit_send_task_mgt_rsp( | |||
3164 | return 0; | 3164 | return 0; |
3165 | } | 3165 | } |
3166 | 3166 | ||
3167 | static bool iscsit_check_inaddr_any(struct iscsi_np *np) | ||
3168 | { | ||
3169 | bool ret = false; | ||
3170 | |||
3171 | if (np->np_sockaddr.ss_family == AF_INET6) { | ||
3172 | const struct sockaddr_in6 sin6 = { | ||
3173 | .sin6_addr = IN6ADDR_ANY_INIT }; | ||
3174 | struct sockaddr_in6 *sock_in6 = | ||
3175 | (struct sockaddr_in6 *)&np->np_sockaddr; | ||
3176 | |||
3177 | if (!memcmp(sock_in6->sin6_addr.s6_addr, | ||
3178 | sin6.sin6_addr.s6_addr, 16)) | ||
3179 | ret = true; | ||
3180 | } else { | ||
3181 | struct sockaddr_in * sock_in = | ||
3182 | (struct sockaddr_in *)&np->np_sockaddr; | ||
3183 | |||
3184 | if (sock_in->sin_addr.s_addr == INADDR_ANY) | ||
3185 | ret = true; | ||
3186 | } | ||
3187 | |||
3188 | return ret; | ||
3189 | } | ||
3190 | |||
3167 | static int iscsit_build_sendtargets_response(struct iscsi_cmd *cmd) | 3191 | static int iscsit_build_sendtargets_response(struct iscsi_cmd *cmd) |
3168 | { | 3192 | { |
3169 | char *payload = NULL; | 3193 | char *payload = NULL; |
@@ -3213,12 +3237,17 @@ static int iscsit_build_sendtargets_response(struct iscsi_cmd *cmd) | |||
3213 | spin_lock(&tpg->tpg_np_lock); | 3237 | spin_lock(&tpg->tpg_np_lock); |
3214 | list_for_each_entry(tpg_np, &tpg->tpg_gnp_list, | 3238 | list_for_each_entry(tpg_np, &tpg->tpg_gnp_list, |
3215 | tpg_np_list) { | 3239 | tpg_np_list) { |
3240 | struct iscsi_np *np = tpg_np->tpg_np; | ||
3241 | bool inaddr_any = iscsit_check_inaddr_any(np); | ||
3242 | |||
3216 | len = sprintf(buf, "TargetAddress=" | 3243 | len = sprintf(buf, "TargetAddress=" |
3217 | "%s%s%s:%hu,%hu", | 3244 | "%s%s%s:%hu,%hu", |
3218 | (tpg_np->tpg_np->np_sockaddr.ss_family == AF_INET6) ? | 3245 | (np->np_sockaddr.ss_family == AF_INET6) ? |
3219 | "[" : "", tpg_np->tpg_np->np_ip, | 3246 | "[" : "", (inaddr_any == false) ? |
3220 | (tpg_np->tpg_np->np_sockaddr.ss_family == AF_INET6) ? | 3247 | np->np_ip : conn->local_ip, |
3221 | "]" : "", tpg_np->tpg_np->np_port, | 3248 | (np->np_sockaddr.ss_family == AF_INET6) ? |
3249 | "]" : "", (inaddr_any == false) ? | ||
3250 | np->np_port : conn->local_port, | ||
3222 | tpg->tpgt); | 3251 | tpg->tpgt); |
3223 | len += 1; | 3252 | len += 1; |
3224 | 3253 | ||