From aaf0177750d55669d64e54cdb59e4f6872e9a295 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Thu, 13 Feb 2003 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2003-02-13 --- ip/ip.c | 2 +- ip/tcp.c | 16 +++++++++++++++- port/portdat.h | 10 ++++++++-- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/ip/ip.c b/ip/ip.c index 5467af7b09ec900d4ebff65427f434608c9189c4..213c5911395da1108b04a13473371b9b03dff2f4 100644 --- a/ip/ip.c +++ b/ip/ip.c @@ -441,7 +441,7 @@ ipiput4(Fs *f, Ipifc *ifc, Block *bp) h = (Ip4hdr*)(bp->rp); /* dump anything that whose header doesn't checksum */ - if(ipcsum(&h->vihl)) { + if((bp->flag & Bipck) == 0 && ipcsum(&h->vihl)) { ip->stats[InHdrErrors]++; netlog(f, Logip, "ip: checksum error %V\n", h->src); freeblist(bp); diff --git a/ip/tcp.c b/ip/tcp.c index fab8dcf1d86d82e34cb1da86141cef7cd2d05e83..31069fdb2c7d137413811ea2aa694b6524a9df48 100644 --- a/ip/tcp.c +++ b/ip/tcp.c @@ -361,7 +361,7 @@ struct Tcppriv * it that number gets acked by the other end, we shut down the connection. * Look for tcpporthogedefense in the code. */ -int tcpporthogdefense = 1; +int tcpporthogdefense = 0; int addreseq(Tcpctl*, Tcppriv*, Tcp*, Block*, ushort); void getreseq(Tcpctl*, Tcp*, Block**, ushort*); @@ -3013,6 +3013,18 @@ tcpadvise(Proto *tcp, Block *bp, char *msg) freeblist(bp); } +static char* +tcpporthogdefensectl(char *val) +{ + if(strcmp(val, "on") == 0) + tcpporthogdefense = 1; + else if(strcmp(val, "off") == 0) + tcpporthogdefense = 0; + else + return "unknown value for tcpporthogdefense"; + return nil; +} + /* called with c qlocked */ char* tcpctl(Conv* c, char** f, int n) @@ -3023,6 +3035,8 @@ tcpctl(Conv* c, char** f, int n) return tcpstartka(c, f, n); if(n >= 1 && strcmp(f[0], "checksum") == 0) return tcpsetchecksum(c, f, n); + if(n >= 1 && strcmp(f[0], "tcpporthogdefense") == 0) + return tcpporthogdefensectl(f[1]); return "unknown control request"; } diff --git a/port/portdat.h b/port/portdat.h index 07cd7530698d315fea22c2325bd537dc41d71bd1..e4440ed61cf2e33890899c43a8db7e74faf1c3fe 100644 --- a/port/portdat.h +++ b/port/portdat.h @@ -124,10 +124,15 @@ enum CCACHE = 0x0080, /* client cache */ }; +/* flag values */ enum { BINTR = (1<<0), BFREE = (1<<1), + Bipck = (1<<2), /* ip checksum */ + Budpck = (1<<3), /* udp checksum */ + Btcpck = (1<<4), /* tcp checksum */ + Bpktck = (1<<5), /* packet checksum */ }; struct Block @@ -137,9 +142,10 @@ struct Block uchar* rp; /* first unconsumed byte */ uchar* wp; /* first empty byte */ uchar* lim; /* 1 past the end of the buffer */ - uchar* base; /* start of the buffer */ + uchar* base; /* start of the buffer */ void (*free)(Block*); - ulong flag; + ushort flag; + ushort checksum; /* IP checksum of complete packet (minus media header) */ }; #define BLEN(s) ((s)->wp - (s)->rp) #define BALLOC(s) ((s)->lim - (s)->base)