linux/net/sctp/inqueue.c
<<
>>
Prefs
   1/* SCTP kernel implementation
   2 * Copyright (c) 1999-2000 Cisco, Inc.
   3 * Copyright (c) 1999-2001 Motorola, Inc.
   4 * Copyright (c) 2002 International Business Machines, Corp.
   5 *
   6 * This file is part of the SCTP kernel implementation
   7 *
   8 * These functions are the methods for accessing the SCTP inqueue.
   9 *
  10 * An SCTP inqueue is a queue into which you push SCTP packets
  11 * (which might be bundles or fragments of chunks) and out of which you
  12 * pop SCTP whole chunks.
  13 *
  14 * This SCTP implementation is free software;
  15 * you can redistribute it and/or modify it under the terms of
  16 * the GNU General Public License as published by
  17 * the Free Software Foundation; either version 2, or (at your option)
  18 * any later version.
  19 *
  20 * This SCTP implementation is distributed in the hope that it
  21 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
  22 *                 ************************
  23 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  24 * See the GNU General Public License for more details.
  25 *
  26 * You should have received a copy of the GNU General Public License
  27 * along with GNU CC; see the file COPYING.  If not, write to
  28 * the Free Software Foundation, 59 Temple Place - Suite 330,
  29 * Boston, MA 02111-1307, USA.
  30 *
  31 * Please send any bug reports or fixes you make to the
  32 * email address(es):
  33 *    lksctp developers <lksctp-developers@lists.sourceforge.net>
  34 *
  35 * Or submit a bug report through the following website:
  36 *    http://www.sf.net/projects/lksctp
  37 *
  38 * Written or modified by:
  39 *    La Monte H.P. Yarroll <piggy@acm.org>
  40 *    Karl Knutson <karl@athena.chicago.il.us>
  41 *
  42 * Any bugs reported given to us we will try to fix... any fixes shared will
  43 * be incorporated into the next SCTP release.
  44 */
  45
  46#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  47
  48#include <net/sctp/sctp.h>
  49#include <net/sctp/sm.h>
  50#include <linux/interrupt.h>
  51#include <linux/slab.h>
  52
  53/* Initialize an SCTP inqueue.  */
  54void sctp_inq_init(struct sctp_inq *queue)
  55{
  56        INIT_LIST_HEAD(&queue->in_chunk_list);
  57        queue->in_progress = NULL;
  58
  59        /* Create a task for delivering data.  */
  60        INIT_WORK(&queue->immediate, NULL);
  61
  62        queue->malloced = 0;
  63}
  64
  65/* Release the memory associated with an SCTP inqueue.  */
  66void sctp_inq_free(struct sctp_inq *queue)
  67{
  68        struct sctp_chunk *chunk, *tmp;
  69
  70        /* Empty the queue.  */
  71        list_for_each_entry_safe(chunk, tmp, &queue->in_chunk_list, list) {
  72                list_del_init(&chunk->list);
  73                sctp_chunk_free(chunk);
  74        }
  75
  76        /* If there is a packet which is currently being worked on,
  77         * free it as well.
  78         */
  79        if (queue->in_progress) {
  80                sctp_chunk_free(queue->in_progress);
  81                queue->in_progress = NULL;
  82        }
  83
  84        if (queue->malloced) {
  85                /* Dump the master memory segment.  */
  86                kfree(queue);
  87        }
  88}
  89
  90/* Put a new packet in an SCTP inqueue.
  91 * We assume that packet->sctp_hdr is set and in host byte order.
  92 */
  93void sctp_inq_push(struct sctp_inq *q, struct sctp_chunk *chunk)
  94{
  95        /* Directly call the packet handling routine.*/
chunk->chrcvra>->madea a>) {
sctp_chunk_free(chunk);
>  8999a>        }
>  9">>a>
1a>        /* Di ass isnowall tg the  sether vefromhe paftwa terrupt.hspan>
/a> */////////*r fragomhe pabketlog ogrssing t/span>
/a> * ////////*rEvt">ul ty,e wiould hacle clupnqueue istoot, elea/span>
/a> */////////*r the imBHeleaed wita. truct 
/a> * ////////*span>
/a>        list_deadd_ils.a>(&chunk->list);&q, gt;in_chunk_list);
/a>        q, gt;immediate, . href="+code=fmtuncclass="sref">fmtunca>(&q, gt;immediate, 
/a>}
/a>
  11 * Puteek athe next SCunk_lr the imquee.  **span>
1  9"sctp_chunk_fr ia> *sctp_inq_puseeka>(struct sctp_inq *queue)
  11  111/a>          ruct sctp_chunk *chunk)
  1114a>        sctp_inunk_fr i_ a> *chuna> = NULL;
  111/a>
  111/a>        chunk)
 queue->in_progress =  111/a>        /* If there is a noore deunks.
  1118a>           (chunk->sctg tletona>   || href="net/sctp/inqueue.c#L9361" id="L19"" class="line" name="L19"">  1119a>        }
  chunk)
gt;chend_of_rtet ha>   || href="net/sctp/inqueue.c#L9361" id="L201" class="line" name="L201">  212/a>               href="+code=INunk" class="sref">chunk)
gt;mapdiscar a>)
  212/a>                NULL;
>  112/a>
  2123a>        chuna> = sctp_inunk_fr i_ a> *chunk)
gt;chunk;
  212/a>
  212/a>        chuna> =  21  212/a>
  212/a>
  21 * Empxtraca neunk_lragomh SCTP inqueue.
  31 *
  31 * PlWARNING:If nou maneedstoot typheCunk_lr thanoer veeue.c,ou maneedstospan>
  31 * emke toahareowinopy of(clone)f thit/span>
>  21 *  span>
  31sctp_chunk *tmtp_inq_puso a>(struct sctp_inq *queue)
  313/a>{
  313/a>        sctp_chunk *chunk)
  313/a>        sctp_inunk_fr i_ a> *chuna> = NULL;
  313/a>
  313/a>        /* CrThassume pon is diat pawass isfe
  41 * ////////*rathe  diaim
  41 *
  414/a>
  4143a>        chunk-& queue->in_progress =){
  4144a>        /* CrTha is a packet what pawasve rebeenorkedg th.
  414/a> * ////////////////*ry bust"  ogrssing torkedstoodoebefe dewasmo reon?span>
  414/a> * ////////////////*span>
  4147a>                chunk->sctg tletona>   || href="net/sctp/inqueue.c#L9361" id="L481" class="line" name="L481">  4148a>                chunk)
gt;chend_of_rtet ha>   || href="net/sctp/inqueue.c#L9361" id="L491" class="line" name="L491">  4149a>        }
  chunk)
gt;mapdiscar a>)
<
  515/a>                sctp_chunk_free(chunk);
  515/a>                chunk)
 queue->in_progress = NULL;
  515/a>                  515/a>                /* CrNoerg theoodo. Nt SCunk_lr the hortet hstpase.
  5154a>        chuna> = sctp_inunk_fr i_ a> *chunk)
gt;chunk;
  515/a>
  515/a>                /* CrForceCunk_lgt;sctkbgt;scta. teoounk_lgt;scunk
  5157a>                litkb_pul.a>(chunk);gt;litkba>);&a href="net/sctp/inqueue.c#L861" id="L481" class="line" name="L581">  5158a>                chunk)
gt;chunk;
 -a href="+code=INunk" class="sref">chunk)
gt;litkba>);gt;lida. a>);
  515/a>
  616/a>                /* CrVery itat pawasve re paase.SCunk_lradiner/span>
  616/a> *
  616/a> */////////////////////////*/span>
  616/a>                sctkb_adinlena>(chunk);gt;litkba>);)lt;sctp_inunk_fr i_ a> *){
  6164a>        sctp_chunk_free(chunk);
  616/a>                chunk)
 queue->in_progress = NULL;
>  516/a>                  6167a>                  61        st  61
  71        /* EmDoawasneedstoote to  next SCcket wht of whe queue. stootgrssin?/*/span>
  71        chunk);

  71                mast_dehea a> *cheny_sa>;
  717/a>
  7174a>        /* CrIshe queue. sety t?//*/span>
  717/a>                mast_deety ta>(queue->in_chunk_list);
  717/a>                NULL;
>  617/a>
  7178a>                cheny_sa>;
 queue->in_chunk_list);. href="+code=fmnt" naass="sref">innt" a>;
  7179a>        }
  chunk)
 queue->in_progress =   81                chst_deery_sa>(cheny_sa>;
struct sctp_chunk *list) {  81                list_del_init(&a href="+code=chtry_sclass="sref">cheny_sa>;
{  818/a>
  818/a>                /* CrThiss diatfilersSCunk_lr the hortet h */
  8184a>        chunk->sctg tletona>   = 1  81                chuna> = sctp_inunk_fr i_ a> *chunk)
gt;litkba>);gt;lida. a>);  81                chunk)
gt;mada. _cesspt" a> =   81        }
  818/a>
  818/a>        chunk)
gt;scunk_lir ia>)
 chuna> =  919/a>        chunk)
gt;chunk;
 =ch__u8a> *chuna> =) +a href="+code=INWORD_ROUN class="sref">INWORD_ROUN a>(&a href="+code=chntoh class="sref">inntoh a>(chuna> =gt;chsengtna>);
<  9191a>        /* DiIthe hounlike callsef wh clIreles="embty,ee pafkb cld hab/span>
  91 */////////* non-ne" ar.f noso, upde a unk
  919/a> * ////////*re pafkbgt;
  919/a> */////////*/span>
  91        chunlike ca>(sctkb_is_nonne" ara>(chunk);gt;litkba>);)){
chunk->chunk;
 t;sctkb_ils._poterrua>(chunk);gt;litkba>);))a href="net/sctp/inqueue.c#L851" id="L8719 class="line" name="L8719>  8197a>                chunk)
gt;chunk;
 =< href="+code=INtkb_ils._poterruclass="sref">sctkb_ils._poterrua>(chunk);gt;litkba>);)>  819/a>        litkb_pul.a>(chunk);gt;litkba>);& sizeofa href="+code=qutp_chunk_fr i_ class="sref">sctp_inunk_fr i_ a> *){chunk)
gt;sctub a>);. href="+code=fmvclass="sref">scva> = NULL;
/* DiSub diners a noong w veralid */
chunk->chunk;
 tlsctkb_ils._poterrua>(chunk);gt;litkba>);))
/* CrThiss dit, ea tg tleton/
chunk->sctg tletona>   = 
chunk->chunk;
 t;sctkb_ils._poterrua>(chunk);gt;litkba>);))
/* RelFC 2960, Secon is6.10  Buling rspan>
         *         /span>
         */        / Paralizeunks.
 *       */        /  thereeceived delitts/l packralizeunks.,t
  12 *       */        / pheCunk_l span>
 *
  121/a> */////////////////DiSincto  neenda whe quunk_lr sortsho  neenda whourhbufferspan>
  121/a> * ////////////////Di(ich isconilsndiatfiwholhortet hstwquu cleean>
  121/a> */////////        / pheCwholhortet h span>
  121/a> * ////////////////*/span>
  121/a>                sctp_chunk_free(chunk);
  1217a>                chunk)
 queue->in_progress = NULL;
  121/a>
  1219a>        }
  NULL;
  222/a>          } else
  222/a>                /* Di ass isato  neenda whe qurtet hstro maedst quunk_lspan>
 */////////////////Di anllsefwasneedstoosendaa SACK span>
  222/a> * ////////////////D/span>
  2224a>        chunk->chend_of_rtet ha>   = 1  222/a>          22  222/a>        INTP i_DEBUG_PRINT a>(": +++tp_inq_puso +++uunk_lr%p[%s],uot;   2228a>                ":  sengtnr%d,afkbgt; <,phref="+code=quunk" class="sref">chunk-&&a href="net/sctp/inqueue.c#L862" id="L292" class="line" name="L292">  2229a>        }
  sctp_chume="a>(INTP i_ST_CHUN a>(chunk);gt;scunk_lir ia>)
gt;sctyp"a>);))&a href="net/sctp/inqueue.c#L862" id="L302" class="line" name="L302">  323/a>                inntoh a>(chunk);gt;scunk_lir ia>)
gt;chsengtna>);
chunk)
gt;litkba>);gt;sclena>(<
  323/a>          turn fa href="+code=NUunk" class="sref">chunk)
  32  323/a> * DiS andstop-halfandlin.
  323/a> * /span>
  323/a> * * Originl ty,e wit qutop-halfandlin.< was scheduledsal paBH. i asnowspan>
  323/a>   *all the pandlin.< dectly ca antp_inq_pusush()satoaiaim<*at ispan>
  323/a>   *e wiknowawass islocksfe
  323/a> * CrThasterrnts diat pae  diutine.* wi thpul. stuffht of whe qspan>
  42 * *nqueue isd intgrssinyit/span>
  42 *
  424/a>
sctp_chq_puset_th_ndlin.(sctp_inq *q, st href="+code=q"rked_tunc_ class="sref">scrked_tunc_ a> *< href="+code=NUul tbketclass="sref">chul tbketa>(<
a href="net/sctp/inqueue.c#L862" id="L132" class="line" name="L432">  4243a>    4244a>        INIT_WORK(&q, gt;immediate, chul tbketa>(<
  424/a>  424/a>  4247a>  
Thasoriginl LXRaftwaws isbthe qu href="nehttp://sourcefe ge.t/sctgrjts/l/lxuc>LXRammenunitsa>; ste setxperint">l versn isbth href="nemailto:lxu@ne"ux.nosclxu@ne"ux.noa>);.
lxu.ne"ux.no kilinyost bedsbth href="nehttp://www.redpi t-ne"tgr.noscRedpi t Le"tgr ASa>; sttgrviners whLe"uxsconsultg thd inoperaon iset rvissi tg ce819/5.