From patchwork Sun Apr 23 12:53:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Vadai X-Patchwork-Id: 753917 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 3w9qFZ0nsmz9ryk for ; Sun, 23 Apr 2017 22:55:14 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1045466AbdDWMzM (ORCPT ); Sun, 23 Apr 2017 08:55:12 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33784 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1045451AbdDWMy4 (ORCPT ); Sun, 23 Apr 2017 08:54:56 -0400 Received: by mail-wm0-f68.google.com with SMTP id y10so1432544wmh.0 for ; Sun, 23 Apr 2017 05:54:55 -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=mN6+43F03PApOJYjW/nlY5/sj4bXQ0+GKP7rRWVhFLU=; b=RuG0AFi1okSOOy9CpErvYdTN2qkwk10tvCbOAyMnKXl0zS0aA4Qb5Xk+wwX1oeNISQ huO9qA+rL4V0Rgqe9PhdML7HlVhY4ViDWusnNrom7BP/3rUwP6NgQhskN2KUmQCF2AtZ hcVO+p+Ck7Op9H74Z+hQ0wP2RFF9QZZ3oXRxfK6/+16ymszKgYqnzH/I13wxsYOFjThC 9aqzeJfRoyeQ52zm0M8k1q1ed/G8tC87TS4cMS6gWUFuLlJ2RkQGefpzckRyVHAHvAFW 2eAUKt6ayoeem2MqcB1i+QBEdRI8WGvMf/0UXArFqDJqGb9/f/Ia5i8wqdLIJRv6dfaz CJgA== X-Gm-Message-State: AN3rC/4q9xrL2k64JRs2vsqCJpgGGT8bcyK3OGjNrhfq2uA3sJiHRoSs GBW6WBGWVaHwiA== X-Received: by 10.28.229.81 with SMTP id c78mr6347009wmh.66.1492952084591; Sun, 23 Apr 2017 05:54:44 -0700 (PDT) Received: from office.vadai.me ([192.116.94.213]) by smtp.gmail.com with ESMTPSA id t16sm9339522wme.16.2017.04.23.05.54.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 23 Apr 2017 05:54:43 -0700 (PDT) From: Amir Vadai To: Stephen Hemminger Cc: netdev@vger.kernel.org, Or Gerlitz , Jamal Hadi Salim , Amir Vadai Subject: [PATCH iproute2 net 5/8] tc/pedit: Support fields bigger than 32 bits Date: Sun, 23 Apr 2017 15:53:53 +0300 Message-Id: <20170423125356.1298-6-amir@vadai.me> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170423125356.1298-1-amir@vadai.me> References: <20170423125356.1298-1-amir@vadai.me> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Make parse_val() accept fields up to 128 bits long, this should be enough for current use cases and involves a minimal change to code. Signed-off-by: Amir Vadai --- tc/m_pedit.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tc/m_pedit.c b/tc/m_pedit.c index 7af074a5a97c..d982c91a2585 100644 --- a/tc/m_pedit.c +++ b/tc/m_pedit.c @@ -256,7 +256,10 @@ int parse_val(int *argc_p, char ***argv_p, __u32 *val, int type) int parse_cmd(int *argc_p, char ***argv_p, __u32 len, int type, __u32 retain, struct m_pedit_sel *sel, struct m_pedit_key *tkey) { - __u32 mask = 0, val = 0; + __u32 mask[4] = { 0 }; + __u32 val[4] = { 0 }; + __u32 *m = &mask[0]; + __u32 *v = &val[0]; __u32 o = 0xFF; int res = -1; int argc = *argc_p; @@ -275,7 +278,7 @@ int parse_cmd(int *argc_p, char ***argv_p, __u32 len, int type, __u32 retain, o = 0xFFFFFFFF; if (matches(*argv, "invert") == 0) { - val = mask = o; + *v = *m = o; } else if (matches(*argv, "set") == 0 || matches(*argv, "add") == 0) { if (matches(*argv, "add") == 0) @@ -287,7 +290,7 @@ int parse_cmd(int *argc_p, char ***argv_p, __u32 len, int type, __u32 retain, } NEXT_ARG(); - if (parse_val(&argc, &argv, &val, type)) + if (parse_val(&argc, &argv, val, type)) return -1; } else if (matches(*argv, "preserve") == 0) { retain = 0; @@ -307,8 +310,8 @@ int parse_cmd(int *argc_p, char ***argv_p, __u32 len, int type, __u32 retain, argv++; } - tkey->val = val; - tkey->mask = mask; + tkey->val = *v; + tkey->mask = *m; if (type == TIPV4) tkey->val = ntohl(tkey->val);