Subject: EtherIP implementation slightly broken?
To: None <tech-net@netbsd.org>
From: Dave Huang <khym@azeotrope.org>
List: tech-net
Date: 03/18/2005 22:57:35
I was looking into tunneling Ethernet frames over IP and came across
EtherIP (RFC 3378), support for which was ported to NetBSD from
OpenBSD earlier this year. However, I also came across this message:
<http://oss.sgi.com/archives/netdev/2005-01/msg00695.html>, which
claims that OpenBSD's implementation puts the version in the wrong
nibble of the header, and that NetBSD has inherited the same problem.
<http://www.monkey.org/openbsd/archive/bugs/0410/msg00017.html>
mentions the same thing.

According to the RFC <http://www.ietf.org/rfc/rfc3378.txt>, the
header looks like:

      Bits 0-3:  Protocol version
      Bits 4-15: Reserved for future use

        0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
     +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
     |               |                                               |
     |    VERSION    |                   RESERVED                    |
     |               |                                               |
     +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

                 Figure 2: EtherIP Header Format (in bits)

NetBSD's src/sys/netinet/in_gif.h says:

struct etherip_header {
        u_int8_t eip_ver;        /* version/reserved */
        u_int8_t eip_pad;        /* required padding byte */
};
#define ETHERIP_VER_VERS_MASK   0x0f
#define ETHERIP_VER_RSVD_MASK   0xf0
#define ETHERIP_VERSION         0x03

So assuming network order in the RFC, it does seem that NetBSD is
putting the version in bits 4-7, rather than in bits 0-3.

Note that I haven't tried interoperating with Linux yet, and may
never actually set up an EtherIP tunnel. However, if I do, it would
be between NetBSD and Linux, so interoperability with Linux is
important to me, while interoperability with OpenBSD is not :)

Side question: is it possible to set up a filter so that only a
certain Ethernet frame type gets sent over the tunnel? It sounds
like the only filtering supported is via ipf, which filters at the
IP level.
-- 
Name: Dave Huang         |  Mammal, mammal / their names are called /
INet: khym@azeotrope.org |  they raise a paw / the bat, the cat /
FurryMUCK: Dahan         |  dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 29 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++