summaryrefslogtreecommitdiff
path: root/sys/netinet/in.c
AgeCommit message (Collapse)Author
2018-07-11Disambiguate the source of panics in sys/net* by adding __func__Nayden Markatchev
magic constant to panic() calls. ok benno@ henning@ tb@
2018-06-03SIOCSIFNETMASK takes a 'struct ifreq', so use 'ifr' for it and drop theTheo Buehler
now unused 'ifra' from in_ioctl(). Discussed with mpi and visa
2018-06-03Better version of the refactoring attempted in r1.154. Move SIOCSIFADDRTheo Buehler
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.
2018-05-31zap trailing whitespaceTheo Buehler
2018-05-31Re-commit the correct half of revision 1.154:Theo Buehler
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
2018-05-31Back out previous. The handling of SIOCSIFADDR is now wrong.Theo Buehler
2018-05-31Some more code shuffling to get rid of one switch in each, in_ioctl()Theo Buehler
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
2018-05-28Next step in disentangling the switches in in_ioctl(). Split out theTheo Buehler
handling of SIOCAIFADDR, SIOCDIFADDR, SIOCSIFADDR into a separate function, analogously to what was done in in6_ioctl(). tested by hrvoje ok visa
2018-05-25Prepare in_ioctl() for further refactoring with the goal of merging theTheo Buehler
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
2018-05-02Split out the handling of SIOCGIF* into a new function, in_ioctl_get(),Theo Buehler
that only needs the read lock. ok visa, mpi
2018-04-30Reduce the scope of the NET_LOCK() in in_control(). Two functions wereTheo Buehler
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
2018-04-24Make the ramdisks compile again, we don't have MROUTING on them.Florian Obser
Found the hard way.
2018-04-24Push NET_LOCK down in the default ifioctl case.Paul Irofti
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@
2018-03-02Revert all the bits of the autocreate 127.0.0.1 on lo(4) creation for now.Claudio Jeker
This needs to go back to the drawing board.
2018-02-10Kill unneeded caddr_t cast.Claudio Jeker
2018-02-10Similar to the IPv6 case create 127.0.0.1/8 on lo(4) interfaces which actClaudio Jeker
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@
2017-11-04Stop calling ifp->if_ioctl() inside in{,6}_ioctl().Martin Pieuchot
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@
2017-10-24Remove some more tests checking for a non-NULL `ifp->if_ioctl'.Martin Pieuchot
if_attach() enforces it is properly defined.
2017-10-24Remove support for never used ioctls originating from KAME.Martin Pieuchot
ok florian@, claudio@, bluhm@
2017-10-20Do not test if if_ioctl is NULL, it isn't.Martin Pieuchot
ok florian@, claudio@, visa@, bluhm@
2017-08-11Validate sockaddr from userland in central functions. This resultsAlexander Bluhm
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@
2017-05-29Per-interface list of addresses, both multicast and unicast, areMartin Pieuchot
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@
2017-05-16Replace remaining splsoftassert(IPL_SOFTNET) by NET_ASSERT_LOCKED().Martin Pieuchot
ok visa@
2017-05-04Introduce sstosa() for converting sockaddr_storage with a type safeAlexander Bluhm
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@
2017-03-27Fix the prefixlen sent by RTM_NEWADDR on new addresses without masks:Rafael Zalamena
calculate the prefixlen using the address before sending the RTM_NEWADDR message. ok claudio@
2017-02-16Revert "Release the NET_LOCK() before entering per-driver ioctl() routine".Martin Pieuchot
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@
2017-02-07Release the NET_LOCK() before entering per-driver ioctl() routine.Martin Pieuchot
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@
2016-12-20Remove duplicate in_ioctl() prototype, it is in in_var.h now.Alexander Bluhm
2016-12-19Remove a recursive splsoftnet() in in_ioctl() that already asserts thatMartin Pieuchot
it is called at IPL_SOFTNET.
2016-12-19If rt_ifa_addlocal() in in_ifinit() fails, the address has beenAlexander Bluhm
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@
2016-12-05Remove recursive splsoftnet()s in ioctl(2) path.Martin Pieuchot
2016-09-04Purge routes attached to an address when this address is removed.Martin Pieuchot
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@
2016-06-13Move the ioctl(2) logic of in{,6}_control() into two new functionsMartin Pieuchot
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).
2016-04-18Put a KERNEL_LOCK/UNLOCK dance around sections that still need someMartin Pieuchot
work in the forwarding path. Tested by Hrvoje Popovski, ok dlg@
2016-01-21Introduce in{,6}_hasmulti(), two functions to check in the hot path ifMartin Pieuchot
an interface joined a specific multicast group. ok phessler@, visa@, dlg@
2015-12-03Get rid of rt_mask() and stop allocating a "struct sockaddr" for everyMartin Pieuchot
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@
2015-11-24No need for <net/if_types.h>Martin Pieuchot
As a bonus this removes a "#if NCARP > 0", say yeah!
2015-09-12Now that rtrequest1(9) properly sets RTF_UP for newly added route,Martin Pieuchot
stop passing it in every rt_ifa_add(9) calls. ok claudio@
2015-09-09gotta if_put after you if_getDavid Gwynne
ok mpi@
2015-08-24In kernel initialize struct sockaddr_in and sockaddr_in6 to zeroAlexander Bluhm
everywhere to avoid passing around pointers to uninitialized stack memory. While there, fix the call to in6_recoverscope() in fill_drlist(). OK deraadt@ mpi@
2015-07-08Use a new RTF_CONNECTED flag for interface (connected) routes.Martin Pieuchot
Recent changes to support multiple interface routes broke the assumption made by all our userland routing daemons concerning interface routes. Historically such routes had a "gateway" sockaddr of type AF_LINK. But to be able to support multiple interface routes as any other multipath routes, they now have a unique "gateway" sockaddr containing their corresponding IP address. This self-describing flag should avoid ambiguity when dealing with interface routes. Issue reported by <mxb AT alumni DOT chalmers DOT se> and benno@ ok claudio@, benno@
2015-07-06We're now creating a connected route for every configured address soMartin Pieuchot
there's no need to flag every address as IFA_ROUTE.
2015-07-06No longer need to manually pass RTF_MPATH to rt_ifa_add(9).Martin Pieuchot
2015-05-26Store the IP address of the corresponding ifa in the rt_gateway fieldMartin Pieuchot
of RTF_CLONING and RTF_BROASCAST routes to not create MPATH conflicts when IP address aliases are used. This change makes it possible to have multiple RTF_CLONING routes with the same priority. Note that any of the existing RTF_CLONING route might be used by the kernel to create a RTF_CLONED route which should not be a problem with aliases since they are attached to the same ifp. This unbreak address aliases since the kernel supports multiple connected routes for a subnet. Found the hardway by djm@, ok claudio@
2015-05-15Allow multiple connected/interface routes to exist at the same time.Claudio Jeker
Use the existing multipath code. Switch away from using the ifa address when making the cloning route and instead put a dummy sockaddr_dl route in. With this it is possible to use the same network on multiple interfaces at the same time. So if wireless and ethernet share the same network the system will use the wired connection as long as there is link. Still missing is builtin proxy-arp for the other interface IPs to allow hitless failover. OK mpi@
2015-01-12Kill the global list of IPv4 addresses.Martin Pieuchot
ok claudio@, mikeb@, bluhm@
2015-01-05Explicitly check for a non NULL ifp in in_control(). Only MROUTINGMartin Pieuchot
ioctl(2)s are an exception to this rule. This makes clear that ifa cannot be used initialized as found by jsg@ with gcc/clang. ok krw@, bluhm@, jca@
2014-12-19unifdef INET in net code as a precursor to removing the pretend option.Ted Unangst
long live the one true internet. ok henning mikeb
2014-11-25Since in_broadcast() is now used to always iterate on all the interfacesMartin Pieuchot
of your system, put it on a diet and kill the superfluous logic. ok mikeb@
2014-11-24Rename rt_ifa_addloop() into rt_ifa_addlocal() and make it return anMartin Pieuchot
error code on failure (unchecked for the moment). ok mikeb@, jmc@