summaryrefslogtreecommitdiffstats
path: root/sys/netinet6/ip6_mroute.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* kernel: use gettime(9)/getuptime(9) in lieu of time_second(9)/time_uptime(9)cheloha2020-06-241-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | time_second(9) and time_uptime(9) are widely used in the kernel to quickly get the system UTC or system uptime as a time_t. However, time_t is 64-bit everywhere, so it is not generally safe to use them on 32-bit platforms: you have a split-read problem if your hardware cannot perform atomic 64-bit reads. This patch replaces time_second(9) with gettime(9), a safer successor interface, throughout the kernel. Similarly, time_uptime(9) is replaced with getuptime(9). There is a performance cost on 32-bit platforms in exchange for eliminating the split-read problem: instead of two register reads you now have a lockless read loop to pull the values from the timehands. This is really not *too* bad in the grand scheme of things, but compared to what we were doing before it is several times slower. There is no performance cost on 64-bit (__LP64__) platforms. With input from visa@, dlg@, and tedu@. Several bugs squashed by visa@. ok kettenis@
* Document the various flavors of NET_LOCK() and rename the reader version.mpi2020-05-271-5/+5
| | | | | | | | | | 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@
* Add RCS Id.bluhm2019-09-041-0/+1
|
* Fix a route use after free in IPv6 multicast route. Move thebluhm2019-09-041-35/+36
| | | | | | | | | | | | | mrt6_mcast6_del() out of the rtable_walk(). This avoids recursion to prevent stack overflow. Also it allows freeing the route outside of the walk. Now mrt6_mcast_del() frees the route only when it is deleted from the routing table. If that fails, it must not be freed. After the route is returned by mf6c_find(), it is reference counted. Then we need a rtfree(), but not in the other case. Name mrt6_mcast_add() and mrt6_mcast_del() consistently. Move rt_timer_remove_all() into mrt6_mcast_del(). Reported-by: syzbot+af7d510593d74c825960@syzkaller.appspotmail.com OK mpi@
* Prevent recursions by not deleting entries inside rtable_walk(9).mpi2019-06-211-3/+5
| | | | | | | | | | | | | | | rtable_walk(9) now passes a routing entry back to the caller when a non zero value is returned and if it asked for it. This allows us to call rtdeletemsg()/rtrequest_delete() from the caller without creating a recursion because of rtflushclone(). Multicast code hasn't been adapted and is still possibly creating recursions. However multicast route entries aren't cloned so if a recursion exists it isn't because of rtflushclone(). Fix stack exhaustion triggered by the use of "-msave-args". Issue reported by Dániel Lévai on bugs@ confirmed by and ok bluhm@.
* Add missing NULL check for the protocol control block (pcb) pointer inanton2019-06-041-0/+3
| | | | | | | | | | mrt{6,}_ioctl. Calling shutdown(2) on the socket prior to the ioctl command can cause it to be NULL. ok bluhm@ claudio@ Reported-by: syzbot+bdc489ecb509995a21ed@syzkaller.appspotmail.com Reported-by: syzbot+156405fdea9f2ab15d40@syzkaller.appspotmail.com
* change rt_ifa_add and rt_ifa_del so they take an rdomain argument.dlg2019-02-131-1/+2
| | | | | | | | | | | | 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-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* RT_TABLEID_MAX is 255, fix places that assumed that it is less than 255.reyk2018-10-101-3/+3
| | | | | | | | | | rtable 255 is a valid routing table or domain id that wasn't handled by the ip[6]_mroute code or by snmpd. The arrays in the ip[6]_mroute code where off by one and didn't allocate space for rtable 255; snmpd simply ignored rtable 255. All other places in the tree seem to handle RT_TABLEID_MAX correctly. OK florian@ benno@ henning@ deraadt@
* Push the NET_LOCK() down in in6_control() similar to what was donetb2018-05-021-5/+14
| | | | | | | | | for in_control(). Protect mrt6_ioctl() and nd6_ioctl() with a read lock and in6_ioctl with the NET_LOCK() while establishing a single exit point. tested by kn ok florian, mpi, visa
* Assert that the corresponding socket is locked when manipulating socketmpi2017-06-261-1/+1
| | | | | | | | | | | | | | | | buffers. This is one step towards unlocking TCP input path. Note that all the functions asserting for the socket lock are not necessarilly MP-safe. All the fields of 'struct socket' aren't protected. Introduce a new kernel-only kqueue hint, NOTE_SUBMIT, to be able to tell when a filter needs to lock the underlying data structures. Logic and name taken from NetBSD. Tested by Hrvoje Popovski. ok claudio@, bluhm@, mikeb@
* Optimize multicast packet sending by using m_dup_pkt() instead ofrzalamena2017-05-171-4/+1
| | | | | | | | m_copym() for cloning packets. m_dup_pkt() creates a new mbuf with the whole packet content and also pre allocates the space for layer 2 headers (Ethernet/VLAN). ok mikeb@
* Replace remaining splsoftassert(IPL_SOFTNET) by NET_ASSERT_LOCKED().mpi2017-05-161-7/+7
| | | | ok visa@
* Make the IPv6 multicast routing code use the OpenBSD routing tablerzalamena2017-05-161-476/+518
| | | | | | | instead of implementing its own. This makes the IPv6 multicast routing code look more like the IPv4 version. ok bluhm@, mpi@
* Added initial IPv6 multicast routing support for multiple rdomains:rzalamena2017-05-081-156/+128
| | | | | | | | * don't share mifs (multicast interface) between rdomains * allow multiple routing sockets connected at the same time if they are in different rdomains. ok bluhm@
* Use percpu counters for ip6statjca2017-02-051-2/+2
| | | | | | | | | Try to follow the existing examples. Some notes: - don't implement counters_dec() yet, which could be used in two similar chunks of code. Let's see if there are more users first. - stop incrementing IPv6-specific mbuf stats, IPv4 has no equivalent. Input from mpi@, ok bluhm@ mpi@
* In sogetopt, preallocate an mbuf to avoid using sleeping mallocs withdhill2017-02-011-3/+1
| | | | | | | | the netlock held. This also changes the prototypes of the *ctloutput functions to take an mbuf instead of an mbuf pointer. help, guidance from bluhm@ and mpi@ ok bluhm@
* Kill various splsoftnet().mpi2017-01-061-63/+22
| | | | ok rzalamena@, visa@
* Remove PIM support from the multicast stack.rzalamena2016-12-221-398/+2
| | | | ok mpi@
* Convert some of the remaining usages of time_second to time_uptime.mpi2016-10-031-2/+2
| | | | | | | | | | | | | | | | time_second is unix time so it can be affected by clock changes. time_uptime is monotonic so it isnt affected by clock changes. that in turn means route expiries wont jump with clock changes if set against time_uptime. the expiry is translated into unix time for export to userland though. Should fix mismatch between route timers that were already converted and ND default routers that were still using time_second. Tested by matthieu@ and sthen@ ok sthen@, dlg@
* Do not use a single global struct route_in6 to cache route lookups.mpi2016-08-231-9/+9
| | | | | | This is a little step towards deprecating 'struct route{,_in6}'. ok jca@, claudio@
* Kill nd6_output(), it doesn't do anything since the resolution logicmpi2016-06-151-4/+0
| | | | | | has been moved to nd6_resolve(). ok visa@, millert@, florian@, sthen@
* Introduce in{,6}_hasmulti(), two functions to check in the hot path ifmpi2016-01-211-3/+1
| | | | | | an interface joined a specific multicast group. ok phessler@, visa@, dlg@
* add sizes to some free() calls. ok claudiotedu2015-12-031-15/+15
|
* Do not cast malloc(9) results.mpi2015-11-131-6/+3
|
* Do not try to guess if there's still an IPv4 multicast routing daemonmpi2015-11-121-28/+18
| | | | | | | | using an interface based on the value of ``ip_mrouter''. Calling SIOCDELMULTI on an interface is correct even if such daemon is running because the Ethernet layer refcounts currently joined multicast groups.
* Unbreak adding a MIFF_REGISTER interface.mpi2015-11-121-5/+4
| | | | | Such interface is created on the fly so if_get() could return NULL because mif6c_pifi doesn't mean what you think in this case.
* unidef MRT6DEBUGmpi2015-11-121-258/+11
|
* More PIM love. Reduce differences with ip_mroute.c and dynamicallympi2015-11-121-47/+73
| | | | allocate the register ifp such that if_get() works.
* Sync headers and get rid of #ifdef MROUTING.mpi2015-11-121-21/+2
|
* Fix PIM build.mpi2015-11-121-3/+5
|
* Remove linkmtu and maxmtu from struct nd_ifinfo. IN6_LINKMTU can nowflorian2015-10-281-4/+3
| | | | | die and ifp->if_mtu is the one true mtu. Suggested by and OK mpi@
* There's no point in abstracting ifp->if_output() as long as pf_test()mpi2015-09-131-1/+2
| | | | | | needs to see lo0 in the output path. ok claudio@
* Stop overwriting the rt_ifp pointer of RTF_LOCAL routes with lo0ifp.mpi2015-09-121-2/+1
| | | | | | | | | Use instead the RTF_LOCAL flag to loop local traffic back to the corresponding protocol queue. With this change rt_ifp is now always the same as rt_ifa->ifa_ifp. ok claudio@
* Introduce if_input_local() a function to feed local traffic back tompi2015-09-121-2/+2
| | | | | | | | | | the protocol queues. It basically does what looutput() was doing but having a generic function will allow us to get rid of the loopback hack overwwritting the rt_ifp field of RTF_LOCAL routes. ok mikeb@, dlg@, claudio@
* Kill yet another argument to functions in IPv6. This time ip6_output'sclaudio2015-09-111-1/+1
| | | | | | | ifpp - XXX: just for statistics ifpp is always NULL in all callers so that statistic confirms ifpp is dying OK mpi@
* More complicated if_put dance. Special handling for multicast_register_ifclaudio2015-09-101-3/+10
| | | | | which is probably not even needed here but who knows for sure. OK dlg@
* In kernel initialize struct sockaddr_in and sockaddr_in6 to zerobluhm2015-08-241-0/+3
| | | | | | | everywhere to avoid passing around pointers to uninitialized stack memory. While there, fix the call to in6_recoverscope() in fill_drlist(). OK deraadt@ mpi@
* rename mbuf ** parameter from m to mp, to match other similar codederaadt2015-07-151-3/+3
|
* Pass an interface index instead of a pointer to in6_addr2scopeid().mpi2015-07-081-4/+4
| | | | ok millert@
* Get rid of the undocumented & temporary* m_copy() macro added formpi2015-06-301-6/+7
| | | | | | | | compatibility with 4.3BSD in September 1989. *Pick your own definition for "temporary". ok bluhm@, claudio@, dlg@
* Store a unique ID, an interface index, rather than a pointer to thempi2015-06-161-5/+5
| | | | | | | | | | | | | | | receiving interface in the packet header of every mbuf. The interface pointer should now be retrieved when necessary with if_get(). If a NULL pointer is returned by if_get(), the interface has probably been destroy/removed and the mbuf should be freed. Such mechanism will simplify garbage collection of mbufs and limit problems with dangling ifp pointers. Tested by jmatthew@ and krw@, discussed with many. ok mikeb@, bluhm@, dlg@
* More damned eye searing whitespace. No change to .o files.krw2015-06-081-25/+25
|
* Remove some includes include-what-you-use claims don'tjsg2015-03-141-1/+0
| | | | | | | have any direct symbols used. Tested for indirect use by compiling amd64/i386/sparc64 kernels. ok tedu@ deraadt@
* Implement 2 sysctl to retrieve the multicast forwarding cache (mf6c) and theclaudio2015-02-091-0/+95
| | | | | multicast interface table (mif6). Will be used by netstat soon. Looked over by guenther@
* convert the multicast filter hash to use siphash, like i did fordlg2015-02-091-4/+18
| | | | | | ip_mroute.c requested by and ok claudio@
* Rename some of the functions by adding a 6 so they do not conflict withclaudio2015-02-081-23/+23
| | | | | the still static functions in ip_mroute.c OK phessler, henning
* unifdef INET in net code as a precursor to removing the pretend option.tedu2014-12-191-4/+0
| | | | | long live the one true internet. ok henning mikeb
* Remove the "multicast_" prefix from the fields a multicast-only struct.mpi2014-12-171-2/+2
| | | | Prodded by claudio@ and mikeb@