]> err.no Git - linux-2.6/blobdiff - net/sctp/sm_sideeffect.c
tipc: Fix skb_under_panic when configuring TIPC without privileges
[linux-2.6] / net / sctp / sm_sideeffect.c
index 02bf32c3026307fd32a345eee2b0620593d44dca..b083312c725aa03294771a5858a4840c806ef924 100644 (file)
@@ -190,20 +190,28 @@ static int sctp_gen_sack(struct sctp_association *asoc, int force,
         * unacknowledged DATA chunk. ...
         */
        if (!asoc->peer.sack_needed) {
-               /* We will need a SACK for the next packet.  */
-               asoc->peer.sack_needed = 1;
+               asoc->peer.sack_cnt++;
 
                /* Set the SACK delay timeout based on the
                 * SACK delay for the last transport
                 * data was received from, or the default
                 * for the association.
                 */
-               if (trans)
+               if (trans) {
+                       /* We will need a SACK for the next packet.  */
+                       if (asoc->peer.sack_cnt >= trans->sackfreq - 1)
+                               asoc->peer.sack_needed = 1;
+
                        asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] =
                                trans->sackdelay;
-               else
+               } else {
+                       /* We will need a SACK for the next packet.  */
+                       if (asoc->peer.sack_cnt >= asoc->sackfreq - 1)
+                               asoc->peer.sack_needed = 1;
+
                        asoc->timeouts[SCTP_EVENT_TIMEOUT_SACK] =
                                asoc->sackdelay;
+               }
 
                /* Restart the SACK timer. */
                sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_RESTART,
@@ -216,6 +224,7 @@ static int sctp_gen_sack(struct sctp_association *asoc, int force,
                        goto nomem;
 
                asoc->peer.sack_needed = 0;
+               asoc->peer.sack_cnt = 0;
 
                sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(sack));
 
@@ -545,14 +554,12 @@ static void sctp_cmd_hb_timers_start(sctp_cmd_seq_t *cmds,
                                     struct sctp_association *asoc)
 {
        struct sctp_transport *t;
-       struct list_head *pos;
 
        /* Start a heartbeat timer for each transport on the association.
         * hold a reference on the transport to make sure none of
         * the needed data structures go away.
         */
-       list_for_each(pos, &asoc->peer.transport_addr_list) {
-               t = list_entry(pos, struct sctp_transport, transports);
+       list_for_each_entry(t, &asoc->peer.transport_addr_list, transports) {
 
                if (!mod_timer(&t->hb_timer, sctp_transport_timeout(t)))
                        sctp_transport_hold(t);
@@ -563,12 +570,11 @@ static void sctp_cmd_hb_timers_stop(sctp_cmd_seq_t *cmds,
                                    struct sctp_association *asoc)
 {
        struct sctp_transport *t;
-       struct list_head *pos;
 
        /* Stop all heartbeat timers. */
 
-       list_for_each(pos, &asoc->peer.transport_addr_list) {
-               t = list_entry(pos, struct sctp_transport, transports);
+       list_for_each_entry(t, &asoc->peer.transport_addr_list,
+                       transports) {
                if (del_timer(&t->hb_timer))
                        sctp_transport_put(t);
        }
@@ -579,10 +585,9 @@ static void sctp_cmd_t3_rtx_timers_stop(sctp_cmd_seq_t *cmds,
                                        struct sctp_association *asoc)
 {
        struct sctp_transport *t;
-       struct list_head *pos;
 
-       list_for_each(pos, &asoc->peer.transport_addr_list) {
-               t = list_entry(pos, struct sctp_transport, transports);
+       list_for_each_entry(t, &asoc->peer.transport_addr_list,
+                       transports) {
                if (timer_pending(&t->T3_rtx_timer) &&
                    del_timer(&t->T3_rtx_timer)) {
                        sctp_transport_put(t);
@@ -593,7 +598,6 @@ static void sctp_cmd_t3_rtx_timers_stop(sctp_cmd_seq_t *cmds,
 
 /* Helper function to update the heartbeat timer. */
 static void sctp_cmd_hb_timer_update(sctp_cmd_seq_t *cmds,
-                                    struct sctp_association *asoc,
                                     struct sctp_transport *t)
 {
        /* Update the heartbeat timer.  */
@@ -1065,7 +1069,6 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
        struct sctp_chunk *new_obj;
        struct sctp_chunk *chunk = NULL;
        struct sctp_packet *packet;
-       struct list_head *pos;
        struct timer_list *timer;
        unsigned long timeout;
        struct sctp_transport *t;
@@ -1397,9 +1400,8 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
                        /* If we've sent any data bundled with
                         * COOKIE-ECHO we need to resend.
                         */
-                       list_for_each(pos, &asoc->peer.transport_addr_list) {
-                               t = list_entry(pos, struct sctp_transport,
-                                              transports);
+                       list_for_each_entry(t, &asoc->peer.transport_addr_list,
+                                       transports) {
                                sctp_retransmit_mark(&asoc->outqueue, t,
                                            SCTP_RTXR_T1_RTX);
                        }
@@ -1457,7 +1459,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
 
                case SCTP_CMD_HB_TIMER_UPDATE:
                        t = cmd->obj.transport;
-                       sctp_cmd_hb_timer_update(commands, asoc, t);
+                       sctp_cmd_hb_timer_update(commands, t);
                        break;
 
                case SCTP_CMD_HB_TIMERS_STOP:
@@ -1536,6 +1538,9 @@ static int sctp_cmd_interpreter(sctp_event_t event_type,
                        error = sctp_auth_asoc_init_active_key(asoc,
                                                GFP_ATOMIC);
                        break;
+               case SCTP_CMD_UPDATE_INITTAG:
+                       asoc->peer.i.init_tag = cmd->obj.u32;
+                       break;
 
                default:
                        printk(KERN_WARNING "Impossible command: %u, %p\n",