From patchwork Wed Jul 3 23:05:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Mashak X-Patchwork-Id: 1127251 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@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=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mojatatu.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="arCqi1Zk"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45fGtK1QVZz9sNC for ; Thu, 4 Jul 2019 09:05:45 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727513AbfGCXFo (ORCPT ); Wed, 3 Jul 2019 19:05:44 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:46505 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726988AbfGCXFn (ORCPT ); Wed, 3 Jul 2019 19:05:43 -0400 Received: by mail-io1-f68.google.com with SMTP id i10so8774223iol.13 for ; Wed, 03 Jul 2019 16:05:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=+zC9Tzfmx77Wn68Z82+otzkVy3oal99q9oMD5yv/YeY=; b=arCqi1Zk3ybTEfXjLajvloOATZNdldDK2hy/yNQKG9QeQzH4X+EOQD0L0RrtAN/Cci OThARPe+3p+tFG4TEcjVH2XIk92y3FE1H18EwG5bQt7EUL1/Zd/u2mB5NF1GiZc4INmS j/x5gdq4o87pN2DuEIqZnAraKX0eU5lbsWQ4axZ4DZV907cSa1+DwU/tdZ106OUaosru WdZzGGsBFzPn1HlhHuIbZrCL+n6gtqSpgVQPGTCSTaA47BP56oPLmPpHU+/ONyINSFkX FLEx7FEEakIdbr784YgvDxGXGA0yYetHGuMMeEhmy9NW2kj37P554ww8C5I03KRDNah8 64mw== 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; bh=+zC9Tzfmx77Wn68Z82+otzkVy3oal99q9oMD5yv/YeY=; b=otwjPI/burJCGBKoaoY2HL4CTmM5M6EB3vyGwp3jGpSJqxz1PuOhVhV1CTHrEfANpU 5IqSX/lisSYS5c135U799ROz2xTUKoJZxa7sYX20kvnTuqW0FCZoEP9F++06XfIrAdcx +DVt3qhtSMjaJZnVtzBEzR1ASAu5YzBA2T8OkgbBYVBGOiB2XB9CCEpzk+BB0wuImWqN ddT70aghGB8gkaoQZFYsZQI+mgQplskmihpA4CjeRNyf6DMAFSFvEcmbB1wLdyTfPI12 PPCx11SJF0ZOalvIL9gr0xd8YNlrMULZxHoHm0SeniHEE11GRdTilEj1MrYE84F8Yr+S yvIg== X-Gm-Message-State: APjAAAU/jVbtKwPzKxpUuzESgFmYpODDNlTuwSM7WsTDNwCXjMfly0S7 gvqbe4mNzvW7URiTuYDxh8Jj8Q== X-Google-Smtp-Source: APXvYqy6NU/col7n1MHi5jMGCYFVR/2E+hHYRlUYkgCrk3lsMCaBOZf15YXMF6CCAUVTPxrLmU8+ow== X-Received: by 2002:a6b:e615:: with SMTP id g21mr11946263ioh.178.1562195142566; Wed, 03 Jul 2019 16:05:42 -0700 (PDT) Received: from mojatatu.com ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id x13sm2803180ioj.18.2019.07.03.16.05.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Jul 2019 16:05:41 -0700 (PDT) From: Roman Mashak To: stephen@networkplumber.org Cc: netdev@vger.kernel.org, kernel@mojatatu.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, Roman Mashak Subject: [PATCH iproute2 1/2] tc: added mask parameter in skbedit action Date: Wed, 3 Jul 2019 19:05:31 -0400 Message-Id: <1562195132-9829-1-git-send-email-mrv@mojatatu.com> X-Mailer: git-send-email 2.7.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add 32-bit missing mask attribute in iproute2/tc, which has been long supported by the kernel side. Signed-off-by: Roman Mashak --- tc/m_skbedit.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/tc/m_skbedit.c b/tc/m_skbedit.c index b6b839f8ef6c..f47c9705a990 100644 --- a/tc/m_skbedit.c +++ b/tc/m_skbedit.c @@ -33,7 +33,7 @@ static void explain(void) fprintf(stderr, "Usage: ... skbedit <[QM] [PM] [MM] [PT] [IF]>\n" "QM = queue_mapping QUEUE_MAPPING\n" "PM = priority PRIORITY\n" - "MM = mark MARK\n" + "MM = mark MARK[/MASK]\n" "PT = ptype PACKETYPE\n" "IF = inheritdsfield\n" "PACKETYPE = is one of:\n" @@ -41,6 +41,7 @@ static void explain(void) "QUEUE_MAPPING = device transmit queue to use\n" "PRIORITY = classID to assign to priority field\n" "MARK = firewall mark to set\n" + "MASK = mask applied to firewall mark (0xffffffff by default)\n" "note: inheritdsfield maps DS field to skb->priority\n"); } @@ -61,7 +62,7 @@ parse_skbedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, struct rtattr *tail; unsigned int tmp; __u16 queue_mapping, ptype; - __u32 flags = 0, priority, mark; + __u32 flags = 0, priority, mark, mask; __u64 pure_flags = 0; struct tc_skbedit sel = { 0 }; @@ -89,12 +90,26 @@ parse_skbedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, } ok++; } else if (matches(*argv, "mark") == 0) { - flags |= SKBEDIT_F_MARK; + char *slash; + NEXT_ARG(); + slash = strchr(*argv, '/'); + if (slash) + *slash = '\0'; + + flags |= SKBEDIT_F_MARK; if (get_u32(&mark, *argv, 0)) { fprintf(stderr, "Illegal mark\n"); return -1; } + + if (slash) { + if (get_u32(&mask, slash + 1, 0)) { + fprintf(stderr, "Illegal mask\n"); + return -1; + } + flags |= SKBEDIT_F_MASK; + } ok++; } else if (matches(*argv, "ptype") == 0) { @@ -133,7 +148,7 @@ parse_skbedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, if (matches(*argv, "index") == 0) { NEXT_ARG(); if (get_u32(&sel.index, *argv, 10)) { - fprintf(stderr, "Pedit: Illegal \"index\"\n"); + fprintf(stderr, "skbedit: Illegal \"index\"\n"); return -1; } argc--; @@ -159,6 +174,9 @@ parse_skbedit(struct action_util *a, int *argc_p, char ***argv_p, int tca_id, if (flags & SKBEDIT_F_MARK) addattr_l(n, MAX_MSG, TCA_SKBEDIT_MARK, &mark, sizeof(mark)); + if (flags & SKBEDIT_F_MASK) + addattr_l(n, MAX_MSG, TCA_SKBEDIT_MASK, + &mask, sizeof(mask)); if (flags & SKBEDIT_F_PTYPE) addattr_l(n, MAX_MSG, TCA_SKBEDIT_PTYPE, &ptype, sizeof(ptype)); @@ -206,6 +224,10 @@ static int print_skbedit(struct action_util *au, FILE *f, struct rtattr *arg) print_uint(PRINT_ANY, "mark", " mark %u", rta_getattr_u32(tb[TCA_SKBEDIT_MARK])); } + if (tb[TCA_SKBEDIT_MASK]) { + print_uint(PRINT_ANY, "mask", "/0x%x", + rta_getattr_u32(tb[TCA_SKBEDIT_MASK])); + } if (tb[TCA_SKBEDIT_PTYPE] != NULL) { ptype = rta_getattr_u16(tb[TCA_SKBEDIT_PTYPE]); if (ptype == PACKET_HOST) From patchwork Wed Jul 3 23:05:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Mashak X-Patchwork-Id: 1127252 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@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=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mojatatu.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="V45QrL68"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45fGtN41Mkz9sBp for ; Thu, 4 Jul 2019 09:05:48 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727525AbfGCXFr (ORCPT ); Wed, 3 Jul 2019 19:05:47 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:43581 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726988AbfGCXFr (ORCPT ); Wed, 3 Jul 2019 19:05:47 -0400 Received: by mail-io1-f65.google.com with SMTP id k20so8815917ios.10 for ; Wed, 03 Jul 2019 16:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vFPN19sE7ysY8YvFFjusSzIZiwIbCJpLduVsj4SmypE=; b=V45QrL680mQAf1Ckd+CGGqcvWQ3c46ho3kPFfX1G8B51xSkqmoWH5cpCq6WvviIsOu fY644/pQ2F8LfY29O9k1zJCH82qtg8+guzEDPuqNgWWx2pyxXyJGsQCcj9rHDUvO5/qo xxr99YhjiklkzklEU/b7dgBRbNv/wfEBEsI43S4YhtVnTWdhbnlvBs85Um1zM1mK7Lyb kUASuNFFSyVX+kChOV6xHkmtd9BFWpnS841utjYlkdGdKcgxt704ewgK7KIcZhzAx5uB bCtJDk58OUINSORBe68HvOe/99KauXIfbJFnXS5GKiuAw6P3ELZj1gORKTfbE4WadLhr DaBQ== 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=vFPN19sE7ysY8YvFFjusSzIZiwIbCJpLduVsj4SmypE=; b=lF3YXuKfv8AjSB4D7zdnNOtWpPxN+Hu4usK8p5P1bI1ndzETQ2KqQdJqPq/sdq2MH7 8iStI4mV9loTRYOZw9meN0uc3gBFON4gsOOhUFcOHlqjfsLamNSiipT5KAd7VbF8EMg/ TDXGrUOx2ysjj6bEeycl5H57EeEK6Xp0//QSnHRuRu+HbmKsgKfCSHk69c1PTenmNlwf 23f/zPz3OkCnm3VtBR47Q++udQpEnrf68iDLG/udD8uLBHoWOvjk11ifuN8oECdV4dXg fSKOvoLpY2l0IHI+pd6FCz1PTwxfrVYv0+WK07Xx65hxU0R+0xLVDT+DHNQLVNa4QjQH HK3g== X-Gm-Message-State: APjAAAUR87g5zSO418TZEZlANM6xgJFdZUWfbMVXcCia0lu5rePWqQ8Z SiFGdA0SCjnIIfW/v3I4Au+G+w== X-Google-Smtp-Source: APXvYqx/aY6pfk+wyih5pqE0S2pmzezUc1M9uvU/g7/oW+vP14XCOm+h1FSSSBOrGPJvK/EnXqwDXA== X-Received: by 2002:a6b:5115:: with SMTP id f21mr705938iob.173.1562195146446; Wed, 03 Jul 2019 16:05:46 -0700 (PDT) Received: from mojatatu.com ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id x13sm2803180ioj.18.2019.07.03.16.05.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Jul 2019 16:05:45 -0700 (PDT) From: Roman Mashak To: stephen@networkplumber.org Cc: netdev@vger.kernel.org, kernel@mojatatu.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, Roman Mashak Subject: [PATCH iproute2 2/2] tc: document 'mask' parameter in skbedit man page Date: Wed, 3 Jul 2019 19:05:32 -0400 Message-Id: <1562195132-9829-2-git-send-email-mrv@mojatatu.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1562195132-9829-1-git-send-email-mrv@mojatatu.com> References: <1562195132-9829-1-git-send-email-mrv@mojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Signed-off-by: Roman Mashak --- man/man8/tc-skbedit.8 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/man/man8/tc-skbedit.8 b/man/man8/tc-skbedit.8 index 2459198261e6..704f63bdb061 100644 --- a/man/man8/tc-skbedit.8 +++ b/man/man8/tc-skbedit.8 @@ -9,8 +9,7 @@ skbedit - SKB editing action .IR QUEUE_MAPPING " ] [" .B priority .IR PRIORITY " ] [" -.B mark -.IR MARK " ] [" +.BI mark " MARK\fR[\fB/\fIMASK] ] [" .B ptype .IR PTYPE " ] [" .BR inheritdsfield " ]" @@ -49,12 +48,14 @@ or a hexadecimal major class ID optionally followed by a colon .RB ( : ) and a hexadecimal minor class ID. .TP -.BI mark " MARK" +.BI mark " MARK\fR[\fB/\fIMASK]" Change the packet's firewall mark value. .I MARK is an unsigned 32bit value in automatically detected format (i.e., prefix with .RB ' 0x ' for hexadecimal interpretation, etc.). +.I MASK +defines the 32-bit mask selecting bits of mark value. Default is 0xffffffff. .TP .BI ptype " PTYPE" Override the packet's type. Useful for setting packet type to host when