summaryrefslogtreecommitdiff
path: root/sys/net/pipex.c
AgeCommit message (Collapse)Author
2024-09-27Previous pipex.c,v 1.155 was broken if the client was not behind a NAT.YASUOKA Masahiko
ok mvs
2024-07-26In pipex_l2tp_input(), check if ipsecflowinfo is not changed insteadYASUOKA Masahiko
of updating it blindly. ok mvs
2024-06-07remove ph_ppp_proto define, unused since rev 1.123Jonathan Gray
2024-01-23Introduce pipex_iterator(), the special thing to performVitaliy Makkoveev
`pipex_session_list' foreach walkthrough with `pipex_list_mtx' mutex(9) relocking. It inserts special item after acquired `session' and keeps it linked until `session' release. Only owner can unlink it's own item, so the LIST_NEXT(session) is always valid even the `session' was unlinked. The iterator skips special items at the `session' acquisition time, as all other foreach loops where `pipex_list_mtx' mutex(9) is not relocked. ok yasuoka
2024-01-23Remove `pipex_rd_head6' and `ps6_rn[2]'. They are not used.Vitaliy Makkoveev
ok yasuoka
2023-12-01pipex(4) layer is completely mp-safe, move the pipex_timer() timeout(9)Vitaliy Makkoveev
handler out of kernel lock. ok bluhm
2023-11-28Remove struct inpcb from in6_embedscope() parameters.Alexander Bluhm
rip6_output() did modify inp_outputopts6 temporarily to provide different ip6_pktopts to in6_embedscope(). Better pass inp_outputopts6 and inp_moptions6 as separate arguments to in6_embedscope(). Simplify the code that deals with these options in in6_embedscope(). Doucument inp_moptions and inp_moptions6 as protected by net lock. OK kn@
2023-09-16Allow counters_read(9) to take an optional scratch buffer.Martin Pieuchot
Using a scratch buffer makes it possible to take a consistent snapshot of per-CPU counters without having to allocate memory. Makes ddb(4) show uvmexp command work in OOM situations. ok kn@, mvs@, cheloha@
2022-08-30Syzkaller found a missing input validation in pipex mppe keylenbits.Alexander Bluhm
Reported-by: syzbot+2eca95b271d07ab91b43@syzkaller.appspotmail.com tested yasuoka@; OK mvs@ yasuoka@
2022-07-25Remove "Static" keyword from pipex(4) layer.Vitaliy Makkoveev
We don't use "static" keyword for functions declaration to allow ddb(4) debug. Also, many "Static" functions are called by pppx(4) layer outside pipex(4) layer. This is the mostly mechanic diff, except the `pipex_pppoe_padding' which should be "static const". ok bluhm@ yasuoka@
2022-07-15Introduce fine grained pipex(4) locking. Use per-session `pxs_mtx'Vitaliy Makkoveev
mutex(9) to protect session context. Except MPPE encryption, PPPOE sessions are mostly immutable, so no lock required for that case. Global pipex(4) data is already protected by `pipex_list_mtx' mutex(9), so pipex(4) doesn't rely on netlock anymore. Recursion was removed from pipex_mppe_input() and pipex_mppe_output(). ok bluhm@
2022-07-12Remove PIPEXCSESSION pipex(4) ioctl(2) command from kernel and man page.Vitaliy Makkoveev
Long time ago pipex(4) session can't be deleted until both pipex(4) input and output queues become empty. Dead sessions were linked to the stack and the `ip_forward' flag was used to prevent packets forwarding. npppd(8) marked such sessions by doing PIPEXCSESSION ioctl(2) call. But since we started to unlink close session from the stack, this logic became unnecessary. Also pipex(4) session could be closed just after close request. npppd(8) was the only userland program which did PIPEXCSESSION ioctl(2) call, and we removed it week ago. It's time to remove the remains. Now the `flags' member of 'pipex_session' structure became immutable. ok yasuoka@
2022-07-10Add missing `pipex_list_mtx' mutex(9) around all sessions loop withinVitaliy Makkoveev
pipex_ip_output(). The all sessions loop was reworked to make possible to drop the lock within. ok bluhm@ yasuoka@.
2022-07-02Remove unused device poll functions.Visa Hankala
Also remove unneeded includes of <sys/poll.h> and <sys/select.h>. Some addenda from jsg@. OK miod@ mpi@
2022-06-28Introduce `pipexoutq' mbuf(9) queue, and put outgoing pipex(4) relatedVitaliy Makkoveev
PPPOE packets within. Do (*if_output)() calls within netisr handler with netlock held. We can't predict netlock state when pipex(4) related (*if_qstart)() handlers called. This means we can't use netlock within pppac_qstart() and pppx_if_qstart() handlers. ok bluhm@
2022-06-26Mark `pipex_enable' as atomic. We never check `pipex_enable' withinVitaliy Makkoveev
(*if_qstart)() and we don't worry it's not serialized with the rest of output path. Also we will process already enqueued pipex(4) packets regardless on `pipex_enable' state. Use the local copy of `pipex_enable' within pppx_if_output(), otherwise we loose consistency. pointed and ok by bluhm@
2022-06-26Don't reset `idle_time' timeout on closed pipex(4) sessions in packetVitaliy Makkoveev
processing path. Such sessions already reached time to live timeout, and the garbage collector waits a little to before kill them. Otherwise we could make session's life time more then PIPEX_CLOSE_TIMEOUT. ok bluhm@
2022-06-26Fix spacing.Vitaliy Makkoveev
2022-06-26The "ifq_set_maxlen(..., 1);" hack we use to enforce pipex(4) relatedVitaliy Makkoveev
(*if_qstart)() be always called with netlock held doesn't work anymore with PPPOE sessions. Introduce `pipex_list_mtx' mutex(9) and use it to protect global pipex(4) lists and radix trees. Protect pipex(4) `session' dereference with reference counters, because we could sleep when accessing pipex(4) from ioctl(2) path, and this is not possible with mutex(9) held. ok bluhm@
2022-06-26'pipex_mppe' and 'pipex_session' structures have uint16_t bit fieldsVitaliy Makkoveev
which represent flags. We mix unlocked access to immutable flags with protected access to mutable ones. This could be not MP independent on some architectures, so convert these fields to u_int `flags' variables. ok bluhm@
2022-01-02spellingJonathan Gray
ok jmc@ reads ok tb@
2021-07-27Introduce mutex(9) to protect pipex(4) session content.mvs
With bluhm@'s diff for parallel forwarding pipex(4) could be accessed in parallel through (*ifp->if_input)() -> ether_input() -> pipex_pppoe_input(). PPPOE pipex(4) sessions are mostly immutable except MPPE crypt. The new per-session `pxs_mtx' mutex(9) used to protect session's `ccp-id' which is incremented each time we send CCP reset-request. The new `pxm_mtx' mutex(9) used to protect MPPE context. Each pipex(4) session has two of them: one for the input and one for output path. Where is no lock order limitations because those new mutex(9)'es never held together. ok bluhm@
2021-07-20Turn pipex(4) session statistics to per-CPU counters. This makes pipex(4)mvs
more compliant to bluhm@'s work on traffic forwarding parallelization. ok yasuoka@ bluhm@
2021-05-15Fix IPsec NAT-T to work with pipex(4). Introduce a new packet tagYASUOKA Masahiko
PACKET_TAG_IPSEC_FLOWINFO to specify the IPsec flow. ok mvs
2021-03-10spellingJonathan Gray
ok gnezdo@ semarie@ mpi@
2021-02-25we don't have to cast to caddr_t when calling m_copydata anymore.David Gwynne
the first cut of this diff was made with coccinelle using this spatch: @rule@ type caddr_t; expression m, off, len, cp; @@ -m_copydata(m, off, len, (caddr_t)cp) +m_copydata(m, off, len, cp) i had fix it's opinionated idea of formatting by hand though, so i'm not sure it was worth it. ok deraadt@ bluhm@
2021-01-19pipex(4): convert ifunit() to if_unit(9)mvs
ok dlg@
2021-01-09Enforce range with sysctl_int_bounded in pipex_sysctlgnezdo
OK millert@
2021-01-02Remove PIPEX{S,G}MODE ioctl(2) commands. This time they are pretty dummymvs
and were kept only for backward compatibility reasons. ok mpi@ yasuoka@
2020-08-30Don't include "net/netisr.h" header. It's not needed here.mvs
ok yasuoka@
2020-08-30pppac(4) uses per cpu counters for collect `ifnet' statistics, but inmvs
pipex(4) layer this `ifnet' still uses `if_data'. Also pppx(4) doesn't use per cpu counters but `if_data'. Add per cpu counters to pppx(4) and pipex(4). This finishes interface statistics collecting mess. ok yasuoka@
2020-08-27Make pipex(4) more common for pppac(4) and pppx(4). ReplaceYASUOKA Masahiko
pipex_iface of struct pipex_session with owner_sc which refers the owner device. This makes ioctl commands for pppac or pppx device simpler. PIPEX{S,G}MODE became dummy since both pppac and pppx is always used with pipex. Also move some pppac specific things to the pppac part on if_pppx.c. suggestions from mvs, ok mvs
2020-08-12Remove interface statistics update for outgoing packets. We shouldn'tmvs
count them because `if_snd' does this. ok yasuoka@
2020-08-04We have `pipexinq' and `pipexoutq' mbuf(9) queues to store pipex(4)mvs
related mbufs. Each mbuf(9) passed to these queues stores the pointer to corresponding pipex(4) session referenced as `m_pkthdr.ph_cookie'. When session was destroyed its reference can still be in these queues so we have use after free issue while pipexintr() dereference it. I removed `pipexinq', `pipexoutq' and pipexintr(). This not only allows us to avoid issue described above, but also removes unnecessary context switch in packet processing. Also it makes code simpler. ok mpi@ yasuoka@
2020-07-29Interface index is unsigned integer. Fix the places where it referencedmvs
as signed. u_int used within pipex(4) for consistency with other code. ok dlg@ mpi@
2020-07-28Document locks which protect pipex(4) global data structures.mvs
ok mpi@
2020-07-17Use interface index instead of pointer to corresponding interfacemvs
within pipex(4) layer. ok mpi@
2020-07-06Protect the whole pipex(4) layer by NET_LOCK(). pipex(4) wasmvs
simultaneously protected by KERNEL_LOCK() and NET_LOCK() and now we have the only lock for it. This step reduces locking mess in this layer. ok mpi@
2020-07-06pipex_rele_session() frees memory pointed by `old_session_keys'. Use it inmvs
pipex_destroy_session() instead of pool_put(9) to prevent memory leak. ok mpi@
2020-06-30Remove unused declaration.mvs
ok deraadt yasuoka
2020-06-22Prevent potencial `state_list' corruption while pppac(4) destroys pipex(4)mvs
sessions by pipex_iface_fini() or by pipex_ioctl() with `PIPEXSMODE' command. ok yasuoka@
2020-06-18Combine and replace duplicated code in pipex(4) and pppx(4) by new functionsmvs
listed below. - pipex_init_session() to check request and alloc new session. - pipex_link_session() to link session to pipex(4) layer. - pipex_unlink_session() to unlink session from pipex(4) layer. - pipex_rele_session() to release session and it's internal allocation. ok mpi@
2020-05-31use ip{,6}_send instead of ip{,6}_output for l2tp and pptp.David Gwynne
pipex output is part of pppx and pppac if_start functions, so it can't rely on or know if it already has NET_LOCK. this defers the ip output stuff to where it can take the NET_LOCK reliably. tested by Vitaliy Makkoveev, who also found that this was necessary after ifq.c 1.38 and provided an excellent analysis of the problem. ok mpi@
2020-04-07Deny to create a pipex session if the session id already exists.Claudio Jeker
From Vitaliy Makkoveev OK yasuoka@
2020-04-06use LIST_FOERACH_SAFE() instead of manual rolling the loop.Claudio Jeker
From Vitaliy Makkoveev
2020-04-06Pass struct pipex_iface_context pointer down to pipex ioctl functions.Claudio Jeker
This way pppx(4) and pppac(4) can be further unified. This is an intermediary step that does not introduce any behaviour change. From Vitaliy Makkoveev
2020-04-04Prevent the destruction of a session owned by another interface.Martin Pieuchot
Issue reported by and fix from Vitaliy Makkoveev.
2020-03-26Unify #ifdef guarding code to remove PPTP and L2TP sessions.Martin Pieuchot
This makes a pattern emerge that should help when starting to protect the global `session' list with something else than the KERNEL_LOCK(). from Vitaliy Makkoveev.
2020-03-25Grab the NET_LOCK() before calling pipex_iface_stop().Martin Pieuchot
This function calls pipex_destroy_session() which requires the lock and pipex_ioctl() already calls it with the NET_LOCK() held. From Vitaliy Makkoveev.
2019-01-31Fix compilation of amd64 kernel when optimization is disabled.Todd C. Miller
C99 inline semantics resulted in undefined symbols. OK deraadt@ mpi@ dlg@