Re: [RFC PATCH 4/9] iscsi: make all iSCSI netlink multicast namespace aware

2023-04-11 Thread Hannes Reinecke

On 4/10/23 21:10, Chris Leech wrote:

As discussed with Lee: you should tear down sessions related to this
namespace from the pernet ->exit callback, otherwise you end up with
session which can no longer been reached as the netlink socket is
gone.


These two follow on changes handle removing active sesions when the
namespace exits. Tested with iscsi_tcp and seems to be working for me.

Chris Leech (2):
   iscsi: make session and connection lists per-net
   iscsi: force destroy sesions when a network namespace exits

  drivers/scsi/scsi_transport_iscsi.c | 122 ++--
  1 file changed, 79 insertions(+), 43 deletions(-)


Thanks a lot!
That's precisely what I had been looking for.

But you really shouldn't have mentioned iSCSI offloads; that was too 
large an opening to _not_ comment on :-)


Cheers,

Hannes
--
Dr. Hannes ReineckeKernel Storage Architect
h...@suse.de  +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew
Myers, Andrew McDonald, Martje Boudien Moerman

--
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 open-iscsi+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/open-iscsi/f3c23291-2f77-4935-4e1c-a61cbe29241a%40suse.de.


Re: [RFC PATCH 4/9] iscsi: make all iSCSI netlink multicast namespace aware

2023-04-10 Thread Chris Leech
> As discussed with Lee: you should tear down sessions related to this
> namespace from the pernet ->exit callback, otherwise you end up with
> session which can no longer been reached as the netlink socket is
> gone.

These two follow on changes handle removing active sesions when the
namespace exits. Tested with iscsi_tcp and seems to be working for me.

Chris Leech (2):
  iscsi: make session and connection lists per-net
  iscsi: force destroy sesions when a network namespace exits

 drivers/scsi/scsi_transport_iscsi.c | 122 ++--
 1 file changed, 79 insertions(+), 43 deletions(-)

-- 
2.39.2

-- 
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 open-iscsi+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/open-iscsi/20230410191033.1069293-1-cleech%40redhat.com.


Re: [RFC PATCH 4/9] iscsi: make all iSCSI netlink multicast namespace aware

2023-03-14 Thread Hannes Reinecke

On 2/8/23 18:40, Lee Duncan wrote:

From: Lee Duncan 

Make use of the per-net netlink sockets. Responses are sent back on the
same socket/namespace the request was received on.  Async events are
reported on the socket/namespace stored in the iscsi_cls_host associated
with the event.

Signed-off-by: Chris Leech 
Signed-off-by: Lee Duncan 
---
  drivers/scsi/scsi_transport_iscsi.c | 92 +++--
  1 file changed, 60 insertions(+), 32 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c 
b/drivers/scsi/scsi_transport_iscsi.c
index 2e2b291bce41..230b43d34c5f 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -2653,8 +2653,8 @@ iscsi_if_transport_lookup(struct iscsi_transport *tt)
  }
  
  static int

