From adbb3637ec50e857f3ec890746e0a7b480860818 Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Wed, 27 Dec 2017 22:44:50 +0000 Subject: [PATCH] cxgbe/iw_cxgbe: Fix iWARP over VLANs (catch up with r326169). Submitted by: KrishnamRaju ErapaRaju @ Chelsio Sponsored by: Chelsio Communications --- sys/dev/cxgbe/iw_cxgbe/cm.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/sys/dev/cxgbe/iw_cxgbe/cm.c b/sys/dev/cxgbe/iw_cxgbe/cm.c index a38e4db66992..ce42a90ad59b 100644 --- a/sys/dev/cxgbe/iw_cxgbe/cm.c +++ b/sys/dev/cxgbe/iw_cxgbe/cm.c @@ -339,23 +339,27 @@ find_real_listen_ep(struct c4iw_listen_ep *master_lep, struct socket *so) { struct adapter *adap = NULL; struct c4iw_listen_ep *lep = NULL; - struct sockaddr_storage remote = { 0 }; - struct ifnet *new_conn_ifp = NULL; + struct ifnet *ifp = NULL, *hw_ifp = NULL; struct listen_port_info *port_info = NULL; - int err = 0, i = 0, - found_portinfo = 0, found_lep = 0; + int i = 0, found_portinfo = 0, found_lep = 0; uint16_t port; - /* STEP 1: get 'ifnet' based on socket's remote address */ - GET_REMOTE_ADDR(&remote, so); - - err = get_ifnet_from_raddr(&remote, &new_conn_ifp); - if (err) { - CTR4(KTR_IW_CXGBE, "%s: Failed to get ifnet, sock %p, " - "master_lep %p err %d", - __func__, so, master_lep, err); - return (NULL); - } + /* + * STEP 1: Figure out 'ifp' of the physical interface, not pseudo + * interfaces like vlan, lagg, etc.. + * TBD: lagg support, lagg + vlan support. + */ + ifp = TOEPCB(so)->l2te->ifp; + if (ifp->if_type == IFT_L2VLAN) { + hw_ifp = VLAN_TRUNKDEV(ifp); + if (hw_ifp == NULL) { + CTR4(KTR_IW_CXGBE, "%s: Failed to get parent ifnet of " + "vlan ifnet %p, sock %p, master_lep %p", + __func__, ifp, so, master_lep); + return (NULL); + } + } else + hw_ifp = ifp; /* STEP 2: Find 'port_info' with listener local port address. */ port = (master_lep->com.local_addr.ss_family == AF_INET) ? @@ -379,7 +383,7 @@ find_real_listen_ep(struct c4iw_listen_ep *master_lep, struct socket *so) list_for_each_entry(lep, &port_info->lep_list, listen_ep_list) { adap = lep->com.dev->rdev.adap; for_each_port(adap, i) { - if (new_conn_ifp == adap->port[i]->vi[0].ifp) { + if (hw_ifp == adap->port[i]->vi[0].ifp) { found_lep =1; goto out; }