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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
.\" $OpenBSD: pipex.4,v 1.10 2015/09/22 11:27:13 sobrado Exp $
.\"
.\" Copyright (c) 2012 YASUOKA Masahiko <yasuoka@openbsd.org>
.\" Copyright (c) 2010 SUENAGA Hiroki <hsuenaga@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: September 22 2015 $
.Dt PIPEX 4
.Os
.Sh NAME
.Nm pipex
.Nd PPP IP EXtension to handle IP/PPP frames in-kernel
.Sh SYNOPSIS
.Cd "option PIPEX"
.Pp
.In sys/socket.h
.In sys/ioctl.h
.In net/pipex.h
.Sh DESCRIPTION
.Nm
is used with
.Xr tun 4
and
.Xr pppx 4 ,
and handles PPP frames and forwards IP packets in-kernel.
It accelerates the performance of packet forwarding, because it reduces
copying of packets between kernel and userland.
.Nm
is disabled by default.
To enable it, set
.Va net.pipex.enable
to
.Sq 1
using
.Xr sysctl 8 .
.Pp
.Nm
adds some extensions to the
.Xr ioctl 2
requests to
.Xr tun 4
or
.Xr pppx 4
devices.
The added requests are as follows:
.Bl -tag -width Ds
.It Dv PIPEXGMODE Fa "int *"
Get the devices's
.Nm
operation mode.
1 to enable
.Nm
on this device; 0 to disable.
.It Dv PIPEXSMODE Fa "int *"
Set the device's
.Nm
operation mode.
1 to enable
.Nm
on this device; 0 to disable.
.It Dv PIPEXASESSION Fa "struct pipex_session_req *"
Add a new PPP session to be handled by
.Nm .
The status of the session is passed as a
.Vt pipex_session_req
structure.
The
.Vt pipex_session_req
structure has the following definition:
.Bd -literal
struct pipex_session_req {
int pr_protocol; /* tunnel protocol */
#define PIPEX_PROTO_L2TP 1 /* protocol L2TP */
#define PIPEX_PROTO_PPTP 2 /* protocol PPTP */
#define PIPEX_PROTO_PPPOE 3 /* protocol PPPoE */
uint16_t pr_session_id; /* session-id */
uint16_t pr_peer_session_id; /* peer's session-id */
uint32_t pr_ppp_flags; /* ppp configuration flags */
#define PIPEX_PPP_ACFC_ACCEPTED 0x0001 /* ACFC accepted */
#define PIPEX_PPP_PFC_ACCEPTED 0x0002 /* PFC accepted */
#define PIPEX_PPP_ACFC_ENABLED 0x0004 /* ACFC enabled */
#define PIPEX_PPP_PFC_ENABLED 0x0008 /* PFC enabled */
#define PIPEX_PPP_MPPE_ACCEPTED 0x0010 /* MPPE accepted */
#define PIPEX_PPP_MPPE_ENABLED 0x0020 /* MPPE enabled */
#define PIPEX_PPP_MPPE_REQUIRED 0x0040 /* MPPE is required */
#define PIPEX_PPP_HAS_ACF 0x0080 /* has ACF */
#define PIPEX_PPP_ADJUST_TCPMSS 0x0100 /* do tcpmss adjustment */
#define PIPEX_PPP_INGRESS_FILTER 0x0200 /* do ingress filter */
int8_t pr_ccp_id; /* ccp current packet id */
int pr_ppp_id; /* ppp id. */
uint16_t pr_peer_mru; /* peer's mru */
uint16_t pr_timeout_sec; /* idle timer */
struct in_addr pr_ip_srcaddr; /* local IP address.
not used by tun(4) */
struct in_addr pr_ip_address; /* framed IP address */
struct in_addr pr_ip_netmask; /* framed IP netmask */
struct sockaddr_in6 pr_ip6_address; /* framed IPv6 address */
int pr_ip6_prefixlen; /* framed IPv6 prefix
length */
union {
struct {
uint32_t snd_nxt; /* send next */
uint32_t rcv_nxt; /* receive next */
uint32_t snd_una; /* unacked */
uint32_t rcv_acked; /* recv acked */
int winsz; /* window size */
int maxwinsz; /* max window size */
int peer_maxwinsz; /* peer's max window size */
} pptp;
struct {
/* select protocol options: 1 for enable */
uint32_t option_flags;
#define PIPEX_L2TP_USE_SEQUENCING 0x00000001
/* use sequence number
on L2TP data messages */
uint16_t tunnel_id; /* our tunnel-id */
uint16_t peer_tunnel_id; /* peer's tunnel-id */
uint32_t ns_nxt; /* send next */
uint32_t nr_nxt; /* receive next */
uint32_t ns_una; /* unacked */
uint32_t nr_acked; /* recv acked */
uint32_t ipsecflowinfo; /* IPsec flow id for NAT-T */
} l2tp;
struct {
char over_ifname[IF_NAMESIZE];
/* ethernet ifname */
} pppoe;
} pr_proto;
struct sockaddr_storage pr_peer_address;
/* peer address of tunnel */
struct sockaddr_storage pr_local_address;
/* our address of tunnel */
struct pipex_mppe_req pr_mppe_recv;
/* mppe key for receive */
struct pipex_mppe_req pr_mppe_send;
/* mppe key for send */
};
.Ed
.Pp
The
.Vt pipex_mppe_req
structure that was used by
.Va pr_mppe_recv
and
.Va pr_mppe_send
has the following definition:
.Bd -literal
struct pipex_mppe_req {
int16_t stateless; /* mppe key mode.
1 for stateless */
int16_t keylenbits; /* mppe key length(in bits)*/
u_char master_key[PIPEX_MPPE_KEYLEN];
/* mppe master key */
};
.Ed
.It Dv PIPEXDSESSION Fa "struct pipex_session_close_req *"
Delete the specified session from the kernel.
Specify the session using a
.Vt pipex_session_stat_req
structure, which has the following definition:
.Bd -literal
struct pipex_session_stat_req {
int psr_protocol; /* tunnel protocol */
uint16_t psr_session_id; /* session-id */
struct pipex_statistics psr_stat; /* statistics */
};
.Ed
.Pp
The
.Va psr_protocol
and
.Va psr_session_id
fields used to specify the session are mandatory.
On successful return, the
.Va psr_stat
field is filled by the kernel.
See
.Dv PIPEXGSTAT
section for a description of the
.Vt pipex_statistics
structure.
.It Dv PIPEXCSESSION Fa "struct pipex_session_config_req *"
Change the configuration of the specified session.
The session and configuration are specified by a
.Vt pipex_session_config_req
structure, which has the following definition:
.Bd -literal
struct pipex_session_config_req {
int pcr_protocol; /* tunnel protocol */
uint16_t pcr_session_id; /* session-id */
int pcr_ip_forward; /* ip_forwarding on/off */
};
.Ed
.It Dv PIPEXGSTAT Fa "struct pipex_session_stat_req *"
Get statistics for the specified session.
Specify the session using a
.Vt pipex_session_stat_req
structure, which has the following definition:
.Bd -literal
struct pipex_session_stat_req {
int psr_protocol; /* tunnel protocol */
uint16_t psr_session_id; /* session-id */
struct pipex_statistics psr_stat; /* statistics */
};
.Ed
.Pp
The
.Va psr_protocol
and
.Va psr_session_id
fields used to specify the session are mandatory.
On successful return, the
.Va psr_stat
field is filled by the kernel.
The
.Vt pipex_statistics
structure has the following definition:
.Bd -literal
struct pipex_statistics {
uint32_t ipackets; /* packets received from tunnel */
uint32_t ierrors; /* error packets received from tunnel */
uint64_t ibytes; /* number of received bytes from tunnel */
uint32_t opackets; /* packets sent to tunnel */
uint32_t oerrors; /* error packets on sending to tunnel */
uint64_t obytes; /* number of sent bytes to tunnel */
uint32_t idle_time; /* idle time in seconds */
};
.Ed
.It Dv PIPEXGCLOSED Fa "struct pipex_session_list_req *"
Get a list of closed sessions.
.Nm
reserves closed sessions for 30 seconds
for userland programs to get statistical information.
On successful return,
the
.Vt pipex_session_list_req
structure is filled by the kernel.
The structure has the following definition.
.Bd -literal
struct pipex_session_list_req {
uint8_t plr_flags;
#define PIPEX_LISTREQ_MORE 0x01 /* has more session */
int plr_ppp_id_count; /* count of PPP id */
int plr_ppp_id[PIPEX_MAX_LISTREQ]; /* PPP id */
};
.Ed
.It Dv PIPEXSIFDESCR Fa "struct pipex_session_descr_req *"
Set the
.Xr pppx 4
interface's description of the session.
This command doesn't work on
.Xr tun 4
devices.
Specify the session and its description using a
.Vt pipex_session_descr_req
structure, which has the following definition:
.Bd -literal
struct pipex_session_descr_req {
int pdr_protocol; /* tunnel protocol */
uint16_t pdr_session_id; /* session-id */
char pdr_descr[IFDESCRSIZE]; /* description */
};
.Ed
.El
.Sh SEE ALSO
.Xr ioctl 2 ,
.Xr pppx 4 ,
.Xr tun 4 ,
.Xr npppd 8 ,
.Xr sysctl 8
.Sh AUTHORS
The
.Nm
was written by
.An Internet Initiative Japan Inc.
|