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;
=09
	memset(&mhdr, 0, sizeof(mhdr));
	memset(&iov,  0, sizeof(iov));
	memset(buffer, 0, CMSG_SPACE(sizeof(struct sctp_sndrcvinfo)));
=09
	/* IO Vector: message data */
	iov.iov_base =3D msg;
	iov.iov_len  =3D sz;
=09
	/* Anciliary data: specify SCTP stream */
	cmsg =3D (struct cmsghdr *)buffer;
	cmsg->cmsg_level =3D IPPROTO_SCTP;
	cmsg->cmsg_type  =3D SCTP_SNDRCV;
	cmsg->cmsg_len   =3D CMSG_LEN(sizeof(struct sctp_sndrcvinfo));

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

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

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

	if ( (ret =3D sendmsg(sock, &mhdr, 0)) < 0) {
		perror("sendmsg");
		exit (1);
	}
	ASSERT( ret =3D=3D sz ); /* There should not be partial delivery =
with sendmsg... */
=09
	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
>=20
> 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:=20
> Over to maintainer(s).
>=20
> http://www.freebsd.org/cgi/query-pr.cgi?pr=3D149488
> _______________________________________________
> 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"
>=20




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