From owner-svn-src-stable@freebsd.org Sun Jun 28 09:41:11 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7C25098DA86; Sun, 28 Jun 2015 09:41:11 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 699A810A4; Sun, 28 Jun 2015 09:41:11 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t5S9fBhH091574; Sun, 28 Jun 2015 09:41:11 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t5S9fA59091572; Sun, 28 Jun 2015 09:41:10 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201506280941.t5S9fA59091572@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Sun, 28 Jun 2015 09:41:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r284908 - stable/10/usr.sbin/ctld X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Jun 2015 09:41:11 -0000 Author: mav Date: Sun Jun 28 09:41:10 2015 New Revision: 284908 URL: https://svnweb.freebsd.org/changeset/base/284908 Log: MFC r284765, r284875: Teach ctld about CTL's physical_port and virtual_port fields. This allows ctld to work with isp(4) virtual ports, specifying them as isp0/1, isp0/2, etc. There are still problems on isp(4) layer with disabling those ports after enabling, but hopefully they can be fixed. Modified: stable/10/usr.sbin/ctld/ctl.conf.5 stable/10/usr.sbin/ctld/kernel.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/ctld/ctl.conf.5 ============================================================================== --- stable/10/usr.sbin/ctld/ctl.conf.5 Sun Jun 28 09:27:34 2015 (r284907) +++ stable/10/usr.sbin/ctld/ctl.conf.5 Sun Jun 28 09:41:10 2015 (r284908) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 19, 2015 +.Dd June 24, 2015 .Dt CTL.CONF 5 .Os .Sh NAME @@ -321,7 +321,9 @@ Optional second argument specifies auth to this specific portal group. If second argument is not specified, target auth group is used. .It Ic port Ar name -Assign specified CTL port (such as "isp0") to the target. +.It Ic port Ar name/pp +.It Ic port Ar name/pp/vp +Assign specified CTL port (such as "isp0" or "isp2/1") to the target. On startup ctld configures LUN mapping and enables all assigned ports. Each port can be assigned to only one target. .It Ic redirect Aq Ar address Modified: stable/10/usr.sbin/ctld/kernel.c ============================================================================== --- stable/10/usr.sbin/ctld/kernel.c Sun Jun 28 09:27:34 2015 (r284907) +++ stable/10/usr.sbin/ctld/kernel.c Sun Jun 28 09:41:10 2015 (r284908) @@ -122,6 +122,8 @@ struct cctl_lun { struct cctl_port { uint32_t port_id; char *port_name; + int pp; + int vp; int cfiscsi_state; char *cfiscsi_target; uint16_t cfiscsi_portal_group_tag; @@ -334,6 +336,10 @@ cctl_end_pelement(void *user_data, const if (strcmp(name, "port_name") == 0) { cur_port->port_name = str; str = NULL; + } else if (strcmp(name, "physical_port") == 0) { + cur_port->pp = strtoul(str, NULL, 0); + } else if (strcmp(name, "virtual_port") == 0) { + cur_port->vp = strtoul(str, NULL, 0); } else if (strcmp(name, "cfiscsi_target") == 0) { cur_port->cfiscsi_target = str; str = NULL; @@ -391,7 +397,7 @@ conf_new_from_kernel(void) struct cctl_lun *lun; struct cctl_port *port; XML_Parser parser; - char *str; + char *str, *name; int len, retval; bzero(&devlist, sizeof(devlist)); @@ -500,18 +506,28 @@ retry_port: conf = conf_new(); + name = NULL; STAILQ_FOREACH(port, &devlist.port_list, links) { + if (name) + free(name); + if (port->pp == 0 && port->vp == 0) + name = checked_strdup(port->port_name); + else if (port->vp == 0) + asprintf(&name, "%s/%d", port->port_name, port->pp); + else + asprintf(&name, "%s/%d/%d", port->port_name, port->pp, + port->vp); if (port->cfiscsi_target == NULL) { log_debugx("CTL port %u \"%s\" wasn't managed by ctld; ", - port->port_id, port->port_name); - pp = pport_find(conf, port->port_name); + port->port_id, name); + pp = pport_find(conf, name); if (pp == NULL) { #if 0 log_debugx("found new kernel port %u \"%s\"", - port->port_id, port->port_name); + port->port_id, name); #endif - pp = pport_new(conf, port->port_name, port->port_id); + pp = pport_new(conf, name, port->port_id); if (pp == NULL) { log_warnx("pport_new failed"); continue; @@ -560,6 +576,8 @@ retry_port: } cp->p_ctl_port = port->port_id; } + if (name) + free(name); STAILQ_FOREACH(lun, &devlist.lun_list, links) { struct cctl_lun_nv *nv;