aboutsummaryrefslogtreecommitdiff
path: root/sys/ofed/drivers/infiniband/core
Commit message (Collapse)AuthorAgeFilesLines
...
* ibcore: Store and restore ah_attr during LAP msg processing.Hans Petter Selasky2021-07-121-3/+29
| | | | | | | | | | | | | | | | | | During CM LAP processing, ah_attr is reinitialized on receiving a LAP request. First likely during CM request processing. ah_attr might get zeroed out if LAP processing fails. Therefore, try to create a new ah_attr for the LAP message. If the initialization fails, continue with older ah_attr. If the initialization passes, consider the new ah_attr by overwriting the older one. Linux commit: 0e225dcb7681c0a8e52fb9dc68bd8ab973de4ca2 MFC after: 1 week Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
* ibcore: Add rdma_reject_msg() helper function.Hans Petter Selasky2021-07-123-0/+83
| | | | | | | | | | | | rdma_reject_msg() returns a pointer to a string message associated with the transport reject reason codes. Linux commit: 77a5db13153906a7e00740b10b2730e53385c5a8 MFC after: 1 week Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
* ibcore: Remove unused and erroneous msg sequence encoding.Hans Petter Selasky2021-07-122-15/+6
| | | | | | | | | | | | | | | | | | | | | | | | In cm_form_tid(), a two bit message sequence number is OR'ed into bit 31-30 of the lower TID value. After Linux commit f06d26537559 ("IB/cm: Randomize starting comm ID"), the local_id is XOR'ed with a 32-bit random value. Hence, bit 31-30 in the lower TID now has an arbitrarily value and it makes no sense to OR in the message sequence number. Adding to that, the evolution in use of IDR routines in cm_alloc_id() has always had the possibility of returning a value with bit 30 set. In addition, said bits are never checked. Hence, remove the encoding and the corresponding enum. Linux commit: 87a37ce9e400e40daee537ff95343e3c94743c6d MFC after: 1 week Reviewed by: kib Sponsored by: Mellanox Technologies // NVIDIA Networking
* mlx4/OFED: replace the struct net_device with struct ifnetBjoern A. Zeeb2021-06-189-61/+61
| | | | | | | | | | | | | | | | | Given all the code does operate on struct ifnet, the last step in this longer series of changes now is to rename struct net_device to struct ifnet (that is what it was defined to in the LinuxKPi code). While mlx4 and OFED are "shared" code the decision was made years ago to not write it based on the netdevice KPI but the native ifnet KPI for most of it. This commit simply spells this out and with that frees "struct netdevice" to be re-done on LinuxKPI to become a more native/mixed implementation over time as needed by, e.g., wireless drivers. Sponsored by: The FreeBSD Foundation MFC after: 10 days Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D30515
* OFED: migrate LinuxKPI net_device/ifnet macros into ofedBjoern A. Zeeb2021-05-273-0/+3
| | | | | | | | | | | | The LinuxKPI net_device actually is an ifnet; in order to further clean that up so we can extend "net_device" migrate the few macros left into ofed and make sure the header is included in all files which need access to the macros. Sponsored by: The FreeBSD Foundation MFC after: 12 days Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D30477
* LinuxKPI/OFED/mlx4: cleanup netdevice.h some moreBjoern A. Zeeb2021-05-262-2/+0
| | | | | | | | | | | | | This removes all unused bits from linux/netdevice.h and migrates two inline functions into the mlx4 and ofed code respectively. This gets the mlx4/ofed (struct ifnet) specific bits down to 7 lines in netdevice.h. Sponsored by: The FreeBSD Foundation MFC after: 13 days Reviewed by: hselasky, kib Differential Revision: https://reviews.freebsd.org/D30461
* LinuxKPI/OFED: (re)move inetdevice.h implementationBjoern A. Zeeb2021-03-302-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | The two functions in linux/inetdevice.h are highly FreeBSD/ifnet specific. This is a result of struct net_device being mapped to struct ifnet. The only known consumer of these functions are two files in the ofed/infiniband code. As a first step of cleaning up copy linux/inetdevice.h to rdma/ib_addr_freebsd.h. (It stayed a separate file to preserve copyright and license of the original file; otherwise it could be merged into ib_addr.h where more EPOCH/vnet/.. are already used). Slightly rename the function to not conflict with LinuxKPI in the future. Remove the three last, now unneeded includes of inetdevice.h and zap linux/inetdevice.h to an empty header file with only the forward include to netdevice.h remaining. Sponsored-by: The FreeBSD Foundation MFC-after: 2 weeks Reviewed-by: hselasky, kib X-D-R: D29366 (extracted as further cleanup) Differential Revision: https://reviews.freebsd.org/D29434
* LinuxKPI: remove < 5.0 version supportBjoern A. Zeeb2021-03-241-2/+1
| | | | | | | | | | | | | | We are not aware of any out-of-tree consumers anymore which would need KPI support for before Linux version 5. Update the two in-tree consumers to use the new KPI. This allows us to remove the extra version check and will also give access to {lower,upper}_32_bits() unconditionally. Sponsored-by: The FreeBSD Foundation Reviewed-by: hselasky, rlibby, rstone MFC-after: 2 weeks X-MFC: to 13 only Differential Revision: https://reviews.freebsd.org/D29391
* ofed/linuxkpi: use proper accessor functionBjoern A. Zeeb2021-03-241-1/+1
| | | | | | | | | | | | | | In the notifier event callback function rather than casting directly to the expected type use the proper accessor function as the mlx drivers already do. This is preparational work to allow us to improve the struct net_device is struct ifnet compat code shortcut in the future. Obtained-from: bz_iwlwifi Sponsored-by: The FreeBSD Foundation MFC-after: 2 weeks Reviewed-by: hselasky Differential Revision: https://reviews.freebsd.org/D29364
* ofed: quiet gcc -Wint-in-bool-contextRyan Libby2021-02-241-2/+4
| | | | | | | | | | | | The int in the argument to the ternary triggered -Wint-in-bool-context from gcc. Upstream linux has a larger and more entangled patch, 12f727721eee61b3d19dedb95cb893b2baa9fe41, which doesn't apply cleanly. When we eventually sync that, we can just drop this change. Reviewed by: hselasky, imp, kib MFC after: 3 days Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D28762
* Fix mismerge in OFED updateRyan Stone2021-02-041-0/+2
| | | | | | | | | | | | | | | When OFED was upgraded to Linux v4.9, a bunch of Linux-specific netlink changes were dropped. Unfortunately, there was a mismerge in this process and as a result ib_sa_cancel_query() would fail to cancel an outstanding MAD. This was causing rdma_destroy_id() to hang indefinitely waiting for the MAD to complete and release the final reference. Sponsored by: Dell Inc. Differential Revision: https://reviews.freebsd.org/D28421 Reviewed by: hselasky, kib MFC after: 2 months
* Fix for referencing file via its vnode in ibore.Hans Petter Selasky2020-11-021-43/+39
| | | | | | | | | | | | | | | | | | | | | Use the native vnode lookup functions, instead of going via the LinuxKPI, because the file referenced is typically created outside the LinuxKPI, and the LinuxKPI's fdget() can only resolve file descriptor numbers which were created by itself. The vnode pointer is used as an identifier to identify XRCD handles which are sharing resources. This patch fixes the so-called XRCD support in ibcore for FreeBSD. Refer to ibv_open_xrcd(3) for more information how the file descriptor argument is used. Reviewed by: kib@ MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Notes: svn path=/head/; revision=367269
* infiniband: Appease CovertyEric van Gyzen2020-08-313-17/+6
| | | | | | | | | | | | | | | | Coverity claims the call to rdma_gid2ip in cma_igmp_send overwrites addr. Use a consistent definition of sockaddr to prevent detections and code changes in the future. Submitted by: bret_ketchum@dell.com Reported by: Coverity Reviewed by: hselasky, kib MFC after: 2 weeks Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D26229 Notes: svn path=/head/; revision=364997
* Infiniband clients must be attached and detached in a specific order in ibcore.Hans Petter Selasky2020-07-068-15/+32
| | | | | | | | | | | | | | | | | | | Currently the linking order of the infiniband, IB, modules decide in which order the clients are attached and detached. For example one IB client may use resources from another IB client. This can lead to a potential deadlock at shutdown. For example if the ipoib is unregistered after the ib_multicast client is detached, then if ipoib is using multicast addresses a deadlock may happen, because ib_multicast will wait for all its resources to be freed before returning from the remove method. Fix this by using module_xxx_order() instead of module_xxx(). Differential Revision: https://reviews.freebsd.org/D23973 MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=362953
* Convert OFED rtable interactions to the new routing KPI.Alexander V. Chernikov2020-04-152-82/+59
| | | | | | | | Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D24387 Notes: svn path=/head/; revision=359966
* Replace rdma_is_upper_dev_rcu() with rdma_vlan_dev_real_dev() in ibcore.Hans Petter Selasky2019-10-162-13/+1
| | | | | | | | | | | This reduces the number of references to VLAN_TRUNKDEV() in ibcore. Currently only VLAN is supported as a child interface in FreeBSD. Remove superfluous RCU locking. Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=353632
* Fix missing epochification of the ibcore code after r353292.Hans Petter Selasky2019-10-151-1/+4
| | | | | | | Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=353547
* OFED: Unbreak SDP support in ibcoreConrad Meyer2019-08-171-19/+214
| | | | | | | | | | | | This regression was introduced in the r326169 Linux v4.9 Infiniband upgrade. Restore the functionality. Reviewed by: hselasky Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D21298 Notes: svn path=/head/; revision=351176
* Fix prio vs. nonprio tagged traffic in RDMACMSlava Shwartsman2019-06-041-3/+17
| | | | | | | | | | | | | | | In current RDMACM implementation RDMACM server will not find a GID index when the request was prio-tagged and the sever is non prio-tagged and vise-versa. According to 802.1Q-2014, VLAN tagged packets with VLAN id 0 should be considered as untagged. Treat RDMACM request the same. Reviewed by: hselasky, kib MFC after: 3 Days Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=348601
* Include eventhandler.h in more compilation unitsConrad Meyer2019-05-211-0/+1
| | | | | | | | | | | | | | | | This was enumerated with exhaustive search for sys/eventhandler.h includes, cross-referenced against EVENTHANDLER_* usage with the comm(1) utility. Manual checking was performed to avoid redundant includes in some drivers where a common os_bsd.h (for example) included sys/eventhandler.h indirectly, but it is possible some of these are redundant with driver-specific headers in ways I didn't notice. (These CUs did not show up as missing eventhandler.h in tinderbox.) X-MFC-With: r347984 Notes: svn path=/head/; revision=348026
* Add new rates to ibcore.Hans Petter Selasky2019-05-081-0/+20
| | | | | | | | | | | | Add the new rates that were added to the Infiniband specification as part of HDR and 2x support. Submitted by: slavash@ MFC after: 3 days Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=347301
* Make sure to error out when arming the CQ fails in ibcore.Hans Petter Selasky2019-05-081-3/+7
| | | | | | | | MFC after: 3 days Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=347257
* Mechanical cleanup of epoch(9) usage in network stack.Gleb Smirnoff2019-01-091-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | - Remove macros that covertly create epoch_tracker on thread stack. Such macros a quite unsafe, e.g. will produce a buggy code if same macro is used in embedded scopes. Explicitly declare epoch_tracker always. - Unmask interface list IFNET_RLOCK_NOSLEEP(), interface address list IF_ADDR_RLOCK() and interface AF specific data IF_AFDATA_RLOCK() read locking macros to what they actually are - the net_epoch. Keeping them as is is very misleading. They all are named FOO_RLOCK(), while they no longer have lock semantics. Now they allow recursion and what's more important they now no longer guarantee protection against their companion WLOCK macros. Note: INP_HASH_RLOCK() has same problems, but not touched by this commit. This is non functional mechanical change. The only functionally changed functions are ni6_addrs() and ni6_store_addrs(), where we no longer enter epoch recursively. Discussed with: jtl, gallatin Notes: svn path=/head/; revision=342872
* ibcore: Fix clearing of bound device interface.Slava Shwartsman2018-12-051-2/+7
| | | | | | | | | | | | | | Binding to a loopback device is not allowed. Make sure the destination device address is global by clearing the bound device interface. Only do this conditionally, else link local addresses won't work. Submitted by: hselasky@ Approved by: hselasky (mentor) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=341534
* ibcore: ip6_dev_find() needs to know the scope ID.Slava Shwartsman2018-12-052-3/+4
| | | | | | | | | | | | Else the wrong network device can be returned for link-local addresses. Submitted by: hselasky@ Approved by: hselasky (mentor) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=341533
* ibcore: Fix sleeping in atomic when RoCE is usedSlava Shwartsman2018-12-051-19/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A couple of places in the CM do spin_lock_irq(&cm_id_priv->lock); ... if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg)) However when the underlying transport is RoCE, this leads to a sleeping function being called with the lock held - the callchain is cm_alloc_response_msg() -> ib_create_ah_from_wc() -> ib_init_ah_from_wc() -> rdma_addr_find_l2_eth_by_grh() -> rdma_resolve_ip() and rdma_resolve_ip() starts out by doing req = kzalloc(sizeof *req, GFP_KERNEL); not to mention rdma_addr_find_l2_eth_by_grh() doing wait_for_completion(&ctx.comp); to wait for the task that rdma_resolve_ip() queues up. Fix this by moving the AH creation out of the lock. Linux commit: c76161181193985087cd716fdf69b5cb6cf9ee85 Submitted by: hselasky@ Approved by: hselasky (mentor) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=341532
* ibcore: Add missing unref of netdevice.Slava Shwartsman2018-12-051-0/+1
| | | | | | | | | | Submitted by: hselasky@ Approved by: hselasky (mentor) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=341531
* ibcore: Fix loopback with rdma-cm.Slava Shwartsman2018-12-051-7/+26
| | | | | | | | | | | | | | | | | Trying to validate loopback fails because rtalloc1() resolves system local addresses to the loopback network interface, lo0. Fix this by explicitly checking for loopback during validation of the source and destination network address. If the source address belongs to a local network interface and is equal to the destination address, there is no need to run the destination address through rtalloc1(). Submitted by: hselasky@ Approved by: hselasky (mentor) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=341530
* ibcore: Make sure all VNETs are scanned for VLAN interfaces.Slava Shwartsman2018-12-051-5/+10
| | | | | | | | | | | | | The master network interface and the VLANs may reside in different VNETs. Make sure that all VNETs are searched when scanning for GID entries. Submitted by: netapp Approved by: hselasky (mentor) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=341529
* ibcore: Always check return value from ib_init_ah_from_wc().Slava Shwartsman2018-12-052-16/+26
| | | | | | | | | | | | | | | | This prevents code from accepting RoCEv1 connections when only ROCEv2 is enabled and vice versa. Linux commit: 0c4386ec77cfcd0ccbdbe8c2e67dd3a49b2a4c7f Submitted by: hselasky@ Approved by: hselasky (mentor) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=341528
* ibcore: Add missing check for failure.Slava Shwartsman2018-12-051-2/+4
| | | | | | | | | | Submitted by: hselasky@ Approved by: hselasky (mentor) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=341527
* ibcore: Fix an array index checkSlava Shwartsman2018-12-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | The array ib_mad_mgmt_class_table.method_table has MAX_MGMT_CLASS (80) elements. Hence compare the array index with that value instead of with IB_MGMT_MAX_METHODS (128). This patch avoids that Coverity reports the following: Overrunning array class->method_table of 80 8-byte elements at element index 127 (byte offset 1016) using index convert_mgmt_class(mad_hdr->mgmt_class) (which evaluates to 127). Linux commit: 2fe2f378dd45847d2643638c07a7658822087836 Submitted by: hselasky@ Approved by: hselasky (mentor) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=341526
* ibcore: Check ib_find_pkey() return value.Slava Shwartsman2018-12-051-2/+3
| | | | | | | | | | | | | Linux commit: d3a2418ee36a59bc02e9d454723f3175dcf4bfd9 Submitted by: hselasky@ Approved by: hselasky (mentor) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=341525
* ibcore: Add support for IB_SPEED_HDR in sysfs rate printout.Slava Shwartsman2018-12-051-0/+5
| | | | | | | | | | Submitted by: hselasky@ Approved by: hselasky (mentor) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=341524
* ibcore: Don't access invalid port.Slava Shwartsman2018-12-051-10/+13
| | | | | | | | | | | | | | The port number in the listen_id_priv has been observed to be zero which means no port has been selected. The current code lacks a check for invalid port number. Submitted by: hselasky@ Approved by: hselasky (mentor) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=341523
* ibcore: Discard unused error codes.Slava Shwartsman2018-12-051-2/+2
| | | | | | | | | | Submitted by: hselasky@ Approved by: hselasky (mentor) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=341522
* ibcore: Make sure GID index variable gets initialized.Slava Shwartsman2018-12-051-3/+1
| | | | | | | | | | Submitted by: hselasky@ Approved by: hselasky (mentor) MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=341521
* Introduce and use sgid_index in CM requests in ibcore.Hans Petter Selasky2018-09-093-9/+38
| | | | | | | | | | | | | | | | | | | | | | For RoCE, when CM requests are received for RC and UD connections, netdevice of the incoming request is unavailable. Because of that CM requests are always forwarded to init_net namespace. Now that we have the GID index available, introduce SGID index in incoming CM requests and refer to the netdevice of it. While at it fix some incorrect uses of init_net and make sure the rdma_create_id() function stores the VNET it is passed. Based on linux commit: cee104334c98dd04e9dd4d9a4fa4784f7f6aada9 MFC after: 3 days Approved by: re (gjb) Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=338541
* Implement get network interface by params function in ipoib.Hans Petter Selasky2018-09-072-38/+39
| | | | | | | | | | | | | | | Also fix the validate_ipv4_net_dev() and validate_ipv6_net_dev() functions which had source and destination addresses swapped, and didn't set the scope ID for IPv6 link-local addresses. This allows applications like krping to work using IPoIB devices. MFC after: 3 days Approved by: re (gjb) Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=338526
* Use __FBSDID() for RCS tags in ibcore.Hans Petter Selasky2018-07-1730-60/+90
| | | | | | | | MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=336391
* Add support for IPv6 multicast in ibcore.Hans Petter Selasky2018-07-171-1/+1
| | | | | | | | | | This change allows us to join IPv6 multicast networks. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=336389
* Add support for RoCEv2 multicast in ibcore.Hans Petter Selasky2018-07-171-0/+13
| | | | | | | | | | | | | | | | When creating address handle from multicast GID, set MAC according to the appropriate formula instead of searching for it in the GID table: - For IPv4 multicast GID use ip_eth_mc_map(). - For IPv6 multicast GID use ipv6_eth_mc_map(). Linux commit: 9636a56fa864464896bf7d1272c701f2b9a57737 MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=336388
* Honor return status of ib_init_ah_from_mcmember() in ibcore.Hans Petter Selasky2018-07-171-4/+8
| | | | | | | | | | | | | | | The return status of ib_init_ah_from_mcmember() is ignored by cma_ib_mc_handler(). Honor it and return error event if ah attribute initialization failed. Linux commit: 6d337179f28cc50ddd7e224f677b4cda70b275fc MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=336387
* Honor port_num while resolving GID for IB link layer in ibcore.Hans Petter Selasky2018-07-171-14/+12
| | | | | | | | | | | | | | | | | | ah_attr contains the port number to which cm_id is bound. However, while searching for GID table for matching GID entry, the port number is ignored. This could cause the wrong GID to be used when the ah_attr is converted to an AH. Linux commit: 563c4ba3bd2b8b0b21c65669ec2226b1cfa1138b MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=336386
* Set IPv4 TOS and IPv6 traffic class field for RoCEv2 traffic in ibcore.Hans Petter Selasky2018-07-171-8/+3
| | | | | | | | | | | The current implementation assumes a static mapping between the TOS bits and the priority code point, PCP bits. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=336385
* Fix for loopback detection in address resolve logic in ibcore.Hans Petter Selasky2018-07-171-0/+8
| | | | | | | | | | | When a loopback address is detected use the network interface which has the loopback flag set to trigger loopback logic in address resolve. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=336384
* Check port number supplied by user verbs cmds in ibcore.Hans Petter Selasky2018-07-172-0/+24
| | | | | | | | | | | | | | | | | | | The ib_uverbs_create_ah() ind ib_uverbs_modify_qp() calls receive the port number from user input as part of its attributes and assumes it is valid. Down on the stack, that parameter is used to access kernel data structures. If the value is invalid, the kernel accesses memory it should not. To prevent this, verify the port number before using it. Linux commit: 5ecce4c9b17bed4dc9cb58bfb10447307569b77b a62ab66b13a0f9bcb17b7b761f6670941ed5cd62 5a7a88f1b488e4ee49eb3d5b82612d4d9ffdf2c3 MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=336383
* Depend on IPv6 stack to resolve link local address for RoCEv2 in ibcore.Hans Petter Selasky2018-07-171-30/+20
| | | | | | | | | | | | | | RoCEv1 does not use the IPv6 stack to resolve the link local DGID since it uses GID address. It forms the DMAC directly from the DGID. Linux commit: 56d0a7d9a0f045ee27a001762deac28c7d28e2e4 MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=336382
* Fix kernel crash during fail to initialize device in ibcore.Hans Petter Selasky2018-07-171-7/+21
| | | | | | | | | | | | | | | | | | | | | | | | This patch fixes the kernel crash that occurs during ib_dealloc_device() called due to provider driver fails with an error after ib_alloc_device() and before it can register using ib_register_device(). This crashed seen in tha lab as below which can occur with any IB device which fails to perform its device initialization before invoking ib_register_device(). This patch avoids touching cache and port immutable structures if device is not yet initialized. It also releases related memory when cache and port immutable data structure initialization fails during register_device() state. Linux commit: 4be3a4fa51f432ef045546d16f25c68a1ab525b9 MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=336381
* Check AF family prior resolving address and introduce safer rdma_addr_size() ↵Hans Petter Selasky2018-07-172-13/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | variants in ibcore. Garbage supplied by user will cause to UCMA module provide zero memory size for memcpy(), because it wasn't checked, it will produce unpredictable results in rdma_resolve_addr(). There are several places in the ucma ABI where userspace can pass in a sockaddr but set the address family to AF_IB. When that happens, rdma_addr_size() will return a size bigger than sizeof struct sockaddr_in6, and the ucma kernel code might end up copying past the end of a buffer not sized for a struct sockaddr_ib. Fix this by introducing new variants int rdma_addr_size_in6(struct sockaddr_in6 *addr); int rdma_addr_size_kss(struct __kernel_sockaddr_storage *addr); that are type-safe for the types used in the ucma ABI and return 0 if the size computed is bigger than the size of the type passed in. We can use these new variants to check what size userspace has passed in before copying any addresses. Linux commit: 2975d5de6428ff6d9317e9948f0968f7d42e5d74 09abfe7b5b2f442a85f4c4d59ecf582ad76088d7 84652aefb347297aa08e91e283adf7b18f77c2d5 MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=336380