summaryrefslogtreecommitdiffstats
path: root/sys/netinet6
Commit message (Collapse)AuthorAgeFilesLines
* Release the ref acquired in nd6_dad_find() if DAD is already in progress.markj2016-02-181-2/+3
| | | | MFC after: 1 week
* Use pfxrtr_del() instead of freeing advertising routers directly.markj2016-02-171-2/+2
| | | | MFC after: 1 week
* Remove a prototype for the non-existent prelist_del().markj2016-02-171-1/+0
| | | | MFC after: 1 week
* Ternary operator has lower priority than OR.glebius2016-02-171-1/+1
| | | | Found by: PVS-Studio
* Add a missing newline to a log message.markj2016-02-121-1/+1
| | | | MFC after: 1 week
* Rename the flags field of struct nd_defrouter to "raflags".markj2016-02-123-9/+9
| | | | | | | This field contains the flags inherited from the corresponding router advertisement message and is not for storing private state. MFC after: 1 week
* Simplify defrtrlist_update() slightly in preparation for future changes.markj2016-02-121-28/+23
| | | | | | No functional change intended. MFC after: 1 week
* Remove a bogus comment from nd6_na_input().markj2016-02-121-6/+0
| | | | | | | The splnet() call that it refers to has been removed, and a lock for the default router list is in fact needed. MFC after: 1 week
* Remove superfluous return statements from the neighbour discovery code.markj2016-02-123-6/+0
| | | | MFC after: 1 week
* Fix style around allocations from M_IP6NDP.markj2016-02-122-9/+6
| | | | | | | - Don't cast the return value of malloc(9). - Use M_ZERO instead of explicitly calling bzero(9). MFC after: 1 week
* Remove some unreferenced NDP debug variable definitions.markj2016-02-121-5/+0
| | | | MFC after: 1 week
* Merge SVN r295220 (bz) from projects/vnet/dteske2016-02-111-1/+3
| | | | | | | Fix a panic that occurs when a vnet interface is unavailable at the time the vnet jail referencing said interface is stopped. Sponsored by: FIS Global, Inc.
* These files were getting sys/malloc.h and vm/uma.h with header pollutionglebius2016-02-012-0/+2
| | | | via sys/mbuf.h
* MFP r287070,r287073: split radix implementation and route table structure.melifaro2016-01-253-24/+25
| | | | | | | | | | | | | | | | | | | | | | | There are number of radix consumers in kernel land (pf,ipfw,nfs,route) with different requirements. In fact, first 3 don't have _any_ requirements and first 2 does not use radix locking. On the other hand, routing structure do have these requirements (rnh_gen, multipath, custom to-be-added control plane functions, different locking). Additionally, radix should not known anything about its consumers internals. So, radix code now uses tiny 'struct radix_head' structure along with internal 'struct radix_mask_head' instead of 'struct radix_node_head'. Existing consumers still uses the same 'struct radix_node_head' with slight modifications: they need to pass pointer to (embedded) 'struct radix_head' to all radix callbacks. Routing code now uses new 'struct rib_head' with different locking macro: RADIX_NODE_HEAD prefix was renamed to RIB_ (which stands for routing information base). New net/route_var.h header was added to hold routing subsystem internal data. 'struct rib_head' was placed there. 'struct rtentry' will also be moved there soon.
* Fix rte refcount leak in ip6_forward().melifaro2016-01-201-2/+5
| | | | | | Reviewed by: ae MFC after: 2 weeks Sponsored by: Yandex LLC
* Verify the packet length in sctp6_input().glebius2016-01-141-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The sctp6_ctlinput() function does not properly check the length of the packet it receives from the ICMP6 input routine. This means that an attacker can craft a packet that will cause a kernel panic. When the kernel receives an ICMP6 error message with one of the types/codes it handles, it calls icmp6_notify_error() to deliver it to the upper-level protocol. icmp6_notify_error() cycles through the extension headers (if any) to find the protocol number of the first non-extension header. It does NOT verify the length of the non-extension header. It passes information about the packet (including the actual packet) to the upper-level protocol's pr_ctlinput function. In the case of SCTP for IPv6, icmp6_notify_error() calls sctp6_ctlinput(). sctp6_ctlinput() assumes that the incoming packet contains a sufficiently-long SCTP header and calls m_copydata() to extract a copy of that header. In turn, m_copydata() assumes that the caller has already verified that the offset and length parameters are correct. If they are incorrect, it will dereference a NULL pointer and cause a kernel panic. In short, no one is sufficiently verifying the input, and the result is a kernel panic. Submitted by: jtl Security: SA-16:01.sctp
* Bring RADIX_MPATH support to new routing KPI to ease migration.melifaro2016-01-111-0/+7
| | | | | | Move actual rte selection process from rtalloc_mpath_fib() to the rt_path_selectrte() function. Add public rt_mpath_select() to use in fibX_lookup_ functions.
* Split in6_selectsrc() into in6_selectsrc_addr() and in6_selectsrc_socket().melifaro2016-01-107-88/+121
| | | | | | | | | | | | | | | | in6_selectsrc() has 2 class of users: socket-based one (raw/udp/pcb/etc) and socket-less (ND code). The main reason for that change is inability to specify non-default FIB for callers w/o socket since (internally) inpcb is used to determine fib. As as result, add 2 wrappers for in6_selectsrc() (making in6_selectsrc() static): 1) in6_selectsrc_socket() for the former class. Embed scope_ambiguous check along with returning hop limit when needed. 2) in6_selectsrc_addr() for the latter case. Add 'fibnum' argument and pass IPv6 address w/ explicitly specified scope as separate argument. Reviewed by: ae (previous version)
* Do not hold ifaddr reference for the whole icmp6_reflect() exec time.melifaro2016-01-101-16/+21
| | | | Copy source address, calculate hlim and release refcount instead.
* Remove prefix check from in6_addroute().melifaro2016-01-091-29/+1
| | | | | | | | | | | | | This check was added in initial? netinet6/ import back in 1999 (r53541). It effectively became unnecessary after 'address/prefix clean-ups' KAME commit 90ff8792e676132096a440dd787f99a5a5860ee8 (github) in 2001 (merged to FreeBSD in r78064) where prefix check was added to nd6_prefix_onlink(). Similar IPv4 check (in_addroute() was added in r137628). Additionally, the right plance for this (or similar) check is the prefix addition code (nd6_prefix_onlink(), nd6_prefix_onlink_rtrequest(), in_addprefix() or rtinit()), but not the generic radix insert routine.
* Remove sys/eventhandler.h from net/route.hmelifaro2016-01-091-0/+1
| | | | Reviewed by: ae
* Finish r293098: make ip6_getpmtu() and ip6_getpmtu_ctl() use new routing APImelifaro2016-01-041-20/+22
|
* Add rib_lookup_info() to provide API for retrieving individual routemelifaro2016-01-042-36/+43
| | | | | | | | | | | | | | | | | | | | | | | entries data in unified format. There are control plane functions that require information other than just next-hop data (e.g. individual rtentry fields like flags or prefix/mask). Given that the goal is to avoid rte reference/refcounting, re-use rt_addrinfo structure to store most rte fields. If caller wants to retrieve key/mask or gateway (which are sockaddrs and are allocated separately), it needs to provide sufficient-sized sockaddrs structures w/ ther pointers saved in passed rt_addrinfo. Convert: * lltable new records checks (in_lltable_rtcheck(), nd6_is_new_addr_neighbor(). * rtsock pre-add/change route check. * IPv6 NS ND-proxy check (RADIX_MPATH code was eliminated because 1) we don't support RTF_ANNOUNCE ND-proxy for networks and there should not be multiple host routes for such hosts 2) if we have multiple routes we should inspect them (which is not done). 3) the entire idea of abusing KRT as storage for ND proxy seems odd. Userland programs should be used for that purpose).
* Remove 'struct route_int6' argument from in6_selectsrc() andmelifaro2016-01-037-53/+29
| | | | | | | | | | | | | | | in6_selectif(). The main task of in6_selectsrc() is to return IPv6 SAS (along with output interface used for scope checks). No data-path code uses route argument for caching. The only users are icmp6 (reflect code), ND6 ns/na generation code. All this fucntions are control-plane, so there is no reason to try to 'optimize' something by passing cached route into to ip6_output(). Given that, simplify code by eliminating in6_selectsrc() 'struct route_in6' argument. Since in6_selectif() is used only by in6_selectsrc(), eliminate its 'struct route_in6' argument, too. While here, reshape rte-related code inside in6_selectif() to free lookup result immediately after saving all the needed fields.
* Handle IPV6_PATHMTU option by spliting ip6_getpmtu_ctl() from ip6_getpmtu().melifaro2016-01-032-32/+96
| | | | | | | | | | | | | | | | | | | | | | | Add ro_mtu field to 'struct route' to be able to pass lookup MTU back to the caller. Currently, ip6_getpmtu() has 2 totally different use cases: 1) control plane (IPV6_PATHMTU req), where we just need to calculate MTU and return it, w/o any reusability. 2) Actual ip6_output() data path where we (nearly) always use the provided route lookup data. If this data is not 'valid' we need to perform another lookup and save the result (which cannot be re-used by ip6_output()). Given that, handle 1) by calling separate function doing rte lookup itself. Resulting MTU is calculated by (newly-added) ip6_calcmtu() used by both ip6_getpmtu_ctl() and ip6_getpmtu(). For 2) instead of storing ref'ed rte, store mtu (the only needed data from the lookup result) inside newly-added ro_mtu field. 'struct route' was shrinked by 8(or 4 bytes) in r292978. Grow it again by 4 bytes. New ro_mtu field will be used in other places like ip/tcp_output (EMSGSIZE handling from output routines). Reviewed by: ae
* Use lltable_get_ifp() instead of direct access to lltable fields.melifaro2016-01-011-2/+4
|
* Implement interface link header precomputation API.melifaro2015-12-316-26/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add if_requestencap() interface method which is capable of calculating various link headers for given interface. Right now there is support for INET/INET6/ARP llheader calculation (IFENCAP_LL type request). Other types are planned to support more complex calculation (L2 multipath lagg nexthops, tunnel encap nexthops, etc..). Reshape 'struct route' to be able to pass additional data (with is length) to prepend to mbuf. These two changes permits routing code to pass pre-calculated nexthop data (like L2 header for route w/gateway) down to the stack eliminating the need for other lookups. It also brings us closer to more complex scenarios like transparently handling MPLS nexthops and tunnel interfaces. Last, but not least, it removes layering violation introduced by flowtable code (ro_lle) and simplifies handling of existing if_output consumers. ARP/ND changes: Make arp/ndp stack pre-calculate link header upon installing/updating lle record. Interface link address change are handled by re-calculating headers for all lles based on if_lladdr event. After these changes, arpresolve()/nd6_resolve() returns full pre-calculated header for supported interfaces thus simplifying if_output(). Move these lookups to separate ether_resolve_addr() function which ether returs error or fully-prepared link header. Add <arp|nd6_>resolve_addr() compat versions to return link addresses instead of pre-calculated data. BPF changes: Raw bpf writes occupied _two_ cases: AF_UNSPEC and pseudo_AF_HDRCMPLT. Despite the naming, both of there have ther header "complete". The only difference is that interface source mac has to be filled by OS for AF_UNSPEC (controlled via BIOCGHDRCMPLT). This logic has to stay inside BPF and not pollute if_output() routines. Convert BPF to pass prepend data via new 'struct route' mechanism. Note that it does not change non-optimized if_output(): ro_prepend handling is purely optional. Side note: hackish pseudo_AF_HDRCMPLT is supported for ethernet and FDDI. It is not needed for ethernet anymore. The only remaining FDDI user is dev/pdq mostly untouched since 2007. FDDI support was eliminated from OpenBSD in 2013 (sys/net/if_fddisubr.c rev 1.65). Flowtable changes: Flowtable violates layering by saving (and not correctly managing) rtes/lles. Instead of passing lle pointer, pass pointer to pre-calculated header data from that lle. Differential Revision: https://reviews.freebsd.org/D4102
* Add the appropriate case statement for IPV6_BINDMULTI so the option can bejtl2015-12-301-0/+1
| | | | | | | | | retrieved with getsockopt(). CID: 1229928 Differential Revision: https://reviews.freebsd.org/D4737 Reviewed by: adrian Sponsored by: Juniper Networks
* This code is not in modules that need KPI stability so no need to usebz2015-12-301-2/+2
| | | | | | | | | the wrapper functions as used in r252511. We can directly use the locking macros. Reviewed by: jtl, rwatson MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D4731
* in6_if2idlen: treat bridge(4) interfaces like other Ethernet interfaceswollman2015-12-281-0/+1
| | | | | | | | | | | bridge(4) interfaces have an if_type of IFT_BRIDGE, rather than IFT_ETHER, even though they only support Ethernet-style links. This caused in6_if2idlen to emit an "unknown link type (209)" warning to the console every time it was called. Add IFT_BRIDGE to the case statement in the appropriate place, indicating that it uses the same IPv6 address format as other Ethernet-like interfaces. MFC after: 1 week
* Remove superfluous return (1) missed in r292601.bz2015-12-231-1/+0
| | | | | | | | Reported by: Matthew D. Fuller (fullermd over-yonder.net), Kevin Bowling (kevin.bowling kev009.com) MFC after: 13 days X-MFC with: r292601 Sponsored by: The FreeBSD Foundation
* Since r256624 we've been leaking routing table allocationsbz2015-12-221-0/+1
| | | | | | | | | | on vnet enabled jail shutdown. Call the provided cleanup routines for IP versions 4 and 6 to plug these leaks. Sponsored by: The FreeBSD Foundation MFC atfer: 2 weeks Reviewed by: gnn Differential Revision: https://reviews.freebsd.org/D4530
* Revert r292275 & r292379smh2015-12-175-166/+30
| | | | | | | glebius has concerns about these changes so reverting those can be discussed and addressed. Sponsored by: Multiplay
* Fix issues introduced by r292275smh2015-12-162-1/+3
| | | | | | | | | | | | * Fix panic for etherswitches which don't have a LLADDR. * Disabled DELAY in unsolicited NDA, which needs further work. * Fixed missing DELAY in carp_send_na. * style(9) fix. Reported by: kp & melifaro X-MFC-With: r292275 MFC after: 1 month Sponsored by: Multiplay
* Provide additional lle data in IPv6 lltable dump used by ndp(8).melifaro2015-12-162-3/+10
| | | | | | | | | | | | | | | Before the change, things like lle state were queried via SIOCGNBRINFO_IN6 by ndp(8) for _each_ lle entry in dump. This ioctl was added in 1999, probably to avoid touching rtsock code. This change maps SIOCGNBRINFO_IN6 data to standard rtsock dump the following way: expire (already) maps to rtm_rmx.rmx_expire isrouter -> rtm_flags & RTF_GATEWAY asked -> rtm_rmx.rmx_pksent state -> rtm_rmx.rmx_state (maps to rmx_weight via define) Reviewed by: ae
* Fix lagg failover due to missing notificationssmh2015-12-155-30/+164
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When using lagg failover mode neither Gratuitous ARP (IPv4) or Unsolicited Neighbour Advertisements (IPv6) are sent to notify other nodes that the address may have moved. This results is slow failover, dropped packets and network outages for the lagg interface when the primary link goes down. We now use the new if_link_state_change_cond with the force param set to allow lagg to force through link state changes and hence fire a ifnet_link_event which are now monitored by rip and nd6. Upon receiving these events each protocol trigger the relevant notifications: * inet4 => Gratuitous ARP * inet6 => Unsolicited Neighbour Announce This also fixes the carp IPv6 NA's that stopped working after r251584 which added the ipv6_route__llma route. The new behavour can be controlled using the sysctls: * net.link.ether.inet.arp_on_link * net.inet6.icmp6.nd6_on_link Also removed unused param from lagg_port_state and added descriptions for the sysctls while here. PR: 156226 MFC after: 1 month Sponsored by: Multiplay Differential Revision: https://reviews.freebsd.org/D4111
* inet6: Do not assume every interface has ip6 enabled.kp2015-12-142-0/+4
| | | | | | | | | | | | | Certain interfaces (e.g. pfsync0) do not have ip6 addresses (in other words, ifp->if_afdata[AF_INET6] is NULL). Ensure we don't panic when the MTU is updated. pfsync interfaces will never have ip6 support, because it's explicitly disabled in in6_domifattach(). PR: 205194 Reviewed by: melifaro, hrs Differential Revision: https://reviews.freebsd.org/D4522
* Remove LLE read lock from IPv6 fast path.melifaro2015-12-133-37/+191
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | LLE structure is mostly unchanged during its lifecycle: there are only 2 things relevant for fast path lookup code: 1) link-level address change. Since r286722, these updates are performed under AFDATA WLOCK. 2) Some sort of feedback indicating that this particular entry is used so we send NS to perform reachability verification instead of expiring entry. The only signal that is needed from fast path is something like binary yes/no. The latter is solved by the following changes: Special r_skip_req (introduced in D3688) value is used for fast path feedback. It is read lockless by fast path, but updated under req_mutex mutex. If this field is non-zero, then fast path will acquire lock and set it back to 0. After transitioning to STALE state, callout timer is armed to run each V_nd6_delay seconds to make sure that if packet was transmitted at the start of given interval, we would be able to switch to PROBE state in V_nd6_delay seconds as user expects. (in STALE state) timer is rescheduled until original V_nd6_gctimer expires keeping lle in STALE state (remaining timer value stored in lle_remtime). (in STALE state) timer is rescheduled if packet was transmitted less that V_nd6_delay seconds ago to make sure we transition to PROBE state exactly after V_n6_delay seconds. As a result, all packets towards lle in REACHABLE/STALE/PROBE states are handled by fast path without acquiring lle read lock. Differential Revision: https://reviews.freebsd.org/D3780
* Use correct lookup key for gif route lookups.melifaro2015-12-091-2/+2
| | | | This fixes r291993 change.
* Make in_arpinput(), inp_lookup_mcast_ifp(), icmp_reflect(),melifaro2015-12-095-58/+49
| | | | | | | | | | | | | | ip_dooptions(), icmp6_redirect_input(), in6_lltable_rtcheck(), in6p_lookup_mcast_ifp() and in6_selecthlim() use new routing api. Eliminate now-unused ip_rtaddr(). Fix lookup key fib6_lookup_nh_basic() which was lost diring merge. Make fib6_lookup_nh_basic() and fib6_lookup_nh_extended() always return IPv6 destination address with embedded scope. Currently rw_gateway has it scope embedded, do the same for non-gatewayed destinations. Sponsored by: Yandex LLC
* Merge helper fib* functions used for basic lookups.melifaro2015-12-085-16/+351
| | | | | | | | | | | | | | | | | | | | Vast majority of rtalloc(9) users require only basic info from route table (e.g. "does the rtentry interface match with the interface I have?". "what is the MTU?", "Give me the IPv4 source address to use", etc..). Instead of hand-rolling lookups, checking if rtentry is up, valid, dealing with IPv6 mtu, finding "address" ifp (almost never done right), provide easy-to-use API hiding all the complexity and returning the needed info into small on-stack structure. This change also helps hiding route subsystem internals (locking, direct rtentry accesses). Additionaly, using this API improves lookup performance since rtentry is not locked. (This is safe, since all the rtentry changes happens under both radix WLOCK and rtentry WLOCK). Sponsored by: Yandex LLC
* Fix the allocation of outgoing streams:tuexen2015-12-061-1/+1
| | | | | | | | | | * When processing a cookie, use the number of streams announced in the INIT-ACK. * When sending an INIT-ACK for an existing association, use the value from the association, not from the end-point. MFC after: 1 week
* mld_v2_dispatch_general_query() is used by mld_fasttimo_vnet() to sendae2015-12-011-0/+10
| | | | | | | | | | | | | | | | | a reply to the MLDv2 General Query. In case when router has a lot of multicast groups, the reply can take several packets due to MTU limitation. Also we have a limit MLD_MAX_RESPONSE_BURST == 4, that limits the number of packets we send in one shot. Then we recalculate the timer value and schedule the remaining packets for sending. The problem is that when we call mld_v2_dispatch_general_query() to send remaining packets, we queue new reply in the same mbuf queue. And when number of packets is bigger than MLD_MAX_RESPONSE_BURST, we get endless reply of MLDv2 reports. To fix this, add the check for remaining packets in the queue. PR: 204831 MFC after: 1 week Sponsored by: Yandex LLC
* Add new rt_foreach_fib_walk_del() function for deleting route entriesmelifaro2015-11-302-21/+19
| | | | | | | | | | | | | | | | | by filter function instead of picking into routing table details in each consumer. Remove now-unused rt_expunge() (eliminating last external RTF_RNH_LOCKED user). This simplifies future nexthops/mulitipath changes and rtrequest1_fib() locking refactoring. Actual changes: Add "rt_chain" field to permit rte grouping while doing batched delete from routing table (thus growing rte 200->208 on amd64). Add "rti_filter" / "rti_filterdata" / "rti_spare" fields to rt_addrinfo to pass filter function to various routing subsystems in standard way. Convert all rt_expunge() customers to new rt_addinfo-based api and eliminate rt_expunge().
* Overhaul if_enc(4) and make it loadable in run-time.ae2015-11-251-3/+27
| | | | | | | | Use hhook(9) framework to achieve ability of loading and unloading if_enc(4) kernel module. INET and INET6 code on initialization registers two helper hooks points in the kernel. if_enc(4) module uses these helper hook points and registers its hooks. IPSEC code uses these hhook points to call helper hooks implemented in if_enc(4).
* in6_mc_get: Fix recursion on if_addr_lock on malloc failurecem2015-11-191-2/+2
| | | | | | | | | | Analogously to r291040, in6_mc_get recurses on if_addr_lock if the M_NOWAIT allocation fails. The fix is the same. Suggested by: Andrey V. Elsukov Reviewed by: jhb (ip4 version) Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D4138 (ip4 version)
* Bring back the ability of passing cached route via nd6_output_ifp().melifaro2015-11-154-7/+7
|
* This fixes several places where callout_stops return is examined. Therrs2015-11-132-2/+2
| | | | | | | | | | new return codes of -1 were mistakenly being considered "true". Callout_stop now returns -1 to indicate the callout had either already completed or was not running and 0 to indicate it could not be stopped. Also update the manual page to make it more consistent no non-zero in the callout_stop or callout_reset descriptions. MFC after: 1 Month with associated callout change.
* Unify setting lladdr for AF_INET[6].melifaro2015-11-073-12/+7
|
* [netinet6]: Create a new IPv6 netisr which expects the frames to have been ↵adrian2015-11-065-8/+146
| | | | | | | | | | | | | | | | | verified. This is required for fragments and encapsulated data (eg tunneling) to be redistributed to the RSS bucket based on the eventual IPv6 header and protocol (TCP, UDP, etc) header. * Add an mbuf tag with the state of IPv6 options parsing before the frame is queued into the direct dispatch handler; * Continue processing and complete the frame reception in the correct RSS bucket / netisr context. Testing results are in the phabricator review. Differential Revision: https://reviews.freebsd.org/D3563 Submitted by: Tiwei Bie <btw@mail.ustc.edu.cn>
OpenPOWER on IntegriCloud