From 7978e1956d603ac3211d1b7ad4df1a7969dfde5a Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Thu, 23 May 2019 17:17:57 +0200
Subject: [PATCH] kernel/netmap: Move headers into <net/netmap/...>.

Note that netmap isn't hooked into the build right now.

We do it like this pretty much everywhere else and it actually helps
dports which (like net/libpcap) would otherwise find our old
<net/netmap_user.h> and think our netmap is usable or current.

Better to selectively fix dports if netmap ever was hooked in.

Reported-by: zrj
---
 Makefile_upgrade.inc               | 2 ++
 etc/mtree/BSD.include.dist         | 2 ++
 include/Makefile                   | 2 +-
 share/man/man4/netmap.4            | 8 ++++----
 sys/net/netmap/netmap.c            | 2 +-
 sys/net/{ => netmap}/netmap.h      | 0
 sys/net/netmap/netmap_freebsd.c    | 2 +-
 sys/net/netmap/netmap_generic.c    | 2 +-
 sys/net/netmap/netmap_mem2.c       | 2 +-
 sys/net/{ => netmap}/netmap_user.h | 2 +-
 sys/net/netmap/netmap_vale.c       | 2 +-
 11 files changed, 15 insertions(+), 11 deletions(-)
 rename sys/net/{ => netmap}/netmap.h (100%)
 rename sys/net/{ => netmap}/netmap_user.h (99%)

diff --git a/Makefile_upgrade.inc b/Makefile_upgrade.inc
index 8c0b206876..3ff783a58e 100644
--- a/Makefile_upgrade.inc
+++ b/Makefile_upgrade.inc
@@ -3652,6 +3652,8 @@ TO_REMOVE+=/usr/include/cpu/varargs.h
 TO_REMOVE+=/usr/include/machine/varargs.h
 TO_REMOVE+=/usr/share/man/man3/varargs.3.gz
 TO_REMOVE+=/usr/include/sys/fd_set.h
+TO_REMOVE+=/usr/include/net/netmap.h
+TO_REMOVE+=/usr/include/net/netmap_user.h
 
 .if !defined(WANT_INSTALLER)
 TO_REMOVE+=/usr/sbin/dfuibe_installer
diff --git a/etc/mtree/BSD.include.dist b/etc/mtree/BSD.include.dist
index 44e929cce9..4d9d00f211 100644
--- a/etc/mtree/BSD.include.dist
+++ b/etc/mtree/BSD.include.dist
@@ -262,6 +262,8 @@
         ..
         lagg
         ..
+        netmap
+        ..
         pf
         ..
         ppp_layer
diff --git a/include/Makefile b/include/Makefile
index 7183e8307d..ad1e9026b7 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -68,7 +68,7 @@ LSUBDIRS= \
 	net/vlan net/ipfw net/ip6fw net/dummynet net/sppp net/ip_mroute \
 	net/ipfw3 net/ipfw3_basic net/ipfw3_layer2 net/ipfw3_layer4 \
 	net/ipfw3_nat net/dummynet3 \
-	net/lagg \
+	net/lagg net/netmap \
 	netgraph/UI netgraph/async netgraph/bpf netgraph/bridge \
 	netgraph/cisco netgraph/echo netgraph/eiface netgraph/etf \
 	netgraph/ether netgraph/fec netgraph/frame_relay netgraph/hole \
diff --git a/share/man/man4/netmap.4 b/share/man/man4/netmap.4
index 2f7eec78e8..66a4014a45 100644
--- a/share/man/man4/netmap.4
+++ b/share/man/man4/netmap.4
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD: head/share/man/man4/netmap.4 228017 2011-11-27 06:55:57Z gjb $
 .\"
-.Dd December 26, 2013
+.Dd May 23, 2019
 .Dt NETMAP 4
 .Os
 .Sh NAME
@@ -164,7 +164,7 @@ to be notified about incoming packet or available transmit buffers.
 .Ss DATA STRUCTURES
 The data structures in the mmapped memory are described below
 (see
-.In net/netmap.h
+.In net/netmap/netmap.h
 for reference).
 All physical devices operating in
 .Nm
@@ -450,7 +450,7 @@ supports the
 .Xr ioctl 2
 command codes supported by network devices, as well as
 specific command codes defined in
-.In net/netmap.h .
+.In net/netmap/netmap.h .
 These specific command codes are as follows:
 .Bl -tag -width ".Dv NIOCTXSYNC"
 .It Dv NIOCGINFO
@@ -576,7 +576,7 @@ The following code implements a traffic generator:
 #include <sys/socket.h>
 #include <sys/time.h>
 #include <sys/types.h>
-#include <net/netmap_user.h>
+#include <net/netmap/netmap_user.h>
 
 #include <fcntl.h>
 #include <poll.h>
diff --git a/sys/net/netmap/netmap.c b/sys/net/netmap/netmap.c
index 6b6a70e00b..55ad77f8f3 100644
--- a/sys/net/netmap/netmap.c
+++ b/sys/net/netmap/netmap.c
@@ -160,7 +160,7 @@ extern struct dev_ops netmap_cdevsw;
 /*
  * common headers
  */
-#include <net/netmap.h>
+#include <net/netmap/netmap.h>
 #include <net/netmap/netmap_kern.h>
 #include <net/netmap/netmap_mem2.h>
 
diff --git a/sys/net/netmap.h b/sys/net/netmap/netmap.h
similarity index 100%
rename from sys/net/netmap.h
rename to sys/net/netmap/netmap.h
diff --git a/sys/net/netmap/netmap_freebsd.c b/sys/net/netmap/netmap_freebsd.c
index ad6f006030..91f3289581 100644
--- a/sys/net/netmap/netmap_freebsd.c
+++ b/sys/net/netmap/netmap_freebsd.c
@@ -49,7 +49,7 @@
 #include <net/ifq_var.h>
 #include <sys/bus.h>	/* bus_dmamap_* */
 
-#include <net/netmap.h>
+#include <net/netmap/netmap.h>
 #include <net/netmap/netmap_kern.h>
 #include <net/netmap/netmap_mem2.h>
 
diff --git a/sys/net/netmap/netmap_generic.c b/sys/net/netmap/netmap_generic.c
index f1e71f9b97..dff6b73698 100644
--- a/sys/net/netmap/netmap_generic.c
+++ b/sys/net/netmap/netmap_generic.c
@@ -75,7 +75,7 @@ __FBSDID("$FreeBSD: head/sys/dev/netmap/netmap.c 257666 2013-11-05 01:06:22Z lui
 #include <sys/bus.h>        /* bus_dmamap_* in netmap_kern.h */
 
 // XXX temporary - D() defined here
-#include <net/netmap.h>
+#include <net/netmap/netmap.h>
 #include <net/netmap/netmap_kern.h>
 #include <net/netmap/netmap_mem2.h>
 
diff --git a/sys/net/netmap/netmap_mem2.c b/sys/net/netmap/netmap_mem2.c
index fbafed5c46..7597c26a04 100644
--- a/sys/net/netmap/netmap_mem2.c
+++ b/sys/net/netmap/netmap_mem2.c
@@ -37,7 +37,7 @@ __FBSDID("$FreeBSD: head/sys/dev/netmap/netmap.c 241723 2012-10-19 09:41:45Z gle
 #include <net/if_var.h>
 #include <sys/bus.h>	/* bus_dmamap_* */
 
-#include <net/netmap.h>
+#include <net/netmap/netmap.h>
 #include <net/netmap/netmap_kern.h>
 #include <net/netmap/netmap_mem2.h>
 
diff --git a/sys/net/netmap_user.h b/sys/net/netmap/netmap_user.h
similarity index 99%
rename from sys/net/netmap_user.h
rename to sys/net/netmap/netmap_user.h
index f9b96e1a5f..4d8b1ccf45 100644
--- a/sys/net/netmap_user.h
+++ b/sys/net/netmap/netmap_user.h
@@ -65,7 +65,7 @@
 
 #include <stdint.h>
 #include <net/if.h>		/* IFNAMSIZ */
-#include <net/netmap.h>
+#include <net/netmap/netmap.h>
 
 #define _NETMAP_OFFSET(type, ptr, offset) \
 	((type)(void *)((char *)(ptr) + (offset)))
diff --git a/sys/net/netmap/netmap_vale.c b/sys/net/netmap/netmap_vale.c
index 0345879430..79101c8a61 100644
--- a/sys/net/netmap/netmap_vale.c
+++ b/sys/net/netmap/netmap_vale.c
@@ -93,7 +93,7 @@ __FBSDID("$FreeBSD: head/sys/dev/netmap/netmap.c 257176 2013-10-26 17:58:36Z gle
  * common headers
  */
 
-#include <net/netmap.h>
+#include <net/netmap/netmap.h>
 #include <net/netmap/netmap_kern.h>
 #include <net/netmap/netmap_mem2.h>
 
-- 
2.21.0

