Diff for /src/sys/net/dummynet/ip_dummynet.c between versions 1.7 and 1.8

version 1.7, 2004/04/13 00:14:00 version 1.8, 2004/04/22 04:21:58
Line 210  heap_init(struct dn_heap *h, int new_siz Line 210  heap_init(struct dn_heap *h, int new_siz
         return 0 ;          return 0 ;
     }      }
     new_size = (new_size + HEAP_INCREMENT ) & ~HEAP_INCREMENT ;      new_size = (new_size + HEAP_INCREMENT ) & ~HEAP_INCREMENT ;
    p = malloc(new_size * sizeof(*p), M_DUMMYNET, M_NOWAIT);    p = malloc(new_size * sizeof(*p), M_DUMMYNET, M_WAITOK | M_ZERO);
    if (p == NULL) { 
        printf(" heap_init, resize %d failed\n", new_size ); 
        return 1 ; /* error */ 
    } 
     if (h->size > 0) {      if (h->size > 0) {
         bcopy(h->p, p, h->size * sizeof(*p) );          bcopy(h->p, p, h->size * sizeof(*p) );
         free(h->p, M_DUMMYNET);          free(h->p, M_DUMMYNET);
Line 837  create_queue(struct dn_flow_set *fs, int Line 833  create_queue(struct dn_flow_set *fs, int
         if ( fs->rq[i] != NULL )          if ( fs->rq[i] != NULL )
             return fs->rq[i] ;              return fs->rq[i] ;
     }      }
    q = malloc(sizeof(*q), M_DUMMYNET, M_NOWAIT | M_ZERO);    q = malloc(sizeof(*q), M_DUMMYNET, M_WAITOK | M_ZERO);
    if (q == NULL) { 
        printf("sorry, cannot allocate queue for new flow\n"); 
        return NULL ; 
    } 
     q->fs = fs ;      q->fs = fs ;
     q->hash_slot = i ;      q->hash_slot = i ;
     q->next = fs->rq[i] ;      q->next = fs->rq[i] ;
Line 1140  dummynet_io(struct mbuf *m, int pipe_nr, Line 1132  dummynet_io(struct mbuf *m, int pipe_nr,
         goto dropit ;          goto dropit ;
   
     /* XXX expensive to zero, see if we can remove it*/      /* XXX expensive to zero, see if we can remove it*/
    pkt = (struct dn_pkt *)malloc(sizeof (*pkt), M_DUMMYNET, M_NOWAIT|M_ZERO);    pkt = malloc(sizeof (*pkt), M_DUMMYNET, M_INTWAIT | M_ZERO | M_NULLOK);
    if ( pkt == NULL )    if (pkt == NULL)
        goto dropit ;               /* cannot allocate packet header        */            goto dropit;        /* cannot allocate packet header        */
 
     /* ok, i can handle the pkt now... */      /* ok, i can handle the pkt now... */
     /* build and enqueue packet + parameters */      /* build and enqueue packet + parameters */
     pkt->hdr.mh_type = MT_TAG;      pkt->hdr.mh_type = MT_TAG;
Line 1440  config_red(struct dn_flow_set *p, struct Line 1433  config_red(struct dn_flow_set *p, struct
         return EINVAL;          return EINVAL;
     }      }
     x->lookup_depth = red_lookup_depth;      x->lookup_depth = red_lookup_depth;
    x->w_q_lookup = (u_int *) malloc(x->lookup_depth * sizeof(int),    x->w_q_lookup = malloc(x->lookup_depth * sizeof(int),
            M_DUMMYNET, M_NOWAIT);                        M_DUMMYNET, M_WAITOK);
    if (x->w_q_lookup == NULL) { 
        printf("sorry, cannot allocate red lookup table\n"); 
        free(x, M_DUMMYNET); 
        return ENOSPC; 
    } 
   
     /* fill the lookup table with (1 - w_q)^x */      /* fill the lookup table with (1 - w_q)^x */
     x->lookup_step = p->lookup_step ;      x->lookup_step = p->lookup_step ;
Line 1479  alloc_hash(struct dn_flow_set *x, struct Line 1467  alloc_hash(struct dn_flow_set *x, struct
     } else                  /* one is enough for null mask */      } else                  /* one is enough for null mask */
         x->rq_size = 1;          x->rq_size = 1;
     x->rq = malloc((1 + x->rq_size) * sizeof(struct dn_flow_queue *),      x->rq = malloc((1 + x->rq_size) * sizeof(struct dn_flow_queue *),
            M_DUMMYNET, M_NOWAIT | M_ZERO);                    M_DUMMYNET, M_WAITOK | M_ZERO);
    if (x->rq == NULL) { 
        printf("sorry, cannot allocate queue\n"); 
        return ENOSPC; 
    } 
     x->rq_elements = 0;      x->rq_elements = 0;
     return 0 ;      return 0 ;
 }  }
Line 1539  config_pipe(struct dn_pipe *p) Line 1523  config_pipe(struct dn_pipe *p)
                  a = b , b = b->next) ;                   a = b , b = b->next) ;
   
         if (b == NULL || b->pipe_nr != p->pipe_nr) { /* new pipe */          if (b == NULL || b->pipe_nr != p->pipe_nr) { /* new pipe */
            x = malloc(sizeof(struct dn_pipe), M_DUMMYNET, M_NOWAIT | M_ZERO);            x = malloc(sizeof(struct dn_pipe), M_DUMMYNET, M_WAITOK | M_ZERO);
            if (x == NULL) { 
                printf("ip_dummynet.c: no memory for new pipe\n"); 
                return ENOSPC; 
            } 
             x->pipe_nr = p->pipe_nr;              x->pipe_nr = p->pipe_nr;
             x->fs.pipe = x ;              x->fs.pipe = x ;
             /* idle_heap is the only one from which we extract from the middle.              /* idle_heap is the only one from which we extract from the middle.
Line 1592  config_pipe(struct dn_pipe *p) Line 1572  config_pipe(struct dn_pipe *p)
         if (b == NULL || b->fs_nr != pfs->fs_nr) { /* new  */          if (b == NULL || b->fs_nr != pfs->fs_nr) { /* new  */
             if (pfs->parent_nr == 0)    /* need link to a pipe */              if (pfs->parent_nr == 0)    /* need link to a pipe */
                 return EINVAL ;                  return EINVAL ;
            x = malloc(sizeof(struct dn_flow_set), M_DUMMYNET, M_NOWAIT|M_ZERO);            x = malloc(sizeof(struct dn_flow_set), M_DUMMYNET, M_WAITOK|M_ZERO);
            if (x == NULL) { 
                printf("ip_dummynet.c: no memory for new flow_set\n"); 
                return ENOSPC; 
            } 
             x->fs_nr = pfs->fs_nr;              x->fs_nr = pfs->fs_nr;
             x->parent_nr = pfs->parent_nr;              x->parent_nr = pfs->parent_nr;
             x->weight = pfs->weight ;              x->weight = pfs->weight ;
Line 1821  dummynet_get(struct sockopt *sopt) Line 1797  dummynet_get(struct sockopt *sopt)
     for (set = all_flow_sets ; set ; set = set->next )      for (set = all_flow_sets ; set ; set = set->next )
         size += sizeof ( *set ) +          size += sizeof ( *set ) +
             set->rq_elements * sizeof(struct dn_flow_queue);              set->rq_elements * sizeof(struct dn_flow_queue);
    buf = malloc(size, M_TEMP, M_NOWAIT);    buf = malloc(size, M_TEMP, M_WAITOK);
    if (buf == 0) { 
        splx(s); 
        return ENOBUFS ; 
    } 
     for (p = all_pipes, bp = buf ; p ; p = p->next ) {      for (p = all_pipes, bp = buf ; p ; p = p->next ) {
         struct dn_pipe *pipe_bp = (struct dn_pipe *)bp ;          struct dn_pipe *pipe_bp = (struct dn_pipe *)bp ;
   

Removed from v.1.7  
changed lines
  Added in v.1.8