summaryrefslogtreecommitdiff
path: root/sys/netinet/in.c
AgeCommit message (Collapse)Author
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@
2014-11-20sizes for simple free cases. sizeof(*) and one case where len is clear.Ted Unangst
2014-11-20funky spacing.Martin Pieuchot
2014-11-20Instead of playing hide-and-seek with the route to destination attachedMartin Pieuchot
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@
2014-11-05Did you ever wonder why loopback's ifas have a destination address?Martin Pieuchot
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.
2014-10-07Do not protect the SIOCSIFADDR call by splnet(). Drivers alreadyMartin Pieuchot
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@
2014-10-02There is no point in trying to purge the default host route forMartin Pieuchot
loopback interfaces because we no longer add it. ok claudio@
2014-10-01Fix loopback related breakage introduced by the conversion of in_ouraddr()Martin Pieuchot
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@.
2014-09-03When a route to prefix (connected route) is added, if its associatedMartin Pieuchot
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@
2014-08-23Move splnet() in in_ifinit() to protect less code that does notAlexander Bluhm
need it. OK mpi@
2014-07-12add a size argument to free. will be used soon, but for now default to 0.Ted Unangst
after discussions with beck deraadt kettenis.
2014-07-12Always create a local route for every configured IPv4 address on theMartin Pieuchot
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.
2014-06-26Calling in{6,}_purgeaddr() is not enough to remove an address fromMartin Pieuchot
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@
2014-06-16Revert "Always create a local route for every configured IPv4 address",Martin Pieuchot
it introduces a regression with default routes & p2p interfaces. Problem reported by naddy@
2014-06-11Always create a local route for every configured IPv4 address on theMartin Pieuchot
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@
2014-04-25Kill in_localaddr(), one less usage of the global list of IPv4 addresses.Martin Pieuchot
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@
2014-04-10Retire rtinit() an use rt_ifa_add(9) and rt_ifa_del(9) to manageMartin Pieuchot
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@
2014-03-27Stop mixing interface address flags with routing entry ones.Martin Pieuchot
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@
2014-03-21Split the magic to add a connected route for every new IPv4 addressMartin Pieuchot
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@
2014-03-14Add missing parens so 'if' statement controls both of the statementsKenneth R Westerback
it was intended to control. No real-world change say mikeb@ and mpi@. ok mpi@
2014-01-21Do not clean the multicast records of an interface when it is destroyedMartin Pieuchot
(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@
2013-12-31bcopy -> memcpy. reviewed with one fix from matthewTed Unangst
2013-11-28Change the way protocol multicast addresses are linked to an interface.Martin Pieuchot
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@
2013-10-23No need to expose twice in_socktrim(), it is only used in one file.Martin Pieuchot
2013-10-18Abstract the fact that IPv4 muticast records are linked to theMartin Pieuchot
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@
2013-10-09Introduce in_ifdetach() a function to remove all the IPv4 addressesMartin Pieuchot
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@
2013-09-26Move the logic for deleting an IPv4 address to its own function.Martin Pieuchot
No functional change. ok henning@, mikeb@
2013-08-28If have an interface pointer, look for an address on its list ratherMartin Pieuchot
than iterating on the global list. ok bluhm@
2013-08-19In case something bad happened when configuring an IPv4 address, makeMartin Pieuchot
sure we add its descriptor back to the tree and interface list to keep the various global structures consistent. ok mikeb@, bluhm@
2013-08-08Insert new IPv4 addresses in only one place, no functional change.Martin Pieuchot
ok mikeb@, henning@
2013-06-23Revert r1.78 for now, it breaks ipv4 on carp. As found the hard way byStuart Henderson
Jeff Ross and later by myself, both on remote systems..
2013-06-20Revert previous and unbreak asr, the new include should be protected.Martin Pieuchot
Reported by naddy@
2013-06-20Allocate the various hook head descriptors as part of the ifnetMartin Pieuchot
structure rather than doing various M_WAITOK allocations during the *attach() functions, we always rely on them anyway. ok mikeb@, uebayasi@