]> err.no Git - linux-2.6/blobdiff - net/sctp/endpointola.c
[SCTP]: sctp_endpoint_lookup_assoc() switched to net-endian.
[linux-2.6] / net / sctp / endpointola.c
index ffda1d680529c4cb4c9fc6b7a478097e44983f54..5ffb1af336c0180321a35e5fcf8cc1ad7ed68d18 100644 (file)
@@ -72,6 +72,10 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
 {
        memset(ep, 0, sizeof(struct sctp_endpoint));
 
+       ep->digest = kzalloc(SCTP_SIGNATURE_SIZE, gfp);
+       if (!ep->digest)
+               return NULL;
+
        /* Initialize the base structure. */
        /* What type of endpoint are we?  */
        ep->base.type = SCTP_EP_TYPE_SOCKET;
@@ -144,6 +148,13 @@ void sctp_endpoint_add_asoc(struct sctp_endpoint *ep,
 {
        struct sock *sk = ep->base.sk;
 
+       /* If this is a temporary association, don't bother
+        * since we'll be removing it shortly and don't
+        * want anyone to find it anyway.
+        */
+       if (asoc->temp)
+               return;
+
        /* Now just add it to our list of asocs */
        list_add_tail(&asoc->asocs, &ep->asocs);
 
@@ -173,7 +184,10 @@ static void sctp_endpoint_destroy(struct sctp_endpoint *ep)
        SCTP_ASSERT(ep->base.dead, "Endpoint is not dead", return);
 
        /* Free up the HMAC transform. */
-       sctp_crypto_free_tfm(sctp_sk(ep->base.sk)->hmac);
+       crypto_free_hash(sctp_sk(ep->base.sk)->hmac);
+
+       /* Free the digest buffer */
+       kfree(ep->digest);
 
        /* Cleanup. */
        sctp_inq_free(&ep->base.inqueue);
@@ -216,7 +230,7 @@ struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *ep,
        struct sctp_endpoint *retval;
 
        sctp_read_lock(&ep->base.addr_lock);
-       if (ep->base.bind_addr.port == laddr->v4.sin_port) {
+       if (htons(ep->base.bind_addr.port) == laddr->v4.sin_port) {
                if (sctp_bind_addr_match(&ep->base.bind_addr, laddr,
                                         sctp_sk(ep->base.sk))) {
                        retval = ep;
@@ -244,7 +258,7 @@ static struct sctp_association *__sctp_endpoint_lookup_assoc(
        struct sctp_association *asoc;
        struct list_head *pos;
 
-       rport = paddr->v4.sin_port;
+       rport = ntohs(paddr->v4.sin_port);
 
        list_for_each(pos, &ep->asocs) {
                asoc = list_entry(pos, struct sctp_association, asocs);
@@ -291,7 +305,7 @@ int sctp_endpoint_is_peeled_off(struct sctp_endpoint *ep,
        bp = &ep->base.bind_addr;
        list_for_each(pos, &bp->address_list) {
                addr = list_entry(pos, struct sctp_sockaddr_entry, list);
-               if (sctp_has_association(&addr->a, paddr)) {
+               if (sctp_has_association(&addr->a_h, paddr)) {
                        sctp_read_unlock(&ep->base.addr_lock);
                        return 1;
                }
@@ -332,8 +346,10 @@ static void sctp_endpoint_bh_rcv(struct sctp_endpoint *ep)
                 * COOKIE-ECHO chunk.
                 */
                if (NULL == chunk->asoc) {
+                       union sctp_addr tmp;
+                       flip_to_n(&tmp, sctp_source(chunk));
                        asoc = sctp_endpoint_lookup_assoc(ep,
-                                                         sctp_source(chunk),
+                                                         &tmp,
                                                          &transport);
                        chunk->asoc = asoc;
                        chunk->transport = transport;