diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2019-03-03 05:25:00 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2019-03-03 05:25:00 +0100 |
commit | 5b972a9aea9383fbb66142a6a9958e01f7028a89 (patch) | |
tree | e66a1ec299f3ed8a9dc7f0b39a9dea29e4cfbcde /sys/src/9/ip/ip.h | |
parent | 0aac600fb3b659b5b9a2a8aaefb821774cf38bd2 (diff) |
devip: fix ip fragmentation handling issues with header options
some protocols assume that Ip4hdr.length[] and Ip6hdr.ploadlen[]
are valid and not out of range within the block but this has
not been verified. also, the ipv4 and ipv6 headers can have variable
length options, which was not considered in the fragmentation and
reassembly code.
to make this sane, ipiput4() and ipiput6() now verify that everything
is in range and trims to block to the expected size before it does
any further processing. now blocklen() and Ip4hdr.length[] are conistent.
ipoput4() and ipoput6() are simpler now, as they can rely on
blocklen() only, not having a special routing case.
ip fragmentation reassembly has to consider that fragments could
arrive with different ip header options, so we store the header+option
size in new Ipfrag.hlen field.
unfraglen() has to make sure not to run past the buffer, and hadle
the case when it encounters multiple fragment headers.
Diffstat (limited to 'sys/src/9/ip/ip.h')
-rw-r--r-- | sys/src/9/ip/ip.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/src/9/ip/ip.h b/sys/src/9/ip/ip.h index a1233ec46..017a8ad2f 100644 --- a/sys/src/9/ip/ip.h +++ b/sys/src/9/ip/ip.h @@ -57,7 +57,7 @@ enum IP_HLEN4= 5, /* v4: Header length in words */ IP_DF= 0x4000, /* v4: Don't fragment */ IP_MF= 0x2000, /* v4: More fragments */ - IP4HDR= 20, /* sizeof(Ip4hdr) */ + IP4HDR= IP_HLEN4<<2, /* sizeof(Ip4hdr) */ IP_MAX= 64*1024, /* Max. Internet packet size, v4 & v6 */ /* 2^Lroot trees in the root table */ @@ -123,9 +123,9 @@ struct Fragment6 struct Ipfrag { + ushort hlen; ushort foff; ushort flen; - uchar payload[]; }; @@ -693,6 +693,7 @@ extern int ipstats(Fs*, char*, int); extern ushort ptclbsum(uchar*, int); extern ushort ptclcsum(Block*, int, int); extern void ip_init(Fs*); +extern void ip_init_6(Fs*); /* * bootp.c |