summaryrefslogtreecommitdiff
path: root/usr/iscsi_netlink.h
diff options
context:
space:
mode:
authorMike Christie <michaelc@cs.wisc.edu>2011-10-06 04:16:03 -0500
committerMike Christie <michaelc@cs.wisc.edu>2011-10-06 04:16:03 -0500
commitc4aee089c879ee51c93d9cb48cd7a521efc667b2 (patch)
tree14045c97612fc61a2cba982146d472f21a3c4ce8 /usr/iscsi_netlink.h
parentca6328cfaf44e7f6a525906677bfbf513a756b2e (diff)
downloadopen-iscsi-c4aee089c879ee51c93d9cb48cd7a521efc667b2.tar.gz
iscsi tools: fix netlink msg setup
This fixes a regression added in deef9e20c2f1b107760b5b4c29289de77fcdc39f and fixes a alignment issue with the new iface netconfig support. The regression was added when we changed how we sent the netlink message header and data from one blob to iovecs. The nlmsg_len was not tracking the header so the kernel was misreading how much data it had to read. This would lead to iscsiadm hanging because logins were not getting completed. This also fixes a issue where the data was not padded so when sending multiple params the params would not start at nice boundaries and could cause unaligned access errors.
Diffstat (limited to 'usr/iscsi_netlink.h')
-rw-r--r--usr/iscsi_netlink.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/usr/iscsi_netlink.h b/usr/iscsi_netlink.h
new file mode 100644
index 0000000..25b41db
--- /dev/null
+++ b/usr/iscsi_netlink.h
@@ -0,0 +1,33 @@
+/*
+ * iSCSI Netlink attr helpers
+ *
+ * Copyright (C) 2011 Red Hat, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * See the file COPYING included with this distribution for more details.
+ */
+
+#ifndef ISCSI_NLA_H
+#define ISCSI_NLA_H
+
+#include <linux/netlink.h>
+
+struct iovec;
+
+#define ISCSI_NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr)))
+#define ISCSI_NLA_DATA(nla) ((void *)((char*)(nla) + ISCSI_NLA_HDRLEN))
+#define ISCSI_NLA_LEN(len) ((len) + NLA_ALIGN(ISCSI_NLA_HDRLEN))
+#define ISCSI_NLA_TOTAL_LEN(len) (NLA_ALIGN(ISCSI_NLA_LEN(len)))
+
+extern struct nlattr *iscsi_nla_alloc(uint16_t type, uint16_t len);
+
+#endif