Page MenuHomeFreeBSD

Allow netcat to be a tun tunnel broker
Needs ReviewPublic

Authored by thj on Fri, Nov 18, 4:16 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 2, 11:15 AM
Unknown Object (File)
Fri, Dec 2, 11:15 AM
Unknown Object (File)
Wed, Nov 30, 4:14 AM
Unknown Object (File)
Mon, Nov 28, 1:19 PM

Details

Reviewers
kevans
Group Reviewers
Klara
Summary

Add tests with this new functionality to test that tun devices can pass packets.

You need to figure both sides with netcat, one side should listen:

  1. ifconfig tun create

tun0

  1. nc -u -l --tun /dev/tun0 192.168.100.12 2600 &
  2. ifconfig tun0 inet 10.4.100.2/24 10.4.100.3 up
  1. ifconfig tun create

tun0

  1. nc -u --tun /dev/tun0 192.168.100.12 2600 &
  2. ifconfig tun0 inet 10.4.100.2/24 10.4.100.2 up

This is very naiive and probably quite fragile, but it is enough to enable tun
tests using just netcat.

Add usage and help strings

Add tun tunnelling test using nc

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Warnings
SeverityLocationCodeMessage
Warningtests/sys/net/if_tun_test.sh:CHMOD1Invalid Executable
Unit
No Test Coverage
Build Status
Buildable 48420
Build 45306: arc lint + arc unit

Event Timeline

thj requested review of this revision.Fri, Nov 18, 4:16 PM
thj retitled this revision from Allow netcat to be a tun tunnel broker Add tests with this new functionality to test that tun devices can pass packets. to Allow netcat to be a tun tunnel broker.Fri, Nov 18, 4:35 PM
thj edited the summary of this revision. (Show Details)

Just some minor simplifications, I think we can just use tun_fd being a valid fd as an indicator that we should be tunneling instead of tracking that in separate state.

contrib/netcat/netcat.c
150

Normally we just use CHAR_MAX to make it clear

164

IMO, let's init tundev to NULL here

337

tundev could be a const char * and you can avoid having to make a copy of optarg here, since we don't need to mutate it later.

339

Drop FreeBSD_tun completely, the below conditional can use tundev != NULL

586

tun_fd >= 0, since we initialize it to -1

864

Let's use tun_fd >= 0 for these ones, as well