From owner-freebsd-net Tue Jan 25 23: 1:35 2000 Delivered-To: freebsd-net@freebsd.org Received: from gatekeeper.tsc.tdk.com (gatekeeper.tsc.tdk.com [207.113.159.21]) by hub.freebsd.org (Postfix) with ESMTP id 481F214F0E for ; Tue, 25 Jan 2000 23:01:32 -0800 (PST) (envelope-from gdonl@tsc.tdk.com) Received: from imap.gv.tsc.tdk.com (imap.gv.tsc.tdk.com [192.168.241.198]) by gatekeeper.tsc.tdk.com (8.8.8/8.8.8) with ESMTP id XAA10658; Tue, 25 Jan 2000 23:01:28 -0800 (PST) (envelope-from gdonl@tsc.tdk.com) Received: from salsa.gv.tsc.tdk.com (salsa.gv.tsc.tdk.com [192.168.241.194]) by imap.gv.tsc.tdk.com (8.9.3/8.9.3) with ESMTP id XAA77723; Tue, 25 Jan 2000 23:01:27 -0800 (PST) (envelope-from Don.Lewis@tsc.tdk.com) Received: (from gdonl@localhost) by salsa.gv.tsc.tdk.com (8.8.5/8.8.5) id XAA29038; Tue, 25 Jan 2000 23:01:27 -0800 (PST) From: Don Lewis Message-Id: <200001260701.XAA29038@salsa.gv.tsc.tdk.com> Date: Tue, 25 Jan 2000 23:01:27 -0800 In-Reply-To: <4.2.2.20000125232750.04074b50@localhost> References: <200001251722.KAA04527@harmony.village.org> <4.2.2.20000125113518.01a59100@localhost> <4.2.2.20000125232750.04074b50@localhost> X-Mailer: Mail User's Shell (7.2.6 beta(5) 10/07/98) To: Brett Glass , Don Lewis , Matthew Dillon Subject: Re: Merged patches Cc: freebsd-net@FreeBSD.ORG Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Jan 25, 11:38pm, Brett Glass wrote: } Subject: Re: Merged patches } At 11:05 PM 1/25/2000 , Don Lewis wrote: } } >A switch based on the TCP flags would be a very unnatural implementation. } >For instance, most of the processing done on a packet received on an } >established connection is the same whether the FIN bit is set or not. } } A switch statement can allow the same group of statements to be executed } for more than one combination of the flags. Yes, but the processing has to be identical unless you add extra flags tests inside the case block. } >If the switch expression was based on the flags, then a large part of } >the code would be duplicated between these two cases. } } It is also possible to "fall through" from one case to another. This makes } the switch statement a very powerful tool for this sort of situation. This only works if one case is preamble for the next. You have to add extra tests if you want to exit the case early for some sets of flags values. And don't forget the /* fall through */. } It } is also possible to call a common subroutine. The overhead of a fixed } subroutine call is often less than that of a conditional branch on } today's CPUs. Don't forget about all the nice unstructured "goto drop" statements that bail out of deeply nested blocks in tcp_input(). It would be pretty inconvenient if you wanted to bail out from the middle of a subroutine. } > Also, the code } >may do some processing on the segment, clear the SYN and/or FIN bits, } >and then continue. } } I'd think it would be unusual -- perhaps bad form -- to alter the flags, } as it would make the code harder to follow. In what situation(s) would } you do this? You have to do this if the flags fall outside the window. if (todrop > 0) { if (thflags & TH_SYN) { thflags &= ~TH_SYN; th->th_seq++; if (th->th_urp > 1) th->th_urp--; else thflags &= ~TH_URG; todrop--; } /* * Following if statement from Stevens, vol. 2, p. 960. */ if (todrop > tlen || (todrop == tlen && (thflags & TH_FIN) == 0)) { /* * Any valid FIN must be to the left of the window. * At this point the FIN must be a duplicate or out * of sequence; drop it. */ thflags &= ~TH_FIN; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message