Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx> --- usr/iscsi/iscsi_rdma.c | 2 +- usr/iscsi/iscsi_tcp.c | 2 +- usr/iscsi/iscsid.c | 20 +++++++++++++++++++- usr/iscsi/iscsid.h | 2 ++ usr/iscsi/isns.c | 2 +- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/usr/iscsi/iscsi_rdma.c b/usr/iscsi/iscsi_rdma.c index b25abf7..6cf5677 100644 --- a/usr/iscsi/iscsi_rdma.c +++ b/usr/iscsi/iscsi_rdma.c @@ -1146,7 +1146,7 @@ static int iscsi_rdma_init(void) { int ret; struct sockaddr_in sock_addr; - short int port = ISCSI_LISTEN_PORT; + short int port = iscsi_listen_port; rdma_evt_channel = rdma_create_event_channel(); diff --git a/usr/iscsi/iscsi_tcp.c b/usr/iscsi/iscsi_tcp.c index edc4e86..75d77ba 100644 --- a/usr/iscsi/iscsi_tcp.c +++ b/usr/iscsi/iscsi_tcp.c @@ -176,7 +176,7 @@ static int iscsi_tcp_init(void) int ret, fd, opt, nr_sock = 0; memset(servname, 0, sizeof(servname)); - snprintf(servname, sizeof(servname), "%d", ISCSI_LISTEN_PORT); + snprintf(servname, sizeof(servname), "%d", iscsi_listen_port); memset(&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_STREAM; diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c index 634e0d1..53e37bf 100644 --- a/usr/iscsi/iscsid.c +++ b/usr/iscsi/iscsid.c @@ -42,6 +42,8 @@ #define MAX_QUEUE_CMD 128 +int iscsi_listen_port = ISCSI_LISTEN_PORT; + enum { IOSTATE_FREE, @@ -828,7 +830,7 @@ static void text_scan_text(struct iscsi_connection *conn) if (ss.ss_family == AF_INET6) *p++ = ']'; - sprintf(p, ":%d,1", ISCSI_LISTEN_PORT); + sprintf(p, ":%d,1", iscsi_listen_port); target_list_build(conn, buf, strcmp(value, "All") ? value : NULL); } else @@ -2253,7 +2255,23 @@ static struct tgt_driver iscsi = { .default_bst = "rdwr", }; +static int iscsi_param_parser(char *p) +{ + while (*p) { + if (!strncmp(p, "port", 4)) + iscsi_listen_port = atoi(p + 5); + + p += strcspn(p, ","); + if (*p == ',') + ++p; + } + + return 0; +} + __attribute__((constructor)) static void iscsi_driver_constructor(void) { register_driver(&iscsi); + + setup_param("iscsi", iscsi_param_parser); } diff --git a/usr/iscsi/iscsid.h b/usr/iscsi/iscsid.h index 02caad2..666d2bb 100644 --- a/usr/iscsi/iscsid.h +++ b/usr/iscsi/iscsid.h @@ -251,6 +251,8 @@ enum task_flags { TASK_in_scsi, }; +extern int iscsi_listen_port; + #define set_task_pending(t) ((t)->flags |= (1 << TASK_pending)) #define clear_task_pending(t) ((t)->flags &= ~(1 << TASK_pending)) #define task_pending(t) ((t)->flags & (1 << TASK_pending)) diff --git a/usr/iscsi/isns.c b/usr/iscsi/isns.c index 88e5211..3bfc1fc 100644 --- a/usr/iscsi/isns.c +++ b/usr/iscsi/isns.c @@ -392,7 +392,7 @@ int isns_target_register(char *name) uint16_t flags = 0, length = 0; struct isns_hdr *hdr = (struct isns_hdr *) buf; struct isns_tlv *tlv; - uint32_t port = htonl(ISCSI_LISTEN_PORT); + uint32_t port = htonl(iscsi_listen_port); uint32_t node = htonl(ISNS_NODE_TARGET); uint32_t type = htonl(2); struct iscsi_target *target; -- 1.5.6.5 -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html