target/iscsi: Replace conn->login_ip with login_sockaddr
Very similar to how it went with local_sockaddr. It was embedded in iscsi_login_stats so some changes there, and we needed to copy in a sockaddr_storage comparison function. Hopefully the kernel will get a standard one soon, our implementation makes the 3rd. isert_set_conn_info() became much smaller. IPV6_ADDRESS_SPACE define goes away, had to modify a call to in6_pton(), can just use -1 since we are sure string is null-terminated. Signed-off-by: Andy Grover <agrover@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:

committed by
Nicholas Bellinger

parent
69d755747d
commit
dc58f760e2
@@ -1372,6 +1372,33 @@ int tx_data(
|
||||
return iscsit_do_tx_data(conn, &c);
|
||||
}
|
||||
|
||||
static bool sockaddr_equal(struct sockaddr_storage *x, struct sockaddr_storage *y)
|
||||
{
|
||||
switch (x->ss_family) {
|
||||
case AF_INET: {
|
||||
struct sockaddr_in *sinx = (struct sockaddr_in *)x;
|
||||
struct sockaddr_in *siny = (struct sockaddr_in *)y;
|
||||
if (sinx->sin_addr.s_addr != siny->sin_addr.s_addr)
|
||||
return false;
|
||||
if (sinx->sin_port != siny->sin_port)
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
case AF_INET6: {
|
||||
struct sockaddr_in6 *sinx = (struct sockaddr_in6 *)x;
|
||||
struct sockaddr_in6 *siny = (struct sockaddr_in6 *)y;
|
||||
if (!ipv6_addr_equal(&sinx->sin6_addr, &siny->sin6_addr))
|
||||
return false;
|
||||
if (sinx->sin6_port != siny->sin6_port)
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void iscsit_collect_login_stats(
|
||||
struct iscsi_conn *conn,
|
||||
u8 status_class,
|
||||
@@ -1388,7 +1415,7 @@ void iscsit_collect_login_stats(
|
||||
ls = &tiqn->login_stats;
|
||||
|
||||
spin_lock(&ls->lock);
|
||||
if (!strcmp(conn->login_ip, ls->last_intr_fail_ip_addr) &&
|
||||
if (sockaddr_equal(&conn->login_sockaddr, &ls->last_intr_fail_sockaddr) &&
|
||||
((get_jiffies_64() - ls->last_fail_time) < 10)) {
|
||||
/* We already have the failure info for this login */
|
||||
spin_unlock(&ls->lock);
|
||||
@@ -1428,8 +1455,7 @@ void iscsit_collect_login_stats(
|
||||
|
||||
ls->last_intr_fail_ip_family = conn->login_family;
|
||||
|
||||
snprintf(ls->last_intr_fail_ip_addr, IPV6_ADDRESS_SPACE,
|
||||
"%s", conn->login_ip);
|
||||
ls->last_intr_fail_sockaddr = conn->login_sockaddr;
|
||||
ls->last_fail_time = get_jiffies_64();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user