ctl.conf.5 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. .\" Copyright (c) 2012 The FreeBSD Foundation
  2. .\" Copyright (c) 2015 Alexander Motin <mav@FreeBSD.org>
  3. .\" All rights reserved.
  4. .\"
  5. .\" This software was developed by Edward Tomasz Napierala under sponsorship
  6. .\" from the FreeBSD Foundation.
  7. .\"
  8. .\" Redistribution and use in source and binary forms, with or without
  9. .\" modification, are permitted provided that the following conditions
  10. .\" are met:
  11. .\" 1. Redistributions of source code must retain the above copyright
  12. .\" notice, this list of conditions and the following disclaimer.
  13. .\" 2. Redistributions in binary form must reproduce the above copyright
  14. .\" notice, this list of conditions and the following disclaimer in the
  15. .\" documentation and/or other materials provided with the distribution.
  16. .\"
  17. .\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
  18. .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
  21. .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. .\" SUCH DAMAGE.
  28. .\"
  29. .Dd October 13, 2020
  30. .Dt CTL.CONF 5
  31. .Os
  32. .Sh NAME
  33. .Nm ctl.conf
  34. .Nd CAM Target Layer / iSCSI target daemon configuration file
  35. .Sh DESCRIPTION
  36. The
  37. .Nm
  38. configuration file is used by the
  39. .Xr ctld 8
  40. daemon.
  41. Lines starting with
  42. .Ql #
  43. are interpreted as comments.
  44. The general syntax of the
  45. .Nm
  46. file is:
  47. .Bd -literal -offset indent
  48. .No pidfile Ar path
  49. .No auth-group Ar name No {
  50. .Dl chap Ar user Ar secret
  51. .Dl ...
  52. }
  53. .No portal-group Ar name No {
  54. .Dl listen Ar address
  55. .\".Dl listen-iser Ar address
  56. .Dl discovery-auth-group Ar name
  57. .Dl ...
  58. }
  59. .No target Ar name {
  60. .Dl auth-group Ar name
  61. .Dl portal-group Ar name
  62. .Dl lun Ar number No {
  63. .Dl path Ar path
  64. .Dl }
  65. .Dl ...
  66. }
  67. .Ed
  68. .Ss Global Context
  69. .Bl -tag -width indent
  70. .It Ic auth-group Ar name
  71. Create an
  72. .Sy auth-group
  73. configuration context,
  74. defining a new auth-group,
  75. which can then be assigned to any number of targets.
  76. .It Ic debug Ar level
  77. The debug verbosity level.
  78. The default is 0.
  79. .It Ic maxproc Ar number
  80. The limit for concurrently running child processes handling
  81. incoming connections.
  82. The default is 30.
  83. A setting of 0 disables the limit.
  84. .It Ic pidfile Ar path
  85. The path to the pidfile.
  86. The default is
  87. .Pa /var/run/ctld.pid .
  88. .It Ic portal-group Ar name
  89. Create a
  90. .Sy portal-group
  91. configuration context,
  92. defining a new portal-group,
  93. which can then be assigned to any number of targets.
  94. .It Ic lun Ar name
  95. Create a
  96. .Sy lun
  97. configuration context, defining a LUN to be exported by any number of targets.
  98. .It Ic target Ar name
  99. Create a
  100. .Sy target
  101. configuration context, which can optionally contain one or more
  102. .Sy lun
  103. contexts.
  104. .It Ic timeout Ar seconds
  105. The timeout for login sessions, after which the connection
  106. will be forcibly terminated.
  107. The default is 60.
  108. A setting of 0 disables the timeout.
  109. .It Ic isns-server Ar address
  110. An IPv4 or IPv6 address and optionally port of iSNS server to register on.
  111. .It Ic isns-period Ar seconds
  112. iSNS registration period.
  113. Registered Network Entity not updated during this period will be unregistered.
  114. The default is 900.
  115. .It Ic isns-timeout Ar seconds
  116. Timeout for iSNS requests.
  117. The default is 5.
  118. .El
  119. .Ss auth-group Context
  120. .Bl -tag -width indent
  121. .It Ic auth-type Ar type
  122. Sets the authentication type.
  123. Type can be either
  124. .Qq Ar none ,
  125. .Qq Ar deny ,
  126. .Qq Ar chap ,
  127. or
  128. .Qq Ar chap-mutual .
  129. In most cases it is not necessary to set the type using this clause;
  130. it is usually used to disable authentication for a given
  131. .Sy auth-group .
  132. .It Ic chap Ar user Ar secret
  133. A set of CHAP authentication credentials.
  134. Note that for any
  135. .Sy auth-group ,
  136. the configuration may only contain either
  137. .Sy chap
  138. or
  139. .Sy chap-mutual
  140. entries; it is an error to mix them.
  141. .It Ic chap-mutual Ar user Ar secret Ar mutualuser Ar mutualsecret
  142. A set of mutual CHAP authentication credentials.
  143. Note that for any
  144. .Sy auth-group ,
  145. the configuration may only contain either
  146. .Sy chap
  147. or
  148. .Sy chap-mutual
  149. entries; it is an error to mix them.
  150. .It Ic initiator-name Ar initiator-name
  151. An iSCSI initiator name.
  152. Only initiators with a name matching one of the defined
  153. names will be allowed to connect.
  154. If not defined, there will be no restrictions based on initiator
  155. name.
  156. .It Ic initiator-portal Ar address Ns Op / Ns Ar prefixlen
  157. An iSCSI initiator portal: an IPv4 or IPv6 address, optionally
  158. followed by a literal slash and a prefix length.
  159. Only initiators with an address matching one of the defined
  160. addresses will be allowed to connect.
  161. If not defined, there will be no restrictions based on initiator
  162. address.
  163. .El
  164. .Ss portal-group Context
  165. .Bl -tag -width indent
  166. .It Ic discovery-auth-group Ar name
  167. Assign a previously defined authentication group to the portal group,
  168. to be used for target discovery.
  169. By default, portal groups are assigned predefined
  170. .Sy auth-group
  171. .Qq Ar default ,
  172. which denies discovery.
  173. Another predefined
  174. .Sy auth-group ,
  175. .Qq Ar no-authentication ,
  176. may be used
  177. to permit discovery without authentication.
  178. .It Ic discovery-filter Ar filter
  179. Determines which targets are returned during discovery.
  180. Filter can be either
  181. .Qq Ar none ,
  182. .Qq Ar portal ,
  183. .Qq Ar portal-name ,
  184. or
  185. .Qq Ar portal-name-auth .
  186. When set to
  187. .Qq Ar none ,
  188. discovery will return all targets assigned to that portal group.
  189. When set to
  190. .Qq Ar portal ,
  191. discovery will not return targets that cannot be accessed by the
  192. initiator because of their
  193. .Sy initiator-portal .
  194. When set to
  195. .Qq Ar portal-name ,
  196. the check will include both
  197. .Sy initiator-portal
  198. and
  199. .Sy initiator-name .
  200. When set to
  201. .Qq Ar portal-name-auth ,
  202. the check will include
  203. .Sy initiator-portal ,
  204. .Sy initiator-name ,
  205. and authentication credentials.
  206. The target is returned if it does not require CHAP authentication,
  207. or if the CHAP user and secret used during discovery match those
  208. used by the target.
  209. Note that when using
  210. .Qq Ar portal-name-auth ,
  211. targets that require CHAP authentication will only be returned if
  212. .Sy discovery-auth-group
  213. requires CHAP.
  214. The default is
  215. .Qq Ar none .
  216. .It Ic listen Ar address
  217. An IPv4 or IPv6 address and port to listen on for incoming connections.
  218. .\".It Ic listen-iser Ar address
  219. .\"An IPv4 or IPv6 address and port to listen on for incoming connections
  220. .\"using iSER (iSCSI over RDMA) protocol.
  221. .It Ic offload Ar driver
  222. Define iSCSI hardware offload driver to use for this
  223. .Sy portal-group .
  224. The default is
  225. .Qq Ar none .
  226. .It Ic option Ar name Ar value
  227. The CTL-specific port options passed to the kernel.
  228. .It Ic redirect Ar address
  229. IPv4 or IPv6 address to redirect initiators to.
  230. When configured, all initiators attempting to connect to portal
  231. belonging to this
  232. .Sy portal-group
  233. will get redirected using "Target moved temporarily" login response.
  234. Redirection happens before authentication and any
  235. .Sy initiator-name
  236. or
  237. .Sy initiator-portal
  238. checks are skipped.
  239. .It Ic tag Ar value
  240. Unique 16-bit tag value of this
  241. .Sy portal-group .
  242. If not specified, the value is generated automatically.
  243. .It Ic foreign
  244. Specifies that this
  245. .Sy portal-group
  246. is listened by some other host.
  247. This host will announce it on discovery stage, but won't listen.
  248. .It Ic dscp Ar value
  249. The DiffServ Codepoint used for sending data. The DSCP can be
  250. set to numeric, or hexadecimal values directly, as well as the
  251. well-defined
  252. .Qq Ar CSx
  253. and
  254. .Qq Ar AFxx
  255. codepoints.
  256. .It Ic pcp Ar value
  257. The 802.1Q Priority CodePoint used for sending packets.
  258. The PCP can be set to a value in the range between
  259. .Qq Ar 0
  260. to
  261. .Qq Ar 7 .
  262. When omitted, the default for the outgoing interface is used.
  263. .El
  264. .Ss target Context
  265. .Bl -tag -width indent
  266. .It Ic alias Ar text
  267. Assign a human-readable description to the target.
  268. There is no default.
  269. .It Ic auth-group Ar name
  270. Assign a previously defined authentication group to the target.
  271. By default, targets that do not specify their own auth settings,
  272. using clauses such as
  273. .Sy chap
  274. or
  275. .Sy initiator-name ,
  276. are assigned
  277. predefined
  278. .Sy auth-group
  279. .Qq Ar default ,
  280. which denies all access.
  281. Another predefined
  282. .Sy auth-group ,
  283. .Qq Ar no-authentication ,
  284. may be used to permit access
  285. without authentication.
  286. Note that this clause can be overridden using the second argument
  287. to a
  288. .Sy portal-group
  289. clause.
  290. .It Ic auth-type Ar type
  291. Sets the authentication type.
  292. Type can be either
  293. .Qq Ar none ,
  294. .Qq Ar deny ,
  295. .Qq Ar chap ,
  296. or
  297. .Qq Ar chap-mutual .
  298. In most cases it is not necessary to set the type using this clause;
  299. it is usually used to disable authentication for a given
  300. .Sy target .
  301. This clause is mutually exclusive with
  302. .Sy auth-group ;
  303. one cannot use
  304. both in a single target.
  305. .It Ic chap Ar user Ar secret
  306. A set of CHAP authentication credentials.
  307. Note that targets must only use one of
  308. .Sy auth-group , chap , No or Sy chap-mutual ;
  309. it is a configuration error to mix multiple types in one target.
  310. .It Ic chap-mutual Ar user Ar secret Ar mutualuser Ar mutualsecret
  311. A set of mutual CHAP authentication credentials.
  312. Note that targets must only use one of
  313. .Sy auth-group , chap , No or Sy chap-mutual ;
  314. it is a configuration error to mix multiple types in one target.
  315. .It Ic initiator-name Ar initiator-name
  316. An iSCSI initiator name.
  317. Only initiators with a name matching one of the defined
  318. names will be allowed to connect.
  319. If not defined, there will be no restrictions based on initiator
  320. name.
  321. This clause is mutually exclusive with
  322. .Sy auth-group ;
  323. one cannot use
  324. both in a single target.
  325. .It Ic initiator-portal Ar address Ns Op / Ns Ar prefixlen
  326. An iSCSI initiator portal: an IPv4 or IPv6 address, optionally
  327. followed by a literal slash and a prefix length.
  328. Only initiators with an address matching one of the defined
  329. addresses will be allowed to connect.
  330. If not defined, there will be no restrictions based on initiator
  331. address.
  332. This clause is mutually exclusive with
  333. .Sy auth-group ;
  334. one cannot use
  335. both in a single target.
  336. .Pp
  337. The
  338. .Sy auth-type ,
  339. .Sy chap ,
  340. .Sy chap-mutual ,
  341. .Sy initiator-name ,
  342. and
  343. .Sy initiator-portal
  344. clauses in the target context provide an alternative to assigning an
  345. .Sy auth-group
  346. defined separately, useful in the common case of authentication settings
  347. specific to a single target.
  348. .It Ic portal-group Ar name Op Ar ag-name
  349. Assign a previously defined portal group to the target.
  350. The default portal group is
  351. .Qq Ar default ,
  352. which makes the target available
  353. on TCP port 3260 on all configured IPv4 and IPv6 addresses.
  354. Optional second argument specifies
  355. .Sy auth-group
  356. for connections to this specific portal group.
  357. If second argument is not specified, target
  358. .Sy auth-group
  359. is used.
  360. .It Ic port Ar name
  361. .It Ic port Ar name/pp
  362. .It Ic port Ar name/pp/vp
  363. Assign specified CTL port (such as "isp0" or "isp2/1") to the target.
  364. This is used to export the target through a specific physical - eg Fibre
  365. Channel - port, in addition to portal-groups configured for the target.
  366. Use
  367. .Cm "ctladm portlist"
  368. command to retrieve the list of available ports.
  369. On startup
  370. .Xr ctld 8
  371. configures LUN mapping and enables all assigned ports.
  372. Each port can be assigned to only one target.
  373. .It Ic redirect Ar address
  374. IPv4 or IPv6 address to redirect initiators to.
  375. When configured, all initiators attempting to connect to this target
  376. will get redirected using "Target moved temporarily" login response.
  377. Redirection happens after successful authentication.
  378. .It Ic lun Ar number Ar name
  379. Export previously defined
  380. .Sy lun
  381. by the parent target.
  382. .It Ic lun Ar number
  383. Create a
  384. .Sy lun
  385. configuration context, defining a LUN exported by the parent target.
  386. .Pp
  387. This is an alternative to defining the LUN separately, useful in the common
  388. case of a LUN being exported by a single target.
  389. .El
  390. .Ss lun Context
  391. .Bl -tag -width indent
  392. .It Ic backend Ar block No | Ar ramdisk
  393. The CTL backend to use for a given LUN.
  394. Valid choices are
  395. .Qq Ar block
  396. and
  397. .Qq Ar ramdisk ;
  398. block is used for LUNs backed
  399. by files or disk device nodes; ramdisk is a bitsink device, used mostly for
  400. testing.
  401. The default backend is block.
  402. .It Ic blocksize Ar size
  403. The blocksize visible to the initiator.
  404. The default blocksize is 512 for disks, and 2048 for CD/DVDs.
  405. .It Ic ctl-lun Ar lun_id
  406. Global numeric identifier to use for a given LUN inside CTL.
  407. By default CTL allocates those IDs dynamically, but explicit specification
  408. may be needed for consistency in HA configurations.
  409. .It Ic device-id Ar string
  410. The SCSI Device Identification string presented to the initiator.
  411. .It Ic device-type Ar type
  412. Specify the SCSI device type to use when creating the LUN.
  413. Currently CTL supports Direct Access (type 0), Processor (type 3)
  414. and CD/DVD (type 5) LUNs.
  415. .It Ic option Ar name Ar value
  416. The CTL-specific options passed to the kernel.
  417. All CTL-specific options are documented in the
  418. .Sx OPTIONS
  419. section of
  420. .Xr ctladm 8 .
  421. .It Ic path Ar path
  422. The path to the file, device node, or
  423. .Xr zfs 8
  424. volume used to back the LUN.
  425. For optimal performance, create the volume with the
  426. .Qq Ar volmode=dev
  427. property set.
  428. .It Ic serial Ar string
  429. The SCSI serial number presented to the initiator.
  430. .It Ic size Ar size
  431. The LUN size, in bytes or by number with a suffix of
  432. .Sy K , M , G , T
  433. (for kilobytes, megabytes, gigabytes, or terabytes).
  434. When the configuration is in UCL format, use the suffix format
  435. .Sy kKmMgG Ns | Ns Sy bB ,
  436. (i.e., 4GB, 4gb, and 4Gb are all equivalent).
  437. .El
  438. .Sh FILES
  439. .Bl -tag -width ".Pa /etc/ctl.conf" -compact
  440. .It Pa /etc/ctl.conf
  441. The default location of the
  442. .Xr ctld 8
  443. configuration file.
  444. .El
  445. .Sh EXAMPLES
  446. .Bd -literal
  447. auth-group ag0 {
  448. chap-mutual "user" "secret" "mutualuser" "mutualsecret"
  449. chap-mutual "user2" "secret2" "mutualuser" "mutualsecret"
  450. initiator-portal 192.168.1.1/16
  451. }
  452. auth-group ag1 {
  453. auth-type none
  454. initiator-name "iqn.2012-06.com.example:initiatorhost1"
  455. initiator-name "iqn.2012-06.com.example:initiatorhost2"
  456. initiator-portal 192.168.1.1/24
  457. initiator-portal [2001:db8::de:ef]
  458. }
  459. portal-group pg0 {
  460. discovery-auth-group no-authentication
  461. listen 0.0.0.0:3260
  462. listen [::]:3260
  463. listen [fe80::be:ef]:3261
  464. }
  465. target iqn.2012-06.com.example:target0 {
  466. alias "Example target"
  467. auth-group no-authentication
  468. lun 0 {
  469. path /dev/zvol/tank/example_0
  470. blocksize 4096
  471. size 4G
  472. }
  473. }
  474. lun example_1 {
  475. path /dev/zvol/tank/example_1
  476. option naa 0x50015178f369f093
  477. }
  478. target iqn.2012-06.com.example:target1 {
  479. auth-group ag0
  480. portal-group pg0
  481. lun 0 example_1
  482. lun 1 {
  483. path /dev/zvol/tank/example_2
  484. option vendor "FreeBSD"
  485. }
  486. }
  487. target naa.50015178f369f092 {
  488. port isp0
  489. port isp1
  490. lun 0 example_1
  491. }
  492. .Ed
  493. .Pp
  494. An equivalent configuration in UCL format, for use with
  495. .Fl u :
  496. .Bd -literal
  497. auth-group {
  498. ag0 {
  499. chap-mutual = [
  500. {
  501. user = "user"
  502. secret = "secretsecret"
  503. mutual-user = "mutualuser"
  504. mutual-secret = "mutualsecret"
  505. },
  506. {
  507. user = "user2"
  508. secret = "secret2secret2"
  509. mutual-user = "mutualuser"
  510. mutual-secret = "mutualsecret"
  511. }
  512. ]
  513. }
  514. ag1 {
  515. auth-type = none
  516. initiator-name = [
  517. "iqn.2012-06.com.example:initiatorhost1",
  518. "iqn.2012-06.com.example:initiatorhost2"
  519. ]
  520. initiator-portal = [192.168.1.1/24, "[2001:db8::de:ef]"]
  521. }
  522. }
  523. portal-group {
  524. pg0 {
  525. discovery-auth-group = no-authentication
  526. listen = [
  527. 0.0.0.0:3260,
  528. "[::]:3260",
  529. "[fe80::be:ef]:3261"
  530. ]
  531. }
  532. }
  533. lun {
  534. example_0 {
  535. path = /dev/zvol/tank/example_0
  536. blocksize = 4096
  537. size = 4GB
  538. }
  539. example_1 {
  540. path = /dev/zvol/tank/example_1
  541. options {
  542. naa = "0x50015178f369f093"
  543. }
  544. }
  545. example_2 {
  546. path = /dev/zvol/tank/example_2
  547. options {
  548. vendor = "FreeBSD"
  549. }
  550. }
  551. }
  552. target {
  553. "iqn.2012-06.com.example:target0" {
  554. alias = "Example target"
  555. auth-group = no-authentication
  556. lun = [
  557. { number = 0, name = example_0 },
  558. ]
  559. }
  560. "iqn.2012-06.com.example:target1" {
  561. auth-group = ag0
  562. portal-group { name = pg0 }
  563. lun = [
  564. { number = 0, name = example_1 },
  565. { number = 1, name = example_2 }
  566. ]
  567. }
  568. naa.50015178f369f092 {
  569. port = isp0
  570. lun = [
  571. { number = 0, name = example_1 }
  572. ]
  573. }
  574. }
  575. .Ed
  576. .Sh SEE ALSO
  577. .Xr ctl 4 ,
  578. .Xr ctladm 8 ,
  579. .Xr ctld 8 ,
  580. .Xr zfs 8
  581. .Sh AUTHORS
  582. The
  583. .Nm
  584. configuration file functionality for
  585. .Xr ctld 8
  586. was developed by
  587. .An Edward Tomasz Napierala Aq Mt trasz@FreeBSD.org
  588. under sponsorship from the FreeBSD Foundation.