Skip to contentSkip to conversation

: More bugfixes

PATCH New Vlad Yasevich 2 participants 7 messages May 9, 2007

Subsystems (3)
lore
Share & tools
lore
#5 lore raw

PATCH 3/3 Do not include ABORT chunk header in the notification.

In reply to Vlad Yasevich

The socket API draft is unclear about whether to include the chunk header or not. Recent discussion on the sctp implementors mailing list clarified that the chunk header shouldn't be included, but the error parameter header still needs to be there.

---
 net/sctp/ulpevent.c |   11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)
net/sctp/ulpevent.c +2 -9
index 661ea2d..bfecb35 100644
@@ -141,11 +141,6 @@ struct sctp_ulpevent  *sctp_ulpevent_make_assoc_change(
 	 * an ABORT, so we need to include it in the sac_info.
 	 */
 	if (chunk) {
-		/* sctp_inqu_pop() has allready pulled off the chunk
-		 * header.  We need to put it back temporarily
-		 */
-		skb_push(chunk->skb, sizeof(sctp_chunkhdr_t));
-
 		/* Copy the chunk data to a new skb and reserve enough
 		 * head room to use as notification.
 		 */
@@ -155,9 +150,6 @@ struct sctp_ulpevent  *sctp_ulpevent_make_assoc_change(
 		if (!skb)
 			goto fail;
 
-		/* put back the chunk header now that we have a copy */
-		skb_pull(chunk->skb, sizeof(sctp_chunkhdr_t));
-
 		/* Embed the event fields inside the cloned skb.  */
 		event = sctp_skb2event(skb);
 		sctp_ulpevent_init(event, MSG_NOTIFICATION, skb->truesize);
@@ -168,7 +160,8 @@ struct sctp_ulpevent  *sctp_ulpevent_make_assoc_change(
 
 		/* Trim the buffer to the right length.  */
 		skb_trim(skb, sizeof(struct sctp_assoc_change) +
-			 ntohs(chunk->chunk_hdr->length));
+			 ntohs(chunk->chunk_hdr->length) -
+			 sizeof(sctp_chunkhdr_t));
 	} else {
 		event = sctp_ulpevent_new(sizeof(struct sctp_assoc_change),
 				  MSG_NOTIFICATION, gfp);
Signature · 1 line
1.5.0.3.438.gc49b2
#3 lore raw

PATCH 2/3 Correctly copy addresses in sctp_copy_laddrs

In reply to Vlad Yasevich

I broke the non-wildcard case recently. This is to fixes it. Now, explictitly bound addresses can ge retrieved using the API.

---
 net/sctp/socket.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
net/sctp/socket.c +8 -4
index cc2ed54..ef03bc4 100644
@@ -4164,6 +4164,7 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len,
 	rwlock_t *addr_lock;
 	int err = 0;
 	void *addrs;
+	void *buf;
 	int bytes_copied = 0;
 
 	if (len != sizeof(struct sctp_getaddrs_old))
@@ -4217,13 +4218,14 @@ static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len,
 		}
 	}
 
+	buf = addrs;
 	list_for_each(pos, &bp->address_list) {
 		addr = list_entry(pos, struct sctp_sockaddr_entry, list);
 		memcpy(&temp, &addr->a, sizeof(temp));
 		sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp);
 		addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
-		memcpy(addrs, &temp, addrlen);
-		to += addrlen;
+		memcpy(buf, &temp, addrlen);
+		buf += addrlen;
 		bytes_copied += addrlen;
 		cnt ++;
 		if (cnt >= getaddrs.addr_num) break;
@@ -4266,6 +4268,7 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
 	size_t space_left;
 	int bytes_copied = 0;
 	void *addrs;
+	void *buf;
 
 	if (len <= sizeof(struct sctp_getaddrs))
 		return -EINVAL;
@@ -4316,6 +4319,7 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
 		}
 	}
 
+	buf = addrs;
 	list_for_each(pos, &bp->address_list) {
 		addr = list_entry(pos, struct sctp_sockaddr_entry, list);
 		memcpy(&temp, &addr->a, sizeof(temp));
@@ -4325,8 +4329,8 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
 			err =  -ENOMEM; /*fixme: right error?*/
 			goto error;
 		}
-		memcpy(addrs, &temp, addrlen);
-		to += addrlen;
+		memcpy(buf, &temp, addrlen);
+		buf += addrlen;
 		bytes_copied += addrlen;
 		cnt ++;
 		space_left -= addrlen;
Signature · 1 line
1.5.0.3.438.gc49b2
#0 lore raw

PATCH 1/1 : More bugfixes

Hi David

This is yet more bugfixes for SCTP:

[SCTP] Prevent OOPS if hmac modules didn't load [SCTP] Correctly copy addresses in sctp_copy_laddrs [SCTP] Do not include ABORT chunk header in the notification.

Please apply.

Thanks
-vlad

#1 lore raw

PATCH 1/3 Prevent OOPS if hmac modules didn't load

SCTP was checking for NULL when trying to detect hmac allocation failure where it should have been using IS_ERR. Also, print a rate limited warning to the log telling the user what happend.

---
 net/sctp/socket.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
net/sctp/socket.c +6 -1
index 64fb074..cc2ed54 100644
@@ -5227,7 +5227,12 @@ int sctp_inet_listen(struct socket *sock, int backlog)
 	/* Allocate HMAC for generating cookie. */
 	if (sctp_hmac_alg) {
 		tfm = crypto_alloc_hash(sctp_hmac_alg, 0, CRYPTO_ALG_ASYNC);
-		if (!tfm) {
+		if (IS_ERR(tfm)) {
+			if (net_ratelimit()) {
+				printk(KERN_INFO
+				       "SCTP: failed to load transform for %s: %ld\n",
+					sctp_hmac_alg, PTR_ERR(tfm));
+			}
 			err = -ENOSYS;
 			goto out;
 		}
Signature · 1 line
1.5.0.3.438.gc49b2
maintainer Applied
#2 lore raw

Re: [PATCH 1/3] [SCTP] Prevent OOPS if hmac modules didn't load

From: Vlad Yasevich <[email protected]>
Date: Wed, 9 May 2007 15:43:48 -0400

Quoted 6 lines

SCTP was checking for NULL when trying to detect hmac allocation failure where it should have been using IS_ERR. Also, print a rate limited warning to the log telling the user what happend.

Applied, thanks Vlad.

maintainer Applied
#6 lore raw

Re: [PATCH 3/3] [SCTP] Do not include ABORT chunk header in the notification.

In reply to Vlad Yasevich

From: Vlad Yasevich <[email protected]>
Date: Wed, 9 May 2007 15:43:50 -0400

Quoted 6 lines

The socket API draft is unclear about whether to include the chunk header or not. Recent discussion on the sctp implementors mailing list clarified that the chunk header shouldn't be included, but the error parameter header still needs to be there.

Applied.