From patchwork Thu Jan 7 09:39:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivani Bhardwaj X-Patchwork-Id: 564224 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 2A09A1402C9 for ; Thu, 7 Jan 2016 20:39:35 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=mQ59E++S; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752018AbcAGJje (ORCPT ); Thu, 7 Jan 2016 04:39:34 -0500 Received: from mail-pa0-f48.google.com ([209.85.220.48]:34807 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751121AbcAGJjc (ORCPT ); Thu, 7 Jan 2016 04:39:32 -0500 Received: by mail-pa0-f48.google.com with SMTP id uo6so236245783pac.1 for ; Thu, 07 Jan 2016 01:39:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=n4QChcVZZSwbibg6/K1L/Ad25lni5odUjEAFJvSNQ88=; b=mQ59E++Sk/Q2sIjfD/tlneO7tYtrya3idFeoWpMmswJHomQE04fvG4VC6APiE5HJ4t rIBkjH0EZitmvIK6PKq+IyTwFwnIZ3ENd5qlw8wa3nSX7xMv1/mLC7HMWE9fQxN/Y/7o Myx+GZ3yY2XPQQun5WFyC6C8qGjyO7b1whcy7nq77uZVmDb6seKsMk9dcizJUzTrjQKY W4Ll7AmGAlsEdWEvIQUbgpl2k+QSr8pXCLX4twMzLusSuyQ885ays90926TJRlkXfTLa MrOboEiNHypcz0YlNrjFBA8ALZd/SFz1Riv4NdUpwSjR92NO25NmBD9cASSqMcBRN1AH nZaw== X-Received: by 10.66.152.204 with SMTP id va12mr66851914pab.0.1452159571818; Thu, 07 Jan 2016 01:39:31 -0800 (PST) Received: from gmail.com ([223.176.149.78]) by smtp.gmail.com with ESMTPSA id yn8sm152492927pac.32.2016.01.07.01.39.29 for (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 07 Jan 2016 01:39:30 -0800 (PST) Date: Thu, 7 Jan 2016 15:09:24 +0530 From: Shivani Bhardwaj To: netfilter-devel@vger.kernel.org Subject: [PATCH] extensions: libip6t_hl: Add translation to nft Message-ID: <20160107093924.GA6686@gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org Add translation for hop limit to nftables. Examples: $ sudo ip6tables-translate -t nat -A postrouting -m hl --hl-gt 3 nft add rule ip6 nat postrouting ip6 hoplimit gt 3 counter $ sudo ip6tables-translate -t nat -A postrouting -m hl ! --hl-eq 3 nft add rule ip6 nat postrouting ip6 hoplimit != 3 counter Signed-off-by: Shivani Bhardwaj --- extensions/libip6t_hl.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/extensions/libip6t_hl.c b/extensions/libip6t_hl.c index 3559db4..0e13df1 100644 --- a/extensions/libip6t_hl.c +++ b/extensions/libip6t_hl.c @@ -97,6 +97,23 @@ static const struct xt_option_entry hl_opts[] = { }; #undef s +static int hl_xlate(const struct xt_entry_match *match, + struct xt_buf *buf, int numeric) +{ + static const char *const op[] = { + [IP6T_HL_EQ] = "ip6 hoplimit", + [IP6T_HL_NE] = "ip6 hoplimit !=", + [IP6T_HL_LT] = "ip6 hoplimit lt", + [IP6T_HL_GT] = "ip6 hoplimit gt" }; + + const struct ip6t_hl_info *info = + (struct ip6t_hl_info *) match->data; + + xt_buf_add(buf, "%s %u ", op[info->mode], info->hop_limit); + + return 1; +} + static struct xtables_match hl_mt6_reg = { .name = "hl", .version = XTABLES_VERSION, @@ -109,6 +126,7 @@ static struct xtables_match hl_mt6_reg = { .x6_parse = hl_parse, .x6_fcheck = hl_check, .x6_options = hl_opts, + .xlate = hl_xlate, };