diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-01-20 15:13:11 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-01-20 15:13:11 +0100 |
commit | 9840c50a3e0d2392a9102484e0caf970d3153790 (patch) | |
tree | 0af291492d82396f063380727c96fa02341143d4 /sys/src/9/ip/gre.c | |
parent | 9d0ba6f162f01253edaa4b8602f620b1869a71ca (diff) |
gre: don't drop pptp packets when smaller than v4 header
Diffstat (limited to 'sys/src/9/ip/gre.c')
-rw-r--r-- | sys/src/9/ip/gre.c | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/sys/src/9/ip/gre.c b/sys/src/9/ip/gre.c index df22c087a..c18153472 100644 --- a/sys/src/9/ip/gre.c +++ b/sys/src/9/ip/gre.c @@ -558,47 +558,45 @@ greiput(Proto *proto, Ipifc *, Block *bp) if(flags & GRE_seq) hdrlen += 4; - if(BLEN(bp) - hdrlen < sizeof(Ip4hdr)){ - print("greretunnel: packet too short (s=%V d=%V)\n", - gre->src, gre->dst); - freeb(bp); - return; - } - ip = (Ip4hdr *)(bp->rp + hdrlen); - qlock(proto); - /* - * Look for a conversation structure for this port and address, or - * match the retunnel part, or match on the raw flag. - */ - for(p = proto->conv; *p; p++) { - c = *p; - if(c->inuse == 0) - continue; + if(eproto != 0x880B && BLEN(bp) - hdrlen >= sizeof(Ip4hdr)){ + ip = (Ip4hdr *)(bp->rp + hdrlen); /* - * Do not stop this session - blocking here - * implies that etherread is blocked. + * Look for a conversation structure for this port and address, or + * match the retunnel part, or match on the raw flag. */ - grec = c->ptcl; - if(memcmp(ip->dst, grec->hoa, sizeof ip->dst) == 0){ - grepdin++; - grebdin += BLEN(bp); - gredownlink(c, bp); - qunlock(proto); - return; - } + for(p = proto->conv; *p; p++) { + c = *p; - if(memcmp(ip->src, grec->hoa, sizeof ip->src) == 0){ - grepuin++; - grebuin += BLEN(bp); - greuplink(c, bp); - qunlock(proto); - return; + if(c->inuse == 0) + continue; + + /* + * Do not stop this session - blocking here + * implies that etherread is blocked. + */ + grec = c->ptcl; + if(memcmp(ip->dst, grec->hoa, sizeof ip->dst) == 0){ + grepdin++; + grebdin += BLEN(bp); + gredownlink(c, bp); + qunlock(proto); + return; + } + + if(memcmp(ip->src, grec->hoa, sizeof ip->src) == 0){ + grepuin++; + grebuin += BLEN(bp); + greuplink(c, bp); + qunlock(proto); + return; + } } } + /* * when we get here, none of the forwarding tunnels matched. now * try to match on raw and conversational sessions. |