PERFORCE change 187531 for review

Edward Tomasz Napierala trasz at FreeBSD.org
Thu Jan 6 11:12:38 UTC 2011


http://p4web.freebsd.org/@@187531?ac=10

Change 187531 by trasz at trasz_victim on 2011/01/06 11:11:48

	Untangle xxx_container_foreach() from HRL, fixing layering violation.

Affected files ...

.. //depot/projects/soc2009/trasz_limits/sys/kern/kern_hrl.c#104 edit
.. //depot/projects/soc2009/trasz_limits/sys/kern/kern_jail.c#29 edit
.. //depot/projects/soc2009/trasz_limits/sys/kern/kern_loginclass.c#24 edit
.. //depot/projects/soc2009/trasz_limits/sys/kern/kern_resource.c#57 edit
.. //depot/projects/soc2009/trasz_limits/sys/sys/hrl.h#50 edit
.. //depot/projects/soc2009/trasz_limits/sys/sys/jail.h#17 edit
.. //depot/projects/soc2009/trasz_limits/sys/sys/loginclass.h#10 edit
.. //depot/projects/soc2009/trasz_limits/sys/sys/resourcevar.h#22 edit

Differences ...

==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_hrl.c#104 (text+ko) ====

@@ -922,8 +922,9 @@
 }
 
 static int
-hrl_rule_remove_callback(struct container *container, const struct hrl_rule *filter, void *arg3)
+hrl_rule_remove_callback(struct container *container, void *arg2, void *arg3)
 {
+	struct hrl_rule *filter = (struct hrl_rule *)arg2;
 	int found = 0;
 
 	mtx_lock(&hrl_lock);
@@ -939,7 +940,7 @@
  * Remove all rules that match the filter.
  */
 int
-hrl_rule_remove(const struct hrl_rule *filter)
+hrl_rule_remove(struct hrl_rule *filter)
 {
 	int error, found = 0;
 	struct proc *p;
@@ -1158,9 +1159,9 @@
 }
 
 static int
-hrl_get_rules_callback(struct container *container,
-    const struct hrl_rule *filter, void *arg3)
+hrl_get_rules_callback(struct container *container, void *arg2, void *arg3)
 {
+	struct hrl_rule *filter = (struct hrl_rule *)arg2;
 	struct hrl_rule_link *link;
 	struct sbuf *sb = (struct sbuf *)arg3;
 

==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_jail.c#29 (text+ko) ====

@@ -4252,11 +4252,9 @@
 SYSCTL_JAIL_PARAM(_allow, socket_af, CTLTYPE_INT | CTLFLAG_RW,
     "B", "Jail may create sockets other than just UNIX/IPv4/IPv6/route");
 
-#ifdef HRL
 int
 prison_container_foreach(int (*callback)(struct container *container,
-    const struct hrl_rule *filter, void *arg3),
-    const struct hrl_rule *filter, void *arg3)
+    void *arg2, void *arg3), void *arg2, void *arg3)
 {
 	int again;
 	struct prison *pr;
@@ -4264,7 +4262,7 @@
 again:
 	sx_slock(&allprison_lock);
 	TAILQ_FOREACH(pr, &allprison, pr_list) {
-		again = (callback)(&pr->pr_container, filter, arg3);
+		again = (callback)(&pr->pr_container, arg2, arg3);
 		if (again != 0) {
 			sx_sunlock(&allprison_lock);
 			goto again;
@@ -4274,7 +4272,6 @@
 
 	return (0);
 }
-#endif
 
 #ifdef DDB
 

==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_loginclass.c#24 (text+ko) ====

@@ -211,11 +211,9 @@
 	return (0);
 }
 
-#ifdef HRL
 int
 loginclass_container_foreach(int (*callback)(struct container *container,
-    const struct hrl_rule *filter, void *arg3),
-    const struct hrl_rule *filter, void *arg3)
+    void *arg2, void *arg3), void *arg2, void *arg3)
 {
 	int again;
 	struct loginclass *lc;
@@ -229,7 +227,7 @@
 		 * recursion on loginclasses_lock.
 		 */
 		loginclass_acquire(lc);
-		again = (callback)(&lc->lc_container, filter, arg3);
+		again = (callback)(&lc->lc_container, arg2, arg3);
 		if (again != 0) {
 			mtx_unlock(&loginclasses_lock);
 			loginclass_release(lc);
@@ -241,7 +239,6 @@
 
 	return (0);
 }
-#endif
 
 static void
 lc_init(void)

==== //depot/projects/soc2009/trasz_limits/sys/kern/kern_resource.c#57 (text+ko) ====

@@ -1293,11 +1293,9 @@
 	rw_wunlock(&uihashtbl_lock);
 }
 
-#ifdef HRL
 int
 ui_container_foreach(int (*callback)(struct container *container,
-    const struct hrl_rule *filter, void *arg3),
-    const struct hrl_rule *filter, void *arg3)
+    void *arg2, void *arg3), void *arg2, void *arg3)
 {
 	int again;
 	struct uidinfo *uip;
@@ -1313,7 +1311,7 @@
 			 * on uihashtbl_lock.
 			 */
 			uihold(uip);
-			again = (callback)(&uip->ui_container, filter, arg3);
+			again = (callback)(&uip->ui_container, arg2, arg3);
 			if (again != 0) {
 				rw_runlock(&uihashtbl_lock);
 				uifree(uip);
@@ -1326,7 +1324,6 @@
 
 	return (0);
 }
-#endif
 
 /*
  * Change the count associated with number of processes

==== //depot/projects/soc2009/trasz_limits/sys/sys/hrl.h#50 (text+ko) ====

@@ -114,7 +114,7 @@
 void	hrl_rule_acquire(struct hrl_rule *rule);
 void	hrl_rule_release(struct hrl_rule *rule);
 int	hrl_rule_add(struct hrl_rule *rule);
-int	hrl_rule_remove(const struct hrl_rule *filter);
+int	hrl_rule_remove(struct hrl_rule *filter);
 
 int	hrl_enforce_proc(struct proc *p, int resource, uint64_t amount);
 uint64_t	hrl_available_proc(struct proc *p, int resource);

==== //depot/projects/soc2009/trasz_limits/sys/sys/jail.h#17 (text+ko) ====

@@ -386,8 +386,7 @@
 int prison_priv_check(struct ucred *cred, int priv);
 int sysctl_jail_param(struct sysctl_oid *, void *, int , struct sysctl_req *);
 int prison_container_foreach(int (*callback)(struct container *container,
-	    const struct hrl_rule *filter, void *arg3),
-	    const struct hrl_rule *filter, void *arg3);
+    void *arg2, void *arg3), void *arg2, void *arg3);
 
 #endif /* _KERNEL */
 #endif /* !_SYS_JAIL_H_ */

==== //depot/projects/soc2009/trasz_limits/sys/sys/loginclass.h#10 (text+ko) ====

@@ -44,9 +44,8 @@
 void	loginclass_acquire(struct loginclass *lc);
 void	loginclass_release(struct loginclass *lc);
 struct loginclass	*loginclass_find(const char *name);
-int	loginclass_container_foreach(int (*callback)(struct container *container,
-	    const struct hrl_rule *filter, void *arg3),
-	    const struct hrl_rule *filter, void *arg3);
+int	loginclass_container_foreach(int (*callback)(struct container
+	    *container, void *arg2, void *arg3), void *arg2, void *arg3);
 
 #endif /* !_SYS_LOGINCLASS_H_ */
 

==== //depot/projects/soc2009/trasz_limits/sys/sys/resourcevar.h#22 (text+ko) ====

@@ -144,8 +144,7 @@
 void	 uihashinit(void);
 void	 uihold(struct uidinfo *uip);
 int	 ui_container_foreach(int (*callback)(struct container *container,
-	    const struct hrl_rule *filter, void *arg3),
-	    const struct hrl_rule *filter, void *arg3);
+	    void *arg2, void *arg3), void *arg2, void *arg3);
 
 #endif /* _KERNEL */
 #endif /* !_SYS_RESOURCEVAR_H_ */


More information about the p4-projects mailing list