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.
---
drivers/scsi/scsi_transport_iscsi.c | 37 ++++++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 13 deletions(-)
diff --git a/drivers/scsi/scsi_transport_iscsi.c
b/drivers/scsi/scsi_transport_iscsi.c
index eacd11557eb7..561f79a3d572 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -2477,8 +2477,7 @@ iscsi_if_transport_lookup(struct iscsi_transport *tt)
}
static int
-iscsi_multicast_skb(struct net *net, struct sk_buff *skb,
- uint32_t group, gfp_t gfp)
+iscsi_multicast_skb(struct net *net, struct sk_buff *skb, u32 group, gfp_t gfp)
{
struct sock *nls;
struct iscsi_net *isn;
@@ -2488,6 +2487,17 @@ iscsi_multicast_skb(struct net *net, struct sk_buff *skb,
return nlmsg_multicast(nls, skb, 0, group, gfp);
}
+static int
+iscsi_unicast_skb(struct net *net, struct sk_buff *skb, u32 portid)
+{
+ struct sock *nls;
+ struct iscsi_net *isn;
+
+ isn = net_generic(net, iscsi_net_id);
+ nls = isn->nls;
+ return nlmsg_unicast(nls, skb, portid);
+}
+
int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,
char *data, uint32_t data_size)
{
@@ -2715,14 +2725,12 @@ void iscsi_ping_comp_event(uint32_t host_no, struct
iscsi_transport *transport,
EXPORT_SYMBOL_GPL(iscsi_ping_comp_event);
static int
-iscsi_if_send_reply(struct net *net, uint32_t group, int seq, int type,
- int done, int multi, void *payload, int size)
+iscsi_if_send_reply(struct net *net, u32 portid, int type,
+ void *payload, int size)
{
struct sk_buff *skb;
struct nlmsghdr *nlh;
int len = nlmsg_total_size(size);
- int flags = multi ? NLM_F_MULTI : 0;
- int t = done ? NLMSG_DONE : type;
skb = alloc_skb(len, GFP_ATOMIC);
if (!skb) {
@@ -2730,10 +2738,9 @@ iscsi_if_send_reply(struct net *net, uint32_t group, int
seq, int type,
return -ENOMEM;
}
- nlh = __nlmsg_put(skb, 0, 0, t, (len - sizeof(*nlh)), 0);
- nlh->nlmsg_flags = flags;
+ nlh = __nlmsg_put(skb, 0, 0, type, (len - sizeof(*nlh)), 0);
memcpy(nlmsg_data(nlh), payload, size);
- return iscsi_multicast_skb(net, skb, group, GFP_ATOMIC);
+ return iscsi_unicast_skb(net, skb, portid);
}
static int
@@ -3679,6 +3686,7 @@ iscsi_if_recv_msg(struct net *net, struct sk_buff *skb,
struct nlmsghdr *nlh, uint32_t *group)
{
int err = 0;
+ u32 portid;
struct iscsi_uevent *ev = nlmsg_data(nlh);
struct iscsi_transport *transport = NULL;
struct iscsi_internal *priv;
@@ -3699,10 +3707,12 @@ iscsi_if_recv_msg(struct net *net, struct sk_buff *skb,
if (!try_module_get(transport->owner))
return -EINVAL;
+ portid = NETLINK_CB(skb).portid;
+
switch (nlh->nlmsg_type) {
case ISCSI_UEVENT_CREATE_SESSION:
err = iscsi_if_create_session(priv, ep, ev,
- NETLINK_CB(skb).portid,
+ portid,
ev->u.c_session.initial_cmdsn,
ev->u.c_session.cmds_max,
ev->u.c_session.queue_depth);
@@ -3716,7 +3726,7 @@ iscsi_if_recv_msg(struct net *net, struct sk_buff *skb,
}
err = iscsi_if_create_session(priv, ep, ev,
- NETLINK_CB(skb).portid,
+ portid,
ev->u.c_bound_session.initial_cmdsn,
ev->u.c_bound_session.cmds_max,
ev->u.c_bound_session.queue_depth);
@@ -3878,6 +3888,7 @@ iscsi_if_rx(struct sk_buff *skb)
{
struct sock *sk = skb->sk;
struct net *net = sock_net(sk);
+ u32 portid = NETLINK_CB(skb).portid;
mutex_lock(&rx_queue_mutex);
while (skb->len >= NLMSG_HDRLEN) {
@@ -3916,8 +3927,8 @@ iscsi_if_rx(struct sk_buff *skb)
break;
if (ev->type == ISCSI_UEVENT_GET_HOST_STATS && !err)
break;
- err = iscsi_if_send_reply(net, group, nlh->nlmsg_seq,
- nlh->nlmsg_type, 0, 0, ev, sizeof(*ev));
+ err = iscsi_if_send_reply(net, portid,
+ nlh->nlmsg_type, ev, sizeof(*ev));
} while (err < 0 && err != -ECONNREFUSED && err != -ESRCH);
skb_pull(skb, rlen);
}
--
2.9.4
--
You received this message because you are subscribed to the Google Groups
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.