Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Switch to a default portal IP of [::0] #211

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/targetcli/ui_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
'''
Expand Down Expand Up @@ -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.")

Expand Down Expand Up @@ -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.

Expand All @@ -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')
Expand Down
9 changes: 5 additions & 4 deletions targetcli.8
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down