diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2022-12-13 22:23:01 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2022-12-13 22:23:01 +0000 |
commit | 074b691f16faba137ab9cb48471fc3160b33da40 (patch) | |
tree | 1fd8f9a2342185717d541655fc74347b5f570f56 /sys/src/9/ip/tcp.c | |
parent | 5f42bde60275e9a0c3d317ee1e052e1aefdcdb19 (diff) |
devip: tcpmssclamp() to minimum of source and destination interface MTU
We used to only clamp to the MTU of the destination interface,
but this is wrong. We have to clamp to the minimum of both
source and destination.
For this, we change the gating argument type of ipoput4()
and ipoput6() from int to Ipifc* to pass the source interface.
Diffstat (limited to 'sys/src/9/ip/tcp.c')
-rw-r--r-- | sys/src/9/ip/tcp.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/sys/src/9/ip/tcp.c b/sys/src/9/ip/tcp.c index f6fbf19ed..a5b1c5f2a 100644 --- a/sys/src/9/ip/tcp.c +++ b/sys/src/9/ip/tcp.c @@ -1391,10 +1391,10 @@ sndrst(Proto *tcp, uchar *source, uchar *dest, ushort length, Tcp *seg, uchar ve switch(version) { case V4: hbp = htontcp4(seg, nil, &ph4, nil); - return ipoput4(tcp->f, hbp, 0, MAXTTL, DFLTTOS, rh); + return ipoput4(tcp->f, hbp, nil, MAXTTL, DFLTTOS, rh); case V6: hbp = htontcp6(seg, nil, &ph6, nil); - return ipoput6(tcp->f, hbp, 0, MAXTTL, DFLTTOS, rh); + return ipoput6(tcp->f, hbp, nil, MAXTTL, DFLTTOS, rh); } return -1; } @@ -1428,12 +1428,12 @@ tcphangup(Conv *s) case V4: tcb->protohdr.tcp4hdr.vihl = IP_VER4; hbp = htontcp4(&seg, nil, &tcb->protohdr.tcp4hdr, tcb); - ipoput4(s->p->f, hbp, 0, s->ttl, s->tos, s); + ipoput4(s->p->f, hbp, nil, s->ttl, s->tos, s); break; case V6: tcb->protohdr.tcp6hdr.vcf[0] = IP_VER6; hbp = htontcp6(&seg, nil, &tcb->protohdr.tcp6hdr, tcb); - ipoput6(s->p->f, hbp, 0, s->ttl, s->tos, s); + ipoput6(s->p->f, hbp, nil, s->ttl, s->tos, s); break; default: panic("tcphangup: version %d", s->ipversion); @@ -1512,10 +1512,10 @@ sndsynack(Proto *tcp, Limbo *lp) switch(lp->version) { case V4: hbp = htontcp4(&seg, nil, &ph4, nil); - return ipoput4(tcp->f, hbp, 0, MAXTTL, DFLTTOS, &rh); + return ipoput4(tcp->f, hbp, nil, MAXTTL, DFLTTOS, &rh); case V6: hbp = htontcp6(&seg, nil, &ph6, nil); - return ipoput6(tcp->f, hbp, 0, MAXTTL, DFLTTOS, &rh); + return ipoput6(tcp->f, hbp, nil, MAXTTL, DFLTTOS, &rh); } return -1; } @@ -2061,7 +2061,7 @@ done: } static void -tcpiput(Proto *tcp, Ipifc*, Block *bp) +tcpiput(Proto *tcp, Ipifc *ifc, Block *bp) { Tcp seg; Tcp4hdr *h4; @@ -2184,7 +2184,7 @@ reset: hnputs_csum(h4->tcpdst+2, nhgets(q->forward.raddr+IPv4off+2), h4->tcpcksum); hnputs_csum(h4->tcpdport, q->forward.rport, h4->tcpcksum); qunlock(tcp); - ipoput4(f, bp, 1, hop - 1, h4->tos, q); + ipoput4(f, bp, ifc, hop - 1, h4->tos, q); return; } s = iphconv(iph); @@ -2757,11 +2757,11 @@ tcpoutput(Conv *s) switch(version){ case V4: - if(ipoput4(f, hbp, 0, s->ttl, s->tos, s) < 0) + if(ipoput4(f, hbp, nil, s->ttl, s->tos, s) < 0) localclose(s, Enoroute); break; case V6: - if(ipoput6(f, hbp, 0, s->ttl, s->tos, s) < 0) + if(ipoput6(f, hbp, nil, s->ttl, s->tos, s) < 0) localclose(s, Enoroute); break; } @@ -2811,13 +2811,13 @@ tcpsendka(Conv *s) /* Build header, link data and compute cksum */ tcb->protohdr.tcp4hdr.vihl = IP_VER4; hbp = htontcp4(&seg, dbp, &tcb->protohdr.tcp4hdr, tcb); - return ipoput4(s->p->f, hbp, 0, s->ttl, s->tos, s); + return ipoput4(s->p->f, hbp, nil, s->ttl, s->tos, s); } else { /* Build header, link data and compute cksum */ tcb->protohdr.tcp6hdr.vcf[0] = IP_VER6; hbp = htontcp6(&seg, dbp, &tcb->protohdr.tcp6hdr, tcb); - return ipoput6(s->p->f, hbp, 0, s->ttl, s->tos, s); + return ipoput6(s->p->f, hbp, nil, s->ttl, s->tos, s); } } @@ -3214,7 +3214,7 @@ tcptrim(Tcpctl *tcb, Tcp *seg, Block **bp, ushort *length) } static void -tcpadvise(Proto *tcp, Block *bp, char *msg) +tcpadvise(Proto *tcp, Block *bp, Ipifc *ifc, char *msg) { Tcp4hdr *h4; Tcp6hdr *h6; @@ -3259,7 +3259,7 @@ tcpadvise(Proto *tcp, Block *bp, char *msg) hnputs(h4->tcpsport, q->forward.rport); qunlock(tcp); - icmpproxyadvice(tcp->f, bp, h4->tcpsrc); + icmpproxyadvice(tcp->f, bp, ifc, h4->tcpsrc); return; } s = iphconv(iph); |