Re: [PATCHv2 1/2] IB/rxe: make rxe_find_route6 compact

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 2018/3/31 11:28, Yanjun Zhu wrote:


On 2018/3/30 2:08, Jason Gunthorpe wrote:
On Thu, Mar 29, 2018 at 03:46:36AM -0400, Zhu Yanjun wrote:
In the file rxe_net.c, to make rxe_find_route6 compact,
IPV6_CONFIG is moved into the function rxe_find_route6.

CC: Srinivas Eeda <srinivas.eeda@xxxxxxxxxx>
CC: Junxiao Bi <junxiao.bi@xxxxxxxxxx>
Signed-off-by: Zhu Yanjun <yanjun.zhu@xxxxxxxxxx>
V1->V2: Follow Jason's advice, remove ifdef.
  drivers/infiniband/sw/rxe/rxe_net.c | 55 ++++++++++++++++---------------------
  1 file changed, 23 insertions(+), 32 deletions(-)

diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c
index 159246b..01f26f3 100644
+++ b/drivers/infiniband/sw/rxe/rxe_net.c
@@ -140,48 +140,39 @@ static struct dst_entry *rxe_find_route4(struct net_device *ndev,
      return &rt->dst;
  }
  -#if IS_ENABLED(CONFIG_IPV6)
  static struct dst_entry *rxe_find_route6(struct net_device *ndev,
                       struct in6_addr *saddr,
                       struct in6_addr *daddr)
  {
-    struct dst_entry *ndst;
-    struct flowi6 fl6 = { { 0 } };
-
-    memset(&fl6, 0, sizeof(fl6));
-    fl6.flowi6_oif = ndev->ifindex;
-    memcpy(&fl6.saddr, saddr, sizeof(*saddr));
-    memcpy(&fl6.daddr, daddr, sizeof(*daddr));
-    fl6.flowi6_proto = IPPROTO_UDP;
-
-    if (unlikely(ipv6_stub->ipv6_dst_lookup(sock_net(recv_sockets.sk6->sk),
-                        recv_sockets.sk6->sk, &ndst, &fl6))) {
-        pr_err_ratelimited("no route to %pI6\n", daddr);
-        goto put;
-    }
+    if (IS_ENABLED(CONFIG_IPV6)) {
+        struct dst_entry *ndst;
+        struct flowi6 fl6 = { { 0 } };
you don't need to re-indent the entire function, I literally did mean
to just add

    if (!IS_ENABLED(CONFIG_IPV6))
            return NULL;

At the top after the variables. That is enough to get the compiler to
eliminare the function calls which are the only problematic thing when
IPv6 is not enabled
sorry. when ipv6 is not enabled, the following will appear.

In file included from ./include/linux/kernel.h:10:0,
                 from ./include/linux/skbuff.h:17,
                 from drivers/infiniband/sw/rxe/rxe_net.c:34:
drivers/infiniband/sw/rxe/rxe_net.c: In function ‘rxe_find_route6’:
drivers/infiniband/sw/rxe/rxe_net.c:159:15: error: ‘ipv6_stub’ undeclared (first use in this function)
  if (unlikely(ipv6_stub->ipv6_dst_lookup(sock_net(recv_sockets.sk6->sk),
               ^
./include/linux/compiler.h:77:42: note: in definition of macro ‘unlikely’
 # define unlikely(x) __builtin_expect(!!(x), 0)
                                          ^
drivers/infiniband/sw/rxe/rxe_net.c:159:15: note: each undeclared identifier is reported only once for each function it appears in
  if (unlikely(ipv6_stub->ipv6_dst_lookup(sock_net(recv_sockets.sk6->sk),
               ^
./include/linux/compiler.h:77:42: note: in definition of macro ‘unlikely’
 # define unlikely(x) __builtin_expect(!!(x), 0)

This is because ipv6_stub is defined in ./net/ipv6/addrconf_core.c. When ipv6 is not enabled, ipv6_stub is not included into kernel.
So I have to use #if.

Zhu Yanjun
OK. I will make a new patch.

Zhu Yanjun

Jason


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


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



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux