mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-22 10:48:02 +00:00
irdma(4): use related vnet for searching netdev
It was found through testing that when ULP uses individual vnet, the search for the correct vlan_id may failing because of no proper interface with given address. The solution is to use vnet associated to the connection whenever possible. Signed-off-by: Bartosz Sobczak <bartosz.sobczak@intel.com> Signed-off-by: Eric Joyner <erj@FreeBSD.org> Reviewed by: erj@ MFC after: 1 day Sponsored by: Intel Corporation Differential Revision: https://reviews.freebsd.org/D41592
This commit is contained in:
parent
01d8215102
commit
bc3a013ccd
|
@ -393,8 +393,7 @@ irdma_get_dst_mac(struct irdma_cm_node *cm_node, struct sockaddr *dst_sin, u8 *d
|
|||
{
|
||||
struct ifnet *netdev = cm_node->iwdev->netdev;
|
||||
#ifdef VIMAGE
|
||||
struct rdma_cm_id *rdma_id = (struct rdma_cm_id *)cm_node->cm_id->context;
|
||||
struct vnet *vnet = rdma_id->route.addr.dev_addr.net;
|
||||
struct vnet *vnet = irdma_cmid_to_vnet(cm_node->cm_id);
|
||||
#endif
|
||||
struct ifnet *ifp;
|
||||
struct llentry *lle;
|
||||
|
@ -492,8 +491,7 @@ irdma_resolve_neigh_lpb_chk(struct irdma_device *iwdev, struct irdma_cm_node *cm
|
|||
struct irdma_cm_info *cm_info)
|
||||
{
|
||||
#ifdef VIMAGE
|
||||
struct rdma_cm_id *rdma_id = (struct rdma_cm_id *)cm_node->cm_id->context;
|
||||
struct vnet *vnet = rdma_id->route.addr.dev_addr.net;
|
||||
struct vnet *vnet = irdma_cmid_to_vnet(cm_node->cm_id);
|
||||
#endif
|
||||
int arpindex;
|
||||
int oldarpindex;
|
||||
|
|
|
@ -121,6 +121,20 @@ static inline u64 *irdma_next_pbl_addr(u64 *pbl, struct irdma_pble_info **pinfo,
|
|||
|
||||
return (*pinfo)->addr;
|
||||
}
|
||||
|
||||
static inline struct vnet *
|
||||
irdma_cmid_to_vnet(struct iw_cm_id *cm_id)
|
||||
{
|
||||
struct rdma_cm_id *rdma_id;
|
||||
|
||||
if (!cm_id)
|
||||
return &init_net;
|
||||
|
||||
rdma_id = (struct rdma_cm_id *)cm_id->context;
|
||||
|
||||
return rdma_id->route.addr.dev_addr.net;
|
||||
}
|
||||
|
||||
#if __FreeBSD_version < 1400026
|
||||
struct ib_cq *irdma_create_cq(struct ib_device *ibdev,
|
||||
const struct ib_cq_init_attr *attr,
|
||||
|
|
|
@ -1624,10 +1624,13 @@ static u8 irdma_iw_get_vlan_prio(u32 *loc_addr, u8 prio, bool ipv4)
|
|||
* vlan id and mac for that address.
|
||||
*/
|
||||
if_t
|
||||
irdma_netdev_vlan_ipv6(u32 *addr, u16 *vlan_id, u8 *mac)
|
||||
irdma_netdev_vlan_ipv6(struct iw_cm_id *cm_id, u32 *addr, u16 *vlan_id, u8 *mac)
|
||||
{
|
||||
if_t ip_dev = NULL;
|
||||
struct in6_addr laddr6;
|
||||
#ifdef VIMAGE
|
||||
struct vnet *vnet = irdma_cmid_to_vnet(cm_id);
|
||||
#endif
|
||||
struct ifaddr *ifa;
|
||||
u16 scope_id = 0;
|
||||
|
||||
|
@ -1641,7 +1644,11 @@ irdma_netdev_vlan_ipv6(u32 *addr, u16 *vlan_id, u8 *mac)
|
|||
IN6_IS_ADDR_MC_INTFACELOCAL(&laddr6))
|
||||
scope_id = ntohs(laddr6.__u6_addr.__u6_addr16[1]);
|
||||
|
||||
#ifdef VIMAGE
|
||||
ip_dev = ip6_ifp_find(vnet, laddr6, scope_id);
|
||||
#else
|
||||
ip_dev = ip6_ifp_find(&init_net, laddr6, scope_id);
|
||||
#endif
|
||||
if (ip_dev) {
|
||||
if (vlan_id)
|
||||
*vlan_id = rdma_vlan_dev_vlan_id(ip_dev);
|
||||
|
@ -1658,12 +1665,19 @@ irdma_netdev_vlan_ipv6(u32 *addr, u16 *vlan_id, u8 *mac)
|
|||
* @addr: local IPv4 address
|
||||
*/
|
||||
u16
|
||||
irdma_get_vlan_ipv4(u32 *addr)
|
||||
irdma_get_vlan_ipv4(struct iw_cm_id *cm_id, u32 *addr)
|
||||
{
|
||||
if_t netdev;
|
||||
#ifdef VIMAGE
|
||||
struct vnet *vnet = irdma_cmid_to_vnet(cm_id);
|
||||
#endif
|
||||
u16 vlan_id = 0xFFFF;
|
||||
|
||||
#ifdef VIMAGE
|
||||
netdev = ip_ifp_find(vnet, htonl(addr[0]));
|
||||
#else
|
||||
netdev = ip_ifp_find(&init_net, htonl(addr[0]));
|
||||
#endif
|
||||
if (netdev) {
|
||||
vlan_id = rdma_vlan_dev_vlan_id(netdev);
|
||||
dev_put(netdev);
|
||||
|
@ -2060,8 +2074,7 @@ irdma_cm_create_ah(struct irdma_cm_node *cm_node, bool wait)
|
|||
struct irdma_ah_info ah_info = {0};
|
||||
struct irdma_device *iwdev = cm_node->iwdev;
|
||||
#ifdef VIMAGE
|
||||
struct rdma_cm_id *rdma_id = (struct rdma_cm_id *)cm_node->cm_id->context;
|
||||
struct vnet *vnet = rdma_id->route.addr.dev_addr.net;
|
||||
struct vnet *vnet = irdma_cmid_to_vnet(cm_node->cm_id);
|
||||
#endif
|
||||
|
||||
ether_addr_copy(ah_info.mac_addr, if_getlladdr(iwdev->netdev));
|
||||
|
@ -3520,11 +3533,11 @@ irdma_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
|
|||
|
||||
if (((struct sockaddr_in *)&cm_id->local_addr)->sin_family == AF_INET) {
|
||||
cm_node->ipv4 = true;
|
||||
cm_node->vlan_id = irdma_get_vlan_ipv4(cm_node->loc_addr);
|
||||
cm_node->vlan_id = irdma_get_vlan_ipv4(cm_id, cm_node->loc_addr);
|
||||
} else {
|
||||
cm_node->ipv4 = false;
|
||||
irdma_netdev_vlan_ipv6(cm_node->loc_addr, &cm_node->vlan_id,
|
||||
NULL);
|
||||
irdma_netdev_vlan_ipv6(cm_id, cm_node->loc_addr,
|
||||
&cm_node->vlan_id, NULL);
|
||||
}
|
||||
irdma_debug(&iwdev->rf->sc_dev, IRDMA_DEBUG_CM, "Accept vlan_id=%d\n",
|
||||
cm_node->vlan_id);
|
||||
|
@ -3719,7 +3732,7 @@ irdma_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
|
|||
cm_info.rem_addr[0] = ntohl(raddr->sin_addr.s_addr);
|
||||
cm_info.loc_port = ntohs(laddr->sin_port);
|
||||
cm_info.rem_port = ntohs(raddr->sin_port);
|
||||
cm_info.vlan_id = irdma_get_vlan_ipv4(cm_info.loc_addr);
|
||||
cm_info.vlan_id = irdma_get_vlan_ipv4(cm_id, cm_info.loc_addr);
|
||||
} else {
|
||||
if (iwdev->vsi.mtu < IRDMA_MIN_MTU_IPV6)
|
||||
return -EINVAL;
|
||||
|
@ -3731,7 +3744,7 @@ irdma_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
|
|||
raddr6->sin6_addr.__u6_addr.__u6_addr32);
|
||||
cm_info.loc_port = ntohs(laddr6->sin6_port);
|
||||
cm_info.rem_port = ntohs(raddr6->sin6_port);
|
||||
irdma_netdev_vlan_ipv6(cm_info.loc_addr, &cm_info.vlan_id, NULL);
|
||||
irdma_netdev_vlan_ipv6(cm_id, cm_info.loc_addr, &cm_info.vlan_id, NULL);
|
||||
}
|
||||
cm_info.cm_id = cm_id;
|
||||
cm_info.qh_qpid = iwdev->vsi.ilq->qp_id;
|
||||
|
@ -3846,7 +3859,7 @@ irdma_create_listen(struct iw_cm_id *cm_id, int backlog)
|
|||
cm_info.loc_port = ntohs(laddr->sin_port);
|
||||
|
||||
if (laddr->sin_addr.s_addr != htonl(INADDR_ANY)) {
|
||||
cm_info.vlan_id = irdma_get_vlan_ipv4(cm_info.loc_addr);
|
||||
cm_info.vlan_id = irdma_get_vlan_ipv4(cm_id, cm_info.loc_addr);
|
||||
} else {
|
||||
cm_info.vlan_id = 0xFFFF;
|
||||
wildcard = true;
|
||||
|
@ -3860,7 +3873,7 @@ irdma_create_listen(struct iw_cm_id *cm_id, int backlog)
|
|||
laddr6->sin6_addr.__u6_addr.__u6_addr32);
|
||||
cm_info.loc_port = ntohs(laddr6->sin6_port);
|
||||
if (!IN6_IS_ADDR_UNSPECIFIED(&laddr6->sin6_addr)) {
|
||||
irdma_netdev_vlan_ipv6(cm_info.loc_addr,
|
||||
irdma_netdev_vlan_ipv6(cm_id, cm_info.loc_addr,
|
||||
&cm_info.vlan_id, NULL);
|
||||
} else {
|
||||
cm_info.vlan_id = 0xFFFF;
|
||||
|
|
|
@ -584,8 +584,9 @@ void irdma_gen_ae(struct irdma_pci_f *rf, struct irdma_sc_qp *qp,
|
|||
struct irdma_gen_ae_info *info, bool wait);
|
||||
void irdma_copy_ip_ntohl(u32 *dst, __be32 *src);
|
||||
void irdma_copy_ip_htonl(__be32 *dst, u32 *src);
|
||||
u16 irdma_get_vlan_ipv4(u32 *addr);
|
||||
if_t irdma_netdev_vlan_ipv6(u32 *addr, u16 *vlan_id, u8 *mac);
|
||||
u16 irdma_get_vlan_ipv4(struct iw_cm_id *cm_id, u32 *addr);
|
||||
if_t irdma_netdev_vlan_ipv6(struct iw_cm_id *cm_id, u32 *addr, u16 *vlan_id,
|
||||
u8 *mac);
|
||||
struct ib_mr *irdma_reg_phys_mr(struct ib_pd *ib_pd, u64 addr, u64 size,
|
||||
int acc, u64 *iova_start);
|
||||
int irdma_upload_qp_context(struct irdma_qp *iwqp, bool freeze, bool raw);
|
||||
|
|
|
@ -3336,7 +3336,7 @@ irdma_attach_mcast(struct ib_qp *ibqp, union ib_gid *ibgid, u16 lid)
|
|||
if (!ipv6_addr_v4mapped((struct in6_addr *)ibgid)) {
|
||||
irdma_copy_ip_ntohl(ip_addr,
|
||||
sgid_addr.saddr_in6.sin6_addr.__u6_addr.__u6_addr32);
|
||||
irdma_netdev_vlan_ipv6(ip_addr, &vlan_id, NULL);
|
||||
irdma_netdev_vlan_ipv6(iwqp->cm_id, ip_addr, &vlan_id, NULL);
|
||||
ipv4 = false;
|
||||
irdma_debug(&iwdev->rf->sc_dev, IRDMA_DEBUG_VERBS,
|
||||
"qp_id=%d, IP6address=%x:%x:%x:%x\n", ibqp->qp_num,
|
||||
|
@ -3345,7 +3345,7 @@ irdma_attach_mcast(struct ib_qp *ibqp, union ib_gid *ibgid, u16 lid)
|
|||
} else {
|
||||
ip_addr[0] = ntohl(sgid_addr.saddr_in.sin_addr.s_addr);
|
||||
ipv4 = true;
|
||||
vlan_id = irdma_get_vlan_ipv4(ip_addr);
|
||||
vlan_id = irdma_get_vlan_ipv4(iwqp->cm_id, ip_addr);
|
||||
irdma_mcast_mac_v4(ip_addr, dmac);
|
||||
irdma_debug(&iwdev->rf->sc_dev, IRDMA_DEBUG_VERBS,
|
||||
"qp_id=%d, IP4address=%x, MAC=%x:%x:%x:%x:%x:%x\n",
|
||||
|
|
Loading…
Reference in a new issue