From owner-freebsd-current@FreeBSD.ORG Tue Apr 10 10:36:19 2007 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9116116A404 for ; Tue, 10 Apr 2007 10:36:19 +0000 (UTC) (envelope-from rrs@cisco.com) Received: from sj-iport-3.cisco.com (sj-iport-3-in.cisco.com [171.71.176.72]) by mx1.freebsd.org (Postfix) with ESMTP id 53E6513C46E for ; Tue, 10 Apr 2007 10:36:19 +0000 (UTC) (envelope-from rrs@cisco.com) Received: from sj-dkim-2.cisco.com ([171.71.179.186]) by sj-iport-3.cisco.com with ESMTP; 10 Apr 2007 03:36:19 -0700 Received: from sj-core-1.cisco.com (sj-core-1.cisco.com [171.71.177.237]) by sj-dkim-2.cisco.com (8.12.11/8.12.11) with ESMTP id l3AAaJKE005840; Tue, 10 Apr 2007 03:36:19 -0700 Received: from xbh-sjc-221.amer.cisco.com (xbh-sjc-221.cisco.com [128.107.191.63]) by sj-core-1.cisco.com (8.12.10/8.12.6) with ESMTP id l3AAaIMF012036; Tue, 10 Apr 2007 10:36:18 GMT Received: from xfe-sjc-212.amer.cisco.com ([171.70.151.187]) by xbh-sjc-221.amer.cisco.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 10 Apr 2007 03:36:18 -0700 Received: from [127.0.0.1] ([171.68.225.134]) by xfe-sjc-212.amer.cisco.com with Microsoft SMTPSVC(6.0.3790.1830); Tue, 10 Apr 2007 03:36:18 -0700 Message-ID: <461B6945.90109@cisco.com> Date: Tue, 10 Apr 2007 06:39:01 -0400 From: Randall Stewart User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.8) Gecko/20061029 FreeBSD/i386 SeaMonkey/1.0.6 MIME-Version: 1.0 To: Martin Kulas References: <20070409214504.GA1780@thunderbird.tld> In-Reply-To: <20070409214504.GA1780@thunderbird.tld> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 10 Apr 2007 10:36:18.0311 (UTC) FILETIME=[12A13170:01C77B5C] DKIM-Signature: v=0.5; a=rsa-sha256; q=dns/txt; l=5400; t=1176201379; x=1177065379; c=relaxed/simple; s=sjdkim2002; h=Content-Type:From:Subject:Content-Transfer-Encoding:MIME-Version; d=cisco.com; i=rrs@cisco.com; z=From:=20Randall=20Stewart=20 |Subject:=20Re=3A=20netcat=20with=20SCTP=20support |Sender:=20; bh=gn3iIpAzmAFfbIPBG0kqvEe4kRGVq37rV6ubaB1jOlU=; b=G8Ju+5J5vuZqjX9cX9wRriOd12ctwyu3cOtGbMOxxBh6kM5z98S/oHa76CI7fR0/0zCYw+gM 3cV6hibq1f7yxfa814aU5oTs/v9E5sFpop4qqkuewatEvcPouOZU/3oa; Authentication-Results: sj-dkim-2; header.From=rrs@cisco.com; dkim=pass (sig from cisco.com/sjdkim2002 verified; ); Cc: freebsd-current@freebsd.org Subject: Re: netcat with SCTP support X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Apr 2007 10:36:19 -0000 Martin: Thanks for checking out SCTP for netcat... let me see if I can re-create this bug with current and figure out what is broken... This sounds like a bug with the TCP model.. I will be a bit slow.. I am on vacation this week and for some crazy reason my wife thinks I should be working on putting in a yard instead of working on the computer :-) I can work only limited times in the AM when everyone is still asleep :-0 So to recreate this.. I set things up run it and ctl-c the client? R Martin Kulas wrote: > Hello! > > I am running -CURRENT and I am happy to have SCTP support. I wrote a patch > for netcat so I can experiment with SCTP. The patch opens a SCTP socket > in one-to-one style. > But there is a problem I could not solve: If I open an SCTP listening socket > with netcat and connect to it with netcat, data transfer works correctly. When I > kill the client process, the server process does not react on the > SHUTDOWN-chunk sent to it: poll() does not notify the process that the > association has been closed. Using TCP poll() works correctly. > Does anyone know how to solve this problem? > > Thanks in advance, > Martin > > > --- netcat.c.orig Fri Mar 30 21:58:02 2007 > +++ netcat.c Mon Apr 9 16:59:21 2007 > @@ -44,6 +44,7 @@ > #ifdef IPSEC > #include > #endif > +#include > #include > #include > #include > @@ -71,6 +72,7 @@ > > /* Command Line Options */ > int Eflag; /* Use IPsec ESP */ > +int cflag; /* Use SCTP */ > int dflag; /* detached, no stdin */ > unsigned int iflag; /* Interval Flag */ > int jflag; /* use jumbo frames if we can */ > @@ -138,8 +140,11 @@ > sv = NULL; > > while ((ch = getopt(argc, argv, > - "46e:DEdhi:jklnoP:p:rSs:tT:Uuvw:X:x:z")) != -1) { > + "c46e:DEdhi:jklnoP:p:rSs:tT:Uuvw:X:x:z")) != -1) { > switch (ch) { > + case 'c': > + cflag = 1; > + break; > case '4': > family = AF_INET; > break; > @@ -257,6 +262,8 @@ > if (argv[0] && !argv[1] && family == AF_UNIX) { > if (uflag) > errx(1, "cannot use -u and -U"); > + if (cflag) > + errx(1, "cannot use -c and -U"); > host = argv[0]; > uport = NULL; > } else if (argv[0] && !argv[1]) { > @@ -283,13 +290,23 @@ > if (family != AF_UNIX) { > memset(&hints, 0, sizeof(struct addrinfo)); > hints.ai_family = family; > - hints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM; > - hints.ai_protocol = uflag ? IPPROTO_UDP : IPPROTO_TCP; > + if (cflag) { > + hints.ai_socktype = SOCK_STREAM; > + // XXX IPPROTO_SCTP not supported form getaddrinfo > + } else { > + hints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM; > + hints.ai_protocol = uflag ? IPPROTO_UDP : IPPROTO_TCP; > + } > if (nflag) > hints.ai_flags |= AI_NUMERICHOST; > } > > + if ( cflag && uflag ) > + errx(1, "cannot use -c and -u"); > + > if (xflag) { > + if (cflag) > + errx(1, "no proxy support for SCTP mode"); > if (uflag) > errx(1, "no proxy support for UDP mode"); > > @@ -418,7 +435,7 @@ > } > > printf("Connection to %s %s port [%s/%s] succeeded!\n", > - host, portlist[i], uflag ? "udp" : "tcp", > + host, portlist[i], uflag ? "udp" : (cflag ? "sctp" : "tcp"), > sv ? sv->s_name : "*"); > } > if (!zflag) > @@ -515,9 +532,15 @@ > > res0 = res; > do { > - if ((s = socket(res0->ai_family, res0->ai_socktype, > - res0->ai_protocol)) < 0) > - continue; > + if (cflag) { > + if ((s = socket(res0->ai_family, res0->ai_socktype, > + IPPROTO_SCTP)) < 0) > + continue; > + } else { > + if ((s = socket(res0->ai_family, res0->ai_socktype, > + res0->ai_protocol)) < 0) > + continue; > + } > #ifdef IPSEC > if (ipsec_policy[0] != NULL) > add_ipsec_policy(s, ipsec_policy[0]); > @@ -532,7 +555,8 @@ > memset(&ahints, 0, sizeof(struct addrinfo)); > ahints.ai_family = res0->ai_family; > ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM; > - ahints.ai_protocol = uflag ? IPPROTO_UDP : IPPROTO_TCP; > + if (!cflag) > + ahints.ai_protocol = uflag ? IPPROTO_UDP : IPPROTO_TCP; > ahints.ai_flags = AI_PASSIVE; > if ((error = getaddrinfo(sflag, pflag, &ahints, &ares))) > errx(1, "getaddrinfo: %s", gai_strerror(error)); > @@ -549,7 +573,7 @@ > break; > else if (vflag) > warn("connect to %s port %s (%s) failed", host, port, > - uflag ? "udp" : "tcp"); > + uflag ? "udp" : (cflag ? "sctp" : "tcp") ); > > close(s); > s = -1; > @@ -587,10 +611,15 @@ > > res0 = res; > do { > - if ((s = socket(res0->ai_family, res0->ai_socktype, > - res0->ai_protocol)) < 0) > - continue; > - > + if (cflag) { > + if ((s = socket(res0->ai_family, res0->ai_socktype, > + IPPROTO_SCTP)) < 0) > + continue; > + } else { > + if ((s = socket(res0->ai_family, res0->ai_socktype, > + res0->ai_protocol)) < 0) > + continue; > + } > ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x)); > if (ret == -1) > err(1, NULL); > -- Randall Stewart NSSTG - Cisco Systems Inc. 803-345-0369 803-317-4952 (cell)