uweseimet / scsi2pi

Advanced performant SCSI/SASI emulation and tools for the PiSCSI/RaSCSI board
https://www.scsi2pi.net
BSD 3-Clause "New" or "Revised" License
9 stars 2 forks source link

s2p: Add a boolean parameter to disable the creation of the piscsi bridge #80

Closed uweseimet closed 7 months ago

uweseimet commented 7 months ago

An new boolean parameter "bridge" shall be added to the list of the supported parameters for the DaynaPort emulation. This parameter shall control whether for physical network interfaces ("eth*") the piscsi bridge shall be created or not. The default of this parameter shall be "true". Any other value shall mean "false".

uweseimet commented 7 months ago

@fdanapfel There does not seem to be much progress with https://github.com/PiSCSI/piscsi/issues/1387. What I wonder is: What is still missing or would have to be changed in the s2p core in order to provide good support for parprouted? Note that I am not talking about documentation or external setups (scripts, parprouted itself etc.), but just about the s2p binary, i.e. the C++ code.

fdanapfel commented 7 months ago

@uweseimet First of all, a big thanks for all the work you have done so far with scsi2pi! And thanks for incorporating some of the suggestions I made.

As far as I can see the only thing thats missing in the s2p binary for supporting parprouted would be to make sure IPv4 forwarding is enabled in the kernel (sudo sysctl -w net.ipv4.ip_forward=1 in shell code, but there is probably also a way to do this in C++) and to put the real interface (wlan0 or eth0) that will be used by the emulated daynaport in promiscuous mode (sudo /sbin/ip link set wlan0 promisc on in shell code, but there is probably also a way to do this in C++) when the daynaport is enabled (and disable promiscuous mode when the daynaport is disabled).

With that after parprouted is started afterwards connecting the piscsi0 interface to the real network interface everything should be there that is required for an Atari or Mac to connect to the network.

uweseimet commented 7 months ago

@fdanapfel Which shell commands can I use to verify the results when I try to implement the equivalent of the shell commands you mentioned in C++? Should any of these operations be optional? I am asking this because I would like to also keep the current behavior. At least for the time being, the best solution would probably be if I could add an option that switches between the current (i.e. without parprouted) s2p behavior, and the behavior needed with parprouted.

fdanapfel commented 7 months ago

@uweseimet To verify that the IPv4 forwarding is enabled you can run the command sysctl net.ipv4.ip_forward which will return net.ipv4.ip_forward = 1 when IPv4 forwarding is enabled. To check if the interface is in promiscuous mode runip a and then check if PROMISC is listed in the flags for that interface, e. g. <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP>

Both settings are required, otherwise the Atari or Mac connected to the Daynaport will only be able to communicate with the Raspberry Pi, but not with the rest of the network even when parprouted is running.

Since as you can see at https://github.com/PiSCSI/piscsi/wiki/Dayna-Port-SCSI-Link#wireless-raspberry-pi-setup enabling the IPv4 forwarding in the kernel is required as well when using the NAT based network setup currently used by PiSCSI, I would suggest combining these options with the parameter discussed in this issue for enabling/disabling the bridge. I. e. if parameter is set to enable bridge then don't set IPv4 forwarding and promiscuous mode, if parameter is set to disable bridge then set IPv4 forwarding and promiscuous mode.

uweseimet commented 7 months ago

@fdanapfel Coupling these changes with the new "bridge" parameter is what I have also been thinking of. I created https://github.com/uweseimet/scsi2pi/issues/84 for this.