X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fiface-packet.c;h=d55b854a565cd9d25f3b9cac0325f2bf11aea8fe;hb=457220e0485aefc6efecbc81ab1343b9cb65d8ba;hp=3acb4bf61259193ee051324f9bf6853a94c4de8f;hpb=80a7fd2f343c65c00d84bc64181d0e9720ae20a6;p=palacios.git diff --git a/linux_module/iface-packet.c b/linux_module/iface-packet.c index 3acb4bf..d55b854 100644 --- a/linux_module/iface-packet.c +++ b/linux_module/iface-packet.c @@ -215,13 +215,13 @@ init_raw_interface(struct raw_interface * iface, const char * eth_dev){ static void inline deinit_raw_interface(struct raw_interface * iface){ - struct v3_packet * recver_state; + struct v3_packet * recver_state, * tmp_state; kthread_stop(iface->recv_thread); sock_release(iface->raw_sock); palacios_free_htable(iface->mac_to_recver, 0, 0); - list_for_each_entry(recver_state, &(iface->brdcast_recvers), node) { + list_for_each_entry_safe(recver_state, tmp_state, &(iface->brdcast_recvers), node) { kfree(recver_state); } } @@ -249,10 +249,11 @@ palacios_packet_connect(struct v3_packet * packet, unsigned long flags; spin_lock_irqsave(&(packet_state.lock), flags); - iface = find_interface(host_nic); + spin_unlock_irqrestore(&(packet_state.lock),flags); + if(iface == NULL){ - iface = (struct raw_interface *)kmalloc(sizeof(struct raw_interface), GFP_ATOMIC); + iface = (struct raw_interface *)kmalloc(sizeof(struct raw_interface), GFP_KERNEL); if (!iface) { printk("Palacios Packet Interface: Fails to allocate interface\n"); return -1; @@ -260,16 +261,13 @@ palacios_packet_connect(struct v3_packet * packet, if(init_raw_interface(iface, host_nic) != 0) { printk("Palacios Packet Interface: Fails to initiate an raw interface on device %s\n", host_nic); kfree(iface); - spin_unlock_irqrestore(&(packet_state.lock), flags); - return -1; } - + spin_lock_irqsave(&(packet_state.lock), flags); list_add(&(iface->node), &(packet_state.open_interfaces)); + spin_unlock_irqrestore(&(packet_state.lock),flags); } - spin_unlock_irqrestore(&(packet_state.lock), flags); - packet->host_packet_data = iface; list_add(&(packet->node), &(iface->brdcast_recvers)); @@ -353,9 +351,9 @@ static int packet_init( void ) { } static int packet_deinit( void ) { - struct raw_interface * iface; + struct raw_interface * iface, * tmp; - list_for_each_entry(iface, &(packet_state.open_interfaces), node) { + list_for_each_entry_safe(iface, tmp, &(packet_state.open_interfaces), node) { deinit_raw_interface(iface); kfree(iface); }