Hi,
The large and nested GIF #ifdefs in protosw make it hard to figure
out what is going on. There are also some inconsistencies
that seem to be oversights.
So I would like to make the #ifdef more specific.
This has been changed:
- In the GIF case, IPPROTO_IPV6 in inetsw got a rip_ctloutput.
- In the non GIF case, IPPROTO_IPV6 in inet6sw lost ipip_sysctl.
ok?
bluhm
Index: netinet/in_proto.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/in_proto.c,v
retrieving revision 1.77
diff -u -p -r1.77 in_proto.c
--- netinet/in_proto.c 9 May 2017 13:33:50 -0000 1.77
+++ netinet/in_proto.c 16 May 2017 17:13:50 -0000
@@ -231,78 +231,62 @@ struct protosw inetsw[] = {
.pr_init = icmp_init,
.pr_sysctl = icmp_sysctl
},
-#if NGIF > 0
{
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_IPV4,
.pr_flags = PR_ATOMIC|PR_ADDR,
+#if NGIF > 0
.pr_input = in_gif_input,
+#else
+ .pr_input = ip4_input,
+#endif
.pr_ctloutput = rip_ctloutput,
.pr_usrreq = rip_usrreq,
.pr_attach = rip_attach,
.pr_sysctl = ipip_sysctl,
.pr_init = ipip_init
},
-{
- .pr_type = SOCK_RAW,
- .pr_domain = &inetdomain,
- .pr_protocol = IPPROTO_ETHERIP,
- .pr_flags = PR_ATOMIC|PR_ADDR,
- .pr_input = etherip_input,
- .pr_ctloutput = rip_ctloutput,
- .pr_usrreq = rip_usrreq,
- .pr_attach = rip_attach,
- .pr_sysctl = etherip_sysctl
-},
#ifdef INET6
{
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
.pr_protocol = IPPROTO_IPV6,
.pr_flags = PR_ATOMIC|PR_ADDR,
+#if NGIF > 0
.pr_input = in_gif_input,
+#else
+ .pr_input = ip4_input,
+#endif
+ .pr_ctloutput = rip_ctloutput,
.pr_usrreq = rip_usrreq, /* XXX */
.pr_attach = rip_attach
},
#endif
-#ifdef MPLS
+#if NGIF > 0
{
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
- .pr_protocol = IPPROTO_MPLS,
+ .pr_protocol = IPPROTO_ETHERIP,
.pr_flags = PR_ATOMIC|PR_ADDR,
.pr_input = etherip_input,
- .pr_usrreq = rip_usrreq,
- .pr_attach = rip_attach
-},
-#endif
-#else /* NGIF */
-{
- .pr_type = SOCK_RAW,
- .pr_domain = &inetdomain,
- .pr_protocol = IPPROTO_IPIP,
- .pr_flags = PR_ATOMIC|PR_ADDR,
- .pr_input = ip4_input,
.pr_ctloutput = rip_ctloutput,
.pr_usrreq = rip_usrreq,
.pr_attach = rip_attach,
- .pr_sysctl = ipip_sysctl,
- .pr_init = ipip_init
+ .pr_sysctl = etherip_sysctl
},
-#ifdef INET6
+#endif /* NGIF */
+#if defined(MPLS) && NGIF > 0
{
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
- .pr_protocol = IPPROTO_IPV6,
+ .pr_protocol = IPPROTO_MPLS,
.pr_flags = PR_ATOMIC|PR_ADDR,
- .pr_input = ip4_input,
- .pr_ctloutput = rip_ctloutput,
- .pr_usrreq = rip_usrreq, /* XXX */
+ .pr_input = etherip_input,
+ .pr_usrreq = rip_usrreq,
.pr_attach = rip_attach
},
-#endif
-#endif /*NGIF*/
+#endif /* MPLS && GIF */
{
.pr_type = SOCK_RAW,
.pr_domain = &inetdomain,
Index: netinet6/in6_proto.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet6/in6_proto.c,v
retrieving revision 1.92
diff -u -p -r1.92 in6_proto.c
--- netinet6/in6_proto.c 9 May 2017 13:33:50 -0000 1.92
+++ netinet6/in6_proto.c 16 May 2017 21:59:21 -0000
@@ -236,61 +236,47 @@ struct protosw inet6sw[] = {
.pr_sysctl = ipcomp_sysctl
},
#endif /* IPSEC */
-#if NGIF > 0
-{
- .pr_type = SOCK_RAW,
- .pr_domain = &inet6domain,
- .pr_protocol = IPPROTO_ETHERIP,
- .pr_flags = PR_ATOMIC|PR_ADDR,
- .pr_input = etherip_input,
- .pr_ctloutput = rip6_ctloutput,
- .pr_usrreq = rip6_usrreq,
- .pr_attach = rip6_attach,
- .pr_sysctl = etherip_sysctl
-},
-{
- .pr_type = SOCK_RAW,
- .pr_domain = &inet6domain,
- .pr_protocol = IPPROTO_IPV6,
- .pr_flags = PR_ATOMIC|PR_ADDR,
- .pr_input = in6_gif_input,
- .pr_ctloutput = rip6_ctloutput,
- .pr_usrreq = rip6_usrreq, /* XXX */
- .pr_attach = rip6_attach
-},
{
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_IPV4,
.pr_flags = PR_ATOMIC|PR_ADDR,
+#if NGIF > 0
.pr_input = in6_gif_input,
+#else
+ .pr_input = ip4_input,
+#endif
.pr_ctloutput = rip6_ctloutput,
.pr_usrreq = rip6_usrreq, /* XXX */
.pr_attach = rip6_attach
},
-#else /* NGIF */
{
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
.pr_protocol = IPPROTO_IPV6,
.pr_flags = PR_ATOMIC|PR_ADDR,
+#if NGIF > 0
+ .pr_input = in6_gif_input,
+#else
.pr_input = ip4_input,
+#endif
.pr_ctloutput = rip6_ctloutput,
.pr_usrreq = rip6_usrreq, /* XXX */
.pr_attach = rip6_attach,
- .pr_sysctl = ipip_sysctl
},
+#if NGIF > 0
{
.pr_type = SOCK_RAW,
.pr_domain = &inet6domain,
- .pr_protocol = IPPROTO_IPV4,
+ .pr_protocol = IPPROTO_ETHERIP,
.pr_flags = PR_ATOMIC|PR_ADDR,
- .pr_input = ip4_input,
+ .pr_input = etherip_input,
.pr_ctloutput = rip6_ctloutput,
- .pr_usrreq = rip6_usrreq, /* XXX */
- .pr_attach = rip6_attach
+ .pr_usrreq = rip6_usrreq,
+ .pr_attach = rip6_attach,
+ .pr_sysctl = etherip_sysctl
},
-#endif /* GIF */
+#endif /* NGIF */
#if NCARP > 0
{
.pr_type = SOCK_RAW,