netgraph(4) divert(4) to UDP Tunnel
Ruslan Ermilov
ru at freebsd.org
Fri Nov 14 00:36:12 PST 2003
On Thu, Nov 13, 2003 at 12:24:35PM -0800, Crist J. Clark wrote:
> I'm trying to play around with netgraph(4) for the first time and
> there seem to be some aspects of it that haven't "clicked" in my head
> just yet.
>
> What I want to do seems like it should be pretty easy. I want to
> send some packets through a UDP tunnel. There is an
> /usr/share/examples/netgraph/udp.tunnel file that is close to what I
> want, but not quite. I want to send packets that have been divert(4)ed
> to the tunnel.
>
> I can make my two ng_ksocket(8) nodes via the ngctl(8) interface,
>
> + mkpeer ksocket d0 inet/dgram/udp
> + name d0 udptun
> + msg d0 bind inet/192.168.64.70:10000
> + msg d0 connect inet/192.168.64.50:10000
> + mkpeer ksocket d1 inet/raw/divert
> + name d1 divtun
> + msg d1 bind inet/0.0.0.0:8668
>
> But how do I then connect the two of them up? I assume that I use
> 'connect' within ngctl(8), but I haven't figured out what the
> arguments need to be with the documentation and examples I've found.
>
> The other thing I suspect I should be doing, is actually running the
> 'mkpeer' through the first node I create in ngctl(8), but I can't seem
> to get that to work,
>
> + mkpeer ksocket d0 inet/dgram/udp
> + name d0 udptun
> + msg d0 bind inet/192.168.64.70:10000
> + msg d0 connect inet/192.168.64.50:10000
> + mkpeer d0 ksocket d1 inet/raw/divert
> ngctl: send msg: Socket is already connected
>
> I think it is actually complaining about the hook between my ngctl
> node and the udptun node and not the creation of the divert socket?
>
> Basically, I think my conceptual problem is with the fact that you
> start with the ngctl(8) node in the middle of everything. How do I
> create my new nodes and get the ngctl(8) node out of the middle?
>
I don't think this is currently possible (I'd like to be mistaken).
The main difference between ng_iface (from the classical tunnel
example) and ng_ksocket is that the first is so-called ``persistent''
node, i.e., when the number of hooks becomes zero, the node does
not get removed automatically. This same is not true for ksocket.
But I think this could be a work around:
ngctl
+ mkpeer tee dummy left2right
+ name dummy mytee
+ mkpeer mytee: ksocket left inet/dgram/udp
+ name mytee:left udp1
+ mkpeer mytee: ksocket right inet/dgram/udp
+ name mytee:right udp2
+ exit
# ngctl show mytee:
Name: mytee Type: tee ID: 0000000e Num hooks: 2
Local hook Peer name Peer type Peer ID Peer hook
---------- --------- --------- ------- ---------
right udp2 ksocket 00000010 inet/dgram/udp
left udp1 ksocket 0000000f inet/dgram/udp
I've omitted any socket-related ops, and both sockets are of type
UDP (I don't have the divert(4) support compiled in on this machine),
but this should not be important.
Cheers,
--
Ruslan Ermilov Sysadmin and DBA,
ru at sunbay.com Sunbay Software Ltd,
ru at FreeBSD.org FreeBSD committer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-net/attachments/20031114/dc0f800b/attachment.bin
More information about the freebsd-net
mailing list