}
-static int add_route_to_cache(struct v3_vnet_pkt * pkt, struct route_list * routes) {
+static int add_route_to_cache(const struct v3_vnet_pkt * pkt, struct route_list * routes) {
memcpy(routes->hash_buf, pkt->hash_buf, VNET_HASH_SIZE);
if (v3_htable_insert(vnet_state.route_cache, (addr_t)routes->hash_buf, (addr_t)routes) == 0) {
return 0;
}
-static int look_into_cache(struct v3_vnet_pkt * pkt, struct route_list ** routes) {
+static int look_into_cache(const struct v3_vnet_pkt * pkt, struct route_list ** routes) {
*routes = (struct route_list *)v3_htable_search(vnet_state.route_cache, (addr_t)(pkt->hash_buf));
// At the end allocate a route_list
// This list will be inserted into the cache so we don't need to free it
-static struct route_list * match_route(struct v3_vnet_pkt * pkt) {
+static struct route_list * match_route(const struct v3_vnet_pkt * pkt) {
struct vnet_route_info * route = NULL;
struct route_list * matches = NULL;
int num_matches = 0;
#ifdef CONFIG_DEBUG_VNET
{
- struct eth_hdr * hdr = (struct eth_hdr *)(pkt->data);
+ struct eth_hdr * hdr = (struct eth_hdr *)(pkt->header);
char dest_str[30];
char src_str[30];
}
#endif
-#ifdef CONFIG_VNET_PROFILE
- struct guest_info *core = (struct guest_info *)private_data;
- uint64_t start, end;
- rdtscll(start);
-#endif
-
flags = v3_lock_irqsave(vnet_state.lock);
look_into_cache(pkt, &matched_routes);
if (matched_routes == NULL) {
- PrintDebug("Vnet: can not find route in cache, looking into routing table\n");
+ PrintDebug("Vnet: send pkt Looking into routing table\n");
matched_routes = match_route(pkt);
if (matched_routes) {
add_route_to_cache(pkt, matched_routes);
} else {
- PrintDebug("Could not find route for packet...\n");
+ PrintDebug("Could not find route for packet... discards packet\n");
v3_unlock_irqrestore(vnet_state.lock, flags);
return -1;
}
v3_unlock_irqrestore(vnet_state.lock, flags);
-#ifdef CONFIG_VNET_PROFILE
- {
- rdtscll(end);
- core->vnet_times.time_route_lookup = end - start;
- }
-#endif
- PrintDebug("Vnet: HandleOnePacket: route matches %d\n", matched_routes->num_routes);
+ PrintDebug("Vnet: send pkt route matches %d\n", matched_routes->num_routes);
for (i = 0; i < matched_routes->num_routes; i++) {
struct vnet_route_info * route = matched_routes->routes[i];
PrintDebug("Vnet: HandleOnePacket: Forward packet according to Route\n");
}
-
-#ifdef CONFIG_VNET_PROFILE
- {
- rdtscll(start);
- core->vnet_times.time_copy_to_guest = start - end;
- }
-#endif
return 0;
}