X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fiface-packet.c;h=6ec4de0a1d9278e88cea38a9364de63d024e1b95;hb=2cce318d177c66ebf6eb5bb2cd156df46f8aca85;hp=4cdec659b9e01c4174c87db630ca3321500f632f;hpb=791ea2f3e21cfbc9c47341efbb98995c33d86fcb;p=palacios.git diff --git a/linux_module/iface-packet.c b/linux_module/iface-packet.c index 4cdec65..6ec4de0 100644 --- a/linux_module/iface-packet.c +++ b/linux_module/iface-packet.c @@ -158,7 +158,12 @@ static int packet_recv_thread( void * arg ) { struct v3_packet * recver_state; struct raw_interface * iface = (struct raw_interface *)arg; - pkt = (unsigned char *)kmalloc(ETHERNET_PACKET_LEN, GFP_KERNEL); + pkt = (unsigned char *)palacios_alloc(ETHERNET_PACKET_LEN); + + if (!pkt) { + ERROR("Unable to allocate packet in vnet receive thread\n"); + return -1; + } INFO("Palacios Raw Packet Bridge: Staring receiving on ethernet device %s\n", iface->eth_dev); @@ -222,7 +227,7 @@ deinit_raw_interface(struct raw_interface * iface){ palacios_free_htable(iface->mac_to_recver, 0, 0); list_for_each_entry_safe(recver_state, tmp_state, &(iface->brdcast_recvers), node) { - kfree(recver_state); + palacios_free(recver_state); } } @@ -248,24 +253,24 @@ palacios_packet_connect(struct v3_packet * packet, struct raw_interface * iface; unsigned long flags; - spin_lock_irqsave(&(packet_state.lock), flags); + palacios_spinlock_lock_irqsave(&(packet_state.lock), flags); iface = find_interface(host_nic); - spin_unlock_irqrestore(&(packet_state.lock),flags); + palacios_spinlock_unlock_irqrestore(&(packet_state.lock),flags); if(iface == NULL){ - iface = (struct raw_interface *)kmalloc(sizeof(struct raw_interface), GFP_KERNEL); + iface = (struct raw_interface *)palacios_alloc(sizeof(struct raw_interface)); if (!iface) { - WARNING("Palacios Packet Interface: Fails to allocate interface\n"); + ERROR("Palacios Packet Interface: Fails to allocate interface\n"); return -1; } if(init_raw_interface(iface, host_nic) != 0) { - WARNING("Palacios Packet Interface: Fails to initiate an raw interface on device %s\n", host_nic); - kfree(iface); + ERROR("Palacios Packet Interface: Fails to initiate an raw interface on device %s\n", host_nic); + palacios_free(iface); return -1; } - spin_lock_irqsave(&(packet_state.lock), flags); + palacios_spinlock_lock_irqsave(&(packet_state.lock), flags); list_add(&(iface->node), &(packet_state.open_interfaces)); - spin_unlock_irqrestore(&(packet_state.lock),flags); + palacios_spinlock_unlock_irqrestore(&(packet_state.lock),flags); } packet->host_packet_data = iface; @@ -296,8 +301,7 @@ palacios_packet_send(struct v3_packet * packet, if(iface->inited == 0 || iface->raw_sock == NULL){ - WARNING("Palacios Packet Interface: Send fails due to inapproriate interface\n"); - + ERROR("Palacios Packet Interface: Send fails due to inapproriate interface\n"); return -1; } @@ -342,7 +346,7 @@ static int packet_init( void ) { V3_Init_Packet(&palacios_packet_hooks); memset(&packet_state, 0, sizeof(struct palacios_packet_state)); - spin_lock_init(&(packet_state.lock)); + palacios_spinlock_init(&(packet_state.lock)); INIT_LIST_HEAD(&(packet_state.open_interfaces)); // REGISTER GLOBAL CONTROL to add interfaces... @@ -355,8 +359,10 @@ static int packet_deinit( void ) { list_for_each_entry_safe(iface, tmp, &(packet_state.open_interfaces), node) { deinit_raw_interface(iface); - kfree(iface); + palacios_free(iface); } + + palacios_spinlock_deinit(&(packet_state.lock)); return 0; }