Subject: bin/26012: pfctl doesn't compile
To: None <gnats-bugs@gnats.NetBSD.org>
From: Peter Postma <peter@pointless.nl>
List: netbsd-bugs
Date: 06/22/2004 19:25:32
>Number:         26012
>Category:       bin
>Synopsis:       pfctl doesn't compile
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 22 17:26:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Peter Postma
>Release:        NetBSD 2.0F
>Organization:
>Environment:
System: NetBSD mercury.pointless.nl 2.0F NetBSD 2.0F (mercury) #2: Tue Jun 22 18:43:56 CEST 2004 peter@mercury.pointless.nl:/usr/obj/sys/arch/sparc64/compile/mercury sparc64
Architecture: sparc64
Machine: sparc64
>Description:
After adding "-I${NETBSDSRCDIR}/sys/dist/pf" to CFLAGS, the following
errors are left:

/usr/src/dist/pf/sbin/pfctl/parse.y: In function `yyparse':
/usr/src/dist/pf/sbin/pfctl/parse.y:1291: error: `CBQCLF_BORROW' undeclared (first use in this function)
/usr/src/dist/pf/sbin/pfctl/parse.y:1291: error: (Each undeclared identifier is reported only once
/usr/src/dist/pf/sbin/pfctl/parse.y:1291: error: for each function it appears in.)


