-
Notifications
You must be signed in to change notification settings - Fork 7
/
README
155 lines (136 loc) · 5.01 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
Sources for building netlink sockets on FreeBSD,
derived from routing sockets in FreeBSD and modified by
Daniele Di Proietto and Luigi Rizzo, Universita` di Pisa - 2014
This project implements netlink and generic netlink sockets,
enough to build the in-kernel openvswitch datapath.
Documentation on netlink sockets is at
http://1984.lsi.us.es/~pablo/docs/spae.pdf
http://tools.ietf.org/html/rfc3549
Code is organised as follows:
- main source files in sys/netlink/
- the BSDmakefile to be copied to sys/modules/netlink/Makefile
- headers part of the API in sys/netlink/net and sys/netlink/linux
to be copied into /usr/include/net and /usr/include/linux
(or /usr/include/netlink/net and /usr/include/netlink/linux/ )
--- NETLINK sockets and functions ---
netlink sockets natively operate on mbufs in FreeBSD,
on sk_buff on linux. To build the native linux code in FreeBSD, use
#define __COMPAT_MBUF_TYPE sk_buff
in the forced include so the netlink prototypes use the correct type.
netlink build routines expect a linear buffer, which is not what
mbufs provide. To help that, we may allocate a linear buffer during
the construction, which is then freed at the end before sending
the mbuf to the kernel clients.
------
NOTE ON THE HEADERS
In the new-world linux kernel:
According to linux convention sources:
include/uapi/linux/netlink.h
API shared by user and kernel, guarded by _UAPI__LINUX_NETLINK_H
and then installed to userspace as
include/linux/*netlink.h guarded by __LINUX_NETLINK_H
include/linux/netlink.h
main kernel API, starts with #include <uapi/linux/netlink.h>
not used by userspace
include/net/netlink.h
extended kernel API, starts with #include <linux/netlink.h>
(i.e. knows everything)
(same goes for genetlink.h nfnetlink.h and other subfamilies).
In FreeBSD we rename uapi/linux/netlink.h to linux/uapi_netlink.h
so we do not need to modify it when installing.
For installation of the header we need to change
etc/mtree/BSD.include.dist
Case 1: files in /usr/include/linux and /usr/include/net
Index: /home/luigi/FreeBSD/head/etc/mtree/BSD.include.dist
===================================================================
--- /home/luigi/FreeBSD/head/etc/mtree/BSD.include.dist (revision 273452)
+++ /home/luigi/FreeBSD/head/etc/mtree/BSD.include.dist (working copy)
@@ -249,6 +249,8 @@
..
libmilter
..
+ linux
+ ..
lzma
..
machine
Index: /home/luigi/FreeBSD/head/share/mk/src.opts.mk
===================================================================
--- /home/luigi/FreeBSD/head/share/mk/src.opts.mk (revision 273452)
+++ /home/luigi/FreeBSD/head/share/mk/src.opts.mk (working copy)
@@ -116,6 +116,7 @@
NDIS \
NETCAT \
NETGRAPH \
+ NETLINK \
NLS_CATALOGS \
NS_CACHING \
NTP \
Index: /home/luigi/FreeBSD/head/include/Makefile
===================================================================
--- /home/luigi/FreeBSD/head/include/Makefile (revision 273452)
+++ /home/luigi/FreeBSD/head/include/Makefile (working copy)
@@ -186,6 +186,14 @@
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
${DESTDIR}${INCLUDEDIR}/netinet
.endif
+.if ${MK_NETLINK} != "no"
+ cd ${.CURDIR}/../sys/netlink/linux; \
+ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
+ ${DESTDIR}${INCLUDEDIR}/linux
+ cd ${.CURDIR}/../sys/netlink/net; \
+ ${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
+ ${DESTDIR}${INCLUDEDIR}/net
+.endif
.if ${MK_PF} != "no"
cd ${.CURDIR}/../sys/netpfil/pf; \
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
@@ -287,6 +295,18 @@
${DESTDIR}${INCLUDEDIR}/netinet; \
done
.endif
+.if ${MK_NETLINK} != "no"
+ cd ${.CURDIR}/../sys/netlink/linux; \
+ for h in *.h; do \
+ ln -fs ../../../sys/netlink/linux/$$h \
+ ${DESTDIR}${INCLUDEDIR}/linux; \
+ done
+ cd ${.CURDIR}/../sys/netlink/net; \
+ for h in *.h; do \
+ ln -fs ../../../sys/netlink/net/$$h \
+ ${DESTDIR}${INCLUDEDIR}/net; \
+ done
+.endif
.if ${MK_PF} != "no"
cd ${.CURDIR}/../sys/netpfil/pf; \
for h in *.h; do \
--- case 2: files in /usr/include/netlink/{net|linux}
Index: /home/luigi/FreeBSD/head/etc/mtree/BSD.include.dist
===================================================================
--- /home/luigi/FreeBSD/head/etc/mtree/BSD.include.dist (revision 273452)
+++ /home/luigi/FreeBSD/head/etc/mtree/BSD.include.dist (working copy)
@@ -275,6 +275,12 @@
..
netipsec
..
+ netlink
+ linux
+ ..
+ net
+ ..
+ ..
netnatm
api
..
Index: /home/luigi/FreeBSD/head/include/Makefile
===================================================================
--- /home/luigi/FreeBSD/head/include/Makefile (revision 273452)
+++ /home/luigi/FreeBSD/head/include/Makefile (working copy)
@@ -52,6 +52,7 @@
geom/mirror geom/mountver geom/multipath geom/nop \
geom/raid geom/raid3 geom/shsec geom/stripe geom/virstor \
netgraph/atm netgraph/netflow \
+ netlink/linux netlink/net \
security/audit \
security/mac_biba security/mac_bsdextended security/mac_lomac \
security/mac_mls security/mac_partition \