-iscsi_multicast_netns(struct net *net, struct sk_buff *skb,
- uint32_t group, gfp_t gfp)
+iscsi_multicast_skb(struct net *net, struct sk_buff *skb,
+   uint32_t group, gfp_t gfp)
  {
struct sock *nls;
struct iscsi_net *isn;
@@ -2665,17 +2665,10 @@ iscsi_multicast_netns(struct net *net, struct sk_buff 
*skb,
  }
  
  static int

-iscsi_multicast_skb(struct sk_buff *skb, uint32_t group, gfp_t gfp)
-{
-   return iscsi_multicast_netns(_net, skb, group, gfp);
-}
-
-static int
-iscsi_unicast_skb(struct sk_buff *skb, u32 portid)
+iscsi_unicast_skb(struct net *net, struct sk_buff *skb, u32 portid)
  {
struct sock *nls;
struct iscsi_net *isn;
-   struct net *net = _net;
  
  	isn = net_generic(net, iscsi_net_id);

nls = isn->nls;
@@ -2690,6 +2683,7 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct 
iscsi_hdr *hdr,
struct iscsi_uevent *ev;
char *pdu;
struct iscsi_internal *priv;
+   struct net *net;
int len = nlmsg_total_size(sizeof(*ev) + sizeof(struct iscsi_hdr) +
   data_size);
  
@@ -2716,7 +2710,8 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct iscsi_hdr *hdr,

memcpy(pdu, hdr, sizeof(struct iscsi_hdr));
memcpy(pdu + sizeof(struct iscsi_hdr), data, data_size);
  
-	return iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);

+   net = iscsi_conn_net(conn);
+   return iscsi_multicast_skb(net, skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
  }
  EXPORT_SYMBOL_GPL(iscsi_recv_pdu);
  
@@ -2727,6 +2722,7 @@ int iscsi_offload_mesg(struct Scsi_Host *shost,

struct nlmsghdr *nlh;
struct sk_buff *skb;
struct iscsi_uevent *ev;
+   struct net *net;
int len = nlmsg_total_size(sizeof(*ev) + data_size);
  
  	skb = alloc_skb(len, GFP_ATOMIC);

@@ -2751,7 +2747,8 @@ int iscsi_offload_mesg(struct Scsi_Host *shost,
  
  	memcpy((char *)ev + sizeof(*ev), data, data_size);
  
-	return iscsi_multicast_skb(skb, ISCSI_NL_GRP_UIP, GFP_ATOMIC);

+   net = iscsi_host_net(shost->shost_data);
+   return iscsi_multicast_skb(net, skb, ISCSI_NL_GRP_UIP, GFP_ATOMIC);
  }
  EXPORT_SYMBOL_GPL(iscsi_offload_mesg);
  
@@ -2761,6 +2758,7 @@ void iscsi_conn_error_event(struct iscsi_cls_conn *conn, enum iscsi_err error)

struct sk_buff  *skb;
struct iscsi_uevent *ev;
struct iscsi_internal *priv;
+   struct net *net;
int len = nlmsg_total_size(sizeof(*ev));
unsigned long flags;
int state;
@@ -2808,7 +2806,8 @@ void iscsi_conn_error_event(struct iscsi_cls_conn *conn, 
enum iscsi_err error)
ev->r.connerror.cid = conn->cid;
ev->r.connerror.sid = iscsi_conn_get_sid(conn);
  
-	iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);

+   net = iscsi_conn_net(conn);
+   iscsi_multicast_skb(net, skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
  
  	iscsi_cls_conn_printk(KERN_INFO, conn, "detected conn error (%d)\n",

  error);
@@ -2822,6 +2821,7 @@ void iscsi_conn_login_event(struct iscsi_cls_conn *conn,
struct sk_buff  *skb;
struct iscsi_uevent *ev;
struct iscsi_internal *priv;
+   struct net *net;
int len = nlmsg_total_size(sizeof(*ev));
  
  	priv = iscsi_if_transport_lookup(conn->transport);

@@ -2842,7 +2842,9 @@ void iscsi_conn_login_event(struct iscsi_cls_conn *conn,
ev->r.conn_login.state = state;
ev->r.conn_login.cid = conn->cid;
ev->r.conn_login.sid = iscsi_conn_get_sid(conn);
-   iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
+
+   net = iscsi_conn_net(conn);
+   iscsi_multicast_skb(net, skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
  
  	iscsi_cls_conn_printk(KERN_INFO, conn, "detected conn login (%d)\n",

  state);
@@ -2853,11 +2855,17 @@ void iscsi_post_host_event(uint32_t host_no, struct 
iscsi_transport *transport,
   enum iscsi_host_event_code code, uint32_t data_size,
   uint8_t *data)
  {
+   struct Scsi_Host *shost;
+   struct net *net;
struct nlmsghdr *nlh;
struct 

[RFC PATCH 4/9] iscsi: make all iSCSI netlink multicast namespace aware

2023-02-08 Thread Lee Duncan
From: Lee Duncan 

Make use of the per-net netlink sockets. Responses are sent back on the
same socket/namespace the request was received on.  Async events are
reported on the socket/namespace stored in the iscsi_cls_host associated
with the event.

Signed-off-by: Chris Leech 
Signed-off-by: Lee Duncan 
---
 drivers/scsi/scsi_transport_iscsi.c | 92 +++--
 1 file changed, 60 insertions(+), 32 deletions(-)

diff --git a/drivers/scsi/scsi_transport_iscsi.c 
b/drivers/scsi/scsi_transport_iscsi.c
index 2e2b291bce41..230b43d34c5f 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -2653,8 +2653,8 @@ iscsi_if_transport_lookup(struct iscsi_transport *tt)
 }
 
 static int
-iscsi_multicast_netns(struct net *net, struct sk_buff *skb,
- uint32_t group, gfp_t gfp)
+iscsi_multicast_skb(struct net *net, struct sk_buff *skb,
+   uint32_t group, gfp_t gfp)
 {
struct sock *nls;
struct iscsi_net *isn;
@@ -2665,17 +2665,10 @@ iscsi_multicast_netns(struct net *net, struct sk_buff 
*skb,
 }
 
 static int
-iscsi_multicast_skb(struct sk_buff *skb, uint32_t group, gfp_t gfp)
-{
-   return iscsi_multicast_netns(_net, skb, group, gfp);
-}
-
-static int
-iscsi_unicast_skb(struct sk_buff *skb, u32 portid)
+iscsi_unicast_skb(struct net *net, struct sk_buff *skb, u32 portid)
 {
struct sock *nls;
struct iscsi_net *isn;
-   struct net *net = _net;
 
isn = net_generic(net, iscsi_net_id);
nls = isn->nls;
@@ -2690,6 +2683,7 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct 
iscsi_hdr *hdr,
struct iscsi_uevent *ev;
char *pdu;
struct iscsi_internal *priv;
+   struct net *net;
int len = nlmsg_total_size(sizeof(*ev) + sizeof(struct iscsi_hdr) +
   data_size);
 
@@ -2716,7 +2710,8 @@ int iscsi_recv_pdu(struct iscsi_cls_conn *conn, struct 
iscsi_hdr *hdr,
memcpy(pdu, hdr, sizeof(struct iscsi_hdr));
memcpy(pdu + sizeof(struct iscsi_hdr), data, data_size);
 
-   return iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
+   net = iscsi_conn_net(conn);
+   return iscsi_multicast_skb(net, skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
 }
 EXPORT_SYMBOL_GPL(iscsi_recv_pdu);
 
@@ -2727,6 +2722,7 @@ int iscsi_offload_mesg(struct Scsi_Host *shost,
struct nlmsghdr *nlh;
struct sk_buff *skb;
struct iscsi_uevent *ev;
+   struct net *net;
int len = nlmsg_total_size(sizeof(*ev) + data_size);
 
skb = alloc_skb(len, GFP_ATOMIC);
@@ -2751,7 +2747,8 @@ int iscsi_offload_mesg(struct Scsi_Host *shost,
 
memcpy((char *)ev + sizeof(*ev), data, data_size);
 
-   return iscsi_multicast_skb(skb, ISCSI_NL_GRP_UIP, GFP_ATOMIC);
+   net = iscsi_host_net(shost->shost_data);
+   return iscsi_multicast_skb(net, skb, ISCSI_NL_GRP_UIP, GFP_ATOMIC);
 }
 EXPORT_SYMBOL_GPL(iscsi_offload_mesg);
 
@@ -2761,6 +2758,7 @@ void iscsi_conn_error_event(struct iscsi_cls_conn *conn, 
enum iscsi_err error)
struct sk_buff  *skb;
struct iscsi_uevent *ev;
struct iscsi_internal *priv;
+   struct net *net;
int len = nlmsg_total_size(sizeof(*ev));
unsigned long flags;
int state;
@@ -2808,7 +2806,8 @@ void iscsi_conn_error_event(struct iscsi_cls_conn *conn, 
enum iscsi_err error)
ev->r.connerror.cid = conn->cid;
ev->r.connerror.sid = iscsi_conn_get_sid(conn);
 
-   iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
+   net = iscsi_conn_net(conn);
+   iscsi_multicast_skb(net, skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
 
iscsi_cls_conn_printk(KERN_INFO, conn, "detected conn error (%d)\n",
  error);
@@ -2822,6 +2821,7 @@ void iscsi_conn_login_event(struct iscsi_cls_conn *conn,
struct sk_buff  *skb;
struct iscsi_uevent *ev;
struct iscsi_internal *priv;
+   struct net *net;
int len = nlmsg_total_size(sizeof(*ev));
 
priv = iscsi_if_transport_lookup(conn->transport);
@@ -2842,7 +2842,9 @@ void iscsi_conn_login_event(struct iscsi_cls_conn *conn,
ev->r.conn_login.state = state;
ev->r.conn_login.cid = conn->cid;
ev->r.conn_login.sid = iscsi_conn_get_sid(conn);
-   iscsi_multicast_skb(skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
+
+   net = iscsi_conn_net(conn);
+   iscsi_multicast_skb(net, skb, ISCSI_NL_GRP_ISCSID, GFP_ATOMIC);
 
iscsi_cls_conn_printk(KERN_INFO, conn, "detected conn login (%d)\n",
  state);
@@ -2853,11 +2855,17 @@ void iscsi_post_host_event(uint32_t host_no, struct 
iscsi_transport *transport,
   enum iscsi_host_event_code code, uint32_t data_size,
   uint8_t *data)
 {
+   struct Scsi_Host *shost;
+   struct net *net;
struct nlmsghdr *nlh;
struct sk_buff *skb;
struct