summaryrefslogtreecommitdiffstats
path: root/sys/net (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* Add sizes to free() callskn2020-09-121-9/+15
| | | | | | These are the last ones in if_pppoe.c and if_spppsubr.c. OK beck
* zap nasty whitespacetb2020-09-011-3/+3
|
* Fix a leak due to a missing free on m_defrag(m, M_NOWAIT) failure.tb2020-09-011-2/+8
| | | | | Reported by Maxime Villard, fix from Matt Dunwoodie after feeedback from claudio who is fine with either of the two suggested fixes going in.
* Don't include "net/netisr.h" header. It's not needed here.mvs2020-08-302-4/+2
| | | | ok yasuoka@
* pppac(4) uses per cpu counters for collect `ifnet' statistics, but inmvs2020-08-302-7/+6
| | | | | | | | | | 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@
* Make sure not to pass NULL to explicit_bzero().tobhe2020-08-281-2/+3
| | | | | | Fixes CID 1496732. ok patrick@
* Add missing #if's to fix build without bpf(4).mvs2020-08-285-7/+23
| | | | ok deraadt@
* Use p2p_rtrequest()kn2020-08-271-1/+2
| | | | | | | | | | | Although technically a point-to-multipoint interface, point-to-point semantics apply/fit when installing local routes, e.g. configuring IPv6 addresses on it. This is to fix SIOCGNBRINFO_IN6 and thus ndp(8). Report and diff from Matt Dunwoodie <ncon at noconroy dot net>, thanks! OK tobhe
* Make pipex(4) more common for pppac(4) and pppx(4). Replaceyasuoka2020-08-274-362/+182
| | | | | | | | | | 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
* Rehash main ruleset after rule expirationkn2020-08-241-12/+9
| | | | | | | | | | | | | | | | When "once" rules expire, they are removed from the active ruleset, hence the main ruleset needs to be rehashed iff itself contains once rules. After the previous commit, pf_setup_pfsync_matching() became much simpler but its name even less accurate; simplify it further and rename it to pf_calc_chksum() while here. Admins using "once" rules in combination with pfsync(4) are hopefully aware of this caveat (self-changing rulesets) already, but now the checksum in "pfctl -v -s info" actually indicates out-of-sync rulesets and is no longer misleading. OK sashan
* Remove ptr_array from struct pf_rulesetkn2020-08-243-25/+10
| | | | | | | | | | | | | | | | | | | Each ruleset's rules are stored in a TAILQ called "ptr" with "rcount" representing the number of rules in the ruleset; "ptr_array" points to an array of the same length. "ptr" is backed by pool_get(9) and may change in size as "expired" rules get removed from the ruleset - see "once" in pf.conf(5). "ptr_array" is allocated momentarily through mallocarray(9) and gets filled with the TAILQ entries, so that the sole user pfsync(4) can access the list of rules by index to pick the n-th rule during state insertion. Remove "ptr_array" and make pfsync iterate over the TAILQ instead to get the matching rule's index. This simplifies both code and data structures and avoids duplicate memory management. OK sashan
* Add sizes to free() callskn2020-08-221-21/+23
| | | | | | | | | | | | Simply reuse struct size or buffer length variables for free() the very same way they are used with malloc(), often within the same scope and/or only a few lines above. This leaves only a few selected free() calls with size zero in due to the fact that there is currently no variable to keep track of name and secret string lengths. OK mvs
* Leave default ifq_maxlen handling to ifq_init()kn2020-08-2119-40/+19
| | | | | | | | | | | | Most clonable interface drivers (except bridge, enc, loop, pppx, switch, trunk and vlan) initialise the send queue's length to IFQ_MAXLEN during *_clone_create() even though ifq_init(), which is eventually called through if_attach(), does the same. Remove all early "ifq_set_maxlen(&ifq->if_snd, IFQ_MAXLEN);" lines to leave it to ifq_init() and have clonable drivers a tad more in sync. OK mvs
* Add sizes to free(9) callskn2020-08-211-14/+21
| | | | | | | | There are either length variables tracking the allocated buffer or strings allocated by their length, reuse the same idiom each time when freeing. Reminder from Peter J. Philipp to account for NUL bytes in strings as well OK mvs
* Allow SIOCSWGDPID and SIOCSWGMAXFLOW ioctls for non-rootkn2020-08-191-3/+1
| | | | | | | | | | | | | | | | | ifconfig(8) detects switch(4) through its unique SIOCSWGDPID ioctl(2) and further does another switch specific ioctl for the default output regardless of configuration and/or members. But since these two ioctls are limited to root, running ifconfig as unprivileged user makes switch interfaces partially appear as bridge devices because the detection fails, e.g. STP parameters are shown instead of datapath id and flow parameters. ifioctl() limits a list of set/write ioctls to root, but these two read-only ioctls seem to have been listed by mistake, so remove them to omit the root check and fix "ifconfig switch" output for unprivileged users. Feedback from dlg
* Zap LOOPALIVECNTkn2020-08-141-2/+1
| | | | | | Unused since r1.138 from 2015: "remove cisco hdlc code from sppp(4)". OK mpi
* Set `IFXF_MPSAFE' bit to pppx(4) related `ifnet'. This moves pppx(4)mvs2020-08-141-15/+9
| | | | | | | packets output out of KERNEL_LOCK. pppx(4) and pipex(4) are ready to this. ok yasuoka@ mpi@
* Add a ROUTE_FLAGFILTER socket option for routing sockets, allowingjmatthew2020-08-132-5/+22
| | | | | | | | filtering out messages for routes with flags matching any bit in a mask. This allows routing daemons to opt out of receiving messages for L2 and broadcast route entries, which they currently discard. ok dlg@ sthen@ deraadt@
* Use rtm_miss() rather than the simpler rtm_send() to send route deletejmatthew2020-08-131-2/+8
| | | | | | | | messages, and save the route flags before deleting the route. For L2 route entries, the RTF_LLINFO flag is cleared during deletion, so saving the flags beforehand means they're correct in the routing socket message. ok mpi@
* Remove interface statistics update for outgoing packets. We shouldn'tmvs2020-08-122-13/+2
| | | | | | count them because `if_snd' does this. ok yasuoka@
* Run start routing without KERNEL_LOCK()kn2020-08-111-6/+6
| | | | | | pfsyncstart() does not require the big lock, make it use the ifq API. OK mvs
* Set `IFXF_MPSAFE' bit to pppac(4) related `ifnet'. This moves pppac(4)mvs2020-08-101-14/+11
| | | | | | | packets output out of KERNEL_LOCK. pppac(4) and pipex(4) are ready to this. ok yasuoka@
* vether(4) is pretty dummy. It contains nothing requires to be protected.mvs2020-08-091-10/+7
| | | | | | | So set `IFXF_MPSAFE' bit. This allows to discard outgoing packets without kernel lock. ok kn@
* pfkey_get may allocate more memory than is needed to hold the SAtobhe2020-08-072-14/+18
| | | | | | information. Make sure to only copy out actually used memory. ok patrick@
* Allow pf(4) to divert packets from bridge(4) to local socket.bluhm2020-08-061-1/+23
| | | | joint work markus@ patrick@ bluhm@
* Remove defines for `netisr' bits which are not used anymore.mvs2020-08-061-5/+1
| | | | ok mpi@
* Use PFKEYV2_LIFETIME_CURRENT instead of magic number.tobhe2020-08-051-2/+2
| | | | ok patrick@
* Revert r1.614 of net/if.c. Modifications of `ifnet' list must still bemvs2020-08-051-6/+3
| | | | done under both the KERNEL_LOCK() and NET_LOCK().
* We have `pipexinq' and `pipexoutq' mbuf(9) queues to store pipex(4)mvs2020-08-045-131/+36
| | | | | | | | | | | | | 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@
* add a BPF_RND load location that provides a random value.dlg2020-08-032-2/+8
| | | | | | | | | | | | | | | | this will be used so a bpf filter can make a decision based on a random number, which in turn will be used so a filter can perform random sampling of packets rather than capturing all packets. random sampling means that we don't have to figure out how to make bpf coordinate multiple concurrent calls to do counter based sampling. BPF_RND is currently backed with arc4random. discussed with many including jmatthew@, alex wilson, claudio@, sthen@, deraadt@, and tb@ ok kn@ tb@ jmatthew@ i call this extended bpf... xBPF.
* `struct bstp_state' stores pointer to parent `ifnet' as `bs_ifp'.mvs2020-07-304-19/+58
| | | | | | | Replace this pointer by interface index. This allow us to avoid some use after free issues caused by ifioctl() races. ok sashan@
* make pflog more mpsafe with variables on the stack instead of globals.dlg2020-07-301-25/+18
| | | | | | | | | | | | | | | | | | | | pflog wants to copy and patch the packet that is being logged to properly show if it is being transformed, and it does this by copying the ip and transport headers into a local mbuf and patching them there, and then wiring the remaining data from the original packet into an mbuf chain hanging off this patched mbuf. it's just unfortunate that the mbufs it was using are global and not locked. this is particularly unfortunate if you're running the stack in parallel on multiple cpus and pflog gets to running concurrently. this changes pflog to use an mbuf on the stack to copy the headers into and patch. the mbuf used to point to the trailing data has been replaced with an m_hdr, also on the stack, like what bpf_mtap_ether does to skip past where a vlan shim should be. ok sashan@ jmatthew@
* Interface index is unsigned integer. Fix the places where it referencedmvs2020-07-295-11/+11
| | | | | | as signed. u_int used within pipex(4) for consistency with other code. ok dlg@ mpi@
* pfsync(4) holds pointer to corresponding `ifnet' as `sc_sync_if'. Thismvs2020-07-291-44/+62
| | | | | | | | pointer obtained by ifunit() and it's reference counter is not bumped. This can cause use after free issue. Replace this pointer by interface index. ok dlg@ sashan@
* Remove SIOCSIFADDRkn2020-07-291-5/+1
| | | | | | | | | | | It serves no purpose and is deprecated as per netintro(4). ifconfig(8) output improves as well: # ifconfig tpmr0 inet6 2001:db8::1 -ifconfig: SIOCAIFADDR: Address family not supported by protocol family +ifconfig: SIOCAIFADDR: Inappropriate ioctl for device OK dlg
* Fix previous commit which referred wrong address and returned wrongyasuoka2020-07-291-8/+8
| | | | | | value. ok sashan
* Use the table on root always if current table is not active.yasuoka2020-07-283-32/+42
| | | | ok sashan
* Document locks which protect pipex(4) global data structures.mvs2020-07-281-11/+19
| | | | ok mpi@
* Add size to free(9) callskn2020-07-281-3/+5
| | | | | | | | | | Those are for the gateway sockaddrs which get allocated in rt_setgate() with the same ROUNDUP(sa_len) approach. mpi already added a sizes for a few rt_gateway sockaddrs in two commits, these are the last one in route.c leaving only ifafree() behind. OK mpi
* Document locks which protect ppp{ac,x}(4) global data structures.mvs2020-07-281-21/+37
| | | | ok mpi@
* Add missing `IFXF_CLONED' flag to clone interfaces.mvs2020-07-285-5/+10
| | | | ok mpi@
* Implement SIOCBRDGIFS, provide SIOCBRDGGRL stubkn2020-07-281-1/+52
| | | | | | | | | | | Required for ifconfig(8) to print tpmr(4) members in bridge fashion. When copying out members, merely fill in the interface names and set IFBIF_SPAN such that ifconfig rightfully assumes no member does STP. As with switch(4), there are no rules but ifconfig requires an ioctl stub. Feedback OK dlg
* Return total size if SIOCBRDGIFS passes in ifbic_len set to zerokn2020-07-281-2/+4
| | | | | | In accordance to bridge(4) which behaves correctly as per the manual. OK dlg
* Use interface index instead of pointer to `ifnet' in carp(4).mvs2020-07-243-15/+23
| | | | ok sashan@
* Increase state counter for least-states when the address is selectedyasuoka2020-07-241-24/+48
| | | | | | | by sticky-address. Also fix the problem that the interface which is specified by the selected table entry is not used properly. ok jung sashan
* Remove lacpmode and lacptimeout bitskn2020-07-241-16/+1
| | | | | | | | | | ifconfig(8) commands "lacptimeout 1" and "lacpmode active" error out with "ifconfig: Invalid option for trunk: tpmr0"; tpmr(4) has no mode or config, so these ioctls are inappropiate in the first place. Remove SIOCSTRUNKOPTS, SIOCGTRUNKOPTS stubs and now unused <net/if_trunk.h>. OK dlg
* Remove trunkdev bitskn2020-07-241-35/+1
| | | | | | | | | | ifconfig(8) prints "trunk: trunkdev tpmrN" for member interfaces, which is misleading as tpmr(4) is being completed into a bridge-like interface. Remove SIOCGTRUNKPORT so tpmr(4) does not report members as trunk devices (next diff will implement SIOCBRDGIFS). OK dlg
* Remove trunkproto bitskn2020-07-241-72/+1
| | | | | | | | | ifconfig(8) prints "trunk: trunkproto none" for tpmr(4) which is useless as there is no configurable protocol in the first place. Remove SIOCSTRUNK and SIOCGTRUNK which were just simple stubs anyway. OK dlg
* Use interface index instead of pointer to `ifnet' in `struct bstp_port'.mvs2020-07-224-79/+102
| | | | ok yasuoka@
* gc some ifmedia stuff that this driver doesnt use.dlg2020-07-221-3/+1
| | | | no functional change.