Skip to content

Commit

Permalink
Merge pull request #1192 from PiSCSI/rdmark-issue-1191
Browse files Browse the repository at this point in the history
Check for predictable network interface names in bridge check
  • Loading branch information
rdmark authored Jul 29, 2023
2 parents 5a6d12c + 51f1e7e commit 34478d1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 3 additions & 1 deletion python/web/src/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,10 +651,12 @@ def attach_device():
if param:
params.update({item.replace(PARAM_PREFIX, ""): param})

return_message = "Attached %(device_type)s to SCSI ID %(id_number)s LUN %(unit_number)s"
if "interface" in params.keys():
bridge_status = is_bridge_configured(params["interface"])
if not bridge_status["status"]:
return response(error=True, message=bridge_status["msg"])
return_message = return_message + " - " + bridge_status["msg"]

kwargs = {
"unit": int(unit),
Expand All @@ -672,7 +674,7 @@ def attach_device():
if process["status"]:
return response(
message=_(
"Attached %(device_type)s to SCSI ID %(id_number)s LUN %(unit_number)s",
return_message,
device_type=get_device_name(device_type),
id_number=scsi_id,
unit_number=unit,
Expand Down
18 changes: 14 additions & 4 deletions python/web/src/web_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,24 +274,34 @@ def is_bridge_configured(interface):
PATH_IPTV4 = "/etc/iptables/rules.v4"
PATH_DHCPCD = "/etc/dhcpcd.conf"
PATH_BRIDGE = "/etc/network/interfaces.d/piscsi_bridge"
return_msg = _("Configure the network bridge for %(interface)s first: ", interface=interface)
to_configure = []
sys_cmd = SysCmds()
if interface.startswith("wlan"):
if interface.startswith("wlan") or interface.startswith("wlx"):
return_msg = _("Wireless network bridge enabled for %(interface)s", interface=interface)
if not sys_cmd.introspect_file(PATH_SYSCTL, r"^net\.ipv4\.ip_forward=1$"):
to_configure.append("IPv4 forwarding")
if not Path(PATH_IPTV4).is_file():
to_configure.append("NAT")
else:
elif interface.startswith("eth") or interface.startswith("enx"):
return_msg = _("Wired network bridge enabled for %(interface)s", interface=interface)
if not sys_cmd.introspect_file(PATH_DHCPCD, r"^denyinterfaces " + interface + r"$"):
to_configure.append(PATH_DHCPCD)
if not Path(PATH_BRIDGE).is_file():
to_configure.append(PATH_BRIDGE)
else:
return_msg = _(
"Unable to detect if %(interface)s is Ethernet or WiFi. "
"Make sure that the correct network bridge is configured.",
interface=interface,
)

if to_configure:
return_msg = _(
"Configure the network bridge for %(interface)s first: ", interface=interface
)
return {"status": False, "msg": return_msg + ", ".join(to_configure)}

return {"status": True, "msg": ""}
return {"status": True, "msg": return_msg}


def is_safe_path(file_name):
Expand Down

0 comments on commit 34478d1

Please sign in to comment.