From patchwork Fri Nov 2 17:35:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyrill Gorcunov X-Patchwork-Id: 196681 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 BBEAC2C00C4 for ; Sat, 3 Nov 2012 04:36:20 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1763234Ab2KBRgT (ORCPT ); Fri, 2 Nov 2012 13:36:19 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:46391 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1763227Ab2KBRgR (ORCPT ); Fri, 2 Nov 2012 13:36:17 -0400 Received: by mail-lb0-f174.google.com with SMTP id n3so2784975lbo.19 for ; Fri, 02 Nov 2012 10:36:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=+oKGDW+5d+zjf6GWgggMFtUJUFDqdIHWt+Z9haiX3yQ=; b=j+awpYcrqlBSqYPGzSymr/jAwC2lsq/ICTlPJ4lVXehR7IouTm/YkTc6rNw7/EqwL6 4vbBU5F6RdCQE/bD/B2Z99lh6hfuPj1DHmNqePEZX88VRgOD2jJZ8cZKj4kWahqg8ome OLh9Zpw3XR2SpwtTz1Mk+gspV2F4551LcK0afYwnQVfEro5QtIvN6sIeOtlIHmhWIGib k1vabGwU1fjrvlfJg6usCqlZsV8Wp/lgA7mUAif+cE5RFHj9hALrJKY+V22azt3m4NIR QEz97PguoRKfP6l5+dZw8eQ0zC736TtDvn9UmsJtWLIuw9tbzsjenem0EDWFK4RgxvHP NB8w== Received: by 10.152.104.107 with SMTP id gd11mr2290585lab.25.1351877775938; Fri, 02 Nov 2012 10:36:15 -0700 (PDT) Received: from moon.localdomain ([188.134.39.130]) by mx.google.com with ESMTPS id lv1sm3299816lab.14.2012.11.02.10.35.51 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 02 Nov 2012 10:35:51 -0700 (PDT) Received: by moon.localdomain (Postfix, from userid 1000) id 59FE0A0A08; Fri, 2 Nov 2012 21:35:50 +0400 (MSK) Date: Fri, 2 Nov 2012 21:35:50 +0400 From: Cyrill Gorcunov To: NETDEV Cc: David Miller , Eric Dumazet , Pavel Emelyanov Subject: [RFC] net: netlink -- Allow netlink_dump to return error code if protocol handler is missed Message-ID: <20121102173550.GH10877@moon> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We've observed that in case if UDP diag module is not supported in kernel the netlink returns NLMSG_DONE without notifying a caller that handler is missed. This patch makes netlink_dump to return error code instead. So as example it become possible to detect such situation and handle it gracefully on userspace level. Signed-off-by: Cyrill Gorcunov CC: David Miller CC: Eric Dumazet CC: Pavel Emelyanov --- net/ipv4/inet_diag.c | 5 ++++- net/netlink/af_netlink.c | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-2.6.git/net/ipv4/inet_diag.c =================================================================== --- linux-2.6.git.orig/net/ipv4/inet_diag.c +++ linux-2.6.git/net/ipv4/inet_diag.c @@ -895,13 +895,16 @@ static int __inet_diag_dump(struct sk_bu struct inet_diag_req_v2 *r, struct nlattr *bc) { const struct inet_diag_handler *handler; + int err = 0; handler = inet_diag_lock_handler(r->sdiag_protocol); if (!IS_ERR(handler)) handler->dump(skb, cb, r, bc); + else + err = PTR_ERR(handler); inet_diag_unlock_handler(handler); - return skb->len; + return err ? : skb->len; } static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) Index: linux-2.6.git/net/netlink/af_netlink.c =================================================================== --- linux-2.6.git.orig/net/netlink/af_netlink.c +++ linux-2.6.git/net/netlink/af_netlink.c @@ -1740,6 +1740,10 @@ static int netlink_dump(struct sock *sk) else __netlink_sendskb(sk, skb); return 0; + } else if (len < 0) { + err = len; + nlk->cb = NULL; + goto errout_skb; } nlh = nlmsg_put_answer(skb, cb, NLMSG_DONE, sizeof(len), NLM_F_MULTI);