From patchwork Wed Jul 8 09:18:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pablo Neira Ayuso X-Patchwork-Id: 492774 X-Patchwork-Delegate: pablo@netfilter.org 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 3CC8C1402BA for ; Wed, 8 Jul 2015 19:12:42 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933745AbbGHJMi (ORCPT ); Wed, 8 Jul 2015 05:12:38 -0400 Received: from mail.us.es ([193.147.175.20]:42259 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933132AbbGHJMf (ORCPT ); Wed, 8 Jul 2015 05:12:35 -0400 Received: (qmail 17466 invoked from network); 8 Jul 2015 11:12:33 +0200 Received: from unknown (HELO us.es) (192.168.2.12) by us.es with SMTP; 8 Jul 2015 11:12:33 +0200 Received: (qmail 25587 invoked by uid 507); 8 Jul 2015 09:12:32 -0000 X-Qmail-Scanner-Diagnostics: from 127.0.0.1 by antivirus2 (envelope-from , uid 501) with qmail-scanner-2.10 (clamdscan: 0.98.7/20661. spamassassin: 3.4.0. Clear:RC:1(127.0.0.1):SA:0(-103.2/7.5):. Processed in 2.380783 secs); 08 Jul 2015 09:12:32 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on antivirus2 X-Spam-Level: X-Spam-Status: No, score=-103.2 required=7.5 tests=BAYES_50,SMTPAUTH_US, USER_IN_WHITELIST autolearn=disabled version=3.4.0 X-Spam-ASN: AS12715 87.216.0.0/16 X-Envelope-From: pablo@netfilter.org Received: from unknown (HELO antivirus2) (127.0.0.1) by us.es with SMTP; 8 Jul 2015 09:12:30 -0000 Received: from 192.168.1.13 (192.168.1.13) by antivirus2 (F-Secure/fsigk_smtp/412/antivirus2); Wed, 08 Jul 2015 11:12:30 +0200 (CEST) X-Virus-Status: clean(F-Secure/fsigk_smtp/412/antivirus2) Received: (qmail 1294 invoked from network); 8 Jul 2015 11:12:30 +0200 Received: from 129.166.216.87.static.jazztel.es (HELO salvia.here) (pneira@us.es@87.216.166.129) by mail.us.es with SMTP; 8 Jul 2015 11:12:30 +0200 From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Cc: kaber@trash.net Subject: [PATCH 1/3 nft] src: get rid of EINTR handling in nft_netlink() Date: Wed, 8 Jul 2015 11:18:06 +0200 Message-Id: <1436347088-9687-1-git-send-email-pablo@netfilter.org> X-Mailer: git-send-email 1.7.10.4 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org The only remaining caller that needs this is netlink_dump_ruleset(), that is used to export the ruleset using markup representation. We can remove it and handle this from do_command_export() now that we have a centralized point to build up the object cache. Signed-off-by: Pablo Neira Ayuso --- src/main.c | 7 ------- src/rule.c | 10 ++++++---- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main.c b/src/main.c index a069f63..52c1597 100644 --- a/src/main.c +++ b/src/main.c @@ -254,14 +254,7 @@ replay: if (ret != 0 || state->nerrs > 0) goto err1; -retry: ret = nft_netlink(state, msgs); - if (ret < 0 && errno == EINTR) { - nft_cache_fini(); - netlink_restart(); - goto retry; - } - err1: list_for_each_entry_safe(cmd, next, &state->cmds, list) { list_del(&cmd->list); diff --git a/src/rule.c b/src/rule.c index 86e77b6..f806db6 100644 --- a/src/rule.c +++ b/src/rule.c @@ -899,11 +899,13 @@ static int do_command_delete(struct netlink_ctx *ctx, struct cmd *cmd) static int do_command_export(struct netlink_ctx *ctx, struct cmd *cmd) { - struct nft_ruleset *rs = netlink_dump_ruleset(ctx, &cmd->handle, - &cmd->location); + struct nft_ruleset *rs; - if (rs == NULL) - return -1; + do { + rs = netlink_dump_ruleset(ctx, &cmd->handle, &cmd->location); + if (rs == NULL && errno != EINTR) + return -1; + } while (rs == NULL); nft_ruleset_fprintf(stdout, rs, cmd->export->format, 0); fprintf(stdout, "\n");