From owner-p4-projects@FreeBSD.ORG Tue Aug 5 01:42:36 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2A06E106567B; Tue, 5 Aug 2008 01:42:36 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E21171065675 for ; Tue, 5 Aug 2008 01:42:35 +0000 (UTC) (envelope-from diego@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id D01978FC13 for ; Tue, 5 Aug 2008 01:42:35 +0000 (UTC) (envelope-from diego@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m751gZa0098068 for ; Tue, 5 Aug 2008 01:42:35 GMT (envelope-from diego@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m751gZiP098066 for perforce@freebsd.org; Tue, 5 Aug 2008 01:42:35 GMT (envelope-from diego@FreeBSD.org) Date: Tue, 5 Aug 2008 01:42:35 GMT Message-Id: <200808050142.m751gZiP098066@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to diego@FreeBSD.org using -f From: Diego Giagio To: Perforce Change Reviews Cc: Subject: PERFORCE change 146676 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Aug 2008 01:42:36 -0000 http://perforce.freebsd.org/chv.cgi?CH=146676 Change 146676 by diego@diego_black on 2008/08/05 01:41:38 Improve preallocation of audit records. Affected files ... .. //depot/projects/soc2008/diego-audit/src/sys/security/audit/audit.c#6 edit .. //depot/projects/soc2008/diego-audit/src/sys/security/audit/audit.h#14 edit Differences ... ==== //depot/projects/soc2008/diego-audit/src/sys/security/audit/audit.c#6 (text) ==== @@ -483,25 +483,25 @@ mtx_unlock(&audit_mtx); } +/* + * Check if there's already a record being constructed. If true, save it + * into thread's record queue. + */ static void audit_enter(struct thread *td) { - /* - * Check if there's already a record being constructed. If true, move - * it temporarily into our record queue. currecord() will now point to - * the new record. - */ if (td->td_ar != NULL) TAILQ_INSERT_TAIL(td->td_arq, td->td_ar, k_q); + td->td_ar = NULL; } +/* + * Check if there were a previous record being constructed. If true, make it + * the current record and remove it from thread's record queue. + */ static void audit_exit(struct thread *td) { - /* - * If there were a previous record begin constructed, return it to - * currecord() and remove it from record queue. - */ td->td_ar = TAILQ_LAST(td->td_arq, kaudit_queue); if (td->td_ar != NULL) TAILQ_REMOVE(td->td_arq, td->td_ar, k_q); @@ -516,6 +516,7 @@ void audit_syscall_enter(unsigned short code, struct thread *td) { + struct kaudit_record *ar; au_event_t event; /* @@ -533,8 +534,16 @@ if (event == AUE_NULL) return; - audit_enter(td); - td->td_ar = audit_begin(event, td); + ar = audit_begin(event, td); + if (ar != NULL) { + /* + * Save the current record into thread's record queue and + * create a new record. + */ + + audit_enter(td); + td->td_ar = ar; + } } /* @@ -559,6 +568,45 @@ else retval = td->td_retval[0]; + /* + * Commit the current record. Turn the previous saved record into the + * current one. + */ + audit_commit(td->td_ar, error, retval); + audit_exit(td); +} + +void +audit_pfil_enter(unsigned short event, struct thread *td) +{ + struct kaudit_record *ar; + + ar = audit_begin(event, td); + if (ar != NULL) { + /* + * Save the current record into thread's record queue and + * create a new record. + */ + + audit_enter(td); + td->td_ar = ar; + } +} + +void +audit_pfil_exit(int error, struct thread *td) +{ + int retval; + + if (error) + retval = -1; + else + retval = 0; + + /* + * Commit the current record. Turn the previous saved record into the + * current one. + */ audit_commit(td->td_ar, error, retval); audit_exit(td); } ==== //depot/projects/soc2008/diego-audit/src/sys/security/audit/audit.h#14 (text) ==== @@ -127,6 +127,9 @@ /* * Functions for auditing packet filter events. */ +void audit_pfil_enter(unsigned short event, struct thread *td); +void audit_pfil_exit(int error, struct thread *td); + void audit_ipfw_enable(int error); void audit_ipfw_disable(int error); void audit_ipfw_addrule(int set, int rulenum, int error);