1.\" $OpenBSD: pipex.4,v 1.13 2020/08/09 14:35:31 mvs Exp $ 2.\" 3.\" Copyright (c) 2012 YASUOKA Masahiko <yasuoka@openbsd.org> 4.\" Copyright (c) 2010 SUENAGA Hiroki <hsuenaga@openbsd.org> 5.\" 6.\" Permission to use, copy, modify, and distribute this software for any 7.\" purpose with or without fee is hereby granted, provided that the above 8.\" copyright notice and this permission notice appear in all copies. 9.\" 10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" 18.Dd $Mdocdate: August 9 2020 $ 19.Dt PIPEX 4 20.Os 21.Sh NAME 22.Nm pipex 23.Nd PPP IP EXtension to handle IP/PPP frames in-kernel 24.Sh SYNOPSIS 25.Cd "option PIPEX" 26.Pp 27.In sys/types.h 28.In sys/socket.h 29.In sys/ioctl.h 30.In net/if.h 31.In net/pipex.h 32.Sh DESCRIPTION 33.Nm 34is used with 35.Xr pppac 4 36and 37.Xr pppx 4 , 38and handles PPP frames and forwards IP packets in-kernel. 39It accelerates the performance of packet forwarding, because it reduces 40copying of packets between kernel and userland. 41.Nm 42is disabled by default. 43To enable it, set 44.Va net.pipex.enable 45to 46.Sq 1 47using 48.Xr sysctl 8 . 49.Pp 50.Nm 51adds some extensions to the 52.Xr ioctl 2 53requests to 54.Xr pppac 4 55or 56.Xr pppx 4 57devices. 58The added requests are as follows: 59.Bl -tag -width Ds 60.It Dv PIPEXGMODE Fa "int *" 61Get the devices's 62.Nm 63operation mode. 641 to enable 65.Nm 66on this device; 0 to disable. 67.It Dv PIPEXSMODE Fa "int *" 68Set the device's 69.Nm 70operation mode. 711 to enable 72.Nm 73on this device; 0 to disable. 74.It Dv PIPEXASESSION Fa "struct pipex_session_req *" 75Add a new PPP session to be handled by 76.Nm . 77The status of the session is passed as a 78.Vt pipex_session_req 79structure. 80The 81.Vt pipex_session_req 82structure has the following definition: 83.Bd -literal 84struct pipex_session_req { 85 int pr_protocol; /* tunnel protocol */ 86#define PIPEX_PROTO_L2TP 1 /* protocol L2TP */ 87#define PIPEX_PROTO_PPTP 2 /* protocol PPTP */ 88#define PIPEX_PROTO_PPPOE 3 /* protocol PPPoE */ 89 uint16_t pr_session_id; /* session-id */ 90 uint16_t pr_peer_session_id; /* peer's session-id */ 91 uint32_t pr_ppp_flags; /* ppp configuration flags */ 92#define PIPEX_PPP_ACFC_ACCEPTED 0x0001 /* ACFC accepted */ 93#define PIPEX_PPP_PFC_ACCEPTED 0x0002 /* PFC accepted */ 94#define PIPEX_PPP_ACFC_ENABLED 0x0004 /* ACFC enabled */ 95#define PIPEX_PPP_PFC_ENABLED 0x0008 /* PFC enabled */ 96#define PIPEX_PPP_MPPE_ACCEPTED 0x0010 /* MPPE accepted */ 97#define PIPEX_PPP_MPPE_ENABLED 0x0020 /* MPPE enabled */ 98#define PIPEX_PPP_MPPE_REQUIRED 0x0040 /* MPPE is required */ 99#define PIPEX_PPP_HAS_ACF 0x0080 /* has ACF */ 100#define PIPEX_PPP_ADJUST_TCPMSS 0x0100 /* do tcpmss adjustment */ 101#define PIPEX_PPP_INGRESS_FILTER 0x0200 /* do ingress filter */ 102 int8_t pr_ccp_id; /* ccp current packet id */ 103 int pr_ppp_id; /* ppp id. */ 104 uint16_t pr_peer_mru; /* peer's mru */ 105 uint16_t pr_timeout_sec; /* idle timer */ 106 107 struct in_addr pr_ip_srcaddr; /* local IP address */ 108 struct in_addr pr_ip_address; /* framed IP address */ 109 struct in_addr pr_ip_netmask; /* framed IP netmask */ 110 struct sockaddr_in6 pr_ip6_address; /* framed IPv6 address */ 111 int pr_ip6_prefixlen; /* framed IPv6 prefix 112 length */ 113 union { 114 struct { 115 uint32_t snd_nxt; /* send next */ 116 uint32_t rcv_nxt; /* receive next */ 117 uint32_t snd_una; /* unacked */ 118 uint32_t rcv_acked; /* recv acked */ 119 int winsz; /* window size */ 120 int maxwinsz; /* max window size */ 121 int peer_maxwinsz; /* peer's max window size */ 122 } pptp; 123 struct { 124 /* select protocol options: 1 for enable */ 125 uint32_t option_flags; 126 #define PIPEX_L2TP_USE_SEQUENCING 0x00000001 127 /* use sequence number 128 on L2TP data messages */ 129 130 uint16_t tunnel_id; /* our tunnel-id */ 131 uint16_t peer_tunnel_id; /* peer's tunnel-id */ 132 uint32_t ns_nxt; /* send next */ 133 uint32_t nr_nxt; /* receive next */ 134 uint32_t ns_una; /* unacked */ 135 uint32_t nr_acked; /* recv acked */ 136 uint32_t ipsecflowinfo; /* IPsec flow id for NAT-T */ 137 } l2tp; 138 struct { 139 char over_ifname[IF_NAMESIZE]; 140 /* ethernet ifname */ 141 } pppoe; 142 } pr_proto; 143 struct sockaddr_storage pr_peer_address; 144 /* peer address of tunnel */ 145 struct sockaddr_storage pr_local_address; 146 /* our address of tunnel */ 147 struct pipex_mppe_req pr_mppe_recv; 148 /* mppe key for receive */ 149 struct pipex_mppe_req pr_mppe_send; 150 /* mppe key for send */ 151}; 152.Ed 153.Pp 154The 155.Vt pipex_mppe_req 156structure that was used by 157.Va pr_mppe_recv 158and 159.Va pr_mppe_send 160has the following definition: 161.Bd -literal 162struct pipex_mppe_req { 163 int16_t stateless; /* mppe key mode. 164 1 for stateless */ 165 int16_t keylenbits; /* mppe key length(in bits)*/ 166 u_char master_key[PIPEX_MPPE_KEYLEN]; 167 /* mppe master key */ 168}; 169.Ed 170.It Dv PIPEXDSESSION Fa "struct pipex_session_close_req *" 171Delete the specified session from the kernel. 172Specify the session using a 173.Vt pipex_session_close_req 174structure, which has the following definition: 175.Bd -literal 176struct pipex_session_close_req { 177 int psr_protocol; /* tunnel protocol */ 178 uint16_t psr_session_id; /* session-id */ 179 struct pipex_statistics psr_stat; /* statistics */ 180}; 181.Ed 182.Pp 183The 184.Va psr_protocol 185and 186.Va psr_session_id 187fields used to specify the session are mandatory. 188On successful return, the 189.Va psr_stat 190field is filled by the kernel. 191See 192.Dv PIPEXGSTAT 193section for a description of the 194.Vt pipex_statistics 195structure. 196.It Dv PIPEXCSESSION Fa "struct pipex_session_config_req *" 197Change the configuration of the specified session. 198The session and configuration are specified by a 199.Vt pipex_session_config_req 200structure, which has the following definition: 201.Bd -literal 202struct pipex_session_config_req { 203 int pcr_protocol; /* tunnel protocol */ 204 uint16_t pcr_session_id; /* session-id */ 205 int pcr_ip_forward; /* ip_forwarding on/off */ 206}; 207.Ed 208.It Dv PIPEXGSTAT Fa "struct pipex_session_stat_req *" 209Get statistics for the specified session. 210Specify the session using a 211.Vt pipex_session_stat_req 212structure, which has the following definition: 213.Bd -literal 214struct pipex_session_stat_req { 215 int psr_protocol; /* tunnel protocol */ 216 uint16_t psr_session_id; /* session-id */ 217 struct pipex_statistics psr_stat; /* statistics */ 218}; 219.Ed 220.Pp 221The 222.Va psr_protocol 223and 224.Va psr_session_id 225fields used to specify the session are mandatory. 226On successful return, the 227.Va psr_stat 228field is filled by the kernel. 229The 230.Vt pipex_statistics 231structure has the following definition: 232.Bd -literal 233struct pipex_statistics { 234 uint32_t ipackets; /* packets received from tunnel */ 235 uint32_t ierrors; /* error packets received from tunnel */ 236 uint64_t ibytes; /* number of received bytes from tunnel */ 237 uint32_t opackets; /* packets sent to tunnel */ 238 uint32_t oerrors; /* error packets on sending to tunnel */ 239 uint64_t obytes; /* number of sent bytes to tunnel */ 240 241 uint32_t idle_time; /* idle time in seconds */ 242}; 243.Ed 244.It Dv PIPEXGCLOSED Fa "struct pipex_session_list_req *" 245Get a list of closed sessions. 246.Nm 247reserves closed sessions for 30 seconds 248for userland programs to get statistical information. 249On successful return, 250the 251.Vt pipex_session_list_req 252structure is filled by the kernel. 253The structure has the following definition. 254.Bd -literal 255struct pipex_session_list_req { 256 uint8_t plr_flags; 257#define PIPEX_LISTREQ_MORE 0x01 /* has more session */ 258 int plr_ppp_id_count; /* count of PPP id */ 259 int plr_ppp_id[PIPEX_MAX_LISTREQ]; /* PPP id */ 260}; 261.Ed 262.It Dv PIPEXSIFDESCR Fa "struct pipex_session_descr_req *" 263Set the 264.Xr pppx 4 265interface's description of the session. 266This command doesn't work on 267.Xr pppac 4 268devices. 269Specify the session and its description using a 270.Vt pipex_session_descr_req 271structure, which has the following definition: 272.Bd -literal 273struct pipex_session_descr_req { 274 int pdr_protocol; /* tunnel protocol */ 275 uint16_t pdr_session_id; /* session-id */ 276 char pdr_descr[IFDESCRSIZE]; /* description */ 277}; 278.Ed 279.El 280.Sh SEE ALSO 281.Xr ioctl 2 , 282.Xr pppac 4 , 283.Xr pppx 4 , 284.Xr npppd 8 , 285.Xr sysctl 8 286.Sh AUTHORS 287The 288.Nm 289was written by 290.An Internet Initiative Japan Inc . 291.Sh BUGS 292.Xr pppx 4 293does not allow sessions with 294.Ic pr_timeout_sec 295set to any value other than 0. 296