From patchwork Sun May 14 08:17:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Vadai X-Patchwork-Id: 762105 X-Patchwork-Delegate: shemminger@vyatta.com 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 3wQc673xxHz9s9c for ; Sun, 14 May 2017 18:18:07 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751580AbdENIR5 (ORCPT ); Sun, 14 May 2017 04:17:57 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:36427 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751402AbdENIRu (ORCPT ); Sun, 14 May 2017 04:17:50 -0400 Received: by mail-wm0-f66.google.com with SMTP id u65so21151422wmu.3 for ; Sun, 14 May 2017 01:17:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FS+Cjd+BeVUgBSsFJUrFVVRngq/3sdHZ1PpHcyZA0KA=; b=erbcVlqKy3atJFiBYs08ztpzEk49OXFuKvA4s+R3NyNf918FRQynLnaeVYRqc4e+Io zP2vkXwo25Gj7WNEINGTN7xYwlRTzjpGDouj+o72BUqWXjSedNvJbCfl+U5sktf4lWed 2Tefo+l+gdi/Lr1+MPytQTfd1a3UVi+5HhQtHWGlj4ND67RlZQgbg1U1WGhK6qJWOKZ1 ERVrArTsTxzL01qfrV9qALgn/76MUDfyMlLebfWIDcOTYbFM+55R1Yq9AfG7Fl5NOi0U xpU5Lq4Q98iumLLgVQ0NRt2DpZXFBl9ApSPyncke+iF7rfJnJmDiQgAvjGLo/pxqC6bh 6hQg== X-Gm-Message-State: AODbwcAOs4zcTfGzIHaUrNiUUKOVXLFW8JqbeNxUrq29bGEnPam0BzZ8 g59Q8TGP/PtkAVb2L1M= X-Received: by 10.28.220.86 with SMTP id t83mr367283wmg.66.1494749868783; Sun, 14 May 2017 01:17:48 -0700 (PDT) Received: from office.vadai.me ([192.116.94.216]) by smtp.gmail.com with ESMTPSA id y190sm7836707wmy.15.2017.05.14.01.17.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 May 2017 01:17:47 -0700 (PDT) From: Amir Vadai To: Stephen Hemminger Cc: netdev@vger.kernel.org, Or Gerlitz , Amir Vadai Subject: [PATCH iproute2 master 2/4] pedit: Do not allow using retain for too big fields Date: Sun, 14 May 2017 11:17:44 +0300 Message-Id: <20170514081746.9010-3-amir@vadai.me> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170514081746.9010-1-amir@vadai.me> References: <20170514081746.9010-1-amir@vadai.me> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Using retain for fields longer than 32 bits is not supported. Do not allow user to do it. Signed-off-by: Amir Vadai --- man/man8/tc-pedit.8 | 3 ++- tc/m_pedit.c | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/man/man8/tc-pedit.8 b/man/man8/tc-pedit.8 index 7f482eafc6c7..9c4d57b972cc 100644 --- a/man/man8/tc-pedit.8 +++ b/man/man8/tc-pedit.8 @@ -266,7 +266,8 @@ Keep the addressed data as is. .BI retain " RVAL" This optional extra part of .I CMD_SPEC -allows to exclude bits from being changed. +allows to exclude bits from being changed. Supported only for 32 bits fields +or smaller. .TP .I CONTROL The following keywords allow to control how the tree of qdisc, classes, diff --git a/tc/m_pedit.c b/tc/m_pedit.c index 7ef2acc52bce..9b74c965932e 100644 --- a/tc/m_pedit.c +++ b/tc/m_pedit.c @@ -353,6 +353,12 @@ int parse_cmd(int *argc_p, char ***argv_p, __u32 len, int type, __u32 retain, argv++; } + if (len > 4 && retain != ~0) { + fprintf(stderr, + "retain is not supported for fields longer the 32 bits\n"); + return -1; + } + if (type == TMAC) { res = pack_mac(sel, tkey, (__u8 *)val); goto done;