From patchwork Tue Aug 28 20:26:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 963117 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netfilter-devel-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nwl.cc Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 420Kzw5td0z9s1x for ; Wed, 29 Aug 2018 06:27:08 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727178AbeH2AUZ (ORCPT ); Tue, 28 Aug 2018 20:20:25 -0400 Received: from orbyte.nwl.cc ([151.80.46.58]:41876 "EHLO orbyte.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727135AbeH2AUZ (ORCPT ); Tue, 28 Aug 2018 20:20:25 -0400 Received: from localhost ([::1]:57152 helo=tatos) by orbyte.nwl.cc with esmtp (Exim 4.90_1) (envelope-from ) id 1fukZu-0006Lp-6i; Tue, 28 Aug 2018 22:27:06 +0200 From: Phil Sutter To: Pablo Neira Ayuso Cc: netfilter-devel@vger.kernel.org Subject: [nft PATCH] json: Fix compile error Date: Tue, 28 Aug 2018 22:26:56 +0200 Message-Id: <20180828202656.19988-1-phil@nwl.cc> X-Mailer: git-send-email 2.18.0 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Commit 9e45a28ca467f ("src: honor /etc/services") broke compiling with JSON support enabled: inet_service_type_print() is not suited for converting inet_service datatype into JSON at all. In order to avoid having to replicate the port value resolving into human-readable name in inet_service_type_json(), just return a numeric value. At least for JSON output, this probably makes most sense either way since the output is expected to be parsed by scripts which have an easier time with numers than names anyway. Fixes: 9e45a28ca467f ("src: honor /etc/services") Signed-off-by: Phil Sutter --- Unless there are objections, I will later follow-up with a patch to convert remaining human readable values into numeric ones in JSON regardless of numeric output or not. This is just a quick fix to unbreak the build. --- src/json.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/json.c b/src/json.c index b70a53f29683d..00d247646cfe2 100644 --- a/src/json.c +++ b/src/json.c @@ -861,10 +861,7 @@ json_t *inet_protocol_type_json(const struct expr *expr, json_t *inet_service_type_json(const struct expr *expr, struct output_ctx *octx) { - if (octx->numeric >= NFT_NUMERIC_PORT) - return integer_type_json(expr, octx); - - return inet_service_type_print(expr, octx); + return json_integer(ntohs(mpz_get_be16(expr->value))); } json_t *mark_type_json(const struct expr *expr, struct output_ctx *octx)