Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Nov 2012 17:26:28 +0000 (UTC)
From:      Andre Oppermann <andre@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r243411 - user/andre/tcp_workqueue/sys/net
Message-ID:  <201211221726.qAMHQSpu031352@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andre
Date: Thu Nov 22 17:26:28 2012
New Revision: 243411
URL: http://svnweb.freebsd.org/changeset/base/243411

Log:
  Introduce typedef for pfil hook callback function and replace all
  spelled out occurrences with it.
  
  Do some style cleanup of the pfil lock function prototypes.

Modified:
  user/andre/tcp_workqueue/sys/net/pfil.c
  user/andre/tcp_workqueue/sys/net/pfil.h

Modified: user/andre/tcp_workqueue/sys/net/pfil.c
==============================================================================
--- user/andre/tcp_workqueue/sys/net/pfil.c	Thu Nov 22 17:00:34 2012	(r243410)
+++ user/andre/tcp_workqueue/sys/net/pfil.c	Thu Nov 22 17:26:28 2012	(r243411)
@@ -236,8 +236,7 @@ pfil_head_get(int type, u_long val)
  * The cookie is simply is a random value that should be unique.
  */
 int
-pfil_add_hook(int (*func)(void *, struct mbuf **, struct ifnet *, int,
-  struct inpcb *), void *arg, int flags, struct pfil_head *ph)
+pfil_add_hook(pfil_func_t func, void *arg, int flags, struct pfil_head *ph)
 {
 
 	return (pfil_add_hook_order(func, arg, "unknown", flags,
@@ -245,9 +244,8 @@ pfil_add_hook(int (*func)(void *, struct
 }
 
 int
-pfil_add_hook_order(int (*func)(void *, struct mbuf **, struct ifnet *, int,
-    struct inpcb *), void *arg, char *name, int flags, uint8_t order,
-    struct pfil_head *ph)
+pfil_add_hook_order(pfil_func_t func, void *arg, char *name, int flags,
+    uint8_t order, struct pfil_head *ph)
 {
 	struct packet_filter_hook *pfh1 = NULL;
 	struct packet_filter_hook *pfh2 = NULL;
@@ -312,8 +310,7 @@ error:
  * list.
  */
 int
-pfil_remove_hook(int (*func)(void *, struct mbuf **, struct ifnet *, int,
-    struct inpcb *), void *arg, int flags, struct pfil_head *ph)
+pfil_remove_hook(pfil_func_t func, void *arg, int flags, struct pfil_head *ph)
 {
 	int err = 0;
 
@@ -333,8 +330,7 @@ pfil_remove_hook(int (*func)(void *, str
 }
 
 int
-pfil_get_cookie(int (*func)(void *, struct mbuf **, struct ifnet *, int,
-    struct inpcb *), void *arg, int flags, struct pfil_head *ph)
+pfil_get_cookie(pfil_func_t func, void *arg, int flags, struct pfil_head *ph)
 {
 	pfil_list_t *list;
 	struct packet_filter_hook *pfh;
@@ -402,9 +398,7 @@ pfil_list_add(pfil_list_t *list, struct 
  * specified list.
  */
 static int
-pfil_list_remove(pfil_list_t *list,
-    int (*func)(void *, struct mbuf **, struct ifnet *, int, struct inpcb *),
-    void *arg)
+pfil_list_remove(pfil_list_t *list, pfil_func_t func, void *arg)
 {
 	struct packet_filter_hook *pfh;
 

Modified: user/andre/tcp_workqueue/sys/net/pfil.h
==============================================================================
--- user/andre/tcp_workqueue/sys/net/pfil.h	Thu Nov 22 17:00:34 2012	(r243410)
+++ user/andre/tcp_workqueue/sys/net/pfil.h	Thu Nov 22 17:26:28 2012	(r243411)
@@ -43,14 +43,16 @@ struct mbuf;
 struct ifnet;
 struct inpcb;
 
+typedef	int	(*pfil_func_t)(void *, struct mbuf **, struct ifnet *, int,
+		    struct inpcb *);
+
 /*
  * The packet filter hooks are designed for anything to call them to
  * possibly intercept the packet.
  */
 struct packet_filter_hook {
         TAILQ_ENTRY(packet_filter_hook) pfil_link;
-	int	(*pfil_func)(void *, struct mbuf **, struct ifnet *, int,
-		    struct inpcb *);
+	pfil_func_t	pfil_func;
 	void	*pfil_arg;
 	int	 pfil_cookie;
 	uint8_t	 pfil_order;
@@ -94,32 +96,29 @@ struct pfil_head {
 	LIST_ENTRY(pfil_head) ph_list;
 };
 
-int	pfil_add_hook(int (*func)(void *, struct mbuf **, struct ifnet *,
-	    int, struct inpcb *), void *, int, struct pfil_head *);
-int	pfil_add_hook_order(int (*func)(void *, struct mbuf **, struct ifnet *,
-	    int, struct inpcb *), void *, char *, int, uint8_t,
+int	pfil_add_hook(pfil_func_t, void *, int, struct pfil_head *);
+int	pfil_add_hook_order(pfil_func_t, void *, char *, int, uint8_t,
 	    struct pfil_head *);
-int	pfil_get_cookie(int (*func)(void *, struct mbuf **, struct ifnet *,
-	    int, struct inpcb *), void *, int, struct pfil_head *);
-int	pfil_remove_hook(int (*func)(void *, struct mbuf **, struct ifnet *,
-	    int, struct inpcb *), void *, int, struct pfil_head *);
+int	pfil_get_cookie(pfil_func_t, void *, int, struct pfil_head *);
+int	pfil_remove_hook(pfil_func_t, void *, int, struct pfil_head *);
+
 int	pfil_run_hooks(struct pfil_head *, struct mbuf **, struct ifnet *,
 	    int, struct inpcb *inp);
 int	pfil_run_inject(struct pfil_head *, struct mbuf **, struct ifnet *,
 	    int, struct inpcb *inp, int cookie);
 
 struct rm_priotracker;	/* Do not require including rmlock header */
-int pfil_try_rlock(struct pfil_head *, struct rm_priotracker *);
-void pfil_rlock(struct pfil_head *, struct rm_priotracker *);
-void pfil_runlock(struct pfil_head *, struct rm_priotracker *);
-void pfil_wlock(struct pfil_head *);
-void pfil_wunlock(struct pfil_head *);
-int pfil_wowned(struct pfil_head *ph);
+int	pfil_try_rlock(struct pfil_head *, struct rm_priotracker *);
+void	pfil_rlock(struct pfil_head *, struct rm_priotracker *);
+void	pfil_runlock(struct pfil_head *, struct rm_priotracker *);
+void	pfil_wlock(struct pfil_head *);
+void	pfil_wunlock(struct pfil_head *);
+int	pfil_wowned(struct pfil_head *ph);
 
 int	pfil_head_register(struct pfil_head *);
 int	pfil_head_unregister(struct pfil_head *);
 
-struct pfil_head *pfil_head_get(int, u_long);
+struct	pfil_head *pfil_head_get(int, u_long);
 
 #define	PFIL_HOOKED(p) ((p)->ph_nhooks > 0)
 #define	PFIL_LOCK_INIT_REAL(l, t)	\



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201211221726.qAMHQSpu031352>