Skip to contentSkip to conversation

libiscsi dhcp handler

RFC-PATCH Rakesh Ranjan 4 participants 9 messages Nov 16, 2009 – Jan 5, 2010

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

Hi mike,

Herein attached patches to support dhcp based provisioning for iSCSI offload capable cards. I have made dhcp code as generic as possible, please go through the code. Based on the feedback I will submit final version of these patches.

Regards
Rakesh Ranjan

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "open-iscsi" group. To post to this group, send email to open-iscsi-/[email protected]
To unsubscribe from this group, send email to open-iscsi+unsubscribe-/[email protected] For more options, visit this group at http://groups.google.com/group/open-iscsi
-~----------~----~----~----~------~----~------~--~---

Quoted 1 line

From 472d53f2ca0122b7fbfeabbcbde2c9a15499042b Mon Sep 17 00:00:00 2001

From: Rakesh Ranjan <[email protected]>
Date: Mon, 16 Nov 2009 18:11:56 +0530
Subject: [PATCH 1/2] Required changes for libiscsi to support dhcp based provisioning for offload capable cards.

These changes adds ISCSI_UEVENT_REQ_IPCONF message to invoke dhcp handler.

---
 Makefile                            |    3 ++-
 include/scsi/iscsi_if.h             |    4 ++++
 include/scsi/libiscsi.h             |   20 ++++++++++++++++++++
 include/scsi/scsi_transport_iscsi.h |    1 +
 scsi_transport_iscsi.c              |   25 +++++++++++++++++++++++++
 5 files changed, 52 insertions(+), 1 deletions(-)
Makefile +2 -1
index 26d33e5..3e5d461 100644
@@ -2,10 +2,11 @@
 # libiscsi modules
 #
 ifneq ($(KERNELRELEASE),)
-	obj-m += libiscsi.o
 	obj-m += libiscsi_tcp.o
 	obj-m += scsi_transport_iscsi.o
 	obj-m += iscsi_tcp.o
+	obj-m += libiscsi.o
+	obj-m += libiscsi_ipconfig.o
 	EXTRA_CFLAGS += -I$(src)/include
 	
 else
include/scsi/iscsi_if.h +4 -0
index d67dda2..135f229 100644
@@ -59,6 +59,7 @@ enum iscsi_uevent_e {
 	ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST	= UEVENT_BASE + 19,
 
 	ISCSI_UEVENT_PATH_UPDATE	= UEVENT_BASE + 20,
+	ISCSI_UEVENT_REQ_IPCONF		= UEVENT_BASE + 21,
 
 	/* up events */
 	ISCSI_KEVENT_RECV_PDU		= KEVENT_BASE + 1,
@@ -172,6 +173,9 @@ struct iscsi_uevent {
 		struct msg_set_path {
 			uint32_t	host_no;
 		} set_path;
+		struct mag_req_ipconf {
+			uint32_t	host_no;
+		} req_ipconf;
 	} u;
 	union {
 		/* messages k -> u */
include/scsi/libiscsi.h +20 -0
index a72edd4..a9af95e 100644
@@ -330,6 +330,18 @@ struct iscsi_host {
 	char			workq_name[20];
 };
 
+/* libiscsi ipconfig */
+struct dhcp_info {
+	__be32 ltime;
+	__be32 serverid;
+	__be32 ipaddr;
+	__be32 netmask;
+	__be32 dnsaddr;
+	__be32 gipaddr;
+	__u8 *mac_addr;
+};
+
+
 /*
  * scsi host template
  */
@@ -427,6 +439,14 @@ extern void iscsi_pool_free(struct iscsi_pool *);
 extern int iscsi_pool_init(struct iscsi_pool *, int, void ***, int);
 
 /*
+ * libiscsi ipconfig helpers
+ */
+extern int libiscsi_do_ipconf(struct net_device *ndev,
+				struct dhcp_info *dinfo);
+extern int libiscsi_ipconfig_recv(struct net_device *ndev,
+					struct sk_buff *skb);
+
+/*
  * inline functions to deal with padding.
  */
 static inline unsigned int
include/scsi/scsi_transport_iscsi.h +1 -0
index 349c7f3..3e5fd96 100644
@@ -134,6 +134,7 @@ struct iscsi_transport {
 	int (*tgt_dscvr) (struct Scsi_Host *shost, enum iscsi_tgt_dscvr type,
 			  uint32_t enable, struct sockaddr *dst_addr);
 	int (*set_path) (struct Scsi_Host *shost, struct iscsi_path *params);
+	int (*req_ipconf) (struct Scsi_Host *shost);
 };
 
 /*
scsi_transport_iscsi.c +25 -0
index ad897df..4897a3f 100644
@@ -1508,6 +1508,28 @@ iscsi_set_path(struct iscsi_transport *transport, struct iscsi_uevent *ev)
 }
 
 static int
+iscsi_req_ipconf(struct iscsi_transport *transport, struct iscsi_uevent *ev)
+{
+	struct Scsi_Host *shost;
+	int err;
+
+	if (!transport->req_ipconf)
+		return -ENOSYS;
+
+	shost = scsi_host_lookup(ev->u.req_ipconf.host_no);
+	if (!shost) {
+		printk(KERN_ERR "ipconf req could not find host no %u\n",
+				ev->u.req_ipconf.host_no);
+		return -ENODEV;
+	}
+
+	err = transport->req_ipconf(shost);
+
+	scsi_host_put(shost);
+	return err;
+}
+
+static int
 iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
 {
 	int err = 0;
@@ -1627,6 +1649,9 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
 	case ISCSI_UEVENT_PATH_UPDATE:
 		err = iscsi_set_path(transport, ev);
 		break;
+	case ISCSI_UEVENT_REQ_IPCONF:
+		err = iscsi_req_ipconf(transport, ev);
+		break;
 	default:
 		err = -ENOSYS;
 		break;
Signature · 1 line
1.6.0.6
Quoted 1 line

From 8df0fd4d0a972bd76bb71d7fdac274b273cec50d Mon Sep 17 00:00:00 2001

From: Rakesh Ranjan <[email protected]>
Date: Mon, 16 Nov 2009 18:32:57 +0530
Subject: [PATCH 2/2] dhcp handler for libiscsi to support dhcp provisioning for offload capable cards.

This module contains a compact dhcp handler to support dhcp based provisioning for offload capable cards.

---
 libiscsi_ipconfig.c |  466 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 466 insertions(+), 0 deletions(-)
 create mode 100644 libiscsi_ipconfig.c
libiscsi_ipconfig.c new file +466 -0

466 lines not on this page · raw message

Signature · 1 line
1.6.0.6
maintainer
#1 lore raw

From: Rakesh Ranjan <[email protected]>
Date: Mon, 16 Nov 2009 18:41:49 +0530

Quoted 4 lines

Herein attached patches to support dhcp based provisioning for iSCSI offload capable cards. I have made dhcp code as generic as possible, please go through the code. Based on the feedback I will submit final version of these patches.

You can't really add objects to the build before the patch that adds the source for that object.

#2 lore raw
Quoted 11 lines · David Miller

From: Rakesh Ranjan <[email protected]>
Date: Mon, 16 Nov 2009 18:41:49 +0530

Quoted 4 lines

Herein attached patches to support dhcp based provisioning for iSCSI offload capable cards. I have made dhcp code as generic as possible, please go through the code. Based on the feedback I will submit final version of these patches.

You can't really add objects to the build before the patch that adds the source for that object.

my mistake, the makefile part of patch is irrelevant. Will send new patch in few mins.

Regards
Rakesh Ranjan

#3 lore raw
In reply to David Miller
Quoted 11 lines · David Miller

From: Rakesh Ranjan <[email protected]>
Date: Mon, 16 Nov 2009 18:41:49 +0530

Quoted 4 lines

Herein attached patches to support dhcp based provisioning for iSCSI offload capable cards. I have made dhcp code as generic as possible, please go through the code. Based on the feedback I will submit final version of these patches.

You can't really add objects to the build before the patch that adds the source for that object.

Hi david,

Fixed patch attached.

Regards
Rakesh Ranjan

Quoted 1 line

From a643bfb01c4edbb2e686dd2500a564c93d402bba Mon Sep 17 00:00:00 2001

From: Rakesh Ranjan <[email protected]>
Date: Mon, 16 Nov 2009 19:07:40 +0530
Subject: [PATCH 1/2] Required changes for libiscsi to support dhcp based provisioning for offload capable cards.

These changes adds ISCSI_UEVENT_REQ_IPCONF message to invoke dhcp handler.

---
 drivers/scsi/scsi_transport_iscsi.c |   25 +++++++++++++++++++++++++
 include/scsi/iscsi_if.h             |    4 ++++
 include/scsi/libiscsi.h             |   20 ++++++++++++++++++++
 include/scsi/scsi_transport_iscsi.h |    1 +
 4 files changed, 50 insertions(+), 0 deletions(-)
drivers/scsi/scsi_transport_iscsi.c +25 -0
index ad897df..4897a3f 100644
@@ -1508,6 +1508,28 @@ iscsi_set_path(struct iscsi_transport *transport, struct iscsi_uevent *ev)
 }
 
 static int
+iscsi_req_ipconf(struct iscsi_transport *transport, struct iscsi_uevent *ev)
+{
+	struct Scsi_Host *shost;
+	int err;
+
+	if (!transport->req_ipconf)
+		return -ENOSYS;
+
+	shost = scsi_host_lookup(ev->u.req_ipconf.host_no);
+	if (!shost) {
+		printk(KERN_ERR "ipconf req could not find host no %u\n",
+				ev->u.req_ipconf.host_no);
+		return -ENODEV;
+	}
+
+	err = transport->req_ipconf(shost);
+
+	scsi_host_put(shost);
+	return err;
+}
+
+static int
 iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
 {
 	int err = 0;
@@ -1627,6 +1649,9 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
 	case ISCSI_UEVENT_PATH_UPDATE:
 		err = iscsi_set_path(transport, ev);
 		break;
+	case ISCSI_UEVENT_REQ_IPCONF:
+		err = iscsi_req_ipconf(transport, ev);
+		break;
 	default:
 		err = -ENOSYS;
 		break;
include/scsi/iscsi_if.h +4 -0
index d67dda2..135f229 100644
@@ -59,6 +59,7 @@ enum iscsi_uevent_e {
 	ISCSI_UEVENT_TRANSPORT_EP_CONNECT_THROUGH_HOST	= UEVENT_BASE + 19,
 
 	ISCSI_UEVENT_PATH_UPDATE	= UEVENT_BASE + 20,
+	ISCSI_UEVENT_REQ_IPCONF		= UEVENT_BASE + 21,
 
 	/* up events */
 	ISCSI_KEVENT_RECV_PDU		= KEVENT_BASE + 1,
@@ -172,6 +173,9 @@ struct iscsi_uevent {
 		struct msg_set_path {
 			uint32_t	host_no;
 		} set_path;
+		struct mag_req_ipconf {
+			uint32_t	host_no;
+		} req_ipconf;
 	} u;
 	union {
 		/* messages k -> u */
include/scsi/libiscsi.h +20 -0
index a72edd4..a9af95e 100644
@@ -330,6 +330,18 @@ struct iscsi_host {
 	char			workq_name[20];
 };
 
+/* libiscsi ipconfig */
+struct dhcp_info {
+	__be32 ltime;
+	__be32 serverid;
+	__be32 ipaddr;
+	__be32 netmask;
+	__be32 dnsaddr;
+	__be32 gipaddr;
+	__u8 *mac_addr;
+};
+
+
 /*
  * scsi host template
  */
@@ -427,6 +439,14 @@ extern void iscsi_pool_free(struct iscsi_pool *);
 extern int iscsi_pool_init(struct iscsi_pool *, int, void ***, int);
 
 /*
+ * libiscsi ipconfig helpers
+ */
+extern int libiscsi_do_ipconf(struct net_device *ndev,
+				struct dhcp_info *dinfo);
+extern int libiscsi_ipconfig_recv(struct net_device *ndev,
+					struct sk_buff *skb);
+
+/*
  * inline functions to deal with padding.
  */
 static inline unsigned int
include/scsi/scsi_transport_iscsi.h +1 -0
index 349c7f3..3e5fd96 100644
@@ -134,6 +134,7 @@ struct iscsi_transport {
 	int (*tgt_dscvr) (struct Scsi_Host *shost, enum iscsi_tgt_dscvr type,
 			  uint32_t enable, struct sockaddr *dst_addr);
 	int (*set_path) (struct Scsi_Host *shost, struct iscsi_path *params);
+	int (*req_ipconf) (struct Scsi_Host *shost);
 };
 
 /*
Signature · 1 line
1.6.0.6
Quoted 1 line

From 604f882083472b515342c43790eb252dd0e9a18b Mon Sep 17 00:00:00 2001

From: Rakesh Ranjan <[email protected]>
Date: Mon, 16 Nov 2009 19:10:00 +0530
Subject: [PATCH 2/2] dhcp handler for libiscsi to support dhcp provisioning for offload capable cards.

This module contains a compact dhcp handler to support dhcp based provisioning for offload capable cards.

---
 drivers/scsi/Makefile            |    2 +-
 drivers/scsi/libiscsi_ipconfig.c |  466 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 467 insertions(+), 1 deletions(-)
 create mode 100644 drivers/scsi/libiscsi_ipconfig.c
drivers/scsi/Makefile +1 -1
index 3ad61db..c53355f 100644
@@ -129,7 +129,7 @@ obj-$(CONFIG_SCSI_HPTIOP)	+= hptiop.o
 obj-$(CONFIG_SCSI_STEX)		+= stex.o
 obj-$(CONFIG_SCSI_MVSAS)	+= mvsas/
 obj-$(CONFIG_PS3_ROM)		+= ps3rom.o
-obj-$(CONFIG_SCSI_CXGB3_ISCSI)	+= libiscsi.o libiscsi_tcp.o cxgb3i/
+obj-$(CONFIG_SCSI_CXGB3_ISCSI)	+= libiscsi.o libiscsi_ipconfig.o libiscsi_tcp.o cxgb3i/
 obj-$(CONFIG_SCSI_BNX2_ISCSI)	+= libiscsi.o bnx2i/
 obj-$(CONFIG_BE2ISCSI)		+= libiscsi.o be2iscsi/
 obj-$(CONFIG_SCSI_PMCRAID)	+= pmcraid.o
drivers/scsi/libiscsi_ipconfig.c new file +466 -0

466 lines not on this page · raw message

Signature · 1 line
1.6.0.6
#4 lore raw
Quoted 8 lines · Rakesh Ranjan
Quoted 7 lines · David Miller

From: Rakesh Ranjan <[email protected]>
Date: Mon, 16 Nov 2009 18:41:49 +0530

Quoted 4 lines

Herein attached patches to support dhcp based provisioning for iSCSI offload capable cards. I have made dhcp code as generic as possible, please go through the code. Based on the feedback I will submit final version of these patches.

Quoted 7 lines
Quoted 3 lines

You can't really add objects to the build before the patch that adds the source for that object.

Hi david,

Fixed patch attached.

ping ...

--

You received this message because you are subscribed to the Google Groups "open-iscsi" group.
To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/[email protected] To unsubscribe from this group, send email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=.

maintainer
#5 lore raw

From: Rakesh Ranjan <[email protected]>
Date: Wed, 18 Nov 2009 08:56:55 +0530

Quoted 1 line

ping ...

I'm too busy, if you're waiting for me. It could take weeks for me to get to this, sorry.

#6 lore raw
In reply to Rakesh Ranjan
Quoted 13 lines · Rakesh Ranjan
Quoted 11 lines · David Miller

From: Rakesh Ranjan <[email protected]>
Date: Mon, 16 Nov 2009 18:41:49 +0530

Quoted 4 lines

Herein attached patches to support dhcp based provisioning for iSCSI offload capable cards. I have made dhcp code as generic as possible, please go through the code. Based on the feedback I will submit final version of these patches.

You can't really add objects to the build before the patch that adds the source for that object.

Quoted 7 lines

Hi david,

Fixed patch attached.

Regards
Rakesh Ranjan

The header file changes cause warnings in allmodconfig.

CC [M] drivers/scsi/be2iscsi/be_iscsi.o
+In file included from drivers/scsi/be2iscsi/be_iscsi.c:21:
+include/scsi/libiscsi.h:445: warning: ‘struct net_device’ declared inside parameter list
+include/scsi/libiscsi.h:445: warning: its scope is only this definition or declaration, which is probably not what you want +include/scsi/libiscsi.h:447: warning: ‘struct sk_buff’ declared inside parameter list
+include/scsi/libiscsi.h:447: warning: ‘struct net_device’ declared inside parameter list

regards,
dan carpenter

#7 lore raw
Quoted 10 lines · Dan Carpenter
Quoted 9 lines · Rakesh Ranjan
Quoted 8 lines · David Miller

From: Rakesh Ranjan <[email protected]>
Date: Mon, 16 Nov 2009 18:41:49 +0530

Quoted 4 lines

Herein attached patches to support dhcp based provisioning for iSCSI offload capable cards. I have made dhcp code as generic as possible, please go through the code. Based on the feedback I will submit final version of these patches.

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

You can't really add objects to the build before the patch that adds the source for that object.

Hi david,

Fixed patch attached.

+ spin_unlock(&rcv_lock);
+
+drop:
+ kfree(pskb);

This should be kfree_skb(pskb)

+out:
+ return rc;
+}
+EXPORT_SYMBOL(libiscsi_ipconfig_recv);

regards,
dan carpenter

maintainer
#8 lore raw
In reply to Rakesh Ranjan

From: Rakesh Ranjan <[email protected]>
Date: Mon, 16 Nov 2009 19:15:34 +0530

drivers/scsi/libiscsi_ipconfig.c line 356

Quoted 5 lines
drivers/scsi/libiscsi_ipconfig.c new file +5 -0
+	/* Construct UDP header */
+	udph = &pkt->udph;
+	udph->source = htons(DHCPC_CLIENT_PORT);
+	udph->dest = htons(DHCPC_SERVER_PORT);
+	udph->len = htons(sizeof(struct dhcp_pkt) - sizeof(struct iphdr));

UDP checksum is not set, and is also not validated on receive.