unsigned long flags;
new_route = (struct vnet_route_info *)Vnet_Malloc(sizeof(struct vnet_route_info));
+
+ if (!new_route) {
+ PrintError("Cannot allocate new route\n");
+ return -1;
+ }
+
memset(new_route, 0, sizeof(struct vnet_route_info));
#ifdef V3_CONFIG_DEBUG_VNET
PrintDebug("VNET/P Core: match_route: Matches=%d\n", num_matches);
- if (num_matches == 0) {
+ if (num_matches <= 0) {
return NULL;
}
matches = (struct route_list *)Vnet_Malloc(sizeof(struct route_list) +
(sizeof(struct vnet_route_info *) * num_matches));
+
+ if (!matches) {
+ PrintError("VNET/P Core: Unable to allocate matches\n");
+ return NULL;
+ }
+
matches->num_routes = num_matches;
{
int i;
int cpu = V3_Get_CPU();
+
Vnet_Print(2, "VNET/P Core: cpu %d: pkt (size %d, src_id:%d, src_type: %d, dst_id: %d, dst_type: %d)\n",
cpu, pkt->size, pkt->src_id,
pkt->src_type, pkt->dst_id, pkt->dst_type);
+
if(net_debug >= 4){
v3_hexdump(pkt->data, pkt->size, NULL, 0);
}
vnet_state.stats.rx_pkts++;
look_into_cache(pkt, &matched_routes);
+
if (matched_routes == NULL) {
- PrintDebug("VNET/P Core: send pkt Looking into routing table\n");
+ PrintDebug("VNET/P Core: sending pkt - matching route\n");
matched_routes = match_route(pkt);
if (matched_routes) {
add_route_to_cache(pkt, matched_routes);
} else {
- PrintDebug("VNET/P Core: Could not find route for packet... discards packet\n");
+ PrintDebug("VNET/P Core: Could not find route for packet... discarding packet\n");
vnet_unlock_irqrestore(vnet_state.lock, flags);
return 0; /* do we return -1 here?*/
}
new_dev = (struct vnet_dev *)Vnet_Malloc(sizeof(struct vnet_dev));
if (new_dev == NULL) {
- Vnet_Print(0, "Malloc fails\n");
+ Vnet_Print(0, "VNET/P Core: Unable to allocate a new device\n");
return -1;
}
new_dev->private_data = priv_data;
new_dev->vm = vm;
new_dev->dev_id = 0;
- new_dev->quote = quote<VNET_MAX_QUOTE?quote:VNET_MAX_QUOTE;
+ new_dev->quote = quote<VNET_MAX_QUOTE ? quote : VNET_MAX_QUOTE;
new_dev->poll = poll_state;
flags = vnet_lock_irqsave(vnet_state.lock);
v3_enqueue(vnet_state.poll_devs, (addr_t)new_dev);
}
} else {
- PrintError("VNET/P: Device with the same MAC is already there\n");
+ PrintError("VNET/P: Device with the same MAC has already been added\n");
}
vnet_unlock_irqrestore(vnet_state.lock, flags);
Vnet_Free(dev);
- PrintDebug("VNET/P Core: Remove Device: dev_id %d\n", dev_id);
+ PrintDebug("VNET/P Core: Removed Device: dev_id %d\n", dev_id);
return 0;
}
tmp_bridge = (struct vnet_brg_dev *)Vnet_Malloc(sizeof(struct vnet_brg_dev));
if (tmp_bridge == NULL) {
- PrintError("Malloc Fails\n");
+ PrintError("VNET/P Core: Unable to allocate new bridge\n");
vnet_state.bridge = NULL;
return -1;
}
if (vnet_state.bridge != NULL && vnet_state.bridge->type == type) {
tmp_bridge = vnet_state.bridge;
- vnet_state.bridge = NULL;
+ vnet_state.bridge = NULL;
}
vnet_unlock_irqrestore(vnet_state.lock, flags);
}
}
+
+ Vnet_Free(tq);
Vnet_Print(0, "VNET/P Polling Thread Done.\n");
vnet_thread_stop(vnet_state.pkt_flush_thread);
// At this point there should be no lock-holder
+ Vnet_Free(vnet_state.poll_devs);
+
+
PrintDebug("Deiniting Device List\n");
// close any devices we have open
deinit_devices_list();