summaryrefslogtreecommitdiffstats
path: root/sys/netinet/ip_mroute.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* 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@
* Fix a route use after free in multicast route. Move the rt_mcast_del()bluhm2019-09-021-33/+36
| | | | | | | | | | | out of the rtable_walk(). This avoids recursion to prevent stack overflow. Also it allows freeing the route outside of the walk. Now mrt_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 mfc_find(), it is reference counted. Then we need a rtfree(), but not in the other caes. Move rt_timer_remove_all() into rt_mcast_del(). OK mpi@
* Prevent recursions by not deleting entries inside rtable_walk(9).mpi2019-06-211-4/+6
| | | | | | | | | | | | | | | 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-1/+4
| | | | | | | | | | 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-2/+3
| | | | | | | | | | | | 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-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | 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-5/+5
| | | | | | | | | | 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@
* Reduce the scope of the NET_LOCK() in in_control(). Two functions weretb2018-04-301-1/+5
| | | | | | | | | | 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
* Change sosetopt() to no longer free the mbuf it receives and changempi2017-09-011-2/+1
| | | | | | all the callers to call m_freem(9). Support from deraadt@ and tedu@, ok visa@, bluhm@
* Assert that the corresponding socket is locked when manipulating socketmpi2017-06-261-2/+2
| | | | | | | | | | | | | | | | 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@
* The IP multicast forward functions return an errno, call the variablebluhm2017-06-191-3/+2
| | | | | | error. Make the ip_mforward() return value consistent. Simplify the caller logic in ipv6_input() like in IPv4. OK mpi@
* Sync three changes that were caught by IPv6 multicast routing review:rzalamena2017-05-161-4/+13
| | | | | | | | * use a variable to allow disabling debugs on run-time * fix a potential memory leak on copyout() failure * don't just blindly use the first address provided by ifalist ok bluhm@
* Make return values more meaningful by using errno instead of -1 or 1.rzalamena2017-05-161-10/+6
| | | | ok bluhm@
* Replace remaining splsoftassert(IPL_SOFTNET) by NET_ASSERT_LOCKED().mpi2017-05-161-6/+6
| | | | ok visa@
* Let malloc() block when the caller of the add route function isrzalamena2017-05-161-12/+13
| | | | | | | setsockopt(), otherwise use non-blocking malloc() for network stack calls. ok bluhm@
* Call rtfree() after each use of routes and make sure the route is validrzalamena2017-05-161-15/+50
| | | | | | | | when finding one. Since rtfree() is being called and rt_llinfo being removed, add checks everywhere to make sure we are using a route that is not being removed. ok bluhm@
* Convert bcopy to memcpy where the memory does not overlap, otherwise,dhill2017-04-061-4/+4
| | | | | | | use memmove. While here, change some previous conversions to a simple assignment. ok deraadt@
* Be more strict on all route iterations, lets always make sure that werzalamena2017-03-171-1/+11
| | | | | | are not going to get a unicast route by accident. ok mpi@
* Make mfc_find() more strict when looking for routes, fixes a problemrzalamena2017-03-141-5/+8
| | | | | | | | | causing ip_mforward() not to send packets to the userland multicast routing daemon. Reported and tested by Paul de Weerd. ok bluhm@, claudio@
* Unbreak 'netstat -g' and make multicast route stats sysctl more robust.rzalamena2017-02-091-30/+47
| | | | ok mpi@
* Test for NULL before dereferencing a pointer not after.jsg2017-02-081-2/+4
| | | | ok krw@
* In sogetopt, preallocate an mbuf to avoid using sleeping mallocs withdhill2017-02-011-18/+13
| | | | | | | | 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@
* Clean up multicast files from unused definitions and comments.rzalamena2017-01-121-36/+2
| | | | ok mpi@
* Remove mfc hash tables and use the OpenBSD routing table for multicastrzalamena2017-01-111-395/+413
| | | | | | | routes. Beside the code simplification and removal, we also get to see the multicast routes now in the route(8) utility. ok mpi@
* Remove the global viftable vector that holds the virtual interfacesrzalamena2017-01-061-143/+116
| | | | | | | | configuration and instead use ifnet to store the configuration and counters. With this we can safely use multicast routing daemons on multiple domains without vif id colisions. ok mpi@
* Simplify code by removing some old pullup macro, killing some variablesrzalamena2017-01-061-19/+10
| | | | | | | | and using m_dup_pkt() instead of m_copym() with max_linkhdr space adjust on packet sending to avoid more mbuf allocations. with input from millert@ and mikeb@, ok mikeb@
* Kill various splsoftnet().mpi2017-01-061-59/+19
| | | | ok rzalamena@, visa@
* Remove some unnecessary code abstractions and while here remove arzalamena2017-01-051-46/+31
| | | | | | splsoftnet. ok mikeb@
* Remove PIM support from the multicast stack.rzalamena2016-12-221-661/+2
| | | | ok mpi@
* Fix build without PIM defined.mpi2016-12-211-2/+2
|
* Fix PIM compilation even though it is disabled.rzalamena2016-12-211-10/+13
| | | | ok bluhm@
* Call the multicast timer callback per domain instead of for all domainsrzalamena2016-12-201-20/+15
| | | | | | | this way we save doing big tables walk and iterating tables that we don't need to. ok mpi@
* Remove unused timeout that was never being set.rzalamena2016-12-201-3/+1
| | | | ok reyk@
* Kill unused function.rzalamena2016-12-191-27/+1
| | | | ok mpi@
* Extend the multicast sockets and multicast hash table support to multiplerzalamena2016-12-191-87/+136
| | | | | | | domains. This is one step towards supporting to run more than one multicast socket in different domains at the same time. ok mpi@
* Propagate the routing table id in ip_mrouter_set() so the MRT_ADD_VIFrzalamena2016-12-131-5/+7
| | | | | | calls won't fail anymore when doing from a different rdomain. ok mpi@
* Kill unused 'struct route'.mpi2016-11-291-2/+1
|
* m_free() and m_freem() test for NULL. Simplify callers which had their ownjsg2016-11-291-3/+2
| | | | | | NULL tests. ok mpi@
* use hashfree. from Mathieu -tedu2016-09-241-2/+2
| | | | ok guenther
* Sync no-argument function declaration and definition by adding (void).naddy2016-03-071-2/+2
| | | | ok mpi@ millert@
* Remove mrtdebug and reduce differences with the v6 version.mpi2015-11-141-108/+3
| | | | Debug informations can already be accessed via mrtstat and pimstat.
* Do not cast malloc(9) results.mpi2015-11-131-7/+4
|
* Kill another tunnel leftover and keep PIM stuff inside #ifdef PIM.mpi2015-11-131-13/+11
|
* Kill another leftover from the tunnel support removal and add more PIM.mpi2015-11-121-39/+16
|
* Sync headers and get rid of #ifdef MROUTING.mpi2015-11-121-8/+4
|
* Remove VIFF_TUNNEL leftovers, tunnels aren't supported since 2006.mpi2015-11-121-109/+22
| | | | Even pimd(8) no longer support them.
* Fix PIM build.mpi2015-11-121-2/+2
|
* 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@
* Replace sockaddr casts with the proper satosin(), ... calls.bluhm2015-09-011-2/+2
| | | | From David Hill; OK mpi@; tested kspillner@; tweaks bluhm@