summaryrefslogtreecommitdiffstats
path: root/usr.sbin/iscsictl
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2011-04-27 19:20:01 +0000
committerclaudio <claudio@openbsd.org>2011-04-27 19:20:01 +0000
commit3471b9125212bd3e4544c2c48cf6804fb7816d28 (patch)
treefbc258e50e376c19e9511f51a4899a60eebc5289 /usr.sbin/iscsictl
parentImplement CTRL_LOG_VERBOSE to toggle log verbosity. (diff)
downloadwireguard-openbsd-3471b9125212bd3e4544c2c48cf6804fb7816d28.tar.xz
wireguard-openbsd-3471b9125212bd3e4544c2c48cf6804fb7816d28.zip
Implement "log verbose|brief" and allow the configuratuin of the
initiatior config which is just the ISID in case someone needs to fix them to a specific value.
Diffstat (limited to 'usr.sbin/iscsictl')
-rw-r--r--usr.sbin/iscsictl/iscsictl.c38
-rw-r--r--usr.sbin/iscsictl/iscsictl.h3
-rw-r--r--usr.sbin/iscsictl/parse.y34
3 files changed, 70 insertions, 5 deletions
diff --git a/usr.sbin/iscsictl/iscsictl.c b/usr.sbin/iscsictl/iscsictl.c
index e577ac56bf7..fd8b7cfab1a 100644
--- a/usr.sbin/iscsictl/iscsictl.c
+++ b/usr.sbin/iscsictl/iscsictl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iscsictl.c,v 1.2 2010/09/25 16:23:01 sobrado Exp $ */
+/* $OpenBSD: iscsictl.c,v 1.3 2011/04/27 19:20:01 claudio Exp $ */
/*
* Copyright (c) 2010 Claudio Jeker <claudio@openbsd.org>
@@ -60,10 +60,12 @@ main (int argc, char* argv[])
struct pdu *pdu;
struct ctrlmsghdr *cmh;
struct session_config *sc;
+ struct initiator_config *ic;
struct session_ctlcfg *s;
struct iscsi_config *cf;
char *tname, *iname;
int ch, csock;
+ int *vp, val = 0;
/* check flags */
while ((ch = getopt(argc, argv, "f:s:")) != -1) {
@@ -100,7 +102,22 @@ main (int argc, char* argv[])
switch (res->action) {
case NONE:
case LOG_VERBOSE:
+ val = 1;
+ /* FALLTHROUGH */
case LOG_BRIEF:
+ if ((pdu = pdu_new()) == NULL)
+ err(1, "pdu_new");
+ if ((cmh = pdu_alloc(sizeof(*cmh))) == NULL)
+ err(1, "pdu_alloc");
+ bzero(cmh, sizeof(*cmh));
+ cmh->type = CTRL_LOG_VERBOSE;
+ cmh->len[0] = sizeof(int);
+ if ((vp = pdu_dup(&val, sizeof(int))) == NULL)
+ err(1, "pdu_dup");
+ pdu_addbuf(pdu, cmh, sizeof(*cmh), 0);
+ pdu_addbuf(pdu, vp, sizeof(int), 1);
+ run_command(csock, pdu);
+ break;
case SHOW:
case SHOW_SUM:
usage();
@@ -108,6 +125,21 @@ main (int argc, char* argv[])
case RELOAD:
if ((cf = parse_config(confname)) == NULL)
errx(1, "errors while loading configuration file.");
+ if (cf->initiator.isid_base != 0) {
+ if ((pdu = pdu_new()) == NULL)
+ err(1, "pdu_new");
+ if ((cmh = pdu_alloc(sizeof(*cmh))) == NULL)
+ err(1, "pdu_alloc");
+ bzero(cmh, sizeof(*cmh));
+ cmh->type = CTRL_INITIATOR_CONFIG;
+ cmh->len[0] = sizeof(*ic);
+ if ((ic = pdu_dup(&cf->initiator,
+ sizeof(cf->initiator))) == NULL)
+ err(1, "pdu_dup");
+ pdu_addbuf(pdu, cmh, sizeof(*cmh), 0);
+ pdu_addbuf(pdu, ic, sizeof(*ic), 1);
+ run_command(csock, pdu);
+ }
SIMPLEQ_FOREACH(s, &cf->sessions, entry) {
if ((pdu = pdu_new()) == NULL)
err(1, "pdu_new");
@@ -167,7 +199,6 @@ main (int argc, char* argv[])
run_command(csock, pdu);
}
-printf("sent pdu to daemon\n");
close(csock);
@@ -204,6 +235,9 @@ run_command(int csock, struct pdu *pdu)
printf("command failed\n");
done = 1;
break;
+ case CTRL_INPROGRESS:
+ printf("command in progress...\n");
+ break;
}
}
}
diff --git a/usr.sbin/iscsictl/iscsictl.h b/usr.sbin/iscsictl/iscsictl.h
index 0768cfacc5e..ffd0ab4d128 100644
--- a/usr.sbin/iscsictl/iscsictl.h
+++ b/usr.sbin/iscsictl/iscsictl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: iscsictl.h,v 1.1 2010/09/24 09:45:17 claudio Exp $ */
+/* $OpenBSD: iscsictl.h,v 1.2 2011/04/27 19:20:01 claudio Exp $ */
/*
* Copyright (c) 2009 David Gwynne <dlg@openbsd.org>
@@ -20,6 +20,7 @@
struct iscsi_config {
SIMPLEQ_HEAD(, session_ctlcfg) sessions;
+ struct initiator_config initiator;
};
struct session_ctlcfg {
diff --git a/usr.sbin/iscsictl/parse.y b/usr.sbin/iscsictl/parse.y
index 2b54da26b50..2efd03804e4 100644
--- a/usr.sbin/iscsictl/parse.y
+++ b/usr.sbin/iscsictl/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.2 2010/09/25 16:23:01 sobrado Exp $ */
+/* $OpenBSD: parse.y,v 1.3 2011/04/27 19:20:01 claudio Exp $ */
/*
* Copyright (c) 2010 David Gwynne <dlg@openbsd.org>
@@ -41,6 +41,7 @@
#include <string.h>
#include <unistd.h>
+#include <scsi/iscsi.h>
#include "iscsid.h"
#include "iscsictl.h"
@@ -99,7 +100,7 @@ typedef struct {
%}
%token TARGET TARGETNAME TARGETADDR
-%token INITIATORNAME INITIATORADDR
+%token INITIATORNAME INITIATORADDR ISID
%token ENABLED DISABLED NORMAL DISCOVERY
%token ADDRESS INET INET6 PORT
%token INCLUDE
@@ -118,6 +119,7 @@ grammar : /* empty */
| grammar '\n'
| grammar include '\n'
| grammar varset '\n'
+ | grammar initiator '\n'
| grammar target '\n'
| grammar error '\n' { file->errors++; }
;
@@ -165,6 +167,33 @@ optnl : '\n' optnl
nl : '\n' optnl /* one or more newlines */
;
+initiator : ISID STRING NUMBER NUMBER {
+ u_int32_t mask1, mask2;
+
+ if (!strcasecmp($2, "oui")) {
+ conf->initiator.isid_base = ISCSI_ISID_OUI;
+ mask1 = 0x3fffff00;
+ mask2 = 0x000000ff;
+ } else if (!strcasecmp($2, "en")) {
+ conf->initiator.isid_base = ISCSI_ISID_EN;
+ mask1 = 0x00ffffff;
+ mask2 = 0;
+ } else if (!strcasecmp($2, "rand")) {
+ conf->initiator.isid_base = ISCSI_ISID_RAND;
+ mask1 = 0x00ffffff;
+ mask2 = 0;
+ } else {
+ yyerror("isid type %s unknown", $2);
+ free($2);
+ YYERROR;
+ }
+ free($2);
+ conf->initiator.isid_base |= $3 & mask1;
+ conf->initiator.isid_base |= ($4 >> 16) & mask2;
+ conf->initiator.isid_qual = $4;
+ }
+ ;
+
target : TARGET STRING {
struct session_ctlcfg *scelm;
@@ -333,6 +362,7 @@ lookup(char *s)
{"inet6", INET6},
{"initiatoraddr", INITIATORADDR},
{"initiatorname", INITIATORNAME},
+ {"isid", ISID},
{"normal", NORMAL},
{"port", PORT},
{"target", TARGET},