sctp: Rework the tsn map to use generic bitmap.
[safe/jmp/linux-2.6] / net / sctp / associola.c
index 024c3eb..f4b2304 100644 (file)
@@ -136,6 +136,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
 
        /* Set association default SACK delay */
        asoc->sackdelay = msecs_to_jiffies(sp->sackdelay);
+       asoc->sackfreq = sp->sackfreq;
 
        /* Set the association default flags controlling
         * Heartbeat, SACK delay, and Path MTU Discovery.
@@ -261,6 +262,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
         * already received one packet.]
         */
        asoc->peer.sack_needed = 1;
+       asoc->peer.sack_cnt = 0;
 
        /* Assume that the peer will tell us if he recognizes ASCONF
         * as part of INIT exchange.
@@ -281,8 +283,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
        if (!sctp_ulpq_init(&asoc->ulpq, asoc))
                goto fail_init;
 
-       /* Set up the tsn tracking. */
-       sctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_SIZE, 0);
+       memset(&asoc->peer.tsn_map, 0, sizeof(struct sctp_tsnmap));
 
        asoc->need_ecne = 0;
 
@@ -400,6 +401,8 @@ void sctp_association_free(struct sctp_association *asoc)
        /* Dispose of any pending chunks on the inqueue. */
        sctp_inq_free(&asoc->base.inqueue);
 
+       sctp_tsnmap_free(&asoc->peer.tsn_map);
+
        /* Free ssnmap storage. */
        sctp_ssnmap_free(asoc->ssnmap);
 
@@ -462,7 +465,7 @@ static void sctp_association_destroy(struct sctp_association *asoc)
                spin_unlock_bh(&sctp_assocs_id_lock);
        }
 
-       BUG_TRAP(!atomic_read(&asoc->rmem_alloc));
+       WARN_ON(atomic_read(&asoc->rmem_alloc));
 
        if (asoc->base.malloced) {
                kfree(asoc);
@@ -597,11 +600,12 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
        /* Check to see if this is a duplicate. */
        peer = sctp_assoc_lookup_paddr(asoc, addr);
        if (peer) {
+               /* An UNKNOWN state is only set on transports added by
+                * user in sctp_connectx() call.  Such transports should be
+                * considered CONFIRMED per RFC 4960, Section 5.4.
+                */
                if (peer->state == SCTP_UNKNOWN) {
-                       if (peer_state == SCTP_ACTIVE)
-                               peer->state = SCTP_ACTIVE;
-                       if (peer_state == SCTP_UNCONFIRMED)
-                               peer->state = SCTP_UNCONFIRMED;
+                       peer->state = SCTP_ACTIVE;
                }
                return peer;
        }
@@ -624,6 +628,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
         * association configured value.
         */
        peer->sackdelay = asoc->sackdelay;
+       peer->sackfreq = asoc->sackfreq;
 
        /* Enable/disable heartbeat, SACK delay, and path MTU discovery
         * based on association setting.
@@ -650,6 +655,7 @@ struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc,
 
        SCTP_DEBUG_PRINTK("sctp_assoc_add_peer:association %p PMTU set to "
                          "%d\n", asoc, asoc->pathmtu);
+       peer->pmtu_pending = 0;
 
        asoc->frag_point = sctp_frag_point(sp, asoc->pathmtu);
 
@@ -1117,8 +1123,8 @@ void sctp_assoc_update(struct sctp_association *asoc,
        asoc->peer.rwnd = new->peer.rwnd;
        asoc->peer.sack_needed = new->peer.sack_needed;
        asoc->peer.i = new->peer.i;
-       sctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_SIZE,
-                        asoc->peer.i.initial_tsn);
+       sctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_INITIAL,
+                        asoc->peer.i.initial_tsn, GFP_ATOMIC);
 
        /* Remove any peer addresses not present in the new association. */
        list_for_each_safe(pos, temp, &asoc->peer.transport_addr_list) {