devip: ignore the evil bit in fragment info field

using ~IP_DF mask to select offset and "more fragments" bits
includes the evil bit 15. so instead define a constant IP_FO
for the fragment offset bits and use (IP_MF|IP_FO). that way
the evil bit gets ignored and doesnt cause any useless calls
to ipreassemble().
front
cinap_lenrek 2019-03-07 22:39:50 +01:00
parent 4885c75526
commit 4b8f7a2110
3 changed files with 6 additions and 5 deletions

View File

@ -401,7 +401,7 @@ icmpiput(Proto *icmp, Ipifc*, Block *bp)
goto raise;
}
p = (Icmp *)bp->rp;
if((nhgets(p->frag) & ~(IP_DF|IP_MF)) == 0){
if((nhgets(p->frag) & IP_FO) == 0){
pr = Fsrcvpcolx(icmp->f, p->proto);
if(pr != nil && pr->advise != nil) {
(*pr->advise)(pr, bp, msg);

View File

@ -333,7 +333,7 @@ ipiput4(Fs *f, Ipifc *ifc, Block *bp)
/* reassemble if the interface expects it */
if(nifc->reassemble){
frag = nhgets(h->frag);
if(frag & ~IP_DF) {
if(frag & (IP_MF|IP_FO)) {
bp = ip4reassemble(ip, frag, bp);
if(bp == nil)
return;
@ -360,7 +360,7 @@ ipiput4(Fs *f, Ipifc *ifc, Block *bp)
}
frag = nhgets(h->frag);
if(frag & ~IP_DF) {
if(frag & (IP_MF|IP_FO)) {
bp = ip4reassemble(ip, frag, bp);
if(bp == nil)
return;
@ -436,7 +436,7 @@ ip4reassemble(IP *ip, int offset, Block *bp)
* and get rid of any fragments that might go
* with it.
*/
if((offset & ~IP_DF) == 0) {
if((offset & (IP_MF|IP_FO)) == 0) {
if(f != nil) {
ip->stats[ReasmFails]++;
ipfragfree4(ip, f);
@ -451,7 +451,7 @@ ip4reassemble(IP *ip, int offset, Block *bp)
}
fp = (Ipfrag*)bp->base;
fp->foff = (offset & 0x1fff)<<3;
fp->foff = (offset & IP_FO)<<3;
fp->flen = fragsize;
/* First fragment allocates a reassembly queue */

View File

@ -57,6 +57,7 @@ enum
IP_HLEN4= 5, /* v4: Header length in words */
IP_DF= 0x4000, /* v4: Don't fragment */
IP_MF= 0x2000, /* v4: More fragments */
IP_FO= 0x1fff, /* v4: Fragment offset */
IP4HDR= IP_HLEN4<<2, /* sizeof(Ip4hdr) */
IP_MAX= 64*1024, /* Max. Internet packet size, v4 & v6 */