Skip to contentSkip to conversation

VIF rules not purged on domain exit

DISCUSSION Jacob Gorm Hansen 1 participant 2 messages Mar 11, 2004

lore
Share & tools
lore
#0 lore raw

hi,

I noticed that apparently networking rules are not purged from the rules list when a domain exists, and newly added rules to not replace existing ones. Is this on purpose?

Jacob

-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click

#1 lore raw
Quoted 5 lines · Jacob Gorm Hansen

hi,

I noticed that apparently networking rules are not purged from the rules list when a domain exists, and newly added rules to not replace existing ones. Is this on purpose?

I've attached a trivial fix in case anyone is interested.

Jacob

xen/common/domain.c +2 -0
@@ -128,6 +128,7 @@
 void __kill_domain(struct task_struct *p)
 {
     extern void destroy_event_channels(struct task_struct *);
+    extern void delete_all_domain_rules(domid_t);
 
     int i;
     struct task_struct **pp;
@@ -152,6 +153,7 @@
         unlink_net_vif(p->net_vif_list[i]);
 
     destroy_event_channels(p);
+    delete_all_domain_rules(p->domain);
 
     /*
      * Note this means that find_domain_by_id may fail, even when the caller
xen/common/network.c +22 -0
@@ -312,6 +312,28 @@
     write_unlock(&net_rule_lock);
     return 0;
 }
+
+void delete_all_domain_rules(domid_t dom_id)
+{
+    net_rule_ent_t **pent, *ent;
+
+    write_lock(&net_rule_lock);
+
+    for ( pent = &net_rule_list; pent != NULL && (ent=*pent); )
+    {
+
+        if ( ent->r.src_dom==dom_id || ent->r.dst_dom==dom_id )
+        {
+            *pent = ent->next;
+            kmem_cache_free(net_rule_cache, ent);
+            continue;
+        }
+
+        pent = &ent->next;
+    }
+    write_unlock(&net_rule_lock);
+}
+ 
  
 static char *idx_to_name(unsigned int idx)
 {