Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Mar 2014 00:40:03 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
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
Message-ID:  <201403050040.s250e32v098454@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <err.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <inttypes.h>
 #include <limits.h>
 #include <netdb.h>
 #include <stdio.h>
@@ -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;



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