Skip to contentSkip to conversation

sctp: fix missing send up SCTP_SENDER_DRY_EVENT when subscribe it

PATCH Superseded Wei Yongjun 2 participants 2 messages Jul 2, 2011

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sctp: fix missing send up SCTP_SENDER_DRY_EVENT when subscribe it

From: Wei Yongjun<[email protected]>

We forgot to send up SCTP_SENDER_DRY_EVENT notification when user app subscribes to this event, and there is no data to be sent or retransmit.

This is required by the Socket API and used by the DTLS/SCTP implementation.

net/sctp/socket.c +23 -0
index 6766913..99e25de 100644
@@ -2073,10 +2073,33 @@ static int sctp_setsockopt_disable_fragments(struct sock *sk,
 static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
 				  unsigned int optlen)
 {
+	struct sctp_association *asoc;
+	struct sctp_ulpevent *event;
+
 	if (optlen>  sizeof(struct sctp_event_subscribe))
 		return -EINVAL;
 	if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
 		return -EFAULT;
+
+	/*
+	 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
+	 * if there is no data to be sent or retransmit, the stack will
+	 * immediately send up this notification.
+	 */
+	if (sctp_ulpevent_type_enabled(SCTP_SENDER_DRY_EVENT,
+				&sctp_sk(sk)->subscribe)) {
+		asoc = sctp_id2assoc(sk, 0);
+
+		if (asoc&&  sctp_outq_is_empty(&asoc->outqueue)) {
+			event = sctp_ulpevent_make_sender_dry_event(asoc,
+					GFP_ATOMIC);
+			if (!event)
+				return -ENOMEM;
+
+			sctp_ulpq_tail_event(&asoc->ulpq, event);
+		}
+	}
+
 	return 0;
 }
 
Signature · 1 line
1.7.5.1
maintainer
#1 lore raw

From: Wei Yongjun <[email protected]>
Date: Sun, 03 Jul 2011 03:18:56 +0800

Review static int · line 2073

Quoted 2 lines
(quoted diff) +0 -0
@@ -2073,10 +2073,33 @@ static int
 sctp_setsockopt_disable_fragments(struct sock *sk,

Patch corrupted by your email client.