From owner-svn-src-head@FreeBSD.ORG Wed Jul 10 12:06:02 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 44D6BDF3; Wed, 10 Jul 2013 12:06:02 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 361A7195A; Wed, 10 Jul 2013 12:06:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6AC62u3021177; Wed, 10 Jul 2013 12:06:02 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r6AC61qo021175; Wed, 10 Jul 2013 12:06:01 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201307101206.r6AC61qo021175@svn.freebsd.org> From: Andre Oppermann Date: Wed, 10 Jul 2013 12:06:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r253150 - head/sys/netinet X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 12:06:02 -0000 Author: andre Date: Wed Jul 10 12:06:01 2013 New Revision: 253150 URL: http://svnweb.freebsd.org/changeset/base/253150 Log: Extend debug logging of TCP timestamp related specification violations. Update related comments and style. Modified: head/sys/netinet/tcp_input.c head/sys/netinet/tcp_syncache.c Modified: head/sys/netinet/tcp_input.c ============================================================================== --- head/sys/netinet/tcp_input.c Wed Jul 10 10:57:09 2013 (r253149) +++ head/sys/netinet/tcp_input.c Wed Jul 10 12:06:01 2013 (r253150) @@ -1446,6 +1446,8 @@ tcp_do_segment(struct mbuf *m, struct tc int thflags, acked, ourfinisacked, needoutput = 0; int rstreason, todrop, win; u_long tiwin; + char *s; + struct in_conninfo *inc; struct tcpopt to; #ifdef TCPDEBUG @@ -1458,6 +1460,7 @@ tcp_do_segment(struct mbuf *m, struct tc short ostate = 0; #endif thflags = th->th_flags; + inc = &tp->t_inpcb->inp_inc; tp->sackhint.last_sack_ack = 0; /* @@ -1546,6 +1549,24 @@ tcp_do_segment(struct mbuf *m, struct tc if (TSTMP_GT(to.to_tsecr, tcp_ts_getticks())) to.to_tsecr = 0; } + /* + * If timestamps were negotiated during SYN/ACK they should + * appear on every segment during this session and vice versa. + */ + if ((tp->t_flags & TF_RCVD_TSTMP) && !(to.to_flags & TOF_TS)) { + if ((s = tcp_log_addrs(inc, th, NULL, NULL))) { + log(LOG_DEBUG, "%s; %s: Timestamp missing, " + "no action\n", s, __func__); + free(s, M_TCPLOG); + } + } + if (!(tp->t_flags & TF_RCVD_TSTMP) && (to.to_flags & TOF_TS)) { + if ((s = tcp_log_addrs(inc, th, NULL, NULL))) { + log(LOG_DEBUG, "%s; %s: Timestamp not expected, " + "no action\n", s, __func__); + free(s, M_TCPLOG); + } + } /* * Process options only when we get SYN/ACK back. The SYN case @@ -2213,15 +2234,14 @@ tcp_do_segment(struct mbuf *m, struct tc */ if ((so->so_state & SS_NOFDREF) && tp->t_state > TCPS_CLOSE_WAIT && tlen) { - char *s; - KASSERT(ti_locked == TI_WLOCKED, ("%s: SS_NOFDEREF && " "CLOSE_WAIT && tlen ti_locked %d", __func__, ti_locked)); INP_INFO_WLOCK_ASSERT(&V_tcbinfo); - if ((s = tcp_log_addrs(&tp->t_inpcb->inp_inc, th, NULL, NULL))) { - log(LOG_DEBUG, "%s; %s: %s: Received %d bytes of data after socket " - "was closed, sending RST and removing tcpcb\n", + if ((s = tcp_log_addrs(inc, th, NULL, NULL))) { + log(LOG_DEBUG, "%s; %s: %s: Received %d bytes of data " + "after socket was closed, " + "sending RST and removing tcpcb\n", s, __func__, tcpstates[tp->t_state], tlen); free(s, M_TCPLOG); } Modified: head/sys/netinet/tcp_syncache.c ============================================================================== --- head/sys/netinet/tcp_syncache.c Wed Jul 10 10:57:09 2013 (r253149) +++ head/sys/netinet/tcp_syncache.c Wed Jul 10 12:06:01 2013 (r253150) @@ -992,12 +992,29 @@ syncache_expand(struct in_conninfo *inc, goto failed; } + /* + * If timestamps were not negotiated during SYN/ACK they + * must not appear on any segment during this session. + */ if (!(sc->sc_flags & SCF_TIMESTAMP) && (to->to_flags & TOF_TS)) { if ((s = tcp_log_addrs(inc, th, NULL, NULL))) log(LOG_DEBUG, "%s; %s: Timestamp not expected, " "segment rejected\n", s, __func__); goto failed; } + + /* + * If timestamps were negotiated during SYN/ACK they should + * appear on every segment during this session. + * XXXAO: This is only informal as there have been unverified + * reports of non-compliants stacks. + */ + if ((sc->sc_flags & SCF_TIMESTAMP) && !(to->to_flags & TOF_TS)) { + if ((s = tcp_log_addrs(inc, th, NULL, NULL))) + log(LOG_DEBUG, "%s; %s: Timestamp missing, " + "no action\n", s, __func__); + } + /* * If timestamps were negotiated the reflected timestamp * must be equal to what we actually sent in the SYN|ACK.