Bug 25758

Summary: tcp_usrreq.c doesn't compile with TCPDEBUG set
Product: Base System Reporter: dgilbert <dgilbert>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.2-STABLE   
Hardware: Any   
OS: Any   

Description dgilbert 2001-03-13 04:00:03 UTC
The following code in tcp_usrreq.c (line 412)

static int
tcp_usr_accept(struct socket *so, struct sockaddr **nam)
{
        int s = splnet();
        int error = 0;
        struct inpcb *inp = sotoinpcb(so);
        struct tcpcb *tp;

        if (so->so_state & SS_ISDISCONNECTED) {
                error = ECONNABORTED;
                goto out;
        }
        COMMON_START();
        in_setpeeraddr(so, nam);
        COMMON_END(PRU_ACCEPT);
}

invokes COMMON_START() incorrectly:

#define COMMON_START()  TCPDEBUG0; \
                        do { \
                                     if (inp == 0) { \
                                             splx(s); \
                                             return EINVAL; \
                                     } \
                                     tp = intotcpcb(inp); \
                                     TCPDEBUG1(); \
                     } while(0)

Where TCPDEBUG0 is

#ifdef TCPDEBUG
#define TCPDEBUG0       int ostate
#define TCPDEBUG1()     ostate = tp ? tp->t_state : 0
#define TCPDEBUG2(req)  if (tp && (so->so_options & SO_DEBUG)) \
                                tcp_trace(TA_USER, ostate, tp, 0, 0, req)
#else
#define TCPDEBUG0
#define TCPDEBUG1()
#define TCPDEBUG2(req)
#endif

Which obviously doesn't work if TCPDEBUG is set.

Fix: 

I'm not familiar with this code ... or what affects what.
How-To-Repeat: Put "options TCPDEBUG" in your kernel and try to compile
Comment 1 Peter Pentchev freebsd_committer freebsd_triage 2001-03-13 07:05:40 UTC
State Changed
From-To: open->feedback

Is this a duplicate of kern/25651, which also contains a patch? 
Does the patch in http://www.FreeBSD.org/cgi-bin/query-pr.cgi?pr=25651 
solve your problem?
Comment 2 jlemon freebsd_committer freebsd_triage 2001-03-13 14:47:58 UTC
State Changed
From-To: feedback->closed

Fixed.