From patchwork Sat Jun 16 07:06:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hurrhnn--- via openwrt-devel X-Patchwork-Id: 930314 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=lists.openwrt.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qJouVhQm"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4177hk4lSVz9rxs for ; Sat, 16 Jun 2018 17:07:14 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Date:Sender:Content-Type: Subject:List-Help:Reply-To:List-Archive:List-Unsubscribe:List-Subscribe:Cc: From:List-Post:List-Id:Message-ID:MIME-Version:To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=QLljoYfKuBsG4rbEOc7SdW7DAwu4vIBf/NARSShysVA=; b=qJouVhQmY9wC+dkt5Sl2uO9uWc mgcyZZ+8TZsL76SKA6ZHmEUjqnGHwW+885s63kOFyvGlt3XYi/CJW08ib49yIClNXJSSJkrILwoEd GmK2wGFLMWjPgx5/odFYfSGjDEAGR0YxiBV9Uxf60tKPdpGDuTafblRscr3mNn3EprTh70HzwuXHk W5qos3dXbcXQdA1LdfnZpnuhJAcSY7YEg2lui1rDsrZpCq8X+hJfEoTNevn8M2J758nEWLhRfBRfY mbQC2hNZYe+bzxImr8WIOMUcbEacguE6DQGhgCvWPe8xL6mu/O+m7pjRvz2sgPXMsUURoyXDww06M FXDyrmxA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fU5IN-0001cR-6B; Sat, 16 Jun 2018 07:06:47 +0000 To: openwrt-devel@lists.openwrt.org MIME-Version: 1.0 Message-ID: List-Id: List-Post: X-Patchwork-Original-From: Kevin Darbyshire-Bryant via openwrt-devel From: hurrhnn--- via openwrt-devel Precedence: list Cc: Kevin Darbyshire-Bryant X-Mailman-Version: 2.1.21 X-BeenThere: openwrt-devel@lists.openwrt.org List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Kevin Darbyshire-Bryant List-Help: Subject: [OpenWrt-Devel] [PATCH 1/2] lantiq: atm: fix ifx_atm driver integration Sender: "openwrt-devel" Date: Sat, 16 Jun 2018 07:06:47 +0000 Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The sender domain has a DMARC Reject/Quarantine policy which disallows sending mailing list messages using the original "From" header. To mitigate this problem, the original message has been wrapped automatically by the mailing list software. When upstream kernel introduced commit c55fa3cccbc2c672e7f118be8f7484e53a8e9e77 we incorrectly updated our hack integration patch that updates atm/common.c +++ b/net/atm/common.c @@ -62,10 +62,16 @@ static void vcc_remove_socket(struct soc write_unlock_irq(&vcc_sklist_lock); } +struct sk_buff* (*ifx_atm_alloc_tx)(struct atm_vcc *, unsigned int) = NULL; +EXPORT_SYMBOL(ifx_atm_alloc_tx); + static bool vcc_tx_ready(struct atm_vcc *vcc, unsigned int size) { struct sock *sk = sk_atm(vcc); + if (ifx_atm_alloc_tx != NULL) + return ifx_atm_alloc_tx(vcc, size) The correct solution is to drop our ifx_atm_alloc_tx replacement hack entirely and let the kernel do its thing. In reality neither pppoatm or BR2684 interfaces actually hit this code, so the incorrect integration would only be noticed with direct socket calls which we are unaware of a use-case. This is not the solution to pppoatm vc-mux failing to work which started the whole investigation, but let's fix it up anyway. With sincerest thanks to dwmw2 & mkresin. Tested-on: lantiq, BT HomeHub 5a Signed-of-by: Kevin Darbyshire-Bryant Signed-off-by: Kevin Darbyshire-Bryant --- .../lantiq/patches-4.14/0004-MIPS-lantiq-add-atm-hack.patch | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/target/linux/lantiq/patches-4.14/0004-MIPS-lantiq-add-atm-hack.patch b/target/linux/lantiq/patches-4.14/0004-MIPS-lantiq-add-atm-hack.patch index 2c73cec55c..a3441f8533 100644 --- a/target/linux/lantiq/patches-4.14/0004-MIPS-lantiq-add-atm-hack.patch +++ b/target/linux/lantiq/patches-4.14/0004-MIPS-lantiq-add-atm-hack.patch @@ -469,7 +469,7 @@ Signed-off-by: John Crispin int max_pcr; /* maximum PCR in cells per second */ --- a/net/atm/common.c +++ b/net/atm/common.c -@@ -62,10 +62,16 @@ static void vcc_remove_socket(struct soc +@@ -62,6 +62,9 @@ static void vcc_remove_socket(struct soc write_unlock_irq(&vcc_sklist_lock); } @@ -479,13 +479,6 @@ Signed-off-by: John Crispin static bool vcc_tx_ready(struct atm_vcc *vcc, unsigned int size) { struct sock *sk = sk_atm(vcc); - -+ if (ifx_atm_alloc_tx != NULL) -+ return ifx_atm_alloc_tx(vcc, size); -+ - if (sk_wmem_alloc_get(sk) && !atm_may_send(vcc, size)) { - pr_debug("Sorry: wmem_alloc = %d, size = %d, sndbuf = %d\n", - sk_wmem_alloc_get(sk), size, sk->sk_sndbuf); --- a/net/atm/proc.c +++ b/net/atm/proc.c @@ -155,7 +155,7 @@ static void *vcc_seq_next(struct seq_fil From patchwork Sat Jun 16 07:07:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hurrhnn--- via openwrt-devel X-Patchwork-Id: 930315 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=lists.openwrt.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tVnmBbah"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4177hq3Cftz9rxs for ; Sat, 16 Jun 2018 17:07:23 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Date:Sender:Content-Type: Subject:List-Help:Reply-To:List-Archive:List-Unsubscribe:List-Subscribe:Cc: From:List-Post:List-Id:Message-ID:MIME-Version:References:In-Reply-To:To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VEPaFAA8r3JzDb1ma/CXlK3USD9Fcn/IkXBRb9zgfVw=; b=tVnmBbahLh43UkUJbyDYKlxkG nGVTUt55GumXV7OT4lFZE1FW0JaCuUx+surW+SZbzv/RcCql/IqI/4Huuk05oIjfa8nTmCFKr+6Lz ir+UMG7Isn5FFnue8Zcxndz6FAkW+xdGr0ibDFnKp2MdIvAQ8PzPrSDH2Y80UiJ0TyQuvLNpW8ihF ZxIGTBKEHCHo4uZ7kUYDJoF5t+pX75pY8Z5n3g91Oa+ygBpAjvyukJxCSCq28MSweBITMsuP6Ck8E /EH0BugaEqeT7/lAyW7qNIqe1aLyzivYeFJvJxqJT8y3ifdWliyKgJbmvAnUst39ILC1sA1/xRpf0 Nxp4NCAHw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fU5Ij-0001ps-Lc; Sat, 16 Jun 2018 07:07:09 +0000 To: openwrt-devel@lists.openwrt.org In-Reply-To: <20180616070619.21459-1-ldir@darbyshire-bryant.me.uk> References: <20180616070619.21459-1-ldir@darbyshire-bryant.me.uk> MIME-Version: 1.0 Message-ID: List-Id: List-Post: X-Patchwork-Original-From: Kevin Darbyshire-Bryant via openwrt-devel From: hurrhnn--- via openwrt-devel Precedence: list Cc: Kevin Darbyshire-Bryant X-Mailman-Version: 2.1.21 X-BeenThere: openwrt-devel@lists.openwrt.org List-Subscribe: , List-Unsubscribe: , List-Archive: Reply-To: Kevin Darbyshire-Bryant List-Help: Subject: [OpenWrt-Devel] [PATCH 2/2] kernel: atm: pppoatm fix vc-mux connection failures Sender: "openwrt-devel" Date: Sat, 16 Jun 2018 07:07:09 +0000 Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The sender domain has a DMARC Reject/Quarantine policy which disallows sending mailing list messages using the original "From" header. To mitigate this problem, the original message has been wrapped automatically by the mailing list software. Backport a hot off the press upstream kernel ATM fix: Preserve value of skb->truesize when accounting to vcc "There's a hack in pskb_expand_head() to avoid adjusting skb->truesize for certain skbs. Ideally it would cover ATM too. It doesn't. Just stashing the accounted value and using it in atm_raw_pop() is probably the easiest way to cope." The issue was introduced in upstream by: commit 14afee4b6092fde451ee17604e5f5c89da33e71e Author: Reshetova, Elena Date: Fri Jun 30 13:08:00 2017 +0300 net: convert sock.sk_wmem_alloc from atomic_t to refcount_t Sincerest thanks to Mathias Kresin for debugging assistance and to David Woodhouse for further guidance, cajoling & patience in interpreting the debug I was giving him and producing a fix! Fixes FS#1567 Signed-off-by: Kevin Darbyshire-Bryant --- ...-sock.sk_wmem_alloc-from-atomic_t-to-refc.patch | 186 +++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 target/linux/generic/backport-4.14/080-net-convert-sock.sk_wmem_alloc-from-atomic_t-to-refc.patch diff --git a/target/linux/generic/backport-4.14/080-net-convert-sock.sk_wmem_alloc-from-atomic_t-to-refc.patch b/target/linux/generic/backport-4.14/080-net-convert-sock.sk_wmem_alloc-from-atomic_t-to-refc.patch new file mode 100644 index 0000000000..8108d99348 --- /dev/null +++ b/target/linux/generic/backport-4.14/080-net-convert-sock.sk_wmem_alloc-from-atomic_t-to-refc.patch @@ -0,0 +1,186 @@ +From 99967eb67d14b2ed17b194a8dac357d641a06e43 Mon Sep 17 00:00:00 2001 +From: David Woodhouse +Date: Fri, 15 Jun 2018 21:00:27 +0100 +Subject: [PATCH] net: convert sock.sk_wmem_alloc from atomic_t to refcount_t + +On Fri, 2018-06-15 at 14:44 +0100, David Woodhouse wrote: +> +> > Or simply use a new field in ATM_SKB(skb) to remember a stable +> > truesize used in both sides (add/sub) +> +> Right, that was my second suggestion ("copy the accounted value..."). +> +> It's a bit of a hack, and I think that actually *using* sock_wfree() +> instead of what's currently in atm_pop_raw() would be the better +> solution. Does anyone remember why we didn't do that in the first +> place? + +That does end up being quite hairy. I don't think it's worth doing. + +This should probably suffice to fix it... + +Kevin this is going to conflict with the ifx_atm_alloc_skb() hack in +the tree you're working on, but that needs to be killed with fire +anyway. It's utterly pointless as discussed. + +From 3368eaeb0a2f09138894dde0f26f879e5228005a Mon Sep 17 00:00:00 2001 +From: David Woodhouse +Date: Fri, 15 Jun 2018 20:49:20 +0100 +Subject: [PATCH] atm: Preserve value of skb->truesize when accounting to vcc + +There's a hack in pskb_expand_head() to avoid adjusting skb->truesize +for certain skbs. Ideally it would cover ATM too. It doesn't. Just +stashing the accounted value and using it in atm_raw_pop() is probably +the easiest way to cope. + +Signed-off-by: David Woodhouse +Signed-off-by: Kevin Darbyshire-Bryant +--- + include/linux/atmdev.h | 15 +++++++++++++++ + net/atm/br2684.c | 3 +-- + net/atm/clip.c | 3 +-- + net/atm/common.c | 3 +-- + net/atm/lec.c | 3 +-- + net/atm/mpc.c | 3 +-- + net/atm/pppoatm.c | 3 +-- + net/atm/raw.c | 4 ++-- + 8 files changed, 23 insertions(+), 14 deletions(-) + +diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h +index 0c27515d..8124815e 100644 +--- a/include/linux/atmdev.h ++++ b/include/linux/atmdev.h +@@ -214,6 +214,7 @@ struct atmphy_ops { + struct atm_skb_data { + struct atm_vcc *vcc; /* ATM VCC */ + unsigned long atm_options; /* ATM layer options */ ++ unsigned int acct_truesize; /* truesize accounted to vcc */ + }; + + #define VCC_HTABLE_SIZE 32 +@@ -241,6 +242,20 @@ void vcc_insert_socket(struct sock *sk); + + void atm_dev_release_vccs(struct atm_dev *dev); + ++static inline void atm_account_tx(struct atm_vcc *vcc, struct sk_buff *skb) ++{ ++ /* ++ * Because ATM skbs may not belong to a sock (and we don't ++ * necessarily want to), skb->truesize may be adjusted, ++ * escaping the hack in pskb_expand_head() which avoids ++ * doing so for some cases. So stash the value of truesize ++ * at the time we accounted it, and atm_pop_raw() can use ++ * that value later, in case it changes. ++ */ ++ refcount_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); ++ ATM_SKB(skb)->acct_truesize = skb->truesize; ++ ATM_SKB(skb)->atm_options = vcc->atm_options; ++} + + static inline void atm_force_charge(struct atm_vcc *vcc,int truesize) + { +diff --git a/net/atm/br2684.c b/net/atm/br2684.c +index 4e111196..bc21f8e8 100644 +--- a/net/atm/br2684.c ++++ b/net/atm/br2684.c +@@ -252,8 +252,7 @@ static int br2684_xmit_vcc(struct sk_buff *skb, struct net_device *dev, + + ATM_SKB(skb)->vcc = atmvcc = brvcc->atmvcc; + pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, atmvcc, atmvcc->dev); +- refcount_add(skb->truesize, &sk_atm(atmvcc)->sk_wmem_alloc); +- ATM_SKB(skb)->atm_options = atmvcc->atm_options; ++ atm_account_tx(atmvcc, skb); + dev->stats.tx_packets++; + dev->stats.tx_bytes += skb->len; + +diff --git a/net/atm/clip.c b/net/atm/clip.c +index 65f706e4..60920a42 100644 +--- a/net/atm/clip.c ++++ b/net/atm/clip.c +@@ -381,8 +381,7 @@ static netdev_tx_t clip_start_xmit(struct sk_buff *skb, + memcpy(here, llc_oui, sizeof(llc_oui)); + ((__be16 *) here)[3] = skb->protocol; + } +- refcount_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); +- ATM_SKB(skb)->atm_options = vcc->atm_options; ++ atm_account_tx(vcc, skb); + entry->vccs->last_use = jiffies; + pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", skb, vcc, vcc->dev); + old = xchg(&entry->vccs->xoff, 1); /* assume XOFF ... */ +diff --git a/net/atm/common.c b/net/atm/common.c +index 83d6f40e..9935cc1f 100644 +--- a/net/atm/common.c ++++ b/net/atm/common.c +@@ -633,10 +633,9 @@ int vcc_sendmsg(struct socket *sock, struct msghdr *m, size_t size) + goto out; + } + pr_debug("%d += %d\n", sk_wmem_alloc_get(sk), skb->truesize); +- refcount_add(skb->truesize, &sk->sk_wmem_alloc); ++ atm_account_tx(vcc, skb); + + skb->dev = NULL; /* for paths shared with net_device interfaces */ +- ATM_SKB(skb)->atm_options = vcc->atm_options; + if (!copy_from_iter_full(skb_put(skb, size), size, &m->msg_iter)) { + kfree_skb(skb); + error = -EFAULT; +diff --git a/net/atm/lec.c b/net/atm/lec.c +index 5741b647..9f236569 100644 +--- a/net/atm/lec.c ++++ b/net/atm/lec.c +@@ -182,9 +182,8 @@ lec_send(struct atm_vcc *vcc, struct sk_buff *skb) + struct net_device *dev = skb->dev; + + ATM_SKB(skb)->vcc = vcc; +- ATM_SKB(skb)->atm_options = vcc->atm_options; ++ atm_account_tx(vcc, skb); + +- refcount_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc); + if (vcc->send(vcc, skb) < 0) { + dev->stats.tx_dropped++; + return; +diff --git a/net/atm/mpc.c b/net/atm/mpc.c +index 56771472..db9a1838 100644 +--- a/net/atm/mpc.c ++++ b/net/atm/mpc.c +@@ -555,8 +555,7 @@ static int send_via_shortcut(struct sk_buff *skb, struct mpoa_client *mpc) + sizeof(struct llc_snap_hdr)); + } + +- refcount_add(skb->truesize, &sk_atm(entry->shortcut)->sk_wmem_alloc); +- ATM_SKB(skb)->atm_options = entry->shortcut->atm_options; ++ atm_account_tx(entry->shortcut, skb); + entry->shortcut->send(entry->shortcut, skb); + entry->packets_fwded++; + mpc->in_ops->put(entry); +diff --git a/net/atm/pppoatm.c b/net/atm/pppoatm.c +index 21d9d341..af8c4b38 100644 +--- a/net/atm/pppoatm.c ++++ b/net/atm/pppoatm.c +@@ -350,8 +350,7 @@ static int pppoatm_send(struct ppp_channel *chan, struct sk_buff *skb) + return 1; + } + +- refcount_add(skb->truesize, &sk_atm(ATM_SKB(skb)->vcc)->sk_wmem_alloc); +- ATM_SKB(skb)->atm_options = ATM_SKB(skb)->vcc->atm_options; ++ atm_account_tx(vcc, skb); + pr_debug("atm_skb(%p)->vcc(%p)->dev(%p)\n", + skb, ATM_SKB(skb)->vcc, ATM_SKB(skb)->vcc->dev); + ret = ATM_SKB(skb)->vcc->send(ATM_SKB(skb)->vcc, skb) +diff --git a/net/atm/raw.c b/net/atm/raw.c +index ee10e8d4..b3ba44aa 100644 +--- a/net/atm/raw.c ++++ b/net/atm/raw.c +@@ -35,8 +35,8 @@ static void atm_pop_raw(struct atm_vcc *vcc, struct sk_buff *skb) + struct sock *sk = sk_atm(vcc); + + pr_debug("(%d) %d -= %d\n", +- vcc->vci, sk_wmem_alloc_get(sk), skb->truesize); +- WARN_ON(refcount_sub_and_test(skb->truesize, &sk->sk_wmem_alloc)); ++ vcc->vci, sk_wmem_alloc_get(sk), ATM_SKB(skb)->acct_truesize); ++ WARN_ON(refcount_sub_and_test(ATM_SKB(skb)->acct_truesize, &sk->sk_wmem_alloc)); + dev_kfree_skb_any(skb); + sk->sk_write_space(sk); + } +-- +2.15.1 (Apple Git-101) +