Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Aug 2010 12:06:20 +0200
From:      Michael Tuexen <Michael.Tuexen@lurchi.franken.de>
To:        brucec@FreeBSD.org
Cc:        freebsd-net@FreeBSD.org, freebsd-amd64@FreeBSD.org
Subject:   Re: amd64/149488: SCTP streams not working on AMD64 platform
Message-ID:  <31388BBC-AA82-46F8-B893-E81588FD97E9@lurchi.franken.de>
In-Reply-To: <201008100920.o7A9K9Gv096464@freefall.freebsd.org>
References:  <201008100920.o7A9K9Gv096464@freefall.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

Dear all,

it is not a problem in the kernel. The application does not handle
the cmsg stuff correctly in send_on_stream().

Using

/* Send a message on a socket and a particular stream */
void send_on_stream(int sock, unsigned int strid, unsigned char * msg, size_t sz)
{
	struct msghdr mhdr;
	struct iovec  iov;
	struct cmsghdr *cmsg;
	struct sctp_sndrcvinfo *info;
	char buffer[CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))];
	ssize_t ret;
	
	memset(&mhdr, 0, sizeof(mhdr));
	memset(&iov,  0, sizeof(iov));
	memset(buffer, 0, CMSG_SPACE(sizeof(struct sctp_sndrcvinfo)));
	
	/* IO Vector: message data */
	iov.iov_base = msg;
	iov.iov_len  = sz;
	
	/* Anciliary data: specify SCTP stream */
	cmsg = (struct cmsghdr *)buffer;
	cmsg->cmsg_level = IPPROTO_SCTP;
	cmsg->cmsg_type  = SCTP_SNDRCV;
	cmsg->cmsg_len   = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));

	info = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg);
	info->sinfo_stream = strid;

	mhdr.msg_iov    = &iov;
	mhdr.msg_iovlen = 1;

	mhdr.msg_control    = buffer;
	mhdr.msg_controllen = cmsg->cmsg_len;

	if ( (ret = sendmsg(sock, &mhdr, 0)) < 0) {
		perror("sendmsg");
		exit (1);
	}
	ASSERT( ret == sz ); /* There should not be partial delivery with sendmsg... */
	
	return;
}

solves the problem.

Best regards
Michael
On Aug 10, 2010, at 11:20 AM, brucec@FreeBSD.org wrote:

> Synopsis: SCTP streams not working on AMD64 platform
> 
> Responsible-Changed-From-To: freebsd-amd64->freebsd-net
> Responsible-Changed-By: brucec
> Responsible-Changed-When: Tue Aug 10 09:19:47 UTC 2010
> Responsible-Changed-Why: 
> Over to maintainer(s).
> 
> http://www.freebsd.org/cgi/query-pr.cgi?pr=149488
> _______________________________________________
> freebsd-net@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-net
> To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org"
> 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?31388BBC-AA82-46F8-B893-E81588FD97E9>