From patchwork Thu Oct 10 21:11:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arturo Borrero X-Patchwork-Id: 282458 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 6813B2C00C3 for ; Fri, 11 Oct 2013 08:12:05 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755363Ab3JJVMC (ORCPT ); Thu, 10 Oct 2013 17:12:02 -0400 Received: from smtp3.cica.es ([150.214.5.190]:47959 "EHLO smtp.cica.es" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755470Ab3JJVMC (ORCPT ); Thu, 10 Oct 2013 17:12:02 -0400 Received: from localhost (unknown [127.0.0.1]) by smtp.cica.es (Postfix) with ESMTP id 712CB51ED67 for ; Thu, 10 Oct 2013 21:12:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at cica.es Received: from smtp.cica.es ([127.0.0.1]) by localhost (mail.cica.es [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4scQ9NSc5a5i for ; Thu, 10 Oct 2013 23:12:00 +0200 (CEST) Received: from nfdev.cica.es (nfdev.cica.es [IPv6:2a00:9ac0:c1ca:31::220]) by smtp.cica.es (Postfix) with ESMTP id 509C951ED2B for ; Thu, 10 Oct 2013 23:12:00 +0200 (CEST) Subject: [nftables PATCH] src: fix return code To: netfilter-devel@vger.kernel.org From: Arturo Borrero Gonzalez Date: Thu, 10 Oct 2013 23:11:56 +0200 Message-ID: <20131010211156.12209.65147.stgit@nfdev.cica.es> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Exit with NFT_EXIT_FAILURE if something went wrong in the netlink zone. Before this patch: # nft list chain filter asd ; echo $? internal:0:0-0: Error: Could not find chain `asd' in table `filter': [...] 0 After this patch: # nft list chain filter asd ; echo $? internal:0:0-0: Error: Could not find chain `asd' in table `filter': [...] 1 Signed-off-by: Arturo Borrero Gonzalez --- src/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/src/main.c b/src/main.c index 3ddcb71..9aa5f1b 100644 --- a/src/main.c +++ b/src/main.c @@ -222,7 +222,7 @@ int main(int argc, char * const *argv) char *buf = NULL, *filename = NULL; unsigned int len; bool interactive = false; - int i, val; + int i, val, rc = NFT_EXIT_FAILURE; while (1) { val = getopt_long(argc, argv, OPTSTRING, options, NULL); @@ -318,11 +318,12 @@ int main(int argc, char * const *argv) exit(NFT_EXIT_FAILURE); } - nft_run(scanner, &state, &msgs); + if (nft_run(scanner, &state, &msgs) == 0) + rc = NFT_EXIT_SUCCESS; out: scanner_destroy(scanner); erec_print_list(stdout, &msgs); xfree(buf); - return 0; + exit(rc); }