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

sctp: implement event notification SCTP_SENDER_DRY_EVENT

This patch implement event notification SCTP_SENDER_DRY_EVENT.
SCTP Socket API Extensions:

6.1.9. SCTP_SENDER_DRY_EVENT

When the SCTP stack has no more user data to send or retransmit, this
notification is given to the user. Also, at the time when a user app
subscribes to this event, if there is no data to be sent or
retransmit, the stack will immediately send up this notification.

Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Wei Yongjun and committed by
David S. Miller
e1cdd553 ee916fd0

+74 -1
+1
include/net/sctp/sm.h
··· 165 165 sctp_state_fn_t sctp_sf_do_prm_asconf; 166 166 167 167 /* Prototypes for other event state functions. */ 168 + sctp_state_fn_t sctp_sf_do_no_pending_tsn; 168 169 sctp_state_fn_t sctp_sf_do_9_2_start_shutdown; 169 170 sctp_state_fn_t sctp_sf_do_9_2_shutdown_ack; 170 171 sctp_state_fn_t sctp_sf_ignore_other;
+3
include/net/sctp/ulpevent.h
··· 132 132 const struct sctp_association *asoc, __u16 key_id, 133 133 __u32 indication, gfp_t gfp); 134 134 135 + struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event( 136 + const struct sctp_association *asoc, gfp_t gfp); 137 + 135 138 void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event, 136 139 struct msghdr *); 137 140 __u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event);
+17
include/net/sctp/user.h
··· 354 354 355 355 enum { SCTP_AUTH_NEWKEY = 0, }; 356 356 357 + /* 358 + * 6.1.9. SCTP_SENDER_DRY_EVENT 359 + * 360 + * When the SCTP stack has no more user data to send or retransmit, this 361 + * notification is given to the user. Also, at the time when a user app 362 + * subscribes to this event, if there is no data to be sent or 363 + * retransmit, the stack will immediately send up this notification. 364 + */ 365 + struct sctp_sender_dry_event { 366 + __u16 sender_dry_type; 367 + __u16 sender_dry_flags; 368 + __u32 sender_dry_length; 369 + sctp_assoc_t sender_dry_assoc_id; 370 + }; 357 371 358 372 /* 359 373 * Described in Section 7.3 ··· 383 369 __u8 sctp_partial_delivery_event; 384 370 __u8 sctp_adaptation_layer_event; 385 371 __u8 sctp_authentication_event; 372 + __u8 sctp_sender_dry_event; 386 373 }; 387 374 388 375 /* ··· 407 392 struct sctp_adaptation_event sn_adaptation_event; 408 393 struct sctp_pdapi_event sn_pdapi_event; 409 394 struct sctp_authkey_event sn_authkey_event; 395 + struct sctp_sender_dry_event sn_sender_dry_event; 410 396 }; 411 397 412 398 /* Section 5.3.1 ··· 426 410 SCTP_ADAPTATION_INDICATION, 427 411 SCTP_AUTHENTICATION_EVENT, 428 412 #define SCTP_AUTHENTICATION_INDICATION SCTP_AUTHENTICATION_EVENT 413 + SCTP_SENDER_DRY_EVENT, 429 414 }; 430 415 431 416 /* Notification error codes used to fill up the error fields in some
+24
net/sctp/sm_statefuns.c
··· 5077 5077 ***************************************************************************/ 5078 5078 5079 5079 /* 5080 + * When the SCTP stack has no more user data to send or retransmit, this 5081 + * notification is given to the user. Also, at the time when a user app 5082 + * subscribes to this event, if there is no data to be sent or 5083 + * retransmit, the stack will immediately send up this notification. 5084 + */ 5085 + sctp_disposition_t sctp_sf_do_no_pending_tsn( 5086 + const struct sctp_endpoint *ep, 5087 + const struct sctp_association *asoc, 5088 + const sctp_subtype_t type, 5089 + void *arg, 5090 + sctp_cmd_seq_t *commands) 5091 + { 5092 + struct sctp_ulpevent *event; 5093 + 5094 + event = sctp_ulpevent_make_sender_dry_event(asoc, GFP_ATOMIC); 5095 + if (!event) 5096 + return SCTP_DISPOSITION_NOMEM; 5097 + 5098 + sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(event)); 5099 + 5100 + return SCTP_DISPOSITION_CONSUME; 5101 + } 5102 + 5103 + /* 5080 5104 * Start the shutdown negotiation. 5081 5105 * 5082 5106 * From Section 9.2:
+1 -1
net/sctp/sm_statetable.c
··· 668 668 /* SCTP_STATE_COOKIE_ECHOED */ \ 669 669 TYPE_SCTP_FUNC(sctp_sf_ignore_other), \ 670 670 /* SCTP_STATE_ESTABLISHED */ \ 671 - TYPE_SCTP_FUNC(sctp_sf_ignore_other), \ 671 + TYPE_SCTP_FUNC(sctp_sf_do_no_pending_tsn), \ 672 672 /* SCTP_STATE_SHUTDOWN_PENDING */ \ 673 673 TYPE_SCTP_FUNC(sctp_sf_do_9_2_start_shutdown), \ 674 674 /* SCTP_STATE_SHUTDOWN_SENT */ \
+28
net/sctp/ulpevent.c
··· 862 862 return NULL; 863 863 } 864 864 865 + /* 866 + * Socket Extensions for SCTP 867 + * 6.3.10. SCTP_SENDER_DRY_EVENT 868 + */ 869 + struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event( 870 + const struct sctp_association *asoc, gfp_t gfp) 871 + { 872 + struct sctp_ulpevent *event; 873 + struct sctp_sender_dry_event *sdry; 874 + struct sk_buff *skb; 875 + 876 + event = sctp_ulpevent_new(sizeof(struct sctp_sender_dry_event), 877 + MSG_NOTIFICATION, gfp); 878 + if (!event) 879 + return NULL; 880 + 881 + skb = sctp_event2skb(event); 882 + sdry = (struct sctp_sender_dry_event *) 883 + skb_put(skb, sizeof(struct sctp_sender_dry_event)); 884 + 885 + sdry->sender_dry_type = SCTP_SENDER_DRY_EVENT; 886 + sdry->sender_dry_flags = 0; 887 + sdry->sender_dry_length = sizeof(struct sctp_sender_dry_event); 888 + sctp_ulpevent_set_owner(event, asoc); 889 + sdry->sender_dry_assoc_id = sctp_assoc2id(asoc); 890 + 891 + return event; 892 + } 865 893 866 894 /* Return the notification type, assuming this is a notification 867 895 * event.