Subject: rfc: socketing it to gre
To: None <email@example.com>
From: David Young <firstname.lastname@example.org>
Date: 09/12/2007 23:08:17
I have made a patch against -current that makes gre(4) exclusively use
sockets for packet (dis)encapsulation and (de)muxing. In the new GRE
world order, you will not see gre(4) produce its own IP header, nor you
will find its hooks in the IP stack: sys/netinet/ip_gre.[ch] are no more!
The patch is at <ftp://cuw.ojctech.com/cuw/dyoung-9cb5d230/gre.patch>.
This is a work in progress. Right now, the only encapsulations I
support are GRE in UDP in IPv4, and GRE in IPv4. In the near future I
will support IPv6, and UDP in IPv6. In principle, you could use some
OSI/AppleTalk datagram protocol for the encapsulation, but that's not
supported quite yet.
I think that more of our tunnel interfaces deserve this socket treatment,
eventually: etherip, gif, and stf.
Review welcome. As always, I will appreciate your help with testing.
*** Some implementation details follow. ***
This patch adds a new protocol/address family-unaware socket option
that tells a socket that it should both add a protocol header to tx'd
datagrams and remove the header from rx'd datagrams. It helps me keep
knowledge of the encapsulating protocol *out* of gre(4). Only sockets
of type (AF_INET, SOCK_RAW) implement the option, right now. Example use:
int onoff = 1, s = socket(...);
setsockopt(s, SOL_SOCKET, SO_NOHEADER, &onoff);
I have also added a new subroutine, fsocreate(), that creates a socket
a la socreate(9) and sticks it into a process's file descriptor table.
I use it in both gre(4) and sys_socket(). gre sticks the sockets it owns
into process 0's file table, so it's clear which socket belongs to who.
David Young OJC Technologies
email@example.com Urbana, IL * (217) 278-3933 ext 24