diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2022-09-17 13:32:58 +0000 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2022-09-17 13:32:58 +0000 |
commit | 5a1c1b590d319d58a178c6d299e99142bf7d4433 (patch) | |
tree | 7dd34e3085dae2fb95317c0d0c0d15081b11a03a /sys/src/9/ip/ipaux.c | |
parent | 05b08f6665b8b0c14c0cb4caa42929db8d26c6c9 (diff) |
devip: do tcp mss clamping when forwarding packets
when forwarding packets (gating), unconditionally
check tcp-syn packets for the mss-size option and
reduce it to fit the mtu of the outgoing interface.
this is done by exporting a new tcpmssclamp() function
from ip/tcp.c that takes an ip packet and its buffer size
and the effective mtu of the interface and adjusts
the mss value of tcp syn options.
this function is now also used by devbridge, enforcing
a tcp mss below the tunnel mtu.
Diffstat (limited to 'sys/src/9/ip/ipaux.c')
-rw-r--r-- | sys/src/9/ip/ipaux.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/src/9/ip/ipaux.c b/sys/src/9/ip/ipaux.c index 50e4e6cc1..9f413ca0e 100644 --- a/sys/src/9/ip/ipaux.c +++ b/sys/src/9/ip/ipaux.c @@ -557,8 +557,11 @@ hnputs_csum(void *p, ushort v, uchar *pcsum) { ulong csum; - assert((((uchar*)p - pcsum) & 1) == 0); - + if(((uchar*)p - pcsum) & 1){ + hnputs_csum((uchar*)p-1, (nhgets((uchar*)p-1) & 0xFF00) | v>>8, pcsum); + hnputs_csum((uchar*)p+1, (nhgets((uchar*)p+1) & 0x00FF) | v<<8, pcsum); + return; + } csum = nhgets(pcsum)^0xFFFF; csum += nhgets(p)^0xFFFF; csum += v; |