From patchwork Fri Sep 8 07:00:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 811335 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3xpSrk3YJbz9s83; Fri, 8 Sep 2017 17:00:38 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1dqDHH-0000lb-PY; Fri, 08 Sep 2017 07:00:35 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1dqDHG-0000k0-1I for kernel-team@lists.canonical.com; Fri, 08 Sep 2017 07:00:34 +0000 Received: from mail-pg0-f69.google.com ([74.125.83.69]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1dqDHF-00039W-LD for kernel-team@lists.canonical.com; Fri, 08 Sep 2017 07:00:33 +0000 Received: by mail-pg0-f69.google.com with SMTP id t3so3617038pgt.7 for ; Fri, 08 Sep 2017 00:00:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=9VHH5uOBld5EHRvZoMUWRANBWTZ6iqyYt7A1J3tw7j4=; b=JO/TiVSE9IHkMHi9N6IxR6eLUOeRbbO2CSEqEPWLhIVIpR6MHGZPfU/1gyIQigZj/L gzErNlE0RC8Q9FN/GN+72rqmgIUAM1WN/N1LCdudoZ+dZWeJq4ZKLGGA9UzcmrN7ezcJ RY55YTfcF6rY5UssruBwI2LKOMG0E25eLrosDUyjbKq3bJlaYVPAinWOFeScyzB055s7 HYYAK63u/w/kG0JRaFtzVMn9Cq/+fhcrhLSJs0f/lfGXp9Ik5aa9w6TCLTIQviDHK9eO aNlwGKluxd4NcS09PpdXrUxYb6yDDxZEfUfdTUi2dOWKtt9YfLtv/RgOkBs+rbgHNeqw RiYw== X-Gm-Message-State: AHPjjUhpz9hRcnlmDBZcKi16CFPv9Cm5t1ydAc1ewpqmokQA7jZ2HAkx Kcyp7CU2L8D373QtTzbVr9p2C0TAnmz0wuVQ8H5ycOk2LosI7/63QIdwKYMQofpBjZ1NGhpcbRO 3W7RswIPh0l4ggxkeutufnWsVg72nhChQfG1Dg00= X-Received: by 10.84.128.72 with SMTP id 66mr2325605pla.119.1504854032218; Fri, 08 Sep 2017 00:00:32 -0700 (PDT) X-Google-Smtp-Source: ADKCNb7tPJPNzPZYIlnllYPWBdCkL8dzP+7LTTcWTHKOv1yeyDY3bokZazAJQ/JMiWfCxRKJ3Pl1WA== X-Received: by 10.84.128.72 with SMTP id 66mr2325593pla.119.1504854032015; Fri, 08 Sep 2017 00:00:32 -0700 (PDT) Received: from localhost.localdomain (124-171-202-56.dyn.iinet.net.au. [124.171.202.56]) by smtp.gmail.com with ESMTPSA id 125sm2138129pff.5.2017.09.08.00.00.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Sep 2017 00:00:31 -0700 (PDT) From: Daniel Axtens To: kernel-team@lists.canonical.com Subject: [SRU][Zesty][PATCH 2/7] net: add dst_pending_confirm flag to skbuff Date: Fri, 8 Sep 2017 17:00:13 +1000 Message-Id: <20170908070018.4141-3-daniel.axtens@canonical.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170908070018.4141-1-daniel.axtens@canonical.com> References: <20170908070018.4141-1-daniel.axtens@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Julian Anastasov BugLink: https://bugs.launchpad.net/bugs/1715812 Add new skbuff flag to allow protocols to confirm neighbour. When same struct dst_entry can be used for many different neighbours we can not use it for pending confirmations. Add sock_confirm_neigh() helper to confirm the neighbour and use it for IPv4, IPv6 and VRF before dst_neigh_output. Signed-off-by: Julian Anastasov Acked-by: Eric Dumazet Signed-off-by: David S. Miller (cherry picked from commit 4ff0620354f2b39b9fe2a91c22c4de9d1fba0c8e) Signed-off-by: Daniel Axtens --- drivers/net/vrf.c | 5 ++++- include/linux/skbuff.h | 12 ++++++++++++ include/net/sock.h | 14 ++++++++++++++ net/ipv4/ip_output.c | 5 ++++- net/ipv6/ip6_output.c | 1 + 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c index f2fd52e71a5e..82232897c994 100644 --- a/drivers/net/vrf.c +++ b/drivers/net/vrf.c @@ -380,6 +380,7 @@ static int vrf_finish_output6(struct net *net, struct sock *sk, if (unlikely(!neigh)) neigh = __neigh_create(&nd_tbl, nexthop, dst->dev, false); if (!IS_ERR(neigh)) { + sock_confirm_neigh(skb, neigh); ret = dst_neigh_output(dst, neigh, skb); rcu_read_unlock_bh(); return ret; @@ -578,8 +579,10 @@ static int vrf_finish_output(struct net *net, struct sock *sk, struct sk_buff *s neigh = __ipv4_neigh_lookup_noref(dev, nexthop); if (unlikely(!neigh)) neigh = __neigh_create(&arp_tbl, &nexthop, dev, false); - if (!IS_ERR(neigh)) + if (!IS_ERR(neigh)) { + sock_confirm_neigh(skb, neigh); ret = dst_neigh_output(dst, neigh, skb); + } rcu_read_unlock_bh(); err: diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index a410715bbef8..ee060e8c6ff1 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -610,6 +610,7 @@ static inline bool skb_mstamp_after(const struct skb_mstamp *t1, * @wifi_acked_valid: wifi_acked was set * @wifi_acked: whether frame was acked on wifi or not * @no_fcs: Request NIC to treat last 4 bytes as Ethernet FCS + * @dst_pending_confirm: need to confirm neighbour * @napi_id: id of the NAPI struct this skb came from * @secmark: security marking * @mark: Generic packet mark @@ -740,6 +741,7 @@ struct sk_buff { __u8 csum_level:2; __u8 csum_bad:1; + __u8 dst_pending_confirm:1; #ifdef CONFIG_IPV6_NDISC_NODETYPE __u8 ndisc_nodetype:2; #endif @@ -3689,6 +3691,16 @@ static inline bool skb_rx_queue_recorded(const struct sk_buff *skb) return skb->queue_mapping != 0; } +static inline void skb_set_dst_pending_confirm(struct sk_buff *skb, u32 val) +{ + skb->dst_pending_confirm = val; +} + +static inline bool skb_get_dst_pending_confirm(const struct sk_buff *skb) +{ + return skb->dst_pending_confirm != 0; +} + static inline struct sec_path *skb_sec_path(struct sk_buff *skb) { #ifdef CONFIG_XFRM diff --git a/include/net/sock.h b/include/net/sock.h index 7e4ca83a6815..dfe020eea2ae 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1818,6 +1818,20 @@ static inline void sk_dst_confirm(struct sock *sk) sk->sk_dst_pending_confirm = 1; } +static inline void sock_confirm_neigh(struct sk_buff *skb, struct neighbour *n) +{ + if (skb_get_dst_pending_confirm(skb)) { + struct sock *sk = skb->sk; + unsigned long now = jiffies; + + /* avoid dirtying neighbour */ + if (n->confirmed != now) + n->confirmed = now; + if (sk && sk->sk_dst_pending_confirm) + sk->sk_dst_pending_confirm = 0; + } +} + bool sk_mc_loop(struct sock *sk); static inline bool sk_can_gso(const struct sock *sk) diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 49e9b2bc6e33..8c85cad2b2af 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -222,7 +222,10 @@ static int ip_finish_output2(struct net *net, struct sock *sk, struct sk_buff *s if (unlikely(!neigh)) neigh = __neigh_create(&arp_tbl, &nexthop, dev, false); if (!IS_ERR(neigh)) { - int res = dst_neigh_output(dst, neigh, skb); + int res; + + sock_confirm_neigh(skb, neigh); + res = dst_neigh_output(dst, neigh, skb); rcu_read_unlock_bh(); return res; diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index b65ce893f1cb..7ceac3b8694a 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -119,6 +119,7 @@ static int ip6_finish_output2(struct net *net, struct sock *sk, struct sk_buff * if (unlikely(!neigh)) neigh = __neigh_create(&nd_tbl, nexthop, dst->dev, false); if (!IS_ERR(neigh)) { + sock_confirm_neigh(skb, neigh); ret = dst_neigh_output(dst, neigh, skb); rcu_read_unlock_bh(); return ret;