Discussion:
missing "struct socket;" in netinet/ip_var.h prevents compiling kernel without MROUTING option
Nick Briggs
2017-07-14 01:38:19 UTC
Permalink
Synopsis: missing "struct socket;" in netinet/ip_var.h prevents compiling without MROUTING option
Category: system
System : OpenBSD 6.1
Details : OpenBSD 6.1-stable (PIGEON) #5: Thu Jul 13 17:09:51 PDT 2017
***@pigeon:/usr/obj/sys/arch/i386/compile/PIGEON

Architecture: OpenBSD.i386
Machine : i386
If the MROUTING option is not included in the kernel configuration, code such as ./sys/net/pfkeyv2_parsemessage.c does not compile, failing with:

cc1: warnings being treated as errors
In file included from /usr/src/sys/net/pfkeyv2_parsemessage.c:79:
/usr/src/sys/netinet/ip_var.h:223: warning: 'struct socket' declared inside parameter list
/usr/src/sys/netinet/ip_var.h:223: warning: its scope is only this definition or declaration, which is probably not what you want
/usr/src/sys/netinet/ip_var.h:254: warning: 'struct socket' declared inside parameter list
/usr/src/sys/netinet/ip_var.h:258: warning: 'struct socket' declared inside parameter list
/usr/src/sys/netinet/ip_var.h:260: warning: 'struct socket' declared inside parameter list
/usr/src/sys/netinet/ip_var.h:261: warning: 'struct socket' declared inside parameter list

because netinet/ip_var.h, which it includes, depends on
#ifdef MROUTING
extern struct socket *ip_mrouter[]; /* multicast routing daemon */
#endif
to get a declaration of struct socket outside of any parameter lists.

This was also reported 25-Jun-2014 by Ivan Solonin on the OpenBSD-misc list, but there was no follow-up or fix.
remove option MROUTING from kernel configuration, rebuild the kernel.
One possibility:

cvs server: Diffing sys/netinet
Index: sys/netinet/ip_var.h
===================================================================
RCS file: /cvs/src/sys/netinet/ip_var.h,v
retrieving revision 1.70
diff -u -p -r1.70 ip_var.h
--- sys/netinet/ip_var.h 13 Mar 2017 20:18:21 -0000 1.70
+++ sys/netinet/ip_var.h 14 Jul 2017 01:11:48 -0000
@@ -216,6 +216,7 @@ extern int la_hold_total;

extern struct rttimer_queue *ip_mtudisc_timeout_q;
extern struct pool ipqent_pool;
+struct socket;
struct route;
struct inpcb;
Ted Unangst
2017-07-14 02:37:24 UTC
Permalink
Post by Nick Briggs
because netinet/ip_var.h, which it includes, depends on
#ifdef MROUTING
extern struct socket *ip_mrouter[]; /* multicast routing daemon */
#endif
to get a declaration of struct socket outside of any parameter lists.
I think this is a better fix. Two parts.

1. pfkeyv2_parsemessage.c doesn't even need this header. remove it.

2. to prevent this from happening again, move the forward declaration in
ip_var.h to the end, so that it will fail regardless of compile options. i
think this is better than deliberately exporting another type here.

tested with and without MROUTING set.

Index: net/pfkeyv2_parsemessage.c
===================================================================
RCS file: /cvs/src/sys/net/pfkeyv2_parsemessage.c,v
retrieving revision 1.52
diff -u -p -r1.52 pfkeyv2_parsemessage.c
--- net/pfkeyv2_parsemessage.c 26 Jun 2017 09:17:55 -0000 1.52
+++ net/pfkeyv2_parsemessage.c 14 Jul 2017 02:35:13 -0000
@@ -76,7 +76,6 @@
#include <sys/mbuf.h>
#include <sys/proc.h>
#include <netinet/ip_ipsp.h>
-#include <netinet/ip_var.h>
#include <net/pfkeyv2.h>

