Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

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>

authored by

Ivan Skytte Jorgensen and committed by
David S. Miller
6ab792f5 882a382c

+94 -1
+4
include/net/sctp/structs.h
··· 275 275 __u16 default_flags; 276 276 __u32 default_context; 277 277 __u32 default_timetolive; 278 + __u32 default_rcv_context; 278 279 279 280 /* Heartbeat interval: The endpoint sends out a Heartbeat chunk to 280 281 * the destination address every heartbeat interval. This value ··· 1657 1656 __u32 default_ppid; 1658 1657 __u32 default_context; 1659 1658 __u32 default_timetolive; 1659 + 1660 + /* Default receive parameters */ 1661 + __u32 default_rcv_context; 1660 1662 1661 1663 /* This tracks outbound ssn for a given stream. */ 1662 1664 struct sctp_ssnmap *ssnmap;
+2
include/net/sctp/user.h
··· 95 95 #define SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO 96 96 SCTP_DELAYED_ACK_TIME, 97 97 #define SCTP_DELAYED_ACK_TIME SCTP_DELAYED_ACK_TIME 98 + SCTP_CONTEXT, /* Receive Context */ 99 + #define SCTP_CONTEXT SCTP_CONTEXT 98 100 99 101 /* Internal Socket Options. Some of the sctp library functions are 100 102 * implemented using these socket options.
+1
net/sctp/associola.c
··· 298 298 asoc->default_flags = sp->default_flags; 299 299 asoc->default_context = sp->default_context; 300 300 asoc->default_timetolive = sp->default_timetolive; 301 + asoc->default_rcv_context = sp->default_rcv_context; 301 302 302 303 return asoc; 303 304
+84
net/sctp/socket.c
··· 2746 2746 return 0; 2747 2747 } 2748 2748 2749 + /* 2750 + * 7.1.29. Set or Get the default context (SCTP_CONTEXT) 2751 + * 2752 + * The context field in the sctp_sndrcvinfo structure is normally only 2753 + * used when a failed message is retrieved holding the value that was 2754 + * sent down on the actual send call. This option allows the setting of 2755 + * a default context on an association basis that will be received on 2756 + * reading messages from the peer. This is especially helpful in the 2757 + * one-2-many model for an application to keep some reference to an 2758 + * internal state machine that is processing messages on the 2759 + * association. Note that the setting of this value only effects 2760 + * received messages from the peer and does not effect the value that is 2761 + * saved with outbound messages. 2762 + */ 2763 + static int sctp_setsockopt_context(struct sock *sk, char __user *optval, 2764 + int optlen) 2765 + { 2766 + struct sctp_assoc_value params; 2767 + struct sctp_sock *sp; 2768 + struct sctp_association *asoc; 2769 + 2770 + if (optlen != sizeof(struct sctp_assoc_value)) 2771 + return -EINVAL; 2772 + if (copy_from_user(&params, optval, optlen)) 2773 + return -EFAULT; 2774 + 2775 + sp = sctp_sk(sk); 2776 + 2777 + if (params.assoc_id != 0) { 2778 + asoc = sctp_id2assoc(sk, params.assoc_id); 2779 + if (!asoc) 2780 + return -EINVAL; 2781 + asoc->default_rcv_context = params.assoc_value; 2782 + } else { 2783 + sp->default_rcv_context = params.assoc_value; 2784 + } 2785 + 2786 + return 0; 2787 + } 2788 + 2749 2789 /* API 6.2 setsockopt(), getsockopt() 2750 2790 * 2751 2791 * Applications use setsockopt() and getsockopt() to set or retrieve ··· 2896 2856 break; 2897 2857 case SCTP_ADAPTION_LAYER: 2898 2858 retval = sctp_setsockopt_adaption_layer(sk, optval, optlen); 2859 + break; 2860 + case SCTP_CONTEXT: 2861 + retval = sctp_setsockopt_context(sk, optval, optlen); 2899 2862 break; 2900 2863 2901 2864 default: ··· 3058 3015 sp->default_flags = 0; 3059 3016 sp->default_context = 0; 3060 3017 sp->default_timetolive = 0; 3018 + 3019 + sp->default_rcv_context = 0; 3061 3020 3062 3021 /* Initialize default setup parameters. These parameters 3063 3022 * can be modified with the SCTP_INITMSG socket option or ··· 4466 4421 } 4467 4422 4468 4423 /* 4424 + * 7.1.29. Set or Get the default context (SCTP_CONTEXT) 4425 + * (chapter and verse is quoted at sctp_setsockopt_context()) 4426 + */ 4427 + static int sctp_getsockopt_context(struct sock *sk, int len, 4428 + char __user *optval, int __user *optlen) 4429 + { 4430 + struct sctp_assoc_value params; 4431 + struct sctp_sock *sp; 4432 + struct sctp_association *asoc; 4433 + 4434 + if (len != sizeof(struct sctp_assoc_value)) 4435 + return -EINVAL; 4436 + 4437 + if (copy_from_user(&params, optval, len)) 4438 + return -EFAULT; 4439 + 4440 + sp = sctp_sk(sk); 4441 + 4442 + if (params.assoc_id != 0) { 4443 + asoc = sctp_id2assoc(sk, params.assoc_id); 4444 + if (!asoc) 4445 + return -EINVAL; 4446 + params.assoc_value = asoc->default_rcv_context; 4447 + } else { 4448 + params.assoc_value = sp->default_rcv_context; 4449 + } 4450 + 4451 + if (put_user(len, optlen)) 4452 + return -EFAULT; 4453 + if (copy_to_user(optval, &params, len)) 4454 + return -EFAULT; 4455 + 4456 + return 0; 4457 + } 4458 + 4459 + /* 4469 4460 * 7.1.17 Set the maximum fragrmentation size (SCTP_MAXSEG) 4470 4461 * 4471 4462 * This socket option specifies the maximum size to put in any outgoing ··· 4638 4557 case SCTP_ADAPTION_LAYER: 4639 4558 retval = sctp_getsockopt_adaption_layer(sk, len, optval, 4640 4559 optlen); 4560 + break; 4561 + case SCTP_CONTEXT: 4562 + retval = sctp_getsockopt_context(sk, len, optval, optlen); 4641 4563 break; 4642 4564 default: 4643 4565 retval = -ENOPROTOOPT;
+3 -1
net/sctp/ulpevent.c
··· 849 849 */ 850 850 sinfo.sinfo_assoc_id = sctp_assoc2id(event->asoc); 851 851 852 + /* context value that is set via SCTP_CONTEXT socket option. */ 853 + sinfo.sinfo_context = event->asoc->default_rcv_context; 854 + 852 855 /* These fields are not used while receiving. */ 853 - sinfo.sinfo_context = 0; 854 856 sinfo.sinfo_timetolive = 0; 855 857 856 858 put_cmsg(msghdr, IPPROTO_SCTP, SCTP_SNDRCV,