diff mbox

[5/7] IB/rxe: Fix destination cache for IPv6

Message ID 1500989968-30889-6-git-send-email-andrew.boyer@dell.com (mailing list archive)
State Changes Requested
Headers show

Commit Message

Andrew Boyer July 25, 2017, 1:39 p.m. UTC
To successfully match an IPv6 path, the path cookie must match. Store it
in the QP so that the IPv6 path can be reused.

Replace open-coded version of dst_check() with the actual call, fixing the
logic. The open-coded version skips the check call if dst->obsolete is 0
(DST_OBSOLETE_NONE), proceeding to replace the route. DST_OBSOLETE_NONE
means that the route may continue to be used, though.

Add dst_clone() in prepare_ipv6_hdr(). Otherwise the reference count goes
negative as packets complete.

Replace sk_dst_get()/dst_release() in rxe_qp_cleanup() with sk_dst_reset().
sk_dst_get() takes a new reference on dst, so the dst_release() doesn't
actually release the original reference, which was the design intent.

Remove unneeded initialization in prepare6().

Fixes: 4ed6ad1eb30e ("IB/rxe: Cache dst in QP instead of getting it...")
Signed-off-by: Andrew Boyer <andrew.boyer@dell.com>
---
 drivers/infiniband/sw/rxe/rxe_net.c   | 9 ++++++---
 drivers/infiniband/sw/rxe/rxe_qp.c    | 9 ++-------
 drivers/infiniband/sw/rxe/rxe_verbs.h | 1 +
 3 files changed, 9 insertions(+), 10 deletions(-)

Comments

kernel test robot July 27, 2017, 6:41 a.m. UTC | #1
Hi Andrew,

[auto build test ERROR on rdma/master]
[also build test ERROR on v4.13-rc2 next-20170726]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Andrew-Boyer/IB-rxe-Move-refcounting-earlier-in-rxe_send/20170726-141937
base:   https://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma.git master
config: i386-randconfig-i1-07240017 (attached as .config)
compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/infiniband//sw/rxe/rxe_net.c: In function 'rxe_find_route':
>> drivers/infiniband//sw/rxe/rxe_net.c:214:6: error: implicit declaration of function 'rt6_get_cookie' [-Werror=implicit-function-declaration]
         rt6_get_cookie((struct rt6_info *)dst);
         ^
   cc1: some warnings being treated as errors

vim +/rt6_get_cookie +214 drivers/infiniband//sw/rxe/rxe_net.c

   184	
   185	static struct dst_entry *rxe_find_route(struct rxe_dev *rxe,
   186						struct rxe_qp *qp,
   187						struct rxe_av *av)
   188	{
   189		struct dst_entry *dst = NULL;
   190	
   191		if (qp_type(qp) == IB_QPT_RC)
   192			dst = sk_dst_get(qp->sk->sk);
   193	
   194		if (!dst || !dst_check(dst, qp->dst_cookie)) {
   195			if (dst)
   196				dst_release(dst);
   197	
   198			if (av->network_type == RDMA_NETWORK_IPV4) {
   199				struct in_addr *saddr;
   200				struct in_addr *daddr;
   201	
   202				saddr = &av->sgid_addr._sockaddr_in.sin_addr;
   203				daddr = &av->dgid_addr._sockaddr_in.sin_addr;
   204				dst = rxe_find_route4(rxe->ndev, saddr, daddr);
   205			} else if (av->network_type == RDMA_NETWORK_IPV6) {
   206				struct in6_addr *saddr6;
   207				struct in6_addr *daddr6;
   208	
   209				saddr6 = &av->sgid_addr._sockaddr_in6.sin6_addr;
   210				daddr6 = &av->dgid_addr._sockaddr_in6.sin6_addr;
   211				dst = rxe_find_route6(rxe->ndev, saddr6, daddr6);
   212				if (dst)
   213					qp->dst_cookie =
 > 214						rt6_get_cookie((struct rt6_info *)dst);
   215			}
   216		}
   217	
   218		return dst;
   219	}
   220	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Moni Shoua July 27, 2017, 12:07 p.m. UTC | #2
On Tue, Jul 25, 2017 at 4:39 PM, Andrew Boyer <andrew.boyer@dell.com> wrote:
> To successfully match an IPv6 path, the path cookie must match. Store it
> in the QP so that the IPv6 path can be reused.
>
> Replace open-coded version of dst_check() with the actual call, fixing the
> logic. The open-coded version skips the check call if dst->obsolete is 0
> (DST_OBSOLETE_NONE), proceeding to replace the route. DST_OBSOLETE_NONE
> means that the route may continue to be used, though.
>
> Add dst_clone() in prepare_ipv6_hdr(). Otherwise the reference count goes
> negative as packets complete.
>
> Replace sk_dst_get()/dst_release() in rxe_qp_cleanup() with sk_dst_reset().
> sk_dst_get() takes a new reference on dst, so the dst_release() doesn't
> actually release the original reference, which was the design intent.
>
> Remove unneeded initialization in prepare6().
>
> Fixes: 4ed6ad1eb30e ("IB/rxe: Cache dst in QP instead of getting it...")
> Signed-off-by: Andrew Boyer <andrew.boyer@dell.com>
> ---
>  drivers/infiniband/sw/rxe/rxe_net.c   | 9 ++++++---
>  drivers/infiniband/sw/rxe/rxe_qp.c    | 9 ++-------
>  drivers/infiniband/sw/rxe/rxe_verbs.h | 1 +
>  3 files changed, 9 insertions(+), 10 deletions(-)
>
Fixes seem to be correct but I identify here 3 unrelated patches.
Please split
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andrew Boyer July 27, 2017, 1:24 p.m. UTC | #3
Looks like I forgot to check for CONFIG_IPV6.

On 7/27/17, 2:41 AM, "kbuild test robot" <lkp@intel.com> wrote:

>Hi Andrew,
>
>[auto build test ERROR on rdma/master]
>[also build test ERROR on v4.13-rc2 next-20170726]
>[if your patch is applied to the wrong git tree, please drop us a note to
>help improve the system]
>
>url:    
>https://github.com/0day-ci/linux/commits/Andrew-Boyer/IB-rxe-Move-refcount
>ing-earlier-in-rxe_send/20170726-141937
>base:   https://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma.git
>master
>config: i386-randconfig-i1-07240017 (attached as .config)
>compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
>reproduce:
>        # save the attached .config to linux build tree
>        make ARCH=i386
>
>All errors (new ones prefixed by >>):
>
>   drivers/infiniband//sw/rxe/rxe_net.c: In function 'rxe_find_route':
>>> drivers/infiniband//sw/rxe/rxe_net.c:214:6: error: implicit
>>>declaration of function 'rt6_get_cookie'
>>>[-Werror=implicit-function-declaration]
>         rt6_get_cookie((struct rt6_info *)dst);
>         ^
>   cc1: some warnings being treated as errors
>
>vim +/rt6_get_cookie +214 drivers/infiniband//sw/rxe/rxe_net.c
>
>   184	
>   185	static struct dst_entry *rxe_find_route(struct rxe_dev *rxe,
>   186						struct rxe_qp *qp,
>   187						struct rxe_av *av)
>   188	{
>   189		struct dst_entry *dst = NULL;
>   190	
>   191		if (qp_type(qp) == IB_QPT_RC)
>   192			dst = sk_dst_get(qp->sk->sk);
>   193	
>   194		if (!dst || !dst_check(dst, qp->dst_cookie)) {
>   195			if (dst)
>   196				dst_release(dst);
>   197	
>   198			if (av->network_type == RDMA_NETWORK_IPV4) {
>   199				struct in_addr *saddr;
>   200				struct in_addr *daddr;
>   201	
>   202				saddr = &av->sgid_addr._sockaddr_in.sin_addr;
>   203				daddr = &av->dgid_addr._sockaddr_in.sin_addr;
>   204				dst = rxe_find_route4(rxe->ndev, saddr, daddr);
>   205			} else if (av->network_type == RDMA_NETWORK_IPV6) {
>   206				struct in6_addr *saddr6;
>   207				struct in6_addr *daddr6;
>   208	
>   209				saddr6 = &av->sgid_addr._sockaddr_in6.sin6_addr;
>   210				daddr6 = &av->dgid_addr._sockaddr_in6.sin6_addr;
>   211				dst = rxe_find_route6(rxe->ndev, saddr6, daddr6);
>   212				if (dst)
>   213					qp->dst_cookie =
> > 214						rt6_get_cookie((struct rt6_info *)dst);
>   215			}
>   216		}
>   217	
>   218		return dst;
>   219	}
>   220	
>
>---
>0-DAY kernel test infrastructure                Open Source Technology
>Center
>https://lists.01.org/pipermail/kbuild-all                   Intel
>Corporation

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
index 0810f38..6aeda61 100644
--- a/drivers/infiniband/sw/rxe/rxe_net.c
+++ b/drivers/infiniband/sw/rxe/rxe_net.c
@@ -191,7 +191,7 @@  static struct dst_entry *rxe_find_route(struct rxe_dev *rxe,
 	if (qp_type(qp) == IB_QPT_RC)
 		dst = sk_dst_get(qp->sk->sk);
 
-	if (!dst || !(dst->obsolete && dst->ops->check(dst, 0))) {
+	if (!dst || !dst_check(dst, qp->dst_cookie)) {
 		if (dst)
 			dst_release(dst);
 
@@ -209,6 +209,9 @@  static struct dst_entry *rxe_find_route(struct rxe_dev *rxe,
 			saddr6 = &av->sgid_addr._sockaddr_in6.sin6_addr;
 			daddr6 = &av->dgid_addr._sockaddr_in6.sin6_addr;
 			dst = rxe_find_route6(rxe->ndev, saddr6, daddr6);
+			if (dst)
+				qp->dst_cookie =
+					rt6_get_cookie((struct rt6_info *)dst);
 		}
 	}
 
@@ -337,7 +340,7 @@  static void prepare_ipv6_hdr(struct dst_entry *dst, struct sk_buff *skb,
 	memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
 	IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED
 			    | IPSKB_REROUTED);
-	skb_dst_set(skb, dst);
+	skb_dst_set(skb, dst_clone(dst));
 
 	__skb_push(skb, sizeof(*ip6h));
 	skb_reset_network_header(skb);
@@ -388,7 +391,7 @@  static int prepare6(struct rxe_dev *rxe, struct rxe_pkt_info *pkt,
 		    struct sk_buff *skb, struct rxe_av *av)
 {
 	struct rxe_qp *qp = pkt->qp;
-	struct dst_entry *dst = NULL;
+	struct dst_entry *dst;
 	struct in6_addr *saddr = &av->sgid_addr._sockaddr_in6.sin6_addr;
 	struct in6_addr *daddr = &av->dgid_addr._sockaddr_in6.sin6_addr;
 
diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c
index 80ccc7c..00bda93 100644
--- a/drivers/infiniband/sw/rxe/rxe_qp.c
+++ b/drivers/infiniband/sw/rxe/rxe_qp.c
@@ -851,13 +851,8 @@  void rxe_qp_cleanup(struct rxe_pool_entry *arg)
 		qp->resp.mr = NULL;
 	}
 
-	if (qp_type(qp) == IB_QPT_RC) {
-		struct dst_entry *dst = NULL;
-
-		dst = sk_dst_get(qp->sk->sk);
-		if (dst)
-			dst_release(dst);
-	}
+	if (qp_type(qp) == IB_QPT_RC)
+		sk_dst_reset(qp->sk->sk);
 
 	free_rd_atomic_resources(qp);
 
diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.h b/drivers/infiniband/sw/rxe/rxe_verbs.h
index b09a9e2..0c2dbe4 100644
--- a/drivers/infiniband/sw/rxe/rxe_verbs.h
+++ b/drivers/infiniband/sw/rxe/rxe_verbs.h
@@ -248,6 +248,7 @@  struct rxe_qp {
 	struct rxe_rq		rq;
 
 	struct socket		*sk;
+	u32			dst_cookie;
 
 	struct rxe_av		pri_av;
 	struct rxe_av		alt_av;