From owner-svn-src-all@FreeBSD.ORG Wed Mar 5 00:40:04 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7BB2A50F; Wed, 5 Mar 2014 00:40:04 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 683A9284; Wed, 5 Mar 2014 00:40:04 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s250e4Br098462; Wed, 5 Mar 2014 00:40:04 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s250e32v098454; Wed, 5 Mar 2014 00:40:03 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201403050040.s250e32v098454@svn.freebsd.org> From: Gleb Smirnoff Date: Wed, 5 Mar 2014 00:40:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262760 - in head: sbin/pfctl sys/net sys/netpfil/pf X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Mar 2014 00:40:04 -0000 Author: glebius Date: Wed Mar 5 00:40:03 2014 New Revision: 262760 URL: http://svnweb.freebsd.org/changeset/base/262760 Log: Instead of playing games with casts simply add 3 more members to the structure pf_rule, that are used when the structure is passed via ioctl(). PR: 187074 Modified: head/sbin/pfctl/pfctl.c head/sys/net/pfvar.h head/sys/netpfil/pf/pf_ioctl.c Modified: head/sbin/pfctl/pfctl.c ============================================================================== --- head/sbin/pfctl/pfctl.c Wed Mar 5 00:26:25 2014 (r262759) +++ head/sbin/pfctl/pfctl.c Wed Mar 5 00:40:03 2014 (r262760) @@ -50,7 +50,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -792,18 +791,17 @@ pfctl_print_rule_counters(struct pf_rule } if (opts & PF_OPT_VERBOSE) { printf(" [ Evaluations: %-8llu Packets: %-8llu " - "Bytes: %-10llu States: %-6"PRIuPTR"]\n", + "Bytes: %-10llu States: %-6lu]\n", (unsigned long long)rule->evaluations, (unsigned long long)(rule->packets[0] + rule->packets[1]), (unsigned long long)(rule->bytes[0] + - rule->bytes[1]), - (uintptr_t)rule->states_cur); + rule->bytes[1]), rule->u_states_cur); if (!(opts & PF_OPT_DEBUG)) printf(" [ Inserted: uid %u pid %u " - "State Creations: %-6"PRIuPTR"]\n", + "State Creations: %-6lu]\n", (unsigned)rule->cuid, (unsigned)rule->cpid, - (uintptr_t)rule->states_tot); + rule->u_states_tot); } } @@ -905,7 +903,7 @@ pfctl_show_rules(int dev, char *path, in case PFCTL_SHOW_LABELS: if (pr.rule.label[0]) { printf("%s %llu %llu %llu %llu" - " %llu %llu %llu %"PRIuPTR"\n", + " %llu %llu %llu %llu\n", pr.rule.label, (unsigned long long)pr.rule.evaluations, (unsigned long long)(pr.rule.packets[0] + @@ -916,7 +914,7 @@ pfctl_show_rules(int dev, char *path, in (unsigned long long)pr.rule.bytes[0], (unsigned long long)pr.rule.packets[1], (unsigned long long)pr.rule.bytes[1], - (uintptr_t)pr.rule.states_tot); + (unsigned long long)pr.rule.u_states_tot); } break; case PFCTL_SHOW_RULES: Modified: head/sys/net/pfvar.h ============================================================================== --- head/sys/net/pfvar.h Wed Mar 5 00:26:25 2014 (r262759) +++ head/sys/net/pfvar.h Wed Mar 5 00:40:03 2014 (r262760) @@ -580,6 +580,10 @@ struct pf_rule { struct pf_addr addr; u_int16_t port; } divert; + + uint64_t u_states_cur; + uint64_t u_states_tot; + uint64_t u_src_nodes; }; /* rule flags */ Modified: head/sys/netpfil/pf/pf_ioctl.c ============================================================================== --- head/sys/netpfil/pf/pf_ioctl.c Wed Mar 5 00:26:25 2014 (r262759) +++ head/sys/netpfil/pf/pf_ioctl.c Wed Mar 5 00:40:03 2014 (r262760) @@ -1349,16 +1349,9 @@ DIOCADDRULE_error: break; } bcopy(rule, &pr->rule, sizeof(struct pf_rule)); - /* - * XXXGL: this is what happens when internal kernel - * structures are used as ioctl API structures. - */ - pr->rule.states_cur = - (counter_u64_t )counter_u64_fetch(rule->states_cur); - pr->rule.states_tot = - (counter_u64_t )counter_u64_fetch(rule->states_tot); - pr->rule.src_nodes = - (counter_u64_t )counter_u64_fetch(rule->src_nodes); + pr->rule.u_states_cur = counter_u64_fetch(rule->states_cur); + pr->rule.u_states_tot = counter_u64_fetch(rule->states_tot); + pr->rule.u_src_nodes = counter_u64_fetch(rule->src_nodes); if (pf_anchor_copyout(ruleset, rule, pr)) { PF_RULES_WUNLOCK(); error = EBUSY;