Skip to content

Commit af17092

Browse files
cleechmartinkpetersen
authored andcommitted
scsi: iscsi: respond to netlink with unicast when appropriate
Instead of always multicasting responses, send a unicast netlink message directed at the correct pid. This will be needed if we ever want to support multiple userspace processes interacting with the kernel over iSCSI netlink simultaneously. Limitations can currently be seen if you attempt to run multiple iscsistart commands in parallel. We've fixed up the userspace issues in iscsistart that prevented multiple instances from running, so now attempts to speed up booting by bringing up multiple iscsi sessions at once in the initramfs are just running into misrouted responses that this fixes. Signed-off-by: Chris Leech <cleech@redhat.com> Reviewed-by: Lee Duncan <lduncan@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 60cc43f commit af17092

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

drivers/scsi/scsi_transport_iscsi.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,6 +2322,12 @@ iscsi_multicast_skb(struct sk_buff *skb, uint32_t group, gfp_t gfp)
23222322
return nlmsg_multicast(nls, skb, 0, group, gfp);
23232323
}
23242324

2325+
static int
2326+
iscsi_unicast_skb(struct sk_buff *skb, u32 portid)
2327+
{
2328+
return nlmsg_unicast(nls, skb, portid);
2329+
}
2330+
23252331
int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
23262332
char *data, uint32_t data_size)
23272333
{
@@ -2524,25 +2530,21 @@ void iscsi_ping_comp_event(uint32_t host_no, struct iscsi_transport *transport,
25242530
EXPORT_SYMBOL_GPL(iscsi_ping_comp_event);
25252531

25262532
static int
2527-
iscsi_if_send_reply(uint32_t group, int seq, int type, int done, int multi,
2528-
void *payload, int size)
2533+
iscsi_if_send_reply(u32 portid, int type, void *payload, int size)
25292534
{
25302535
struct sk_buff *skb;
25312536
struct nlmsghdr *nlh;
25322537
int len = nlmsg_total_size(size);
2533-
int flags = multi ? NLM_F_MULTI : 0;
2534-
int t = done ? NLMSG_DONE : type;
25352538

25362539
skb = alloc_skb(len, GFP_ATOMIC);
25372540
if (!skb) {
25382541
printk(KERN_ERR "Could not allocate skb to send reply.\n");
25392542
return -ENOMEM;
25402543
}
25412544

2542-
nlh = __nlmsg_put(skb, 0, 0, t, (len - sizeof(*nlh)), 0);
2543-
nlh->nlmsg_flags = flags;
2545+
nlh = __nlmsg_put(skb, 0, 0, type, (len - sizeof(*nlh)), 0);
25442546
memcpy(nlmsg_data(nlh), payload, size);
2545-
return iscsi_multicast_skb(skb, group, GFP_ATOMIC);
2547+
return iscsi_unicast_skb(skb, portid);
25462548
}
25472549

25482550
static int
@@ -3470,6 +3472,7 @@ static int
34703472
iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
34713473
{
34723474
int err = 0;
3475+
u32 portid;
34733476
struct iscsi_uevent *ev = nlmsg_data(nlh);
34743477
struct iscsi_transport *transport = NULL;
34753478
struct iscsi_internal *priv;
@@ -3490,10 +3493,12 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
34903493
if (!try_module_get(transport->owner))
34913494
return -EINVAL;
34923495

3496+
portid = NETLINK_CB(skb).portid;
3497+
34933498
switch (nlh->nlmsg_type) {
34943499
case ISCSI_UEVENT_CREATE_SESSION:
34953500
err = iscsi_if_create_session(priv, ep, ev,
3496-
NETLINK_CB(skb).portid,
3501+
portid,
34973502
ev->u.c_session.initial_cmdsn,
34983503
ev->u.c_session.cmds_max,
34993504
ev->u.c_session.queue_depth);
@@ -3506,7 +3511,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
35063511
}
35073512

35083513
err = iscsi_if_create_session(priv, ep, ev,
3509-
NETLINK_CB(skb).portid,
3514+
portid,
35103515
ev->u.c_bound_session.initial_cmdsn,
35113516
ev->u.c_bound_session.cmds_max,
35123517
ev->u.c_bound_session.queue_depth);
@@ -3664,6 +3669,8 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
36643669
static void
36653670
iscsi_if_rx(struct sk_buff *skb)
36663671
{
3672+
u32 portid = NETLINK_CB(skb).portid;
3673+
36673674
mutex_lock(&rx_queue_mutex);
36683675
while (skb->len >= NLMSG_HDRLEN) {
36693676
int err;
@@ -3699,8 +3706,8 @@ iscsi_if_rx(struct sk_buff *skb)
36993706
break;
37003707
if (ev->type == ISCSI_UEVENT_GET_CHAP && !err)
37013708
break;
3702-
err = iscsi_if_send_reply(group, nlh->nlmsg_seq,
3703-
nlh->nlmsg_type, 0, 0, ev, sizeof(*ev));
3709+
err = iscsi_if_send_reply(portid, nlh->nlmsg_type,
3710+
ev, sizeof(*ev));
37043711
} while (err < 0 && err != -ECONNREFUSED && err != -ESRCH);
37053712
skb_pull(skb, rlen);
37063713
}

0 commit comments

Comments
 (0)