summaryrefslogtreecommitdiffstats
path: root/sys/netinet/in.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* In kernel initialize struct sockaddr_in and sockaddr_in6 to zerobluhm2015-08-241-2/+4
| | | | | | | everywhere to avoid passing around pointers to uninitialized stack memory. While there, fix the call to in6_recoverscope() in fill_drlist(). OK deraadt@ mpi@
* Use a new RTF_CONNECTED flag for interface (connected) routes.mpi2015-07-081-3/+4
| | | | | | | | | | | | | | | | | 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@
* We're now creating a connected route for every configured address sompi2015-07-061-8/+2
| | | | there's no need to flag every address as IFA_ROUTE.
* No longer need to manually pass RTF_MPATH to rt_ifa_add(9).mpi2015-07-061-3/+3
|
* Store the IP address of the corresponding ifa in the rt_gateway fieldmpi2015-05-261-5/+4
| | | | | | | | | | | | | | | 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@
* Allow multiple connected/interface routes to exist at the same time.claudio2015-05-151-124/+4
| | | | | | | | | | | 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@
* Kill the global list of IPv4 addresses.mpi2015-01-121-54/+65
| | | | ok claudio@, mikeb@, bluhm@
* Explicitly check for a non NULL ifp in in_control(). Only MROUTINGmpi2015-01-051-23/+18
| | | | | | | 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@
* unifdef INET in net code as a precursor to removing the pretend option.tedu2014-12-191-3/+1
| | | | | long live the one true internet. ok henning mikeb
* Since in_broadcast() is now used to always iterate on all the interfacesmpi2014-11-251-22/+5
| | | | | | of your system, put it on a diet and kill the superfluous logic. ok mikeb@
* Rename rt_ifa_addloop() into rt_ifa_addlocal() and make it return anmpi2014-11-241-4/+4
| | | | | | error code on failure (unchecked for the moment). ok mikeb@, jmc@
* sizes for simple free cases. sizeof(*) and one case where len is clear.tedu2014-11-201-3/+3
|
* funky spacing.mpi2014-11-201-2/+2
|
* Instead of playing hide-and-seek with the route to destination attachedmpi2014-11-201-85/+18
| | | | | | | | to p2p interfaces always mark them as Multipath. This way we can have multiple routes to the same destination as long as the local address is different. ok mikeb@
* Did you ever wonder why loopback's ifas have a destination address?mpi2014-11-051-3/+1
| | | | | | | | | It is of course not to make your life more complicated when you are dealing with ifa_ifwithaddr()! It was to reuse the point-to-point code to add a route to 127.0.0.1. But now we have local routes and we don't need this hack anymore :) ok mikeb@ as part of a larger diff.
* Do not protect the SIOCSIFADDR call by splnet(). Drivers alreadympi2014-10-071-5/+2
| | | | | | | | | | | | raise it inside their ioctl handler (except for carp(4), what else?). In general, global structures manipulated in the softnet codepath only require a splsoftnet() protection when they are modified in process (ioctl) context. Also put some IPL_SOFNET asserts in functions accessing global structures. Previous version diff ok mikeb@, with inputs from and ok bluhm@
* There is no point in trying to purge the default host route formpi2014-10-021-4/+4
| | | | | | loopback interfaces because we no longer add it. ok claudio@
* Fix loopback related breakage introduced by the conversion of in_ouraddr()mpi2014-10-011-4/+4
| | | | | | | | | to use the routing table. Do not create a host route for loopback addresses apart from the local ones otherwise these addresses are not considered as part of the machine. Reported by deraadt@ and Heiko Zimmermann on bugs@.
* When a route to prefix (connected route) is added, if its associatedmpi2014-09-031-19/+45
| | | | | | | | | | | | | | | | | | broadcast address is non null, add a broadcast entry flagged with RTF_BROADCAST. Re-use the existing logic to switch a route to prefix from an ifa to another to also move this broadcast entry. Prior to this change broadcast entries were simple clonned ARP entries, that would be deleted once their timer expired since they would always be incomplete. With this change they are now persistant and identifiable with a new flag This version of the diff prevent a corruption reported by millert@ ok mikeb@, florian@
* Move splnet() in in_ifinit() to protect less code that does notbluhm2014-08-231-10/+5
| | | | | need it. OK mpi@
* add a size argument to free. will be used soon, but for now default to 0.tedu2014-07-121-3/+3
| | | | after discussions with beck deraadt kettenis.
* Always create a local route for every configured IPv4 address on thempi2014-07-121-2/+7
| | | | | | | | | | | | | | | | machine and restore the original behavior of RTM_ADD and RTM_DELETE by always generating one message per locally configured address. This time, make sure the local route is removed during an address change, since at least pppoe(4) do some funky magics with wildcard addresses that might corrupt the routing tree, as found by naddy@ Also do not add a local route if the specified address is 0.0.0.0, to prevent a tree corruption, as found by guenther@. Putting this in now so that it gets tested, claudio@ agrees. Please contact me if you find any route-related regression caused by this change.
* Calling in{6,}_purgeaddr() is not enough to remove an address frommpi2014-06-261-1/+2
| | | | | | | | | | | | an interface. Two other operations are performed when issuing a SIOCDIFADDR{_IN6,} ioctl: call the address hook and the per-driver ioctl function. Since carp(4) relies on an address hook to recalculate its hash, make sure to call this hook when IFXF_NOINET6 is set or when the rdomain is changed. ok henning@, mikeb@
* Revert "Always create a local route for every configured IPv4 address",mpi2014-06-161-4/+1
| | | | | | it introduces a regression with default routes & p2p interfaces. Problem reported by naddy@
* Always create a local route for every configured IPv4 address on thempi2014-06-111-1/+4
| | | | | | | machine and restore the original behavior of RTM_ADD and RTM_DELETE by always generating one message per locally configured address. Tested by krw@, jca@ and florian@
* Kill in_localaddr(), one less usage of the global list of IPv4 addresses.mpi2014-04-251-17/+1
| | | | | | | | | | This function is used only once in our tree to optimize the size of the MSS if the forward address correspond to a host on one of our subnets, but only if ip.mutdisc is disable, which is not the default! While here get rid of the "#ifdef RTV_MTU", it is here. ok henning@, mikeb@, bluhm@
* Retire rtinit() an use rt_ifa_add(9) and rt_ifa_del(9) to managempi2014-04-101-14/+17
| | | | | | | | | | connected routes to prefixes/hosts. Since the introduction of rt_ifa_addloop(9) and rt_ifa_delloop(9), rtinit() was just a wrapper, so use the underlying functions directly and document them. Inputs from and ok mikeb@, manpage tweaks from jmc@
* Stop mixing interface address flags with routing entry ones.mpi2014-03-271-10/+10
| | | | | | | | | | Instead of always copying ifa_flags to the routing entry flags when creating a route by calling rtinit(), explicitly pass the RTF_CLONING flag when required. This means ifa_flags are now *only* used to check if an address has an associated route that was created by the kernel auto-magically. ok benno@
* Split the magic to add a connected route for every new IPv4 addressmpi2014-03-211-72/+136
| | | | | | | | | | | | | added to an interface into two functions: one for route to prefix and one for route to host. This magic has been added to work around the behavior of rtinit() and preserve the connected route to prefix when the first address of a subnet is removed. Since this "feature" has been present for point- to-point interfaces too for more than 10 years, this diff does not change anything in this regard, even if I'm not sure it makes sense. Tested by benno@
* Add missing parens so 'if' statement controls both of the statementskrw2014-03-141-2/+3
| | | | | | it was intended to control. No real-world change say mikeb@ and mpi@. ok mpi@
* Do not clean the multicast records of an interface when it is destroyedmpi2014-01-211-20/+15
| | | | | | | | | | | (unplugged). Even if it makes no sense to keep them around if the interface is no more, we cannot safely remove them since pcb multicast options might keep a pointer to them. Fixes a user after free introduced by the multicast address linking rewrite and reported by Alexey Suslikov, thanks! ok claudio@
* bcopy -> memcpy. reviewed with one fix from matthewtedu2013-12-311-18/+18
|
* Change the way protocol multicast addresses are linked to an interface.mpi2013-11-281-47/+50
| | | | | | | | | | | | | | | | | | | | | | Instead of linking multicast records to the first configured address of the corresponding protocol, making this address and its position in the global list special, add them to a new list directly linked to the interface descriptor. This new multicast address list is similar to the address list, all its elements contain a protocol agnostic part. This design allows us to be able to join a multicast group without necessarily having a configured address. That means IPv6 multicast kludges are no longer needed. Another benefit is to be able to add and remove an IP address from an interface without worrying about multicast records. That means that the global IPv4 list is no longer needed since the first configured address of an interface is no longer special. This new list might also be extended in the future to contain the link-layer addresses used to configure hardware filters. Tested by sthen@ and weerd@, ok mikeb@
* No need to expose twice in_socktrim(), it is only used in one file.mpi2013-10-231-1/+2
|
* Abstract the fact that IPv4 muticast records are linked to thempi2013-10-181-2/+2
| | | | | | | | | interface descriptor throught the first configured address in the global list, this will help reducing the size of future diffs. No object change. ok sthen@
* Introduce in_ifdetach() a function to remove all the IPv4 addressesmpi2013-10-091-1/+14
| | | | | | | | | | of an interface, named after its IPv6 equivalent. Make use of it instead of removing addresses by hand when detaching or destroying an interface. As a bonus, multicast records linked to the just divorced^Wdetached interface are no longer leaked. No objection from the gang, ok mikeb@
* Move the logic for deleting an IPv4 address to its own function.mpi2013-09-261-28/+31
| | | | | | No functional change. ok henning@, mikeb@
* If have an interface pointer, look for an address on its list rathermpi2013-08-281-17/+18
| | | | | | than iterating on the global list. ok bluhm@
* In case something bad happened when configuring an IPv4 address, makempi2013-08-191-11/+17
| | | | | | | sure we add its descriptor back to the tree and interface list to keep the various global structures consistent. ok mikeb@, bluhm@
* Insert new IPv4 addresses in only one place, no functional change.mpi2013-08-081-4/+8
| | | | ok mikeb@, henning@
* Revert r1.78 for now, it breaks ipv4 on carp. As found the hard way bysthen2013-06-231-13/+8
| | | | Jeff Ross and later by myself, both on remote systems..
* Revert previous and unbreak asr, the new include should be protected.mpi2013-06-201-4/+4
| | | | Reported by naddy@
* Allocate the various hook head descriptors as part of the ifnetmpi2013-06-201-4/+4
| | | | | | | structure rather than doing various M_WAITOK allocations during the *attach() functions, we always rely on them anyway. ok mikeb@, uebayasi@
* Always add/remove IPv4 addresses consistently from the global list and tree.mpi2013-06-171-8/+13
| | | | ok bluhm@, mikeb@
* Remove the scrub argument from in_ifinit() and simply call in_ifscrub()mpi2013-05-311-12/+5
| | | | | | unconditionally for SIOCSIFADDR. ok bluhm@, henning@
* Make SIOCSIFDSTMASK and SIOCSIFNETMASK fail if there is no previousmpi2013-05-131-3/+3
| | | | | | | | | | address configured on the interface just like SIOCSIFBRDADDR does. This prevent the global IPv4 address list and the per-interface list to be out of sync until one of SIOCAIFADDR or SIOCSIFADDR ioctl(2) is issued. ok mikeb@, sthen@
* Simplify the check to call in_ifinit() by merging two conditionalmpi2013-04-171-15/+14
| | | | | | viariables. ok mikeb@
* simple replacement of LIST_END with NULL. ok mpitedu2013-03-221-4/+3
|
* Remove the IFAFREE() macro, the ifafree() function it was calling alreadympi2013-03-071-4/+4
| | | | | | check for the reference counter. ok mikeb@, miod@, pelikan@, kettenis@, krw@
* in_scrubprefix needs the same netmask checking as in_addprefix (which wasclaudio2012-07-101-9/+12
| | | | | | added in 1.40). This fixes a pathological case where in_scrubprefix would do the wrong thing. Found and reported by glebius@FreeBSD OK bluhm@