#if NPF > 0
Index: netinet/ip_var.h
===================================================================
RCS file: /cvs/src/sys/netinet/ip_var.h,v
retrieving revision 1.79
diff -u -p -r1.79 ip_var.h
--- netinet/ip_var.h 26 Jun 2017 19:06:12 -0000 1.79
+++ netinet/ip_var.h 14 Jul 2017 02:34:17 -0000
@@ -193,9 +193,6 @@ struct ipq {
extern struct ipstat ipstat;
extern LIST_HEAD(ipqhead, ipq) ipq; /* ip reass. queue */
extern int ip_defttl; /* default IP ttl */
-#ifdef MROUTING
-extern struct socket *ip_mrouter[]; /* multicast routing daemon */
-#endif

#define IPMTUDISCTIMEOUT (10 * 60) /* as per RFC 1191 */

@@ -259,6 +256,10 @@ int rip_output(struct mbuf *, struct so
int rip_usrreq(struct socket *,
int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
int rip_attach(struct socket *, int);
+
+#ifdef MROUTING
+extern struct socket *ip_mrouter[]; /* multicast routing daemon */
+#endif

#endif /* _KERNEL */
#endif /* _NETINET_IP_VAR_H_ */
Nick Briggs
2017-07-14 03:27:37 UTC
Permalink
I'm good with that.
Post by Ted Unangst
Post by Nick Briggs
because netinet/ip_var.h, which it includes, depends on
#ifdef MROUTING
extern struct socket *ip_mrouter[]; /* multicast routing daemon */
#endif
to get a declaration of struct socket outside of any parameter lists.
I think this is a better fix. Two parts.
1. pfkeyv2_parsemessage.c doesn't even need this header. remove it.
2. to prevent this from happening again, move the forward declaration in
ip_var.h to the end, so that it will fail regardless of compile options. i
think this is better than deliberately exporting another type here.
tested with and without MROUTING set.
Index: net/pfkeyv2_parsemessage.c
===================================================================
RCS file: /cvs/src/sys/net/pfkeyv2_parsemessage.c,v
retrieving revision 1.52
diff -u -p -r1.52 pfkeyv2_parsemessage.c
--- net/pfkeyv2_parsemessage.c 26 Jun 2017 09:17:55 -0000 1.52
+++ net/pfkeyv2_parsemessage.c 14 Jul 2017 02:35:13 -0000
@@ -76,7 +76,6 @@
#include <sys/mbuf.h>
#include <sys/proc.h>
#include <netinet/ip_ipsp.h>
-#include <netinet/ip_var.h>
#include <net/pfkeyv2.h>
#if NPF > 0
Index: netinet/ip_var.h
===================================================================
RCS file: /cvs/src/sys/netinet/ip_var.h,v
retrieving revision 1.79
diff -u -p -r1.79 ip_var.h
--- netinet/ip_var.h 26 Jun 2017 19:06:12 -0000 1.79
+++ netinet/ip_var.h 14 Jul 2017 02:34:17 -0000
@@ -193,9 +193,6 @@ struct ipq {
extern struct ipstat ipstat;
extern LIST_HEAD(ipqhead, ipq) ipq; /* ip reass. queue */
extern int ip_defttl; /* default IP ttl */
-#ifdef MROUTING
-extern struct socket *ip_mrouter[]; /* multicast routing daemon */
-#endif
#define IPMTUDISCTIMEOUT (10 * 60) /* as per RFC 1191 */
@@ -259,6 +256,10 @@ int rip_output(struct mbuf *, struct so
int rip_usrreq(struct socket *,
int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *);
int rip_attach(struct socket *, int);
+
+#ifdef MROUTING
+extern struct socket *ip_mrouter[]; /* multicast routing daemon */
+#endif
#endif /* _KERNEL */
#endif /* _NETINET_IP_VAR_H_ */
Loading...