Bug: fail to discover vpn interface
Summary
The interface created when using OpenVPN (tun0, tun1, etc.) is not discoverable by OpenCPI and therefore cannot be used for remote containers. This is of course problematic when the remote device exists on the other side of a VPN tunnel.
@aolivarez identified a workaround by setting the environment variable OCPI_TRANSFER_IP_ADDRESS
to the VPN IP address of the local machine. However, it would be nice to be able to use the OCPI_SOCKET_INTERFACE=tun0
to tell OpenCPI to use the VPN tunnel interface to communicate with a remote device on the other side of the VPN.
OCPI_TRANSFER_IP_ADDRESS
is found in opencpi/runtime/dataplane/xfer/drivers/socket/src/DtSocketXfer.cxx
.
Interface discovery happens in opencpi/os/linux/src/OcpiOsEther.cxx
.
Steps to reproduce
Lots of moving parts on this one and a VPN connection is required. An example will be given for the plutosdr platform and assumes a fresh clone of opencpi
scripts/install-opencpi.sh
source cdk/opencpi-setup.sh -s
ocpiadmin install platform adi_plutosdr0_31 ocpi.osp.plutosdr
ocpiadmin install platform plutosdr
ocpiadmin deploy platform adi_plutosdr0_31 plutosdr
export OCPI_SERVER_ADDRESSES=1.2.3.4:12345 # EXAMPLE
ocpiremote load -s adi_plutosdr0_31 -w plutosdr
ocpiremote start
cd projects/assets/applications
export OCPI_LIBRARY_PATH=/path/to/opencpi/projects/core:/path/to/opencpi/projects/assets
export OCPI_SOCKET_INTERFACE=tun0
ocpirun -v -d -m bias=hdl testbias.xml
Context
Testing workshop docker image
Expected correct behavior
OpenCPI should be able to discover all interfaces as reported by ifconfig
or ip a
or cat /proc/net/dev
or ls /sys/class/net
, etc. Also, ocpihdl ethers
should show the device as well? It's a question because the tun0
interface does not have a MAC address and is not an actual Ethernet interface, but is instead an encapsulation interface operating at the IP layer.
Relevant logs and/or screenshots
root@1af764cbe5a4:/opencpi/projects/assets/applications# ocpirun -v -d -P bias=adi_plutosdr0_31 testbias.xml
Available containers are: 0: pluto-17.opencpi-test.net:33333/rcc0 [model: rcc os: linux platform: adi_plutosdr0_31], 1: rcc0 [model: rcc os: linux platform: ubuntu18_04]
Actual deployment is:
Instance 0 file_read (spec ocpi.core.file_read) on rcc container 1: rcc0, using file_read in /opencpi/projects/core/artifacts/ocpi.core.file_read.rcc.0.ubuntu18_04.so dated Sun Aug 23 22:06:25 2020
Instance 1 bias (spec ocpi.core.bias) on rcc container 0: pluto-17.opencpi-test.net:33333/rcc0, using bias in /opencpi/projects/core/artifacts/ocpi.core.bias.rcc.0.adi_plutosdr0_31.so dated Tue Aug 25 02:19:06 2020
Instance 2 file_write (spec ocpi.core.file_write) on rcc container 1: rcc0, using file_write in /opencpi/projects/core/artifacts/ocpi.core.file_write.rcc.0.ubuntu18_04.so dated Sun Aug 23 22:06:30 2020
Application XML parsed and deployments (containers and artifacts) chosen
Exiting for exception: Cannot obtain a local IP address: No address found for socket interface: tun0 (Success [0])
Environment info
- OpenCPI Version used: develop (c8edaa46)
- Type of install (Source or RPM): Docker image registry.gitlab.com/opencpi/opencpi/ubuntu18.04-workshop:20200825
- Environment vars (
env | grep -i ocpi | sort
): Don't have them anymore - Operating System and version (ex. CentOS 7): Ubuntu 18.04
- Link to your project on GitLab (optional): NA
Possible fixes
As mentioned in the description, setting OCPI_TRANSFER_IP_ADDRESS
to the VPN IP address of the local computer is a workaround.
Acceptance criteria
See "Expected correct behavior" section above. Here is a local test log showing a successful "testbias" run over a VPN connection using the Pluto on the "opencpi-partner.net" network:
$ ocpirun -v -d -P bias=adi_plutosdr0_32 testbias.xml
Received server information from "10.2.0.12:12345". Available containers are:
10.2.0.12:12345/PL:0 platform plutosdr, model hdl, os , version , arch , build
Transports: ocpi-dma-pio,8c:ae:4c:db:0c:70,0,0,0x41,0x101|ocpi-socket-rdma, ,1,0,0x42,0x41|
10.2.0.12:12345/rcc0 platform adi_plutosdr0_32, model rcc, os linux, version adi_p0_32, arch aarch32, build
Transports: ocpi-dma-pio,8c:ae:4c:db:0c:70,1,0,0x103,0x103|ocpi-smb-pio,8c:ae:4c:db:0c:70,0,0,0xb,0xb|ocpi-socket-rdma, ,1,0,0x42,0x43|ocpi-udp-rdma, ,1,0,0x42,0x41|ocpi-ether-rdma,8c:ae:4c:db:0c:70,1,0,0x102,0x101|
Available containers are: 0: 10.2.0.12:12345/PL:0 [model: hdl os: platform: plutosdr], 1: 10.2.0.12:12345/rcc0 [model: rcc os: linux platform: adi_plutosdr0_32], 2: rcc0 [model: rcc os: linux platform: centos7]
Actual deployment is:
Instance 0 file_read (spec ocpi.core.file_read) on rcc container 2: rcc0, using file_read in /opt/downloads/opencpi/projects/core/artifacts/ocpi.core.file_read.rcc.0.centos7.so dated Tue Oct 18 17:02:02 2022
Instance 1 bias (spec ocpi.core.bias) on rcc container 1: 10.2.0.12:12345/rcc0, using bias_cc in /opt/downloads/opencpi/projects/core/artifacts/ocpi.core.bias_cc.rcc.0.adi_plutosdr0_32.so dated Wed Oct 19 01:44:16 2022
Instance 2 file_write (spec ocpi.core.file_write) on rcc container 2: rcc0, using file_write in /opt/downloads/opencpi/projects/core/artifacts/ocpi.core.file_write.rcc.0.centos7.so dated Tue Oct 18 17:02:06 2022
Application XML parsed and deployments (containers and artifacts) chosen [2 s 400 ms]
Application established: containers, workers, connections all created [0 s 248 ms]
Dump of all initial property values:
Property 0: file_read.fileName = "test.input" (cached)
Property 1: file_read.messagesInFile = "false" (cached)
Property 2: file_read.opcode = "0" (cached)
Property 3: file_read.messageSize = "16"
Property 4: file_read.granularity = "4" (cached)
Property 5: file_read.repeat = "false"
Property 6: file_read.bytesRead = "0"
Property 7: file_read.messagesWritten = "0"
Property 8: file_read.suppressEOF = "false"
Property 9: file_read.badMessage = "false"
Property 16: bias.biasValue = "16909060"
Property 20: bias.testws = "0"
Property 21: bias.param1 = "5" (parameter)
Property 22: bias.param2 = "6,7,8" (parameter)
Property 28: file_write.fileName = "test.output" (cached)
Property 29: file_write.messagesInFile = "false" (cached)
Property 30: file_write.bytesWritten = "0"
Property 31: file_write.messagesWritten = "0"
Property 32: file_write.stopOnEOF = "true" (cached)
Property 36: file_write.suppressWrites = "false"
Property 37: file_write.countData = "false"
Property 38: file_write.bytesPerSecond = "0"
Application started/running [0 s 467 ms]
Waiting for application to finish (no time limit)
Application finished [4 s 648 ms]
Dump of all final property values:
Property 0: file_read.fileName = "test.input" (cached)
Property 1: file_read.messagesInFile = "false" (cached)
Property 2: file_read.opcode = "0" (cached)
Property 3: file_read.messageSize = "16"
Property 4: file_read.granularity = "4" (cached)
Property 5: file_read.repeat = "false" (cached)
Property 6: file_read.bytesRead = "4000"
Property 7: file_read.messagesWritten = "250"
Property 8: file_read.suppressEOF = "false" (cached)
Property 9: file_read.badMessage = "false"
Property 16: bias.biasValue = "16909060"
Property 20: bias.testws = "0"
Property 28: file_write.fileName = "test.output" (cached)
Property 29: file_write.messagesInFile = "false" (cached)
Property 30: file_write.bytesWritten = "4000"
Property 31: file_write.messagesWritten = "250"
Property 32: file_write.stopOnEOF = "true" (cached)
Property 36: file_write.suppressWrites = "false" (cached)
Property 37: file_write.countData = "false" (cached)
Property 38: file_write.bytesPerSecond = "865"
And here is an ocpihdl -l10 ethers
run:
$ ocpihdl -l10 ethers
OCPI(10:998.0766): if_nameindex scan: 1 = lo (1 total)
OCPI(10:998.0766): if_nameindex scan: 2 = em1 (2 total)
OCPI(10:998.0766): if_nameindex scan: 3 = wlp0s20f0u8 (3 total)
OCPI(10:998.0766): if_nameindex scan: 4 = virbr0 (4 total)
OCPI(10:998.0766): if_nameindex scan: 5 = virbr0-nic (5 total)
OCPI(10:998.0766): if_nameindex scan: 9 = tun0 (6 total)
OCPI(10:998.0766): found interface 'lo' which is up, connected, at address <ANY>:0
1. lo: MAC address none, up, connected, loopback, IP address: 127.0.0.1
OCPI(10:998.0766): found interface 'em1' which is up, disconnected, at address e4:b9:7a:ea:f3:a6
2. em1: MAC address e4:b9:7a:ea:f3:a6, up, disconnected
OCPI(10:998.0767): found interface 'wlp0s20f0u8' which is up, connected, at address 00:c0:ca:97:ea:d6
3. wlp0s20f0u8: MAC address 00:c0:ca:97:ea:d6, up, connected, IP address: 192.168.11.119
OCPI(10:998.0767): found interface 'virbr0' which is up, disconnected, at address 52:54:00:fe:98:dc
4. virbr0: MAC address 52:54:00:fe:98:dc, up, disconnected, IP address: 192.168.122.1
OCPI(10:998.0767): Invalid type or failed parsing parameter file(s) for '/sys/class/net/virbr0-nic'
OCPI(10:998.0767): found interface 'tun0' which is up, connected, at address <ANY>:0
9. tun0: MAC address none, up, connected, IP address: 10.12.0.3
OCPI(10:998.0767): if_nameindex scan: 1 = lo (1 total)
OCPI(10:998.0767): if_nameindex scan: 2 = em1 (2 total)
OCPI(10:998.0767): if_nameindex scan: 3 = wlp0s20f0u8 (3 total)
OCPI(10:998.0767): if_nameindex scan: 4 = virbr0 (4 total)
OCPI(10:998.0767): if_nameindex scan: 5 = virbr0-nic (5 total)
OCPI(10:998.0767): if_nameindex scan: 9 = tun0 (6 total)
OCPI(10:998.0767): found interface 'lo' which is up, connected, at address <ANY>:0
OCPI(10:998.0767): found interface 'em1' which is up, disconnected, at address e4:b9:7a:ea:f3:a6
OCPI(10:998.0767): Establishing system identity from interface 'em1': e4:b9:7a:ea:f3:a6
System identity is: e4:b9:7a:ea:f3:a6
Finally, here is an environment variable dump showing that OCPI_TRANSFER_IP_ADDRESS is not set:
$ env | grep OCPI
OCPI_TOOL_PLATFORM=centos7
OCPI_PREREQUISITES_DIR=/opt/downloads/opencpi/prerequisites
OCPI_TOOL_OS_VERSION=c7
OCPI_CDK_DIR=/opt/downloads/opencpi/cdk
OCPI_XILINX_VIVADO_VERSION=2021.2
OCPI_ROOT_DIR=/opt/downloads/opencpi
OCPI_SERVER_ADDRESSES=10.2.0.12:12345
OCPI_TOOL_OS=linux
OCPI_SOCKET_INTERFACE=tun0
OCPI_TOOL_PLATFORM_DIR=/opt/downloads/opencpi/project-registry/ocpi.core/exports/rcc/platforms/centos7
OCPI_TOOL_ARCH=x86_64
OCPI_TOOL_DIR=centos7