Mike Christie 3949e1
diff -Naurp open-iscsi-2.0-872-rc4-bnx2i/include/iscsi_if.h open-iscsi-2.0-872-rc4-bnx2i.work/include/iscsi_if.h
Mike Christie 3949e1
--- open-iscsi-2.0-872-rc4-bnx2i/include/iscsi_if.h	2011-10-10 13:57:38.000000000 -0500
Mike Christie 3949e1
+++ open-iscsi-2.0-872-rc4-bnx2i.work/include/iscsi_if.h	2011-10-11 00:40:49.000000000 -0500
Mike Christie 3949e1
@@ -320,10 +320,11 @@ enum iscsi_net_param {
Mike Christie 3949e1
 	ISCSI_NET_PARAM_VLAN_ID			= 13,
Mike Christie 3949e1
 	ISCSI_NET_PARAM_VLAN_PRIORITY		= 14,
Mike Christie 3949e1
 	ISCSI_NET_PARAM_VLAN_ENABLED		= 15,
Mike Christie 3949e1
-	ISCSI_NET_PARAM_IFACE_TYPE		= 16,
Mike Christie 3949e1
-	ISCSI_NET_PARAM_IFACE_NAME		= 17,
Mike Christie 3949e1
-	ISCSI_NET_PARAM_MTU			= 18,
Mike Christie 3949e1
-	ISCSI_NET_PARAM_PORT			= 19,
Mike Christie 3949e1
+	ISCSI_NET_PARAM_VLAN_TAG		= 16,
Mike Christie 3949e1
+	ISCSI_NET_PARAM_IFACE_TYPE		= 17,
Mike Christie 3949e1
+	ISCSI_NET_PARAM_IFACE_NAME		= 18,
Mike Christie 3949e1
+	ISCSI_NET_PARAM_MTU			= 19,
Mike Christie 3949e1
+	ISCSI_NET_PARAM_PORT			= 20,
Mike Christie 3949e1
 };
Mike Christie 3949e1
 
Mike Christie 3949e1
 enum iscsi_conn_state {
Mike Christie 3949e1
diff -Naurp open-iscsi-2.0-872-rc4-bnx2i/usr/host.c open-iscsi-2.0-872-rc4-bnx2i.work/usr/host.c
Mike Christie 3949e1
--- open-iscsi-2.0-872-rc4-bnx2i/usr/host.c	2011-10-10 13:57:38.000000000 -0500
Mike Christie 3949e1
+++ open-iscsi-2.0-872-rc4-bnx2i.work/usr/host.c	2011-10-11 00:41:01.000000000 -0500
Mike Christie 3949e1
@@ -132,22 +132,67 @@ static int print_host_iface(void *data, 
Mike Christie 3949e1
 		printf("%sIPaddress: %s\n", prefix, UNKNOWN_VALUE);
Mike Christie 3949e1
 	else if (strchr(iface->ipaddress, '.')) {
Mike Christie 3949e1
 		printf("%sIPaddress: %s\n", prefix, iface->ipaddress);
Mike Christie 3949e1
-		printf("%sGateway: %s\n", prefix, iface->gateway);
Mike Christie 3949e1
-		printf("%sSubnet: %s\n", prefix, iface->subnet_mask);
Mike Christie 3949e1
-		printf("%sBootProto: %s\n", prefix, iface->bootproto);
Mike Christie 3949e1
+
Mike Christie 3949e1
+		if (!strlen(iface->gateway))
Mike Christie 3949e1
+			printf("%sGateway: %s\n", prefix, UNKNOWN_VALUE);
Mike Christie 3949e1
+		else
Mike Christie 3949e1
+			printf("%sGateway: %s\n", prefix, iface->gateway);
Mike Christie 3949e1
+		if (!strlen(iface->subnet_mask))
Mike Christie 3949e1
+			printf("%sSubnet: %s\n", prefix, UNKNOWN_VALUE);
Mike Christie 3949e1
+		else
Mike Christie 3949e1
+			printf("%sSubnet: %s\n", prefix, iface->subnet_mask);
Mike Christie 3949e1
+		if (!strlen(iface->bootproto))
Mike Christie 3949e1
+			printf("%sBootProto: %s\n", prefix, UNKNOWN_VALUE);
Mike Christie 3949e1
+		else
Mike Christie 3949e1
+			printf("%sBootProto: %s\n", prefix, iface->bootproto);
Mike Christie 3949e1
 	} else {
Mike Christie 3949e1
 		printf("%sIPaddress: [%s]\n", prefix, iface->ipaddress);
Mike Christie 3949e1
-		printf("%sIPaddress Autocfg: %s\n", prefix, iface->ipv6_autocfg);
Mike Christie 3949e1
-		printf("%sLink Local Address: [%s]\n", prefix,
Mike Christie 3949e1
-		       iface->ipv6_linklocal);
Mike Christie 3949e1
-		printf("%sLink Local Autocfg: %s\n", prefix,
Mike Christie 3949e1
-		       iface->linklocal_autocfg);
Mike Christie 3949e1
-		printf("%sRouter Address: [%s]\n", prefix, iface->ipv6_router);
Mike Christie 3949e1
+
Mike Christie 3949e1
+		if (!strlen(iface->ipv6_autocfg))
Mike Christie 3949e1
+			printf("%sIPaddress Autocfg: %s\n", prefix,
Mike Christie 3949e1
+			       UNKNOWN_VALUE);
Mike Christie 3949e1
+		else
Mike Christie 3949e1
+			printf("%sIPaddress Autocfg: %s\n", prefix,
Mike Christie 3949e1
+			       iface->ipv6_autocfg);
Mike Christie 3949e1
+		if (!strlen(iface->ipv6_linklocal))
Mike Christie 3949e1
+			printf("%sLink Local Address: %s\n", prefix,
Mike Christie 3949e1
+			       UNKNOWN_VALUE);
Mike Christie 3949e1
+		else
Mike Christie 3949e1
+			printf("%sLink Local Address: [%s]\n", prefix,
Mike Christie 3949e1
+			       iface->ipv6_linklocal);
Mike Christie 3949e1
+		if (!strlen(iface->linklocal_autocfg))
Mike Christie 3949e1
+			printf("%sLink Local Autocfg: %s\n", prefix,
Mike Christie 3949e1
+			       UNKNOWN_VALUE);
Mike Christie 3949e1
+		else
Mike Christie 3949e1
+			printf("%sLink Local Autocfg: %s\n", prefix,
Mike Christie 3949e1
+			       iface->linklocal_autocfg);
Mike Christie 3949e1
+		if (!strlen(iface->ipv6_router))
Mike Christie 3949e1
+			printf("%sRouter Address: %s\n", prefix,
Mike Christie 3949e1
+			      UNKNOWN_VALUE);
Mike Christie 3949e1
+		else
Mike Christie 3949e1
+			printf("%sRouter Address: [%s]\n", prefix,
Mike Christie 3949e1
+			       iface->ipv6_router);
Mike Christie 3949e1
 	}
Mike Christie 3949e1
 
Mike Christie 3949e1
-	printf("%sMTU: %u\n", prefix, iface->mtu);
Mike Christie 3949e1
-	printf("%svlan ID: %u\n", prefix, iface->vlan_id);
Mike Christie 3949e1
-	printf("%svlan priority: %u\n", prefix, iface->vlan_priority);
Mike Christie 3949e1
+	if (!iface->port)
Mike Christie 3949e1
+		printf("%sPort: %s\n", prefix, UNKNOWN_VALUE);
Mike Christie 3949e1
+	else
Mike Christie 3949e1
+		printf("%sPort: %u\n", prefix, iface->port);
Mike Christie 3949e1
+
Mike Christie 3949e1
+	if (!iface->mtu)
Mike Christie 3949e1
+		printf("%sMTU: %s\n", prefix, UNKNOWN_VALUE);
Mike Christie 3949e1
+	else
Mike Christie 3949e1
+		printf("%sMTU: %u\n", prefix, iface->mtu);
Mike Christie 3949e1
+
Mike Christie 3949e1
+	if (iface->vlan_id == UINT16_MAX)
Mike Christie 3949e1
+		printf("%sVLAN ID: %s\n", prefix, UNKNOWN_VALUE);
Mike Christie 3949e1
+	else
Mike Christie 3949e1
+		printf("%sVLAN ID: %u\n", prefix, iface->vlan_id);
Mike Christie 3949e1
+
Mike Christie 3949e1
+	if (iface->vlan_priority == UINT8_MAX)
Mike Christie 3949e1
+		printf("%sVLAN priority: %s\n", prefix, UNKNOWN_VALUE);
Mike Christie 3949e1
+	else
Mike Christie 3949e1
+		printf("%sVLAN priority: %u\n", prefix, iface->vlan_priority);
Mike Christie 3949e1
 	return 0;
Mike Christie 3949e1
 }
Mike Christie 3949e1
 
Mike Christie 3949e1
diff -Naurp open-iscsi-2.0-872-rc4-bnx2i/usr/iface.c open-iscsi-2.0-872-rc4-bnx2i.work/usr/iface.c
Mike Christie 3949e1
--- open-iscsi-2.0-872-rc4-bnx2i/usr/iface.c	2011-10-10 13:57:38.000000000 -0500
Mike Christie 3949e1
+++ open-iscsi-2.0-872-rc4-bnx2i.work/usr/iface.c	2011-10-11 00:40:49.000000000 -0500
Mike Christie 3949e1
@@ -41,6 +41,7 @@
Mike Christie 3949e1
 #include "fw_context.h"
Mike Christie 3949e1
 #include "sysdeps.h"
Mike Christie 3949e1
 #include "iscsi_err.h"
Mike Christie 3949e1
+#include "iscsi_netlink.h"
Mike Christie 3949e1
 
Mike Christie 3949e1
 /*
Mike Christie 3949e1
  * Default ifaces for use with transports that do not bind to hardware
Mike Christie 3949e1
@@ -1141,14 +1142,16 @@ static int iface_fill_port(struct iovec 
Mike Christie 3949e1
 	int len;
Mike Christie 3949e1
 	struct iscsi_iface_param_info *net_param;
Mike Christie 3949e1
 	uint16_t port = 3260;
Mike Christie 3949e1
+	struct nlattr *attr;
Mike Christie 3949e1
 
Mike Christie 3949e1
-	len = sizeof(struct iscsi_iface_param_info) + 2;
Mike Christie 3949e1
-	iov->iov_base = calloc(len, sizeof(char));
Mike Christie 3949e1
-	if (!(iov->iov_base))
Mike Christie 3949e1
+	len = sizeof(struct iscsi_iface_param_info) + sizeof(port);
Mike Christie 3949e1
+	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_PORT, len);
Mike Christie 3949e1
+	if (!iov->iov_base)
Mike Christie 3949e1
 		return 1;
Mike Christie 3949e1
+	attr = iov->iov_base;
Mike Christie 3949e1
+	iov->iov_len = NLA_ALIGN(attr->nla_len);
Mike Christie 3949e1
 
Mike Christie 3949e1
-	iov->iov_len = len;
Mike Christie 3949e1
-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
Mike Christie 3949e1
+	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
Mike Christie 3949e1
 	net_param->param = ISCSI_NET_PARAM_PORT;
Mike Christie 3949e1
 	net_param->iface_type = iface_type;
Mike Christie 3949e1
 	net_param->iface_num = iface->iface_num;
Mike Christie 3949e1
@@ -1166,14 +1169,16 @@ static int iface_fill_mtu(struct iovec *
Mike Christie 3949e1
 	int len;
Mike Christie 3949e1
 	struct iscsi_iface_param_info *net_param;
Mike Christie 3949e1
 	uint16_t mtu = 0;
Mike Christie 3949e1
+	struct nlattr *attr;
Mike Christie 3949e1
 
Mike Christie 3949e1
 	len = sizeof(struct iscsi_iface_param_info) + 2;
Mike Christie 3949e1
-	iov->iov_base = calloc(len, sizeof(char));
Mike Christie 3949e1
+	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_MTU, len);
Mike Christie 3949e1
 	if (!(iov->iov_base))
Mike Christie 3949e1
 		return 1;
Mike Christie 3949e1
+	attr = iov->iov_base;
Mike Christie 3949e1
+	iov->iov_len = NLA_ALIGN(attr->nla_len);
Mike Christie 3949e1
 
Mike Christie 3949e1
-	iov->iov_len = len;
Mike Christie 3949e1
-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
Mike Christie 3949e1
+	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
Mike Christie 3949e1
 	net_param->param = ISCSI_NET_PARAM_MTU;
Mike Christie 3949e1
 	net_param->iface_type = iface_type;
Mike Christie 3949e1
 	net_param->iface_num = iface->iface_num;
Mike Christie 3949e1
@@ -1191,15 +1196,17 @@ static int iface_fill_vlan_id(struct iov
Mike Christie 3949e1
 	int len;
Mike Christie 3949e1
 	struct iscsi_iface_param_info *net_param;
Mike Christie 3949e1
 	uint16_t vlan = 0;
Mike Christie 3949e1
+	struct nlattr *attr;
Mike Christie 3949e1
 
Mike Christie 3949e1
 	len = sizeof(struct iscsi_iface_param_info) + 2;
Mike Christie 3949e1
-	iov->iov_base = calloc(len, sizeof(char));
Mike Christie 3949e1
+	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_VLAN_TAG, len);
Mike Christie 3949e1
 	if (!(iov->iov_base))
Mike Christie 3949e1
 		return 1;
Mike Christie 3949e1
 
Mike Christie 3949e1
-	iov->iov_len = len;
Mike Christie 3949e1
-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
Mike Christie 3949e1
-	net_param->param = ISCSI_NET_PARAM_VLAN_ID;
Mike Christie 3949e1
+	attr = iov->iov_base;
Mike Christie 3949e1
+	iov->iov_len = NLA_ALIGN(attr->nla_len);
Mike Christie 3949e1
+	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
Mike Christie 3949e1
+	net_param->param = ISCSI_NET_PARAM_VLAN_TAG;
Mike Christie 3949e1
 	net_param->iface_type = iface_type;
Mike Christie 3949e1
 	net_param->iface_num = iface->iface_num;
Mike Christie 3949e1
 	net_param->param_type = ISCSI_NET_PARAM;
Mike Christie 3949e1
@@ -1222,14 +1229,16 @@ static int iface_fill_vlan_state(struct 
Mike Christie 3949e1
 {
Mike Christie 3949e1
 	int len;
Mike Christie 3949e1
 	struct iscsi_iface_param_info *net_param;
Mike Christie 3949e1
+	struct nlattr *attr;
Mike Christie 3949e1
 
Mike Christie 3949e1
 	len = sizeof(struct iscsi_iface_param_info) + 1;
Mike Christie 3949e1
-	iov->iov_base = calloc(len, sizeof(char));
Mike Christie 3949e1
+	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_VLAN_ENABLED, len);
Mike Christie 3949e1
 	if (!(iov->iov_base))
Mike Christie 3949e1
 		return 1;
Mike Christie 3949e1
 
Mike Christie 3949e1
-	iov->iov_len = len;
Mike Christie 3949e1
-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
Mike Christie 3949e1
+	attr = iov->iov_base;
Mike Christie 3949e1
+	iov->iov_len = NLA_ALIGN(attr->nla_len);
Mike Christie 3949e1
+	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
Mike Christie 3949e1
 	net_param->param = ISCSI_NET_PARAM_VLAN_ENABLED;
Mike Christie 3949e1
 	net_param->iface_type = iface_type;
Mike Christie 3949e1
 	net_param->iface_num = iface->iface_num;
Mike Christie 3949e1
@@ -1248,14 +1257,16 @@ static int iface_fill_net_state(struct i
Mike Christie 3949e1
 {
Mike Christie 3949e1
 	int len;
Mike Christie 3949e1
 	struct iscsi_iface_param_info *net_param;
Mike Christie 3949e1
+	struct nlattr *attr;
Mike Christie 3949e1
 
Mike Christie 3949e1
 	len = sizeof(struct iscsi_iface_param_info) + 1;
Mike Christie 3949e1
-	iov->iov_base = calloc(len, sizeof(char));
Mike Christie 3949e1
+	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_IFACE_ENABLE, len);
Mike Christie 3949e1
 	if (!(iov->iov_base))
Mike Christie 3949e1
 		return 1;
Mike Christie 3949e1
 
Mike Christie 3949e1
-	iov->iov_len = len;
Mike Christie 3949e1
-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
Mike Christie 3949e1
+	attr = iov->iov_base;
Mike Christie 3949e1
+	iov->iov_len = NLA_ALIGN(attr->nla_len);
Mike Christie 3949e1
+	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
Mike Christie 3949e1
 	net_param->param = ISCSI_NET_PARAM_IFACE_ENABLE;
Mike Christie 3949e1
 	net_param->iface_type = iface_type;
Mike Christie 3949e1
 	net_param->iface_num = iface->iface_num;
Mike Christie 3949e1
@@ -1273,14 +1284,16 @@ static int iface_fill_net_bootproto(stru
Mike Christie 3949e1
 {
Mike Christie 3949e1
 	int len;
Mike Christie 3949e1
 	struct iscsi_iface_param_info *net_param;
Mike Christie 3949e1
+	struct nlattr *attr;
Mike Christie 3949e1
 
Mike Christie 3949e1
 	len = sizeof(struct iscsi_iface_param_info) + 1;
Mike Christie 3949e1
-	iov->iov_base = calloc(len, sizeof(char));
Mike Christie 3949e1
+	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_IPV4_BOOTPROTO, len);
Mike Christie 3949e1
 	if (!(iov->iov_base))
Mike Christie 3949e1
 		return 1;
Mike Christie 3949e1
 
Mike Christie 3949e1
-	iov->iov_len = len;
Mike Christie 3949e1
-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
Mike Christie 3949e1
+	attr = iov->iov_base;
Mike Christie 3949e1
+	iov->iov_len = NLA_ALIGN(attr->nla_len);
Mike Christie 3949e1
+	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
Mike Christie 3949e1
 	net_param->param = ISCSI_NET_PARAM_IPV4_BOOTPROTO;
Mike Christie 3949e1
 	net_param->iface_type = ISCSI_IFACE_TYPE_IPV4;
Mike Christie 3949e1
 	net_param->iface_num = iface->iface_num;
Mike Christie 3949e1
@@ -1298,14 +1311,16 @@ static int iface_fill_net_autocfg(struct
Mike Christie 3949e1
 {
Mike Christie 3949e1
 	int len;
Mike Christie 3949e1
 	struct iscsi_iface_param_info *net_param;
Mike Christie 3949e1
+	struct nlattr *attr;
Mike Christie 3949e1
 
Mike Christie 3949e1
 	len = sizeof(struct iscsi_iface_param_info) + 1;
Mike Christie 3949e1
-	iov->iov_base = calloc(len, sizeof(char));
Mike Christie 3949e1
+	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG, len);
Mike Christie 3949e1
 	if (!(iov->iov_base))
Mike Christie 3949e1
 		return 1;
Mike Christie 3949e1
 
Mike Christie 3949e1
-	iov->iov_len = len;
Mike Christie 3949e1
-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
Mike Christie 3949e1
+	attr = iov->iov_base;
Mike Christie 3949e1
+	iov->iov_len = NLA_ALIGN(attr->nla_len);
Mike Christie 3949e1
+	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
Mike Christie 3949e1
 	net_param->param = ISCSI_NET_PARAM_IPV6_ADDR_AUTOCFG;
Mike Christie 3949e1
 	net_param->iface_type = ISCSI_IFACE_TYPE_IPV6;
Mike Christie 3949e1
 	net_param->param_type = ISCSI_NET_PARAM;
Mike Christie 3949e1
@@ -1327,14 +1342,17 @@ static int iface_fill_linklocal_autocfg(
Mike Christie 3949e1
 {
Mike Christie 3949e1
 	int len;
Mike Christie 3949e1
 	struct iscsi_iface_param_info *net_param;
Mike Christie 3949e1
+	struct nlattr *attr;
Mike Christie 3949e1
 
Mike Christie 3949e1
 	len = sizeof(struct iscsi_iface_param_info) + 1;
Mike Christie 3949e1
-	iov->iov_base = calloc(len, sizeof(char));
Mike Christie 3949e1
+	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG,
Mike Christie 3949e1
+					len);
Mike Christie 3949e1
 	if (!(iov->iov_base))
Mike Christie 3949e1
 		return 1;
Mike Christie 3949e1
 
Mike Christie 3949e1
-	iov->iov_len = len;
Mike Christie 3949e1
-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
Mike Christie 3949e1
+	attr = iov->iov_base;
Mike Christie 3949e1
+	iov->iov_len = NLA_ALIGN(attr->nla_len);
Mike Christie 3949e1
+	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
Mike Christie 3949e1
 	net_param->param = ISCSI_NET_PARAM_IPV6_LINKLOCAL_AUTOCFG;
Mike Christie 3949e1
 	net_param->iface_type = ISCSI_IFACE_TYPE_IPV6;
Mike Christie 3949e1
 	net_param->param_type = ISCSI_NET_PARAM;
Mike Christie 3949e1
@@ -1353,14 +1371,17 @@ static int iface_fill_router_autocfg(str
Mike Christie 3949e1
 {
Mike Christie 3949e1
 	int len;
Mike Christie 3949e1
 	struct iscsi_iface_param_info *net_param;
Mike Christie 3949e1
+	struct nlattr *attr;
Mike Christie 3949e1
 
Mike Christie 3949e1
 	len = sizeof(struct iscsi_iface_param_info) + 1;
Mike Christie 3949e1
-	iov->iov_base = calloc(len, sizeof(char));
Mike Christie 3949e1
+	iov->iov_base = iscsi_nla_alloc(ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG,
Mike Christie 3949e1
+					len);
Mike Christie 3949e1
 	if (!(iov->iov_base))
Mike Christie 3949e1
 		return 1;
Mike Christie 3949e1
 
Mike Christie 3949e1
-	iov->iov_len = len;
Mike Christie 3949e1
-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
Mike Christie 3949e1
+	attr = iov->iov_base;
Mike Christie 3949e1
+	iov->iov_len = NLA_ALIGN(attr->nla_len);
Mike Christie 3949e1
+	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
Mike Christie 3949e1
 	net_param->param = ISCSI_NET_PARAM_IPV6_ROUTER_AUTOCFG;
Mike Christie 3949e1
 	net_param->iface_type = ISCSI_IFACE_TYPE_IPV6;
Mike Christie 3949e1
 	net_param->param_type = ISCSI_NET_PARAM;
Mike Christie 3949e1
@@ -1381,14 +1402,16 @@ static int iface_fill_net_ipv4_addr(stru
Mike Christie 3949e1
 	int rc = 1;
Mike Christie 3949e1
 	int len;
Mike Christie 3949e1
 	struct iscsi_iface_param_info *net_param;
Mike Christie 3949e1
+	struct nlattr *attr;
Mike Christie 3949e1
 
Mike Christie 3949e1
 	len = sizeof(struct iscsi_iface_param_info) + 4;
Mike Christie 3949e1
-	iov->iov_base = calloc(len, sizeof(char));
Mike Christie 3949e1
+	iov->iov_base = iscsi_nla_alloc(param, len);
Mike Christie 3949e1
 	if (!(iov->iov_base))
Mike Christie 3949e1
 		return 1;
Mike Christie 3949e1
 
Mike Christie 3949e1
-	iov->iov_len = len;
Mike Christie 3949e1
-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
Mike Christie 3949e1
+	attr = iov->iov_base;
Mike Christie 3949e1
+	iov->iov_len = NLA_ALIGN(attr->nla_len);
Mike Christie 3949e1
+	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
Mike Christie 3949e1
 	net_param->param = param;
Mike Christie 3949e1
 	net_param->iface_type = ISCSI_IFACE_TYPE_IPV4;
Mike Christie 3949e1
 	net_param->iface_num = iface->iface_num;
Mike Christie 3949e1
@@ -1435,14 +1458,16 @@ static int iface_fill_net_ipv6_addr(stru
Mike Christie 3949e1
 	int rc;
Mike Christie 3949e1
 	int len;
Mike Christie 3949e1
 	struct iscsi_iface_param_info *net_param;
Mike Christie 3949e1
+	struct nlattr *attr;
Mike Christie 3949e1
 
Mike Christie 3949e1
 	len = sizeof(struct iscsi_iface_param_info) + 16;
Mike Christie 3949e1
-	iov->iov_base = calloc(len, sizeof(char));
Mike Christie 3949e1
+	iov->iov_base = iscsi_nla_alloc(param, len);
Mike Christie 3949e1
 	if (!(iov->iov_base))
Mike Christie 3949e1
 		return 1;
Mike Christie 3949e1
 
Mike Christie 3949e1
-	iov->iov_len = len;
Mike Christie 3949e1
-	net_param = (struct iscsi_iface_param_info *)(iov->iov_base);
Mike Christie 3949e1
+	attr = iov->iov_base;
Mike Christie 3949e1
+	iov->iov_len = NLA_ALIGN(attr->nla_len);
Mike Christie 3949e1
+	net_param = (struct iscsi_iface_param_info *)ISCSI_NLA_DATA(attr);
Mike Christie 3949e1
 	net_param->param = param;
Mike Christie 3949e1
 	net_param->iface_type = ISCSI_IFACE_TYPE_IPV6;
Mike Christie 3949e1
 	net_param->iface_num = iface->iface_num;
Mike Christie 3949e1
diff -Naurp open-iscsi-2.0-872-rc4-bnx2i/usr/initiator.c open-iscsi-2.0-872-rc4-bnx2i.work/usr/initiator.c
Mike Christie 3949e1
--- open-iscsi-2.0-872-rc4-bnx2i/usr/initiator.c	2011-10-10 13:57:38.000000000 -0500
Mike Christie 3949e1
+++ open-iscsi-2.0-872-rc4-bnx2i.work/usr/initiator.c	2011-10-11 00:39:57.000000000 -0500
Mike Christie 3949e1
@@ -1682,9 +1682,10 @@ static void session_conn_process_login(v
Mike Christie 3949e1
 			    session->nrec.conn[conn->id].address,
Mike Christie 3949e1
 			    session->nrec.conn[conn->id].port,
Mike Christie 3949e1
 			    session->nrec.iface.name);
Mike Christie 3949e1
-	} else
Mike Christie 3949e1
+	} else {
Mike Christie 3949e1
 		session->notify_qtask = NULL;
Mike Christie 3949e1
-
Mike Christie 3949e1
+		mgmt_ipc_write_rsp(c->qtask, ISCSI_SUCCESS);
Mike Christie 3949e1
+	}
Mike Christie 3949e1
 
Mike Christie 3949e1
 	/*
Mike Christie 3949e1
 	 * reset ERL=0 reopen counter
Mike Christie 3949e1
diff -Naurp open-iscsi-2.0-872-rc4-bnx2i/usr/iscsi_netlink.h open-iscsi-2.0-872-rc4-bnx2i.work/usr/iscsi_netlink.h
Mike Christie 3949e1
--- open-iscsi-2.0-872-rc4-bnx2i/usr/iscsi_netlink.h	1969-12-31 18:00:00.000000000 -0600
Mike Christie 3949e1
+++ open-iscsi-2.0-872-rc4-bnx2i.work/usr/iscsi_netlink.h	2011-10-11 00:40:34.000000000 -0500
Mike Christie 3949e1
@@ -0,0 +1,33 @@
Mike Christie 3949e1
+/*
Mike Christie 3949e1
+ * iSCSI Netlink attr helpers
Mike Christie 3949e1
+ *
Mike Christie 3949e1
+ * Copyright (C) 2011 Red Hat, Inc. All rights reserved.
Mike Christie 3949e1
+ *
Mike Christie 3949e1
+ * This program is free software; you can redistribute it and/or modify
Mike Christie 3949e1
+ * it under the terms of the GNU General Public License as published
Mike Christie 3949e1
+ * by the Free Software Foundation; either version 2 of the License, or
Mike Christie 3949e1
+ * (at your option) any later version.
Mike Christie 3949e1
+ *
Mike Christie 3949e1
+ * This program is distributed in the hope that it will be useful, but
Mike Christie 3949e1
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
Mike Christie 3949e1
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Mike Christie 3949e1
+ * General Public License for more details.
Mike Christie 3949e1
+ *
Mike Christie 3949e1
+ * See the file COPYING included with this distribution for more details.
Mike Christie 3949e1
+ */
Mike Christie 3949e1
+
Mike Christie 3949e1
+#ifndef ISCSI_NLA_H
Mike Christie 3949e1
+#define ISCSI_NLA_H
Mike Christie 3949e1
+
Mike Christie 3949e1
+#include <linux netlink.h="">
Mike Christie 3949e1
+
Mike Christie 3949e1
+struct iovec;
Mike Christie 3949e1
+
Mike Christie 3949e1
+#define ISCSI_NLA_HDRLEN	((int) NLA_ALIGN(sizeof(struct nlattr)))
Mike Christie 3949e1
+#define ISCSI_NLA_DATA(nla)	((void *)((char*)(nla) + ISCSI_NLA_HDRLEN))
Mike Christie 3949e1
+#define ISCSI_NLA_LEN(len) 	((len) + NLA_ALIGN(ISCSI_NLA_HDRLEN))
Mike Christie 3949e1
+#define ISCSI_NLA_TOTAL_LEN(len) (NLA_ALIGN(ISCSI_NLA_LEN(len)))
Mike Christie 3949e1
+
Mike Christie 3949e1
+extern struct nlattr *iscsi_nla_alloc(uint16_t type, uint16_t len);
Mike Christie 3949e1
+
Mike Christie 3949e1
+#endif
Mike Christie 3949e1
diff -Naurp open-iscsi-2.0-872-rc4-bnx2i/usr/iscsi_sysfs.c open-iscsi-2.0-872-rc4-bnx2i.work/usr/iscsi_sysfs.c
Mike Christie 3949e1
--- open-iscsi-2.0-872-rc4-bnx2i/usr/iscsi_sysfs.c	2011-10-10 13:57:38.000000000 -0500
Mike Christie 3949e1
+++ open-iscsi-2.0-872-rc4-bnx2i.work/usr/iscsi_sysfs.c	2011-10-11 00:41:01.000000000 -0500
Mike Christie 3949e1
@@ -561,28 +561,28 @@ static int iscsi_sysfs_read_iface(struct
Mike Christie 3949e1
 			      "link_local_addr", iface->ipv6_linklocal,
Mike Christie 3949e1
 			      sizeof(iface->ipv6_linklocal));
Mike Christie 3949e1
 
Mike Christie 3949e1
-		if (sysfs_get_str(iface_kern_id, ISCSI_IFACE_SUBSYS,
Mike Christie 3949e1
-				  "linklocal_autocfg",
Mike Christie 3949e1
-				   iface->linklocal_autocfg,
Mike Christie 3949e1
-				   sizeof(iface->linklocal_autocfg))) {
Mike Christie 3949e1
-			/* misspelled in some test kernels */
Mike Christie 3949e1
-			sysfs_get_str(iface_kern_id, ISCSI_IFACE_SUBSYS,
Mike Christie 3949e1
-				      "link_local_autocfg",
Mike Christie 3949e1
-				      iface->linklocal_autocfg,
Mike Christie 3949e1
-				      sizeof(iface->linklocal_autocfg));
Mike Christie 3949e1
-		}
Mike Christie 3949e1
+		sysfs_get_str(iface_kern_id, ISCSI_IFACE_SUBSYS,
Mike Christie 3949e1
+			      "link_local_autocfg", iface->linklocal_autocfg,
Mike Christie 3949e1
+			      sizeof(iface->linklocal_autocfg));
Mike Christie 3949e1
 
Mike Christie 3949e1
 		sysfs_get_str(iface_kern_id, ISCSI_IFACE_SUBSYS, "router_addr",
Mike Christie 3949e1
 			      iface->ipv6_router,
Mike Christie 3949e1
 			      sizeof(iface->ipv6_router));
Mike Christie 3949e1
 	}
Mike Christie 3949e1
 
Mike Christie 3949e1
-	sysfs_get_uint16(iface_kern_id, ISCSI_IFACE_SUBSYS, "mtu",
Mike Christie 3949e1
-			 &iface->mtu);
Mike Christie 3949e1
-	sysfs_get_uint16(iface_kern_id, ISCSI_IFACE_SUBSYS, "vlan",
Mike Christie 3949e1
-			 &iface->vlan_id);
Mike Christie 3949e1
-	sysfs_get_uint8(iface_kern_id, ISCSI_IFACE_SUBSYS, "vlan_priority",
Mike Christie 3949e1
-			 &iface->vlan_priority);
Mike Christie 3949e1
+	if (sysfs_get_uint16(iface_kern_id, ISCSI_IFACE_SUBSYS, "port",
Mike Christie 3949e1
+			     &iface->port))
Mike Christie 3949e1
+		iface->port = 0;
Mike Christie 3949e1
+	if (sysfs_get_uint16(iface_kern_id, ISCSI_IFACE_SUBSYS, "mtu",
Mike Christie 3949e1
+			     &iface->mtu))
Mike Christie 3949e1
+		iface->mtu = 0;
Mike Christie 3949e1
+	if (sysfs_get_uint16(iface_kern_id, ISCSI_IFACE_SUBSYS, "vlan_id",
Mike Christie 3949e1
+			     &iface->vlan_id))
Mike Christie 3949e1
+		iface->vlan_id = UINT16_MAX;
Mike Christie 3949e1
+
Mike Christie 3949e1
+	if (sysfs_get_uint8(iface_kern_id, ISCSI_IFACE_SUBSYS, "vlan_priority",
Mike Christie 3949e1
+			    &iface->vlan_priority))
Mike Christie 3949e1
+		iface->vlan_priority = UINT8_MAX;
Mike Christie 3949e1
 
Mike Christie 3949e1
 	if (sscanf(iface_kern_id, "ipv%d-iface-%u-%u", &iface_type,
Mike Christie 3949e1
 		   &tmp_host_no, &iface_num) == 3)
Mike Christie 3949e1
diff -Naurp open-iscsi-2.0-872-rc4-bnx2i/usr/netlink.c open-iscsi-2.0-872-rc4-bnx2i.work/usr/netlink.c
Mike Christie 3949e1
--- open-iscsi-2.0-872-rc4-bnx2i/usr/netlink.c	2011-10-10 13:57:38.000000000 -0500
Mike Christie 3949e1
+++ open-iscsi-2.0-872-rc4-bnx2i.work/usr/netlink.c	2011-10-11 00:40:34.000000000 -0500
Mike Christie 3949e1
@@ -38,6 +38,7 @@
Mike Christie 3949e1
 #include "initiator.h"
Mike Christie 3949e1
 #include "iscsi_sysfs.h"
Mike Christie 3949e1
 #include "transport.h"
Mike Christie 3949e1
+#include "iscsi_netlink.h"
Mike Christie 3949e1
 
Mike Christie 3949e1
 static int ctrl_fd;
Mike Christie 3949e1
 static struct sockaddr_nl src_addr, dest_addr;
Mike Christie 3949e1
@@ -63,6 +64,19 @@ static int ctldev_handle(void);
Mike Christie 3949e1
 
Mike Christie 3949e1
 #define NLM_SETPARAM_DEFAULT_MAX (NI_MAXHOST + 1 + sizeof(struct iscsi_uevent))
Mike Christie 3949e1
 
Mike Christie 3949e1
+struct nlattr *iscsi_nla_alloc(uint16_t type, uint16_t len)
Mike Christie 3949e1
+{
Mike Christie 3949e1
+	struct nlattr *attr;
Mike Christie 3949e1
+
Mike Christie 3949e1
+	attr = calloc(1, ISCSI_NLA_TOTAL_LEN(len));
Mike Christie 3949e1
+	if (!attr)
Mike Christie 3949e1
+		return NULL; 
Mike Christie 3949e1
+
Mike Christie 3949e1
+	attr->nla_len = ISCSI_NLA_LEN(len);
Mike Christie 3949e1
+	attr->nla_type = type;
Mike Christie 3949e1
+	return attr;
Mike Christie 3949e1
+}
Mike Christie 3949e1
+
Mike Christie 3949e1
 static int
Mike Christie 3949e1
 kread(char *data, int count)
Mike Christie 3949e1
 {