From patchwork Thu Feb 19 21:24:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Farnsworth X-Patchwork-Id: 441764 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id CE0EE140172 for ; Fri, 20 Feb 2015 08:43:17 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752381AbbBSVnG (ORCPT ); Thu, 19 Feb 2015 16:43:06 -0500 Received: from logos.farnz.org.uk ([93.93.135.63]:50198 "EHLO logos.farnz.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752612AbbBSVnE (ORCPT ); Thu, 19 Feb 2015 16:43:04 -0500 X-Greylist: delayed 1102 seconds by postgrey-1.27 at vger.kernel.org; Thu, 19 Feb 2015 16:43:04 EST Received: from hummingbird.visitors.farnz.org.uk ([81.187.250.204] helo=hummingbird.farnz.org.uk) by logos.farnz.org.uk with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.84) (envelope-from ) id 1YOYaM-0000fe-0c; Thu, 19 Feb 2015 21:24:39 +0000 From: Simon Farnsworth To: netdev@vger.kernel.org Cc: Michal Ostrowski , Dan Williams , Simon Farnsworth Subject: [PATCH] pppoe: Use workqueue to die properly when a PADT is received Date: Thu, 19 Feb 2015 21:24:28 +0000 Message-Id: <1424381068-22252-1-git-send-email-simon@farnz.org.uk> X-Mailer: git-send-email 2.1.0 X-Spam-Score: -1.0 (-) X-Spam-Report: Spam detection software, running on the system "logos.farnz.org.uk", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: When a PADT frame is received, the socket may not be in a good state to close down the PPP interface. The current implementation handles this by simply blocking all further PPP traffic, and hoping that the lack of traffic will trigger the user to investigate. [...] Content analysis details: (-1.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When a PADT frame is received, the socket may not be in a good state to close down the PPP interface. The current implementation handles this by simply blocking all further PPP traffic, and hoping that the lack of traffic will trigger the user to investigate. Use schedule_work to get to a process context from which we clear down the PPP interface, in a fashion analogous to hangup on a TTY-based PPP interface. This causes pppd to disconnect immediately, and allows tools to take immediate corrective action. Signed-off-by: Simon Farnsworth Tested-by: Christoph Schulz Tested-by: Dan Williams --- Note that I'm not subscribed to netdev; please cc me on any replies. The patch falls out of https://bugzilla.gnome.org/show_bug.cgi?id=742939 I'm trying to get NetworkManager back to using kernel PPPoE partly because it performs a little better, and mostly because kernel PPPoE copes with larger MTUs than userspace PPPoE. Dan Williams (cc'd) has tested a previous version of this patch; the differences to this version are only cosmetic. drivers/net/ppp/pppoe.c | 17 ++++++++++++++++- include/linux/if_pppox.h | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c index d2408a5..9c97e9b 100644 --- a/drivers/net/ppp/pppoe.c +++ b/drivers/net/ppp/pppoe.c @@ -455,6 +455,18 @@ out: return NET_RX_DROP; } +static void pppoe_unbind_sock_work(struct work_struct *work) +{ + struct pppox_sock *po = container_of(work, struct pppox_sock, + proto.pppoe.padt_work); + struct sock *sk = sk_pppox(po); + + lock_sock(sk); + pppox_unbind_sock(sk); + release_sock(sk); + sock_put(sk); +} + /************************************************************************ * * Receive a PPPoE Discovery frame. @@ -500,7 +512,8 @@ static int pppoe_disc_rcv(struct sk_buff *skb, struct net_device *dev, } bh_unlock_sock(sk); - sock_put(sk); + if (!schedule_work(&po->proto.pppoe.padt_work)) + sock_put(sk); } abort: @@ -613,6 +626,8 @@ static int pppoe_connect(struct socket *sock, struct sockaddr *uservaddr, lock_sock(sk); + INIT_WORK(&po->proto.pppoe.padt_work, pppoe_unbind_sock_work); + error = -EINVAL; if (sp->sa_protocol != PX_PROTO_OE) goto end; diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h index aff7ad8..66a7d76 100644 --- a/include/linux/if_pppox.h +++ b/include/linux/if_pppox.h @@ -19,6 +19,7 @@ #include #include #include +#include #include static inline struct pppoe_hdr *pppoe_hdr(const struct sk_buff *skb) @@ -32,6 +33,7 @@ struct pppoe_opt { struct pppoe_addr pa; /* what this socket is bound to*/ struct sockaddr_pppox relay; /* what socket data will be relayed to (PPPoE relaying) */ + struct work_struct padt_work;/* Work item for handling PADT */ }; struct pptp_opt {