commit a92b413 removed the logging of local ip and port.
For debugging puposes these information can be important.
Restore functionality by using the new thread safe replacement
for inet_ntoa called inet_ntop.
Signed-off-by: Peter Lieven <pl@dlhnet.de>
a process might have a connection to different LUNs on the same target.
To be able to distinguish the different connections add the LUN id to the target
to log messages.
Signed-off-by: Peter Lieven <pl@dlhnet.de>
In iSCSI synchronous operations, a struct iscsi_sync_state variable
(state) is allocated on the stack, and its address is assigned to
pdu->scsi_cbdata.private_data. This address is eventually used in
the PDU callback function.
However, if a reconnection occurs during a synchronous operation
(e.g., read or write), but the connect function fails (iscsi->fd
will be set to -1), the event_loop times out and exits. At this point,
unprocessed PDUs remain. If the PDU callback function is triggered
after the timeout (e.g., during iscsi_destroy_context), it may
access the pdu->scsi_cbdata.private_data address, which no longer
points to the original stack allocation. Writing to this invalid
address in the callback corrupts the current stack structure,
leading to process crash.
This patch addresses the issue by scanning PDUs before exiting the
event_loop due connect timedout, ensuring the unprocessed PDUs are
properly handled to prevent stack corruption and crash.
Signed-off-by: raywang <honglei.wang@smartx.com>
When iscsi->fd gets invalid, there is not point to
keep stuck in the event loop, instead could give an
accurate error about the invalid fd.
Signed-off-by: Tianren Zhang <tianren@smartx.com>
On reconnect case, the iscsi_tcp_connect tries to reuse
the fd number of old_iscsi. However, this fd could have been
already closed in previous iscsi_tcp_disconnect if
iscsi->fd == iscsi->old_iscsi->fd and the fd number
might have been allocated to some other caller, in this
case the fd reuse in iscsi_tcp_connect is not safe anymore.
Solve this by not closing the fd if iscsi and old_iscsi
share the same fd on reconnect to "really" reserve this
fd number.
Signed-off-by: Tianren Zhang <tianren@smartx.com>
The pdu indata alloc by iscsi_malloc with a undetermined size, but free
by iscsi_sfree. The iscsi_sfree can only be used to free memory which
size is equal to iscsi->smalloc_size.
Signed-off-by: IriKa Qiu <qiujie.jq@gmail.com>
When an iSCSI connection enters the reconnection phase, the backoff
time (next_reconnect) increases with reconnection retry_cnt. However,
if the client detects that the target has recovered before reaching
next_reconnect, calling iscsi_reconnect/iscsi_force_reconnect has no
any effect, making fast reconnection impossible.
This patch introduces an interface to reset next_reconnect, so that
the client can reset the backoff time upon detecting target recovery
and achieve faster reconnection.
Resolves: https://github.com/sahlberg/libiscsi/issues/428
Signed-off-by: raywang <honglei.wang@smartx.com>
Add these files to libiscsi-utils package:
- /usr/bin/iscsi-discard
- /usr/bin/iscsi-md5sum
- /usr/bin/iscsi-pr
- /usr/share/man/man1/iscsi-md5sum.1.gz
Signed-off-by: Han Han <hhan@redhat.com>
Implement a more generic wrapper API for message digests, so
that it is easier to also include gnutls as an option.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
libgcrypt is a relatively large dependency that is used only for
the sake of computing MD5 in the CHAP authentication protocol.
Allow distributions to disable it forcibly and rely on the
embedded MD5 implementation.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This patch adds a timestamp before each logged line. That could help
correlating a logging to a network-trace. Because of offsets in time
between the tracer and the test and the DUT, this does not always help.
These changes are carried in debian for a long time, some since 2016.
The last one (implicity) is new in 1.20.0.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
values that are put into it are defined as hexadecimal. This is a bit
confusing (grepping through the code for 251658241 did not result in
anything while the hex variant f000001 resulted in SCSI_STATUS_ERROR).
Originally, we use this in scsi-lowlevel.c only, this works as static
function. It also could be used to dump ISCSI opcode, so move it into
common utils.h/utils.c.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>