amd64/149488: SCTP streams not working on AMD64 platform

Michael Tuexen Michael.Tuexen at lurchi.franken.de
Tue Aug 10 10:06:24 UTC 2010


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 at 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 at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-net
> To unsubscribe, send any mail to "freebsd-net-unsubscribe at freebsd.org"
> 



More information about the freebsd-amd64 mailing list