From patchwork Sat Nov 3 19:30:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyrill Gorcunov X-Patchwork-Id: 196931 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 0D1A52C00D7 for ; Sun, 4 Nov 2012 06:30:42 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754556Ab2KCTak (ORCPT ); Sat, 3 Nov 2012 15:30:40 -0400 Received: from mail-la0-f46.google.com ([209.85.215.46]:56968 "EHLO mail-la0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752592Ab2KCTaj (ORCPT ); Sat, 3 Nov 2012 15:30:39 -0400 Received: by mail-la0-f46.google.com with SMTP id h6so3289478lag.19 for ; Sat, 03 Nov 2012 12:30:37 -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=vmoPQQ2f6cKa6e/Kcur4czvkgKtOulB+6gf+m7d/vjA=; b=AIyA6rSZL3wyxsnjFou8erheMXA5Cl0WgTHAhnKisUYhanZIXR0gTR0xQu0SCjvcB7 G+3c/qZf5HdlPQlZ/kL/f7wsGZ+qcC9mvgaBL/e01O8+ToH98h4dCh3ovrDhyQ+XKt3z UYg94dk/O09H5IcP5Q0tt7cf8Czevaq8OKrLeEVwi1PVO/rf28ELx0XDCY+O38MxgMv4 J/5BW44y3F3yhgpV9B8e5K+yeRVDokAt5lnv3Iu2WpLEcNU1hNHNTpz8ClQ+1e66xZcV qN3WiVcWytawl/3s+TZp32j+XDfm0FvCGei8YnaM6bmgz5EoI4UoFpg5UksJGvQi7t/x LxKA== Received: by 10.112.24.6 with SMTP id q6mr2237172lbf.24.1351971037679; Sat, 03 Nov 2012 12:30:37 -0700 (PDT) Received: from moon.localdomain ([188.134.39.130]) by mx.google.com with ESMTPS id q2sm4252639lbd.14.2012.11.03.12.30.35 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 03 Nov 2012 12:30:36 -0700 (PDT) Received: by moon.localdomain (Postfix, from userid 1000) id E92C7A0A12; Sat, 3 Nov 2012 23:30:34 +0400 (MSK) Date: Sat, 3 Nov 2012 23:30:34 +0400 From: Cyrill Gorcunov To: NETDEV Cc: David Miller , Eric Dumazet , Pavel Emelyanov Subject: [PATCH] net: inet_diag -- Return error code if protocol handler is missed Message-ID: <20121103193034.GF6055@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 __inet_diag_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 Acked-by: Pavel Emelyanov --- net/ipv4/inet_diag.c | 5 ++++- 1 file changed, 4 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)