Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp469779pxv; Fri, 9 Jul 2021 02:06:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUUJpur5lw8CGVaerIdG8seJhvGNIk6XdVJGd9n5aznNBUEBpWzNHu6WN0SgsNQeRNvVue X-Received: by 2002:a92:de12:: with SMTP id x18mr26000674ilm.302.1625821599581; Fri, 09 Jul 2021 02:06:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625821599; cv=none; d=google.com; s=arc-20160816; b=oVRTztfeJp4IaQq41h4ZyncmMZW6l6ELD5PLCsYQmlcpNSurb8hjOXoycDcvWwuHIo m3/qLdjg/wcN7X986LI6Dc3jnwOw9PHtStpeBUdmaXGJikPV0Lx9glTXwTnY8PlDhEwP 1pt7dLWLNgG+ud6ACTCoHo1mF+X1iNxHmQ/r6F8WMgze5dUaln5fMsHoUUC+Y727/1qz 4y+WBF5JX0bBI9CsGHxdbQ7lherB/V90NzTezo1defakJ4yFgYsXxBIBTdo3rbEJQWNJ wglH4gvQ/drbtKzwuD6O1o0uxbFCpdRRKzWQ6JjVDyAZ1SFnXXEGJLi6tZqWfPDfcMtR CtHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:subject:from:dkim-signature; bh=bAHAmll9iZ3ZS6kuA6smeZGKYExMEehIWaRaiXEaIhw=; b=Xe8x9sYvUWAFj01YBXIgzyX8y8d3KGH92GBQKxn2FMl8Fm9aBogy4NmXyhIxkrDPMw 82YAdR32UkWSdZ4t2++ylYapI041jj1SeO5jReBqFv274sr/u073L9kf0zdliezdfgSQ Rtp8lNjqmZDk/hPY+5Gzm/FvX1IKqE1PfCboceavdKvFJjeAhD+z5RgjKJoJm9yiid4I akzryF1CIuJJulY+R69QthYaELq76jgu5x2u8iA/qZ5BsKPoLG+/7FuC7ezXleb161qA 3A3tKWMJ9pVrqGxm3LAG2dgRKtAduiMh0G83RwFveYLG/HzWmT//K56a2DAOnaG6pagU ZFgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=Wt+jQ05O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o17si5133086ill.146.2021.07.09.02.06.27; Fri, 09 Jul 2021 02:06:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=Wt+jQ05O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231758AbhGIJIV (ORCPT + 99 others); Fri, 9 Jul 2021 05:08:21 -0400 Received: from relay.sw.ru ([185.231.240.75]:59556 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229563AbhGIJIV (ORCPT ); Fri, 9 Jul 2021 05:08:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Content-Type:MIME-Version:Date:Message-ID:Subject :From; bh=bAHAmll9iZ3ZS6kuA6smeZGKYExMEehIWaRaiXEaIhw=; b=Wt+jQ05O4i1YgH8tq47 jR/tZ8+vDs94qehwiYsdfna4sIytgKqNPF04W6ccNARfk9aBKcvkI2dlAVbXGfxzQND1PCyNd1kcx G0FR91jfMWKTEXtK4WHNPL0fnKlaOEr0K3Nw4cQQQtITeaSH+HqbybfeXRIOApyU7Mj4qJwagL0=; Received: from [10.93.0.56] by relay.sw.ru with esmtp (Exim 4.94.2) (envelope-from ) id 1m1mS0-003Pln-Ik; Fri, 09 Jul 2021 12:05:36 +0300 From: Vasily Averin Subject: [PATCH IPV6 v2 3/4] ipv6: ip6_finish_output2 refactoring To: "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Jakub Kicinski , Eric Dumazet Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <1cbf3c7b-455e-f3a5-cc2c-c18ce8be4ce1@gmail.com> Message-ID: Date: Fri, 9 Jul 2021 12:05:35 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commonly used dereferences was replaced by variables. Signed-off-by: Vasily Averin --- net/ipv6/ip6_output.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 9418802..9ae3baa 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -83,9 +83,11 @@ static int ip6_finish_output2(struct net *net, struct sock *sk, struct sk_buff * { struct dst_entry *dst = skb_dst(skb); struct net_device *dev = dst->dev; + struct inet6_dev *idev = ip6_dst_idev(dst); unsigned int hh_len = LL_RESERVED_SPACE(dev); int delta = hh_len - skb_headroom(skb); - const struct in6_addr *nexthop; + const struct in6_addr *daddr, *nexthop; + struct ipv6hdr *hdr; struct neighbour *neigh; int ret; @@ -94,18 +96,17 @@ static int ip6_finish_output2(struct net *net, struct sock *sk, struct sk_buff * skb = skb_expand_head(skb, delta); if (!skb) { - IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTDISCARDS); + IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTDISCARDS); return -ENOMEM; } - if (ipv6_addr_is_multicast(&ipv6_hdr(skb)->daddr)) { - struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb)); - + hdr = ipv6_hdr(skb); + daddr = &hdr->daddr; + if (ipv6_addr_is_multicast(daddr)) { if (!(dev->flags & IFF_LOOPBACK) && sk_mc_loop(sk) && ((mroute6_is_socket(net, skb) && !(IP6CB(skb)->flags & IP6SKB_FORWARDED)) || - ipv6_chk_mcast_addr(dev, &ipv6_hdr(skb)->daddr, - &ipv6_hdr(skb)->saddr))) { + ipv6_chk_mcast_addr(dev, daddr, &hdr->saddr))) { struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC); /* Do not check for IFF_ALLMULTI; multicast routing @@ -116,7 +117,7 @@ static int ip6_finish_output2(struct net *net, struct sock *sk, struct sk_buff * net, sk, newskb, NULL, newskb->dev, dev_loopback_xmit); - if (ipv6_hdr(skb)->hop_limit == 0) { + if (hdr->hop_limit == 0) { IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTDISCARDS); kfree_skb(skb); @@ -125,9 +126,7 @@ static int ip6_finish_output2(struct net *net, struct sock *sk, struct sk_buff * } IP6_UPD_PO_STATS(net, idev, IPSTATS_MIB_OUTMCAST, skb->len); - - if (IPV6_ADDR_MC_SCOPE(&ipv6_hdr(skb)->daddr) <= - IPV6_ADDR_SCOPE_NODELOCAL && + if (IPV6_ADDR_MC_SCOPE(daddr) <= IPV6_ADDR_SCOPE_NODELOCAL && !(dev->flags & IFF_LOOPBACK)) { kfree_skb(skb); return 0; @@ -142,10 +141,10 @@ static int ip6_finish_output2(struct net *net, struct sock *sk, struct sk_buff * } rcu_read_lock_bh(); - nexthop = rt6_nexthop((struct rt6_info *)dst, &ipv6_hdr(skb)->daddr); - neigh = __ipv6_neigh_lookup_noref(dst->dev, nexthop); + nexthop = rt6_nexthop((struct rt6_info *)dst, daddr); + neigh = __ipv6_neigh_lookup_noref(dev, nexthop); if (unlikely(!neigh)) - neigh = __neigh_create(&nd_tbl, nexthop, dst->dev, false); + neigh = __neigh_create(&nd_tbl, nexthop, dev, false); if (!IS_ERR(neigh)) { sock_confirm_neigh(skb, neigh); ret = neigh_output(neigh, skb, false); @@ -154,7 +153,7 @@ static int ip6_finish_output2(struct net *net, struct sock *sk, struct sk_buff * } rcu_read_unlock_bh(); - IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES); + IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTNOROUTES); kfree_skb(skb); return -EINVAL; } -- 1.8.3.1