summaryrefslogtreecommitdiffstats
path: root/sys/netinet/in.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* spellingjsg2021-03-101-2/+2
| | | | ok gnezdo@ semarie@ mpi@
* Document the various flavors of NET_LOCK() and rename the reader version.mpi2020-05-271-3/+3
| | | | | | | | | | Since our last concurrency mistake only ioctl(2) ans sysctl(2) code path take the reader lock. This is mostly for documentation purpose as long as the softnet thread is converted back to use a read lock. dlg@ said that comments should be good enough. ok sashan@
* Guard SIOCDELMULTI if_ioctl calls with KERNEL_LOCK() where the call isvisa2020-03-151-1/+3
| | | | | | | | | | made from socket close path. Most device drivers are not MP-safe yet, and the closing of AF_INET and AF_INET6 sockets is no longer under the kernel lock. This fixes a panic seen by jcs@. OK mpi@
* Don't require a valid sa_len for a bunch of IPv4 "get" ioctlsjca2019-12-011-3/+6
| | | | | Same fix as for the IPv6 case. Fixes a regression in ports/net/openvpn spotted by landry@, ok bluhm@
* Although ifconfig(8) checks it already, enforce contiguous inetbluhm2019-11-281-4/+21
| | | | | netmask in the kernel. OK visa@
* convert interface address change hooks to tasks and a task_list.dlg2019-11-081-5/+5
| | | | | | | | | | | | | | | this follows what's been done for detach and link state hooks, and makes handling of hooks generally more robust. address hooks are a bit different to detach/link state hooks in that there's only a few things that register hooks (carp, pf, vxlan), but a lot of places to run the hooks (lots of ipv4 and ipv6 address configuration). an address hook cookie was in struct pfi_kif, which is part of the pf abi. rather than break pfctl -sI, this maintains the void * used for the cookie and uses it to store a task, which is then used as intended with the new api.
* Do propper kernel input validation for in_control() ioctl(2)bluhm2019-11-071-40/+63
| | | | | | | | | | SIOCGIFADDR, SIOCGIFNETMASK, SIOCGIFDSTADDR, SIOCGIFBRDADDR, SIOCSIFADDR, SIOCSIFNETMASK, SIOCSIFDSTADDR, and SIOCSIFBRDADDR. Name in_ioctl_set_ifaddr() consistently. Use in_sa2sin() to validate inet address. Combine if_addrlist loops and add comment. Although netmask is not a inet address, length must be valid. Reported-by: syzbot+5fc6da002fc4e8d994be@syzkaller.appspotmail.com OK visa@
* Kernel is missing propper input validation when configuring addresses.bluhm2019-10-231-33/+64
| | | | | | Fix the SIOCAIFADDR and SIOCDIFADDR ioctl(2) by implementing in_sa2sin() to validate inet address family and address length. OK visa@
* Add IFXF_AUTOCONF4 to if_xflags to match IFXF_AUTOCONF6. Letkrw2019-07-251-1/+4
| | | | | | ifconfig set/unset it. ok deraadt@ kmos@
* change rt_ifa_add and rt_ifa_del so they take an rdomain argument.dlg2019-02-131-9/+15
| | | | | | | | | | | | this allows mpls interfaces (mpe, mpw) to pass the rdomain they wish the local label to be in, rather than have it implicitly forced to 0 by these functions. right now they'll pass 0, but it will soon be possible to have them rx packets in other rdomains. previously the functions used ifp->if_rdomain for the rdomain. everything other than mpls still passes ifp->if_rdomain. ok mpi@
* remove the implict RTF_MPATH flag that rt_ifa_add() sets on new routes.dlg2019-02-101-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | MPLS interfaces (ab)use rt_ifa_add for adding the local MPLS label that they listen on for incoming packets, while every other use of rt_ifa_add is for adding addresses on local interfaces. MPLS does this cos the addresses involved are in basically the same shape as ones used for setting up local addresses. It is appropriate for interfaces to want RTF_MPATH on local addresses, but in the MPLS case it means you can have multiple local things listening on the same label, which doesn't actually work. mpe in particular keeps track of in use labels to it can handle collisions, however, mpw does not. It is currently possible to have multiple mpw interfaces on the same local label, and sharing the same label as mpe or possible normal forwarding labels. Moving the RTF_MPATH flag out of rt_ifa_add means all the callers that still want it need to pass it themselves. The mpe and mpw callers are left alone without the flag, and will now get EEXIST from rt_ifa_add when a label is already in use. ok (and a huge amount of patience and help) mpi@ claudio@ is ok with the idea, but saw a much much earlier solution to the problem
* Disambiguate the source of panics in sys/net* by adding __func__nayden2018-07-111-4/+4
| | | | | magic constant to panic() calls. ok benno@ henning@ tb@
* SIOCSIFNETMASK takes a 'struct ifreq', so use 'ifr' for it and drop thetb2018-06-031-3/+2
| | | | | | now unused 'ifra' from in_ioctl(). Discussed with mpi and visa
* Better version of the refactoring attempted in r1.154. Move SIOCSIFADDRtb2018-06-031-35/+78
| | | | | | | | | | | | | to its own function and merge the two switches in in_ioctl_change_ifaddr(). Finally: each ioctl has its own case and privilege check. ok visa As an aside, an audit of the ports tree has shown that we should continue to support the legacy ioctls SIOCSIF{,BRD,DST}ADDR, SIOCSIFNETMASK despite the fact that they have been deprecated for the better part of two decades and FreeBSD dropped support 7 years ago. Too many ports still rely on them. Thanks to sthen and visa for their help with that.
* zap trailing whitespacetb2018-05-311-3/+3
|
* Re-commit the correct half of revision 1.154:tb2018-05-311-23/+27
| | | | | | | | | Some more code shuffling to get rid of one switch in in_ioctl(). This way there is one case for each of SIOCSIFBRDADDR, SIOCSIFDSTADDR and SIOCSIFNETMASK, starting with a privilege check before any global data is modified. ok visa
* Back out previous. The handling of SIOCSIFADDR is now wrong.tb2018-05-311-71/+45
|
* Some more code shuffling to get rid of one switch in each, in_ioctl()tb2018-05-311-45/+71
| | | | | | | | | | and in_ioctl_change_ifaddr(). This way there is one case per ioctl starting with a privilege check before any global data is modified. The code paths are now straightforward. Some code duplication between SIOCSIFADDR and SIOCAIFADDR, but that can be addressed later. tested by hrvoje ok visa
* Next step in disentangling the switches in in_ioctl(). Split out thetb2018-05-281-43/+75
| | | | | | | | handling of SIOCAIFADDR, SIOCDIFADDR, SIOCSIFADDR into a separate function, analogously to what was done in in6_ioctl(). tested by hrvoje ok visa
* Prepare in_ioctl() for further refactoring with the goal of merging thetb2018-05-251-10/+15
| | | | | | | | two big switches in this function. Error out early in the default case without grabbing the NET_LOCK() and move SIOCSIFNETMASK a bit up. This will reduce the noise in an upcoming diff. ok visa
* Split out the handling of SIOCGIF* into a new function, in_ioctl_get(),tb2018-05-021-32/+77
| | | | | | that only needs the read lock. ok visa, mpi
* Reduce the scope of the NET_LOCK() in in_control(). Two functions weretb2018-04-301-32/+50
| | | | | | | | | | protected: mrt_ioctl() and in_ioctl(). The former has no other callers and only needs a read lock. The latter will need refactoring to reduce the lock's scope further. In a first step, establish a single exit point and protect most of the function body with the NET_LOCK() while removing the NET_LOCK() from a handful of callers. suggested by & ok mpi, ok visa
* Make the ramdisks compile again, we don't have MROUTING on them.florian2018-04-241-7/+7
| | | | Found the hard way.
* Push NET_LOCK down in the default ifioctl case.pirofti2018-04-241-3/+10
| | | | | | | For the PRU_CONTROL bit the NET_LOCK surrounds in[6]_control() and on the ENOTSUPP case we guard the driver if_ioctl functions. OK mpi@
* Revert all the bits of the autocreate 127.0.0.1 on lo(4) creation for now.claudio2018-03-021-57/+1
| | | | This needs to go back to the drawing board.
* Kill unneeded caddr_t cast.claudio2018-02-101-2/+2
|
* Similar to the IPv6 case create 127.0.0.1/8 on lo(4) interfaces which actclaudio2018-02-101-1/+57
| | | | | | | as loopback interfaces for each rdomain (including lo0). This is done when the interface is brought up. This is now also done by default (either on attach of lo0 or when creating the rdomain). OK mpi@
* Stop calling ifp->if_ioctl() inside in{,6}_ioctl().mpi2017-11-041-4/+3
| | | | | | | | | Instead return EOPNOTSUPP and call it from ifioctl(). This will help getting per-driver ioctl routines outside of need the NET_LOCK(). While here always return ENXIO when ``ifp'' is NULL. ok visa@, florian@
* Remove some more tests checking for a non-NULL `ifp->if_ioctl'.mpi2017-10-241-5/+4
| | | | if_attach() enforces it is properly defined.
* Remove support for never used ioctls originating from KAME.mpi2017-10-241-200/+6
| | | | ok florian@, claudio@, bluhm@
* Do not test if if_ioctl is NULL, it isn't.mpi2017-10-201-6/+1
| | | | ok florian@, claudio@, visa@, bluhm@
* Validate sockaddr from userland in central functions. This resultsbluhm2017-08-111-1/+19
| | | | | | | in common checks for unix, inet, inet6 instead of partial checks here and there. Some checks are already done at a higher layer, but better be paranoid with user input. OK claudio@ millert@
* Per-interface list of addresses, both multicast and unicast, arempi2017-05-291-5/+1
| | | | | | | | | | | | | currently protected by the NET_LOCK(). They are not accessed in the hot path, so protecting them with a mutex could be an option. However since we're now going to run with a NET_LOCK() for some time, assert that it is held. IPsec is not yet ready to run without KERNEL_LOCK(), so assert it is held, even in the forwarding path. Tested by sthen@, ok visa@, claudio@, bluhm@
* Replace remaining splsoftassert(IPL_SOFTNET) by NET_ASSERT_LOCKED().mpi2017-05-161-6/+6
| | | | ok visa@
* Introduce sstosa() for converting sockaddr_storage with a type safebluhm2017-05-041-7/+6
| | | | | | | inline function instead of casting it to sockaddr. While there, use inline instead of __inline for all these conversions. Some struct sockaddr casts can be avoided completely. OK dhill@ mpi@
* Fix the prefixlen sent by RTM_NEWADDR on new addresses without masks:rzalamena2017-03-271-10/+11
| | | | | | | calculate the prefixlen using the address before sending the RTM_NEWADDR message. ok claudio@
* Revert "Release the NET_LOCK() before entering per-driver ioctl() routine".mpi2017-02-161-4/+1
| | | | | | | | | | | | | | | This is most likely to be the cause of the deadlock seen by port builders since it's the only changed that happened after a2k17. Instead bring back pirofti@ original hack to release the NET_LOCK() inside iwm(4) and iwn(4). This fixes some splassert reported by bluhm@ Deadlock reported by naddy@ and rpe@ and ajacoutot@ confirmed the deadlock has been introduced post a2k17. Tested by and ok tb@
* Release the NET_LOCK() before entering per-driver ioctl() routine.mpi2017-02-071-2/+6
| | | | | | | | | This prevents a deadlock with the X server and some wireless drivers. The real fix is to take unix domain socket code out of the NET_LOCK(). Issue reported by pirofti@ and ajacoutot@ ok tb@, stsp@, pirofti@
* Remove duplicate in_ioctl() prototype, it is in in_var.h now.bluhm2016-12-201-2/+1
|
* Remove a recursive splsoftnet() in in_ioctl() that already asserts thatmpi2016-12-191-5/+1
| | | | it is called at IPL_SOFTNET.
* If rt_ifa_addlocal() in in_ifinit() fails, the address has beenbluhm2016-12-191-3/+10
| | | | | | | | added to the interface address list, but the local route is missing. This inconsistency could result in a "ifa == rt->rt_ifa" assertion panic later. So in case of a route add error, remove the interface address to get a consistent state again. OK stsp@ mpi@
* Remove recursive splsoftnet()s in ioctl(2) path.mpi2016-12-051-13/+7
|
* Purge routes attached to an address when this address is removed.mpi2016-09-041-1/+4
| | | | | | | This is done to stop using stale ifa attached to routes, which is the easiest way to make rtisvalid(9) MP-safe. sthen@ and henning@ like it, ok claudio@
* Move the ioctl(2) logic of in{,6}_control() into two new functionsmpi2016-06-131-20/+31
| | | | | | | | | in{,6}_ioctl() that do not deal with sockets. This will allow to automagically configure interface addresses in the kernel without too many layer violations. Required by upcoming umb(4).
* Put a KERNEL_LOCK/UNLOCK dance around sections that still need somempi2016-04-181-1/+3
| | | | | | work in the forwarding path. Tested by Hrvoje Popovski, ok dlg@
* Introduce in{,6}_hasmulti(), two functions to check in the hot path ifmpi2016-01-211-1/+16
| | | | | | an interface joined a specific multicast group. ok phessler@, visa@, dlg@
* Get rid of rt_mask() and stop allocating a "struct sockaddr" for everympi2015-12-031-1/+10
| | | | | | | | | | | | | route entry in ART. rt_plen() now represents the prefix length of a route entry and should be used instead. For now use a "struct sockaddr_in6" to represent the mask when needed, this should be then replaced by the prefix length and RTA_NETMASK only used for compatibility with userland. ok claudio@
* No need for <net/if_types.h>mpi2015-11-241-6/+1
| | | | As a bonus this removes a "#if NCARP > 0", say yeah!
* Now that rtrequest1(9) properly sets RTF_UP for newly added route,mpi2015-09-121-5/+4
| | | | | | stop passing it in every rt_ifa_add(9) calls. ok claudio@
* gotta if_put after you if_getdlg2015-09-091-1/+2
| | | | ok mpi@