All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: linux-sctp@vger.kernel.org
Subject: RE: [PATCH net-next 3/5] net: sctp: implement rfc6458, 5.3.5. SCTP_RCVINFO cmsg support
Date: Mon, 07 Jul 2014 08:54:07 +0000	[thread overview]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6D1726D583@AcuExch.aculab.com> (raw)
In-Reply-To: <1404507908-6949-4-git-send-email-dborkman@redhat.com>

From: Daniel Borkmann
> From: Geir Ola Vaagland <geirola@gmail.com>
> 
> This patch implements section 5.3.5. of RFC6458, that is, support
> for 'SCTP Receive Information Structure' (SCTP_RCVINFO) which is
> placed into ancillary data cmsghdr structure for each recvmsg()
> call.
> 
> This option can be enabled/disabled via setsockopt(2) on SOL_SCTP
> level by setting an int value with 1/0 for SCTP_RECVRCVINFO in user
> space applications as per RFC6458, section 8.1.29.
> 
> The sctp_rcvinfo structure is defined as per RFC as below ...
> 
>   struct sctp_rcvinfo {
>     uint16_t rcv_sid;
>     uint16_t rcv_ssn;
>     uint16_t rcv_flags;
>     <-- 2 bytes hole  -->
>     uint32_t rcv_ppid;
>     uint32_t rcv_tsn;
>     uint32_t rcv_cumtsn;
>     uint32_t rcv_context;
>     sctp_assoc_t rcv_assoc_id;
>   };
> 
> ... and provided under cmsg_level IPPROTO_SCTP, cmsg_type
> SCTP_RCVINFO, while cmsg_data[] contains struct sctp_rcvinfo.
> An sctp_rcvinfo item always corresponds to the data in msg_iov.
> 
> Joint work with Daniel Borkmann.
...
> +/* RFC6458, Section 5.3.5 SCTP Receive Information Structure
> + * (SCTP_SNDRCV)
> + */
> +void sctp_ulpevent_read_rcvinfo(const struct sctp_ulpevent *event,
> +				struct msghdr *msghdr)
> +{
> +	struct sctp_rcvinfo rinfo;
> +
> +	if (sctp_ulpevent_is_notification(event))
> +		return;
> +
> +	memset(&rinfo, 0, sizeof(struct sctp_rcvinfo));
> +	rinfo.rcv_sid = event->stream;
> +	rinfo.rcv_ssn = event->ssn;
> +	rinfo.rcv_ppid = event->ppid;
> +	rinfo.rcv_flags = event->flags;
> +	rinfo.rcv_tsn = event->tsn;
> +	rinfo.rcv_cumtsn = event->cumtsn;
> +	rinfo.rcv_assoc_id = sctp_assoc2id(event->asoc);
> +	rinfo.rcv_context = event->asoc->default_rcv_context;
> +
> +	put_cmsg(msghdr, IPPROTO_SCTP, SCTP_RCVINFO,
> +		 sizeof(rinfo), &rinfo);
> +}

This gets called for every receive data chunk (since the user needs to
verify the ssn and stream).

It really ought to be possible to write the 'cmsg' data with quite so
many memory accesses.

Perhaps you should add named fields for the pads so they can be explicitly zeroed.

It also seems that put_cmsg() should be able to return the pointer to
where the data should be written - instead on copying the data itself.

	David




  reply	other threads:[~2014-07-07  8:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-04 21:05 [PATCH net-next 3/5] net: sctp: implement rfc6458, 5.3.5. SCTP_RCVINFO cmsg support Daniel Borkmann
2014-07-07  8:54 ` David Laight [this message]
2014-07-07  8:56 ` David Laight
2014-07-08  8:51 ` Daniel Borkmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=063D6719AE5E284EB5DD2968C1650D6D1726D583@AcuExch.aculab.com \
    --to=david.laight@aculab.com \
    --cc=linux-sctp@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.