diff --git a/src/targetcli/ui_target.py b/src/targetcli/ui_target.py index 893d1ef..60b194c 100644 --- a/src/targetcli/ui_target.py +++ b/src/targetcli/ui_target.py @@ -43,6 +43,7 @@ auth_params = ('userid', 'password', 'mutual_userid', 'mutual_password') int_params = ('enable',) discovery_params = auth_params + int_params +default_portal_listen = "::0" class UIFabricModule(UIRTSLibNode): ''' @@ -340,10 +341,10 @@ def ui_command_create(self, tag=None): if tpg.has_feature("nps") and self.shell.prefs['auto_add_default_portal']: try: - NetworkPortal(tpg, "0.0.0.0") + NetworkPortal(tpg, f"[{default_portal_listen}]") self.shell.log.info("Global pref auto_add_default_portal=true") self.shell.log.info("Created default portal listening on all IPs" - " (0.0.0.0), port 3260.") + f" ({default_portal_listen}), port 3260.") except RTSLibError: self.shell.log.info("Default portal not created, TPGs within a target cannot share ip:port.") @@ -1280,9 +1281,9 @@ def ui_command_create(self, ip_address=None, ip_port=None): Creates a Network Portal with the specified IP address and port. If the port is omitted, the default port for the target fabric will be used. If the IP address is omitted, - INADDR_ANY (0.0.0.0) will be used. + IN6ADDR_ANY (::0) will be used. - Choosing IN6ADDR_ANY (::0) will listen on all IPv6 interfaces + The default IN6ADDR_ANY (::0) will listen on all IPv6 interfaces as well as IPv4, assuming IPV6_V6ONLY sockopt has not been set. @@ -1298,12 +1299,12 @@ def ui_command_create(self, ip_address=None, ip_port=None): # FIXME: Add a specfile parameter to determine default port default_port = 3260 ip_port = self.ui_eval_param(ip_port, 'number', default_port) - ip_address = self.ui_eval_param(ip_address, 'string', "0.0.0.0") + ip_address = self.ui_eval_param(ip_address, 'string', default_portal_listen) if ip_port == default_port: self.shell.log.info("Using default IP port %d" % ip_port) - if ip_address == "0.0.0.0": - self.shell.log.info("Binding to INADDR_ANY (0.0.0.0)") + if ip_address == default_portal_listen: + self.shell.log.info(f"Binding to INADDR_ANY ({default_portal_listen})") portal = NetworkPortal(self.tpg, self._canonicalize_ip(ip_address), ip_port, mode='create') diff --git a/targetcli.8 b/targetcli.8 index a73f785..5ecbb13 100644 --- a/targetcli.8 +++ b/targetcli.8 @@ -159,9 +159,10 @@ ports. These addr:port pairs are called Both IPv4 and IPv6 addresses are supported. .P When a target is created, targetcli automatically creates a default -portal listening on all IPv4 addresses (shown as 0.0.0.0) on port 3260. -If a different configuration is needed, the default portal can be -removed and portals configured as desired. +portal listening on all IPv4 and IPv6 addresses (shown as ::0) on port +3260. If IPV6_V6ONLY is set, the default will only listen on all IPv6 +addresses. If a different configuration is needed, the default portal can +be removed and portals configured as desired. .P If the hardware supports it, .B iSER @@ -299,7 +300,7 @@ target.) .B portals/ create .br Add a portal, i.e. an IP address and TCP port via which the target can -be contacted by initiators. Only required if the default 0.0.0.0:3260 +be contacted by initiators. Only required if the default [::0]:3260 portal is not present. .P .B luns/ create /backstores/fileio/disk1