matt-williams / rina-interposer

Interposer between BSD Sockets/POSIX and RINA
1 stars 2 forks source link

tested rina-interposer with netcat (using IRATI), netcat server complains #1

Open edugrasa opened 6 years ago

edugrasa commented 6 years ago

Congrats for this excellent initiative! (the rina-interposer)

I've just tried the netcat example in the README with the IRATI implementation (instead of rlite), and I'm not sure if the output of the experiment is the expected one (maybe it is). The netcat server registers in the DIF and the flow gets allocated, but after flow allocation the netcat server complains that the connection is invalid and closes. Is that what should happen? Thanks a lot!

Here is the nc client output:

root@e2-edu-vm2:~/rina-interposer# RINA_DIF=normal.DIF RINA_LOCAL_APPL=nc-client RINA_REMOTE_APPL=nc-server RINA_VERBOSE=hey LD_PRELOAD=$(pwd)/libinterposer.so nc 1.2.3.4 1234
socket(2, 1, 6)...
...returns 3
connect(3, 0x9a791d8, 16)...
  RINA_DIF=normal.DIF, RINA_LOCAL_APPL=nc-client, RINA_REMOTE_APPL=nc-server => RINA interposer enabled!
  rina_flow_alloc("normal.DIF", "nc-client", "nc-server", NULL, 0)...
  ...returns 5
  RINA FD = 5 - swapping for 3
...returns -1

And here is the output from the netcat server (in verbose mode):

root@e2-edu-vm3:~/rina-interposer# RINA_DIF=normal.DIF RINA_LOCAL_APPL=nc-server LD_PRELOAD=$(pwd)/libinterposer.so nc -vvl 1.2.3.4 1234
1.2.3.4: inverse host lookup failed: Unknown host
18512(1508335983)#librina.ctrldev (DBG): Wrote ctrl msg of 72 bytes to cfd 5
18512(1508335983)#librina.ctrldev (DBG): Trying to read ctrl msg of 54 bytes
18512(1508335983)#librina.ctrldev (DBG): Read ctrl msg of 54 bytes from cfd 5
local getsockname failed : Socket operation on non-socket
listening on [any] 0 ... : Socket operation on non-socket

/*  Here the netcat server is registered at the DIF and waits for flow allocation */

getsockopt failed : Socket operation on non-socket
IP options: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  : Socket operation on non-socket
post-rcv getsockname failed : Socket operation on non-socket
invalid connection to [0.0.0.0] from localhost [127.0.0.1] 1234
root@e2-edu-vm3:~/rina-interposer# 
matt-williams commented 6 years ago

Thanks! I haven't tried with IRATI, but will try to take a look this weekend.

One thing that might be worth trying is removing the vv from nc -vvl 1.2.3.4 1234 - it's just possible that the getsockopt call is only being made to get diagnostic information (which wouldn't be required if we weren't verbose logging).

...but your issue does raise a genuine problem - since the RINA file descriptors are not sockets, calls to any socket-fd-expecting function (such as getsockopt) will fail at present. (I was lucky that, at least in my testing, nc did not make any such calls.) I think the answer is for the interposer to mock these out too - either by mocking out every socket option (which sounds like a lot of work) or by opening a real socket and calling getsockopt on that (which would obviously give incorrect results, but they might look right enough to allow the process to continue).

edugrasa commented 6 years ago

Tried without -vv and same issues, maybe it depends on the netcat version. I've been more lucky with iperf, got it to send traffic between a client and server in TCP mode. I've also submitted a PR for your consideration, somewhat related to it: https://github.com/matt-williams/rina-interposer/pull/2