Select the types of activity you want to include in your feed.
[SCTP]: Add support for SCTP_CONTEXT socket option.
Signed-off-by: Ivan Skytte Jorgensen <isj-sctp@i1.dk> Signed-off-by: Sridhar Samudrala <sri@us.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
···27462746 return 0;27472747}2748274827492749+/*27502750+ * 7.1.29. Set or Get the default context (SCTP_CONTEXT)27512751+ *27522752+ * The context field in the sctp_sndrcvinfo structure is normally only27532753+ * used when a failed message is retrieved holding the value that was27542754+ * sent down on the actual send call. This option allows the setting of27552755+ * a default context on an association basis that will be received on27562756+ * reading messages from the peer. This is especially helpful in the27572757+ * one-2-many model for an application to keep some reference to an27582758+ * internal state machine that is processing messages on the27592759+ * association. Note that the setting of this value only effects27602760+ * received messages from the peer and does not effect the value that is27612761+ * saved with outbound messages.27622762+ */27632763+static int sctp_setsockopt_context(struct sock *sk, char __user *optval,27642764+ int optlen)27652765+{27662766+ struct sctp_assoc_value params;27672767+ struct sctp_sock *sp;27682768+ struct sctp_association *asoc;27692769+27702770+ if (optlen != sizeof(struct sctp_assoc_value))27712771+ return -EINVAL;27722772+ if (copy_from_user(¶ms, optval, optlen))27732773+ return -EFAULT;27742774+27752775+ sp = sctp_sk(sk);27762776+27772777+ if (params.assoc_id != 0) {27782778+ asoc = sctp_id2assoc(sk, params.assoc_id);27792779+ if (!asoc)27802780+ return -EINVAL;27812781+ asoc->default_rcv_context = params.assoc_value;27822782+ } else {27832783+ sp->default_rcv_context = params.assoc_value;27842784+ }27852785+27862786+ return 0;27872787+}27882788+27492789/* API 6.2 setsockopt(), getsockopt()27502790 *27512791 * Applications use setsockopt() and getsockopt() to set or retrieve···28962856 break;28972857 case SCTP_ADAPTION_LAYER:28982858 retval = sctp_setsockopt_adaption_layer(sk, optval, optlen);28592859+ break;28602860+ case SCTP_CONTEXT:28612861+ retval = sctp_setsockopt_context(sk, optval, optlen);28992862 break;2900286329012864 default:···30583015 sp->default_flags = 0;30593016 sp->default_context = 0;30603017 sp->default_timetolive = 0;30183018+30193019+ sp->default_rcv_context = 0;3061302030623021 /* Initialize default setup parameters. These parameters30633022 * can be modified with the SCTP_INITMSG socket option or···44664421}4467442244684423/*44244424+ * 7.1.29. Set or Get the default context (SCTP_CONTEXT)44254425+ * (chapter and verse is quoted at sctp_setsockopt_context())44264426+ */44274427+static int sctp_getsockopt_context(struct sock *sk, int len,44284428+ char __user *optval, int __user *optlen)44294429+{44304430+ struct sctp_assoc_value params;44314431+ struct sctp_sock *sp;44324432+ struct sctp_association *asoc;44334433+44344434+ if (len != sizeof(struct sctp_assoc_value))44354435+ return -EINVAL;44364436+44374437+ if (copy_from_user(¶ms, optval, len))44384438+ return -EFAULT;44394439+44404440+ sp = sctp_sk(sk);44414441+44424442+ if (params.assoc_id != 0) {44434443+ asoc = sctp_id2assoc(sk, params.assoc_id);44444444+ if (!asoc)44454445+ return -EINVAL;44464446+ params.assoc_value = asoc->default_rcv_context;44474447+ } else {44484448+ params.assoc_value = sp->default_rcv_context;44494449+ }44504450+44514451+ if (put_user(len, optlen))44524452+ return -EFAULT;44534453+ if (copy_to_user(optval, ¶ms, len))44544454+ return -EFAULT;44554455+44564456+ return 0;44574457+}44584458+44594459+/*44694460 * 7.1.17 Set the maximum fragrmentation size (SCTP_MAXSEG)44704461 *44714462 * This socket option specifies the maximum size to put in any outgoing···46384557 case SCTP_ADAPTION_LAYER:46394558 retval = sctp_getsockopt_adaption_layer(sk, len, optval,46404559 optlen);45604560+ break;45614561+ case SCTP_CONTEXT:45624562+ retval = sctp_getsockopt_context(sk, len, optval, optlen);46414563 break;46424564 default:46434565 retval = -ENOPROTOOPT;
+3-1
net/sctp/ulpevent.c
···849849 */850850 sinfo.sinfo_assoc_id = sctp_assoc2id(event->asoc);851851852852+ /* context value that is set via SCTP_CONTEXT socket option. */853853+ sinfo.sinfo_context = event->asoc->default_rcv_context;854854+852855 /* These fields are not used while receiving. */853853- sinfo.sinfo_context = 0;854856 sinfo.sinfo_timetolive = 0;855857856858 put_cmsg(msghdr, IPPROTO_SCTP, SCTP_SNDRCV,