From owner-svn-src-all@FreeBSD.ORG Wed May 7 07:35:22 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1F204919; Wed, 7 May 2014 07:35:22 +0000 (UTC) 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 000A79C; Wed, 7 May 2014 07:35:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s477ZL7d020161; Wed, 7 May 2014 07:35:21 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s477ZLus020157; Wed, 7 May 2014 07:35:21 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201405070735.s477ZLus020157@svn.freebsd.org> From: Edward Tomasz Napierala Date: Wed, 7 May 2014 07:35:21 +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: r265511 - 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-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 May 2014 07:35:22 -0000 Author: trasz Date: Wed May 7 07:35:21 2014 New Revision: 265511 URL: http://svnweb.freebsd.org/changeset/base/265511 Log: MFC r264528: Rework the way we enable CTL iSCSI port. Previously conf_apply() needed it to be already enabled, because listening in proxy mode requires it; however, it's conf_apply() that opens pidfiles, so it resulted in port being enabled before pidfile was opened. This was not so bad, but it was also disabled when pidfile couldn't be opened due to ctld already running; this means that starting second ctld instance screwed up the first. Sponsored by: The FreeBSD Foundation Modified: stable/10/usr.sbin/ctld/ctld.c stable/10/usr.sbin/ctld/ctld.h stable/10/usr.sbin/ctld/parse.y Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/ctld/ctld.c ============================================================================== --- stable/10/usr.sbin/ctld/ctld.c Wed May 7 07:33:56 2014 (r265510) +++ stable/10/usr.sbin/ctld/ctld.c Wed May 7 07:35:21 2014 (r265511) @@ -1209,6 +1209,19 @@ conf_apply(struct conf *oldconf, struct } } + if (oldconf->conf_kernel_port_on != newconf->conf_kernel_port_on) { + if (newconf->conf_kernel_port_on == true) { + log_debugx("enabling CTL iSCSI port"); + error = kernel_port_on(); + if (error != 0) + log_errx(1, "failed to enable CTL iSCSI port, exiting"); + } else { + error = kernel_port_off(); + if (error != 0) + log_warnx("failed to disable CTL iSCSI port"); + } + } + TAILQ_FOREACH_SAFE(oldtarg, &oldconf->conf_targets, t_next, tmptarg) { /* * First, remove any targets present in the old configuration @@ -1837,11 +1850,6 @@ main(int argc, char **argv) newconf->conf_debug = debug; } - log_debugx("enabling CTL iSCSI port"); - error = kernel_port_on(); - if (error != 0) - log_errx(1, "failed to enable CTL iSCSI port, exiting"); - error = conf_apply(oldconf, newconf); if (error != 0) log_errx(1, "failed to apply configuration, exiting"); @@ -1886,9 +1894,6 @@ main(int argc, char **argv) log_debugx("disabling CTL iSCSI port " "and terminating all connections"); - error = kernel_port_off(); - if (error != 0) - log_warnx("failed to disable CTL iSCSI port"); oldconf = newconf; newconf = conf_new(); Modified: stable/10/usr.sbin/ctld/ctld.h ============================================================================== --- stable/10/usr.sbin/ctld/ctld.h Wed May 7 07:33:56 2014 (r265510) +++ stable/10/usr.sbin/ctld/ctld.h Wed May 7 07:35:21 2014 (r265511) @@ -156,6 +156,7 @@ struct conf { bool conf_default_pg_defined; bool conf_default_ag_defined; + bool conf_kernel_port_on; }; #define CONN_SESSION_TYPE_NONE 0 Modified: stable/10/usr.sbin/ctld/parse.y ============================================================================== --- stable/10/usr.sbin/ctld/parse.y Wed May 7 07:33:56 2014 (r265510) +++ stable/10/usr.sbin/ctld/parse.y Wed May 7 07:35:21 2014 (r265511) @@ -773,6 +773,8 @@ conf_new_from_file(const char *path) portal_group_add_listen(pg, "[::]:3260", false); } + conf->conf_kernel_port_on = true; + error = conf_verify(conf); if (error != 0) { conf_delete(conf);