Changeset 28440 in vbox for trunk/src/VBox/Devices/Network
- Timestamp:
- Apr 18, 2010 7:57:56 PM (15 years ago)
- Location:
- trunk/src/VBox/Devices/Network
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DrvNAT.cpp
r28396 r28440 667 667 PDRVNAT pThis = PDMINS_2_DATA(pDrvIns, PDRVNAT); 668 668 int nFDs = -1; 669 int ms;670 669 #ifdef RT_OS_WINDOWS 671 670 HANDLE *phEvents = slirp_get_events(pThis->pNATState); -
trunk/src/VBox/Devices/Network/slirp/debug.c
r26180 r28440 192 192 { 193 193 char buff[256]; 194 int n;194 size_t n; 195 195 struct socket *so, *so_next; 196 196 -
trunk/src/VBox/Devices/Network/slirp/misc.c
r28434 r28440 127 127 128 128 static void *slirp_uma_alloc(uma_zone_t zone, 129 int size, uint8_t *pflags, int fWait)129 int size, uint8_t *pflags, int fWait) 130 130 { 131 131 struct item *it; 132 132 uint8_t *sub_area; 133 int cChunk;134 int i; 133 void *ret = NULL; 134 135 135 RTCritSectEnter(&zone->csZone); 136 free_list_check: 137 if (!LIST_EMPTY(&zone->free_items)) 136 for (;;) 138 137 { 139 zone->cur_items++; 140 it = LIST_FIRST(&zone->free_items); 138 if (!LIST_EMPTY(&zone->free_items)) 139 { 140 zone->cur_items++; 141 it = LIST_FIRST(&zone->free_items); 142 LIST_REMOVE(it, list); 143 LIST_INSERT_HEAD(&zone->used_items, it, list); 144 if (zone->pfInit) 145 zone->pfInit(zone->pData, (void *)&it[1], zone->size, M_DONTWAIT); 146 ret = (void *)&it[1]; 147 break; 148 } 149 150 if (!zone->master_zone) 151 { 152 /* We're on master zone and we cant allocate more */ 153 Log2(("NAT: no room on %s zone\n", zone->name)); 154 break; 155 } 156 157 /* we're on sub-zone we need get chunk of master zone and split 158 * it for sub-zone conforming chunks. 159 */ 160 sub_area = slirp_uma_alloc(zone->master_zone, zone->master_zone->size, NULL, 0); 161 if (!sub_area) 162 { 163 /* No room on master */ 164 Log2(("NAT: no room on %s zone for %s zone\n", zone->master_zone->name, zone->name)); 165 break; 166 } 167 zone->max_items++; 168 it = &((struct item *)sub_area)[-1]; 169 /* it's chunk descriptor of master zone we should remove it 170 * from the master list first 171 */ 172 Assert((it->zone && it->zone->magic == ZONE_MAGIC)); 173 RTCritSectEnter(&it->zone->csZone); 174 /* @todo should we alter count of master counters? */ 141 175 LIST_REMOVE(it, list); 142 LIST_INSERT_HEAD(&zone->used_items, it, list); 143 if (zone->pfInit) 144 zone->pfInit(zone->pData, (void *)&it[1], zone->size, M_DONTWAIT); 145 RTCritSectLeave(&zone->csZone); 146 return (void *)&it[1]; 176 RTCritSectLeave(&it->zone->csZone); 177 /* @todo '+ zone->size' should be depend on flag */ 178 memset(it, 0, sizeof(struct item)); 179 it->zone = zone; 180 it->magic = ITEM_MAGIC; 181 LIST_INSERT_HEAD(&zone->free_items, it, list); 182 if (zone->cur_items >= zone->max_items) 183 LogRel(("NAT: zone(%s) has reached it maximum\n", zone->name)); 147 184 } 148 149 if (zone->master_zone == NULL) 150 { 151 /* We're on master zone and we cant allocate more */ 152 Log2(("NAT: no room on %s zone\n", zone->name)); 153 RTCritSectLeave(&zone->csZone); 154 return NULL; 155 } 156 157 /* we're on sub-zone we need get chunk of master zone and split 158 * it for sub-zone conforming chunks. 159 */ 160 sub_area = slirp_uma_alloc(zone->master_zone, zone->master_zone->size, NULL, 0); 161 if (sub_area == NULL) 162 { 163 /*No room on master*/ 164 Log2(("NAT: no room on %s zone for %s zone\n", zone->master_zone->name, zone->name)); 165 RTCritSectLeave(&zone->csZone); 166 return NULL; 167 } 168 zone->max_items ++; 169 it = &((struct item *)sub_area)[-1]; 170 /* it's chunk descriptor of master zone we should remove it 171 * from the master list first 172 */ 173 Assert((it->zone && it->zone->magic == ZONE_MAGIC)); 174 RTCritSectEnter(&it->zone->csZone); 175 /*@todo should we alter count of master counters ?*/ 176 LIST_REMOVE(it, list); 177 RTCritSectLeave(&it->zone->csZone); 178 /*@todo '+ zone->size' should be depend on flag */ 179 memset(it, 0, sizeof(struct item)); 180 it->zone = zone; 181 it->magic = ITEM_MAGIC; 182 LIST_INSERT_HEAD(&zone->free_items, it, list); 183 if (zone->cur_items >= zone->max_items) 184 LogRel(("NAT: zone(%s) has reached it maximum\n", zone->name)); 185 goto free_list_check; 186 185 RTCritSectLeave(&zone->csZone); 186 return ret; 187 187 } 188 188 … … 373 373 374 374 m = m_getjcl(pData, M_NOWAIT, MT_HEADER, M_PKTHDR, size); 375 m->m_len = size 375 m->m_len = size; 376 376 *ppvBuf = mtod(m, void *); 377 377 *pcbBuf = size; … … 386 386 static void zone_destroy(uma_zone_t zone) 387 387 { 388 struct item *it;389 388 RTCritSectEnter(&zone->csZone); 390 389 LogRel(("NAT: zone(nm:%s, used:%d)\n", zone->name, zone->cur_items));
Note:
See TracChangeset
for help on using the changeset viewer.