/usr/src/dist/pf/sbin/pfctl/pfctl_parser.c: In function `print_status':
/usr/src/dist/pf/sbin/pfctl/pfctl_parser.c:596: warning: long long int format, long unsigned int arg (arg 3)


/usr/src/dist/pf/sbin/pfctl/pfctl_altq.c: In function `print_cbq_opts':
/usr/src/dist/pf/sbin/pfctl/pfctl_altq.c:563: error: `CBQCLF_BORROW' undeclared (first use in this function)
/usr/src/dist/pf/sbin/pfctl/pfctl_altq.c:563: error: (Each undeclared identifier is reported only once
/usr/src/dist/pf/sbin/pfctl/pfctl_altq.c:563: error: for each function it appears in.)


/usr/src/dist/pf/sbin/pfctl/pfctl_qstats.c:45: error: field `priq_stats' has incomplete type
/usr/src/dist/pf/sbin/pfctl/pfctl_qstats.c:46: error: field `hfsc_stats' has incomplete type

>How-To-Repeat:
>Fix:
The following diff fixes the build for me, but the changes are quite
aggressive (i ripped out a part from altq).

Index: parse.y
===================================================================
RCS file: /cvsroot/src/dist/pf/sbin/pfctl/parse.y,v
retrieving revision 1.2
diff -u -r1.2 parse.y
--- parse.y	22 Jun 2004 15:16:30 -0000	1.2
+++ parse.y	22 Jun 2004 17:23:09 -0000
@@ -1287,8 +1287,8 @@
 cbqflags_item	: STRING	{
 			if (!strcmp($1, "default"))
 				$$ = CBQCLF_DEFCLASS;
-			else if (!strcmp($1, "borrow"))
-				$$ = CBQCLF_BORROW;
+//			else if (!strcmp($1, "borrow"))
+//				$$ = CBQCLF_BORROW;
 			else if (!strcmp($1, "red"))
 				$$ = CBQCLF_RED;
 			else if (!strcmp($1, "ecn"))
Index: pfctl.c
===================================================================
RCS file: /cvsroot/src/dist/pf/sbin/pfctl/pfctl.c,v
retrieving revision 1.2
diff -u -r1.2 pfctl.c
--- pfctl.c	22 Jun 2004 15:16:30 -0000	1.2
+++ pfctl.c	22 Jun 2004 17:23:10 -0000
@@ -1372,6 +1372,7 @@
 int
 pfctl_test_altqsupport(int dev, int opts)
 {
+#ifdef __OpenBSD__
 	struct pfioc_altq pa;
 
 	if (ioctl(dev, DIOCGETALTQS, &pa)) {
@@ -1384,6 +1385,9 @@
 			err(1, "DIOCGETALTQS");
 	}
 	return (1);
+#else
+	return (0);
+#endif
 }
 
 int
@@ -1655,8 +1659,10 @@
 			pfctl_show_nat(dev, opts, anchorname, rulesetname);
 			break;
 		case 'q':
+#ifdef __OpenBSD__
 			pfctl_show_altq(dev, ifaceopt, opts,
 			    opts & PF_OPT_VERBOSE2);
+#endif
 			break;
 		case 's':
 			pfctl_show_states(dev, ifaceopt, opts);
@@ -1680,7 +1686,9 @@
 			pfctl_show_nat(dev, opts, anchorname, rulesetname);
 			pfctl_show_rules(dev, opts, 0, anchorname,
 			    rulesetname);
+#ifdef __OpenBSD__
 			pfctl_show_altq(dev, ifaceopt, opts, 0);
+#endif
 			pfctl_show_states(dev, ifaceopt, opts);
 			pfctl_show_src_nodes(dev, opts);
 			pfctl_show_status(dev, opts);
Index: pfctl_altq.c
===================================================================
RCS file: /cvsroot/src/dist/pf/sbin/pfctl/pfctl_altq.c,v
retrieving revision 1.2
diff -u -r1.2 pfctl_altq.c
--- pfctl_altq.c	22 Jun 2004 15:16:30 -0000	1.2
+++ pfctl_altq.c	22 Jun 2004 17:23:11 -0000
@@ -560,8 +560,10 @@
 			printf(" cleardscp");
 		if (opts->flags & CBQCLF_FLOWVALVE)
 			printf(" flowvalve");
+#if 0
 		if (opts->flags & CBQCLF_BORROW)
 			printf(" borrow");
+#endif
 		if (opts->flags & CBQCLF_WRR)
 			printf(" wrr");
 		if (opts->flags & CBQCLF_EFFICIENT)
Index: pfctl_parser.c
===================================================================
RCS file: /cvsroot/src/dist/pf/sbin/pfctl/pfctl_parser.c,v
retrieving revision 1.2
diff -u -r1.2 pfctl_parser.c
--- pfctl_parser.c	22 Jun 2004 15:16:30 -0000	1.2
+++ pfctl_parser.c	22 Jun 2004 17:23:12 -0000
@@ -593,7 +593,7 @@
 		    s->src_nodes, "");
 		for (i = 0; i < SCNT_MAX; i++) {
 			printf("  %-25s %14lld ", pf_scounters[i],
-				    s->scounters[i]);
+				    (unsigned long long)s->scounters[i]);
 			if (runtime > 0)
 				printf("%14.1f/s\n",
 				    (double)s->scounters[i] / (double)runtime);
Index: Makefile
===================================================================
RCS file: /cvsroot/src/sbin/pfctl/Makefile,v
retrieving revision 1.1
diff -u -r1.1 Makefile
--- Makefile	22 Jun 2004 15:16:30 -0000	1.1
+++ Makefile	22 Jun 2004 17:23:24 -0000
@@ -3,8 +3,8 @@
 
 PROG=	pfctl
 SRCS=	pfctl.c parse.y pfctl_parser.c pf_print_state.c pfctl_altq.c
-SRCS+=	pfctl_osfp.c pfctl_radix.c pfctl_table.c pfctl_qstats.c
-CPPFLAGS+=-I${NETBSDSRCDIR}/dist/pf/sbin/pfctl
+SRCS+=	pfctl_osfp.c pfctl_radix.c pfctl_table.c
+CPPFLAGS+=-I${NETBSDSRCDIR}/dist/pf/sbin/pfctl -I${NETBSDSRCDIR}/sys/dist/pf
 YFLAGS=
 MAN=	pfctl.8
 
>Release-Note:
>Audit-Trail:
>Unformatted: