From patchwork Wed Jul 10 12:40:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hurley X-Patchwork-Id: 1130375 X-Patchwork-Delegate: dsahern@gmail.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=netronome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="hMiSgM6N"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45kJhR4tsSz9sBF for ; Wed, 10 Jul 2019 22:41:11 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727438AbfGJMlK (ORCPT ); Wed, 10 Jul 2019 08:41:10 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:44560 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726658AbfGJMlI (ORCPT ); Wed, 10 Jul 2019 08:41:08 -0400 Received: by mail-wr1-f65.google.com with SMTP id p17so2280788wrf.11 for ; Wed, 10 Jul 2019 05:41:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ROsNFih7aIvvYO4hZ5LpXiKTnrDc8efW5guC8WGQZAw=; b=hMiSgM6N75GSOTElnmJnUf6399W00z/c5NFuzls/PlisXc5PctICSFisgt6BTRVFki dDi2pavksb7Gi7U7CpyNKw4l7HO+dx/JWzJqWs3dTdmKJt1DqrTm21uvA2EtBcsHtz3m RWrvxL9Y0Oik2bfwbpWTX58RqdppWn+L4STnMCJkbHtFLppd7+FY9H8+c2J8lcAXA3g6 TCVzgxUgJEjGIaxcP/ToBmdL8noIEfQcw6LdZcRnE2AJYj4gWzkjs3UIoyZFg9eok3YT 4VSJerGT39rnyjqte02arLa8pZUUD6uoJWuYHLjrQMfJaAwRRT4s1CYCq4izJGcv3ZR+ PXyw== 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=ROsNFih7aIvvYO4hZ5LpXiKTnrDc8efW5guC8WGQZAw=; b=d9C2vaAmYlX2A8eEkDAfrKTeLmsNBg5ISWkVzIlrIff3KoRXvdN/AAz1J7RF8YjisU xV1en7cyYOXufNZ2MNkwU3A0fCaeN01ZsvNY1vqi0gxXd32SuvquEbhh+48GLnv/023d myjaC8FBmws58F3dMYhhXW54pLf5vMnZWNKk4Olmf109OjRwykgeQUUoLHjZksF322pX nMQ4iG1bc26AX/XkKzFIdAxqNrOicTbxMTFHbLFi24k6g7mO3e1spa0jITHlDWDHA+cp YZdzG0nRNv7qmIrtou8iSyMzhh1YryaQvyr5Kbt6QtVU3WsteX0iDvntOHiauuRGxG/6 1LcQ== X-Gm-Message-State: APjAAAWnJ6Hd9bBC+/+5tF9eAAh4Oc0ROeapla6Dd51n+gXi/U/mCiGV DuHj16GJLlNoi+whj+FhJDGxlzpoItc= X-Google-Smtp-Source: APXvYqxeUHTLRpHHdHOouiMU7xUYWASATf6JPv2xluWAfvgOtNmlVgafFW0CJg6ieqYBvSBgGeiygA== X-Received: by 2002:adf:e841:: with SMTP id d1mr31732704wrn.204.1562762466197; Wed, 10 Jul 2019 05:41:06 -0700 (PDT) Received: from jhurley-Precision-Tower-3420.netronome.com ([80.76.204.157]) by smtp.gmail.com with ESMTPSA id z5sm1406759wmf.48.2019.07.10.05.41.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Jul 2019 05:41:05 -0700 (PDT) From: John Hurley To: netdev@vger.kernel.org Cc: davem@davemloft.net, jiri@mellanox.com, xiyou.wangcong@gmail.com, dsahern@gmail.com, willemdebruijn.kernel@gmail.com, stephen@networkplumber.org, simon.horman@netronome.com, jakub.kicinski@netronome.com, oss-drivers@netronome.com, John Hurley Subject: [PATCH iproute2-next v2 1/3] lib: add mpls_uc and mpls_mc as link layer protocol names Date: Wed, 10 Jul 2019 13:40:38 +0100 Message-Id: <1562762440-25656-2-git-send-email-john.hurley@netronome.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1562762440-25656-1-git-send-email-john.hurley@netronome.com> References: <1562762440-25656-1-git-send-email-john.hurley@netronome.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Update the llproto_names array to allow users to reference the mpls protocol ids with the names 'mpls_uc' for unicast MPLS and 'mpls_mc' for multicast. Signed-off-by: John Hurley Reviewed-by: Jakub Kicinski --- lib/ll_proto.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ll_proto.c b/lib/ll_proto.c index 78c3961..2a0c1cb 100644 --- a/lib/ll_proto.c +++ b/lib/ll_proto.c @@ -78,6 +78,8 @@ __PF(TIPC,tipc) __PF(AOE,aoe) __PF(8021Q,802.1Q) __PF(8021AD,802.1ad) +__PF(MPLS_UC,mpls_uc) +__PF(MPLS_MC,mpls_mc) { 0x8100, "802.1Q" }, { 0x88cc, "LLDP" }, From patchwork Wed Jul 10 12:40:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hurley X-Patchwork-Id: 1130376 X-Patchwork-Delegate: dsahern@gmail.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=netronome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="tvmD+uSK"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45kJhS2lf0z9sMQ for ; Wed, 10 Jul 2019 22:41:12 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727415AbfGJMlK (ORCPT ); Wed, 10 Jul 2019 08:41:10 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:34941 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725956AbfGJMlJ (ORCPT ); Wed, 10 Jul 2019 08:41:09 -0400 Received: by mail-wr1-f65.google.com with SMTP id y4so2326512wrm.2 for ; Wed, 10 Jul 2019 05:41:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2CeTc72p/cbXq9knA0iWK6b+dKY9nbe1iBbuMYB3OgU=; b=tvmD+uSKMleUDsk74krEs7aQvlijyXP9iOKWAIrn53d2N6f2lFpZj9bSOGzP9MnCp1 5fnXk/5FVdIXH/BKvrwqfBOCCMvKBWcqLyjA8jAoaayK+uwG+kpSFhpEb+FLEJSt270R YBuJHq1iPn9lvxv9V2y3nugxkNQFR/XOuwQGktD67t0zwltzCriODAi4IpbQ9x37rk4+ 9V2rLEFYc00DFYbMdHn++0E3o8mRXkkwbSYAIjmgmSTMq7UBS4rUfQpsLeEkvsQoxeX6 ZzSWf1FlThEqg8gx+dXwxz2uRAFEtJn9ngJf/TT0Rq6YKnthhuPDx6J1WePCg5JwtLoD fd6w== 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=2CeTc72p/cbXq9knA0iWK6b+dKY9nbe1iBbuMYB3OgU=; b=GyQKsSnYpis+298swMyuc8neQyOK6lM94zClwFapRf81fliZs2Yqux+XbcjEicHWJK xSzShhfp6xtYQLtxvEIiu1J3co8X1+Opx/CXmbhU4zSGdOmENHhz0Y6FzsbpdUnr16s7 oN+iQMKGRcbs20cTTOgY1AsGnLUizQfvzV6yhbZ6iwMOg31LPCy39z+oPM9/U0vg5fX7 /uQgVZ19ncFRBFRLU4yWBeT0KVGlvwgbbd7PubaHyw4mp33gJ43kGaf6h9FxyFOZvLZT rVcdi8YdKqwzKvnIO+idKSRknwsuzuxAK1qzkLhZT0Bkfxev3DfivT4pxbP1Rm9hpa+b ZaCQ== X-Gm-Message-State: APjAAAUY7Z8hI6yXFMJOd19y3j/sR9hjpAz/K9xkuYaxmmXYwupwfmF0 vg1oAacb29VLkdx/vYnaMuTqHO7eWb0= X-Google-Smtp-Source: APXvYqyMqb8GwR48ZSN+NSlZ5NYeXNkR3acW26LeDs7+m8xXmCxqkE/LYva5EZRYP+whcFJusFJP/g== X-Received: by 2002:adf:ce88:: with SMTP id r8mr33502769wrn.42.1562762467346; Wed, 10 Jul 2019 05:41:07 -0700 (PDT) Received: from jhurley-Precision-Tower-3420.netronome.com ([80.76.204.157]) by smtp.gmail.com with ESMTPSA id z5sm1406759wmf.48.2019.07.10.05.41.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Jul 2019 05:41:06 -0700 (PDT) From: John Hurley To: netdev@vger.kernel.org Cc: davem@davemloft.net, jiri@mellanox.com, xiyou.wangcong@gmail.com, dsahern@gmail.com, willemdebruijn.kernel@gmail.com, stephen@networkplumber.org, simon.horman@netronome.com, jakub.kicinski@netronome.com, oss-drivers@netronome.com, John Hurley Subject: [PATCH iproute2-next v2 2/3] tc: add mpls actions Date: Wed, 10 Jul 2019 13:40:39 +0100 Message-Id: <1562762440-25656-3-git-send-email-john.hurley@netronome.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1562762440-25656-1-git-send-email-john.hurley@netronome.com> References: <1562762440-25656-1-git-send-email-john.hurley@netronome.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Create a new action type for TC that allows the pushing, popping, and modifying of MPLS headers. Signed-off-by: John Hurley Reviewed-by: Jakub Kicinski --- tc/Makefile | 1 + tc/m_mpls.c | 276 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 277 insertions(+) create mode 100644 tc/m_mpls.c diff --git a/tc/Makefile b/tc/Makefile index 60abdde..09ff369 100644 --- a/tc/Makefile +++ b/tc/Makefile @@ -39,6 +39,7 @@ TCMODULES += q_drr.o TCMODULES += q_qfq.o TCMODULES += m_gact.o TCMODULES += m_mirred.o +TCMODULES += m_mpls.o TCMODULES += m_nat.o TCMODULES += m_pedit.o TCMODULES += m_ife.o diff --git a/tc/m_mpls.c b/tc/m_mpls.c new file mode 100644 index 0000000..0ae6d62 --- /dev/null +++ b/tc/m_mpls.c @@ -0,0 +1,276 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +/* Copyright (C) 2019 Netronome Systems, Inc. */ + +#include +#include +#include +#include +#include +#include + +#include "utils.h" +#include "rt_names.h" +#include "tc_util.h" + +static const char * const action_names[] = { + [TCA_MPLS_ACT_POP] = "pop", + [TCA_MPLS_ACT_PUSH] = "push", + [TCA_MPLS_ACT_MODIFY] = "modify", + [TCA_MPLS_ACT_DEC_TTL] = "dec_ttl", +}; + +static void explain(void) +{ + fprintf(stderr, + "Usage: mpls pop [ protocol MPLS_PROTO ]\n" + " mpls push [ protocol MPLS_PROTO ] [ label MPLS_LABEL ] [ tc MPLS_TC ]\n" + " [ ttl MPLS_TTL ] [ bos MPLS_BOS ] [CONTROL]\n" + " mpls modify [ label MPLS_LABEL ] [ tc MPLS_TC ] [ ttl MPLS_TTL ] [CONTROL]\n" + " for pop MPLS_PROTO is next header of packet - e.g. ip or mpls_uc\n" + " for push MPLS_PROTO is one of mpls_uc or mpls_mc\n" + " with default: mpls_uc\n" + " CONTROL := reclassify | pipe | drop | continue | pass |\n" + " goto chain \n"); +} + +static void usage(void) +{ + explain(); + exit(-1); +} + +static bool can_modify_mpls_fields(unsigned int action) +{ + return action == TCA_MPLS_ACT_PUSH || action == TCA_MPLS_ACT_MODIFY; +} + +static bool can_modify_ethtype(unsigned int action) +{ + return action == TCA_MPLS_ACT_PUSH || action == TCA_MPLS_ACT_POP; +} + +static bool is_valid_label(__u32 label) +{ + return label <= 0xfffff; +} + +static bool check_double_action(unsigned int action, const char *arg) +{ + if (!action) + return false; + + fprintf(stderr, + "Error: got \"%s\" but action already set to \"%s\"\n", + arg, action_names[action]); + explain(); + return true; +} + +static int parse_mpls(struct action_util *a, int *argc_p, char ***argv_p, + int tca_id, struct nlmsghdr *n) +{ + struct tc_mpls parm = {}; + __u32 label = 0xffffffff; + unsigned int action = 0; + char **argv = *argv_p; + struct rtattr *tail; + int argc = *argc_p; + __u16 proto = 0; + __u8 bos = 0xff; + __u8 tc = 0xff; + __u8 ttl = 0; + + if (matches(*argv, "mpls") != 0) + return -1; + + NEXT_ARG(); + + while (argc > 0) { + if (matches(*argv, "pop") == 0) { + if (check_double_action(action, *argv)) + return -1; + action = TCA_MPLS_ACT_POP; + } else if (matches(*argv, "push") == 0) { + if (check_double_action(action, *argv)) + return -1; + action = TCA_MPLS_ACT_PUSH; + } else if (matches(*argv, "modify") == 0) { + if (check_double_action(action, *argv)) + return -1; + action = TCA_MPLS_ACT_MODIFY; + } else if (matches(*argv, "dec_ttl") == 0) { + if (check_double_action(action, *argv)) + return -1; + action = TCA_MPLS_ACT_DEC_TTL; + } else if (matches(*argv, "label") == 0) { + if (!can_modify_mpls_fields(action)) + invarg("only valid for push/modify", *argv); + NEXT_ARG(); + if (get_u32(&label, *argv, 0) || !is_valid_label(label)) + invarg("label must be <=0xFFFFF", *argv); + } else if (matches(*argv, "tc") == 0) { + if (!can_modify_mpls_fields(action)) + invarg("only valid for push/modify", *argv); + NEXT_ARG(); + if (get_u8(&tc, *argv, 0) || (tc & ~0x7)) + invarg("tc field is 3 bits max", *argv); + } else if (matches(*argv, "ttl") == 0) { + if (!can_modify_mpls_fields(action)) + invarg("only valid for push/modify", *argv); + NEXT_ARG(); + if (get_u8(&ttl, *argv, 0) || !ttl) + invarg("ttl must be >0 and <=255", *argv); + } else if (matches(*argv, "bos") == 0) { + if (!can_modify_mpls_fields(action)) + invarg("only valid for push/modify", *argv); + NEXT_ARG(); + if (get_u8(&bos, *argv, 0) || (bos & ~0x1)) + invarg("bos must be 0 or 1", *argv); + } else if (matches(*argv, "protocol") == 0) { + if (!can_modify_ethtype(action)) + invarg("only valid for push/pop", *argv); + NEXT_ARG(); + if (ll_proto_a2n(&proto, *argv)) + invarg("protocol is invalid", *argv); + } else if (matches(*argv, "help") == 0) { + usage(); + } else { + break; + } + + NEXT_ARG_FWD(); + } + + if (!action) + incomplete_command(); + + parse_action_control_dflt(&argc, &argv, &parm.action, + false, TC_ACT_PIPE); + + if (argc) { + if (matches(*argv, "index") == 0) { + NEXT_ARG(); + if (get_u32(&parm.index, *argv, 10)) + invarg("illegal index", *argv); + NEXT_ARG_FWD(); + } + } + + if (action == TCA_MPLS_ACT_PUSH && !label) + missarg("label"); + + if (action == TCA_MPLS_ACT_PUSH && proto && + proto != htons(ETH_P_MPLS_UC) && proto != htons(ETH_P_MPLS_MC)) { + fprintf(stderr, + "invalid push protocol \"0x%04x\" - use mpls_(uc|mc)\n", + ntohs(proto)); + return -1; + } + + if (action == TCA_MPLS_ACT_POP && !proto) + missarg("protocol"); + + parm.m_action = action; + tail = addattr_nest(n, MAX_MSG, tca_id | NLA_F_NESTED); + addattr_l(n, MAX_MSG, TCA_MPLS_PARMS, &parm, sizeof(parm)); + if (label != 0xffffffff) + addattr_l(n, MAX_MSG, TCA_MPLS_LABEL, &label, sizeof(label)); + if (proto) + addattr_l(n, MAX_MSG, TCA_MPLS_PROTO, &proto, sizeof(proto)); + if (tc != 0xff) + addattr8(n, MAX_MSG, TCA_MPLS_TC, tc); + if (ttl) + addattr8(n, MAX_MSG, TCA_MPLS_TTL, ttl); + if (bos != 0xff) + addattr8(n, MAX_MSG, TCA_MPLS_BOS, bos); + addattr_nest_end(n, tail); + + *argc_p = argc; + *argv_p = argv; + return 0; +} + +static int print_mpls(struct action_util *au, FILE *f, struct rtattr *arg) +{ + struct rtattr *tb[TCA_MPLS_MAX + 1]; + struct tc_mpls *parm; + SPRINT_BUF(b1); + __u32 val; + + if (!arg) + return -1; + + parse_rtattr_nested(tb, TCA_MPLS_MAX, arg); + + if (!tb[TCA_MPLS_PARMS]) { + fprintf(stderr, "[NULL mpls parameters]\n"); + return -1; + } + parm = RTA_DATA(tb[TCA_MPLS_PARMS]); + + print_string(PRINT_ANY, "kind", "%s ", "mpls"); + print_string(PRINT_ANY, "mpls_action", " %s", + action_names[parm->m_action]); + + switch (parm->m_action) { + case TCA_MPLS_ACT_POP: + if (tb[TCA_MPLS_PROTO]) { + __u16 proto; + + proto = rta_getattr_u16(tb[TCA_MPLS_PROTO]); + print_string(PRINT_ANY, "protocol", " protocol %s", + ll_proto_n2a(proto, b1, sizeof(b1))); + } + break; + case TCA_MPLS_ACT_PUSH: + if (tb[TCA_MPLS_PROTO]) { + __u16 proto; + + proto = rta_getattr_u16(tb[TCA_MPLS_PROTO]); + print_string(PRINT_ANY, "protocol", " protocol %s", + ll_proto_n2a(proto, b1, sizeof(b1))); + } + /* Fallthrough */ + case TCA_MPLS_ACT_MODIFY: + if (tb[TCA_MPLS_LABEL]) { + val = rta_getattr_u32(tb[TCA_MPLS_LABEL]); + print_uint(PRINT_ANY, "label", " label %u", val); + } + if (tb[TCA_MPLS_TC]) { + val = rta_getattr_u8(tb[TCA_MPLS_TC]); + print_uint(PRINT_ANY, "tc", " tc %u", val); + } + if (tb[TCA_MPLS_BOS]) { + val = rta_getattr_u8(tb[TCA_MPLS_BOS]); + print_uint(PRINT_ANY, "bos", " bos %u", val); + } + if (tb[TCA_MPLS_TTL]) { + val = rta_getattr_u8(tb[TCA_MPLS_TTL]); + print_uint(PRINT_ANY, "ttl", " ttl %u", val); + } + break; + } + print_action_control(f, " ", parm->action, ""); + + print_uint(PRINT_ANY, "index", "\n\t index %u", parm->index); + print_int(PRINT_ANY, "ref", " ref %d", parm->refcnt); + print_int(PRINT_ANY, "bind", " bind %d", parm->bindcnt); + + if (show_stats) { + if (tb[TCA_MPLS_TM]) { + struct tcf_t *tm = RTA_DATA(tb[TCA_MPLS_TM]); + + print_tm(f, tm); + } + } + + print_string(PRINT_FP, NULL, "%s", _SL_); + + return 0; +} + +struct action_util mpls_action_util = { + .id = "mpls", + .parse_aopt = parse_mpls, + .print_aopt = print_mpls, +}; From patchwork Wed Jul 10 12:40:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Hurley X-Patchwork-Id: 1130377 X-Patchwork-Delegate: dsahern@gmail.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=netronome.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="PDLEZKRd"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 45kJhV5f8fz9sBF for ; Wed, 10 Jul 2019 22:41:14 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727509AbfGJMlN (ORCPT ); Wed, 10 Jul 2019 08:41:13 -0400 Received: from mail-wm1-f53.google.com ([209.85.128.53]:36397 "EHLO mail-wm1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727112AbfGJMlL (ORCPT ); Wed, 10 Jul 2019 08:41:11 -0400 Received: by mail-wm1-f53.google.com with SMTP id g67so2126775wme.1 for ; Wed, 10 Jul 2019 05:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gr9HEsxvkhORqGpDxpOnjSaFaOUXWvJHYXoYUcexVM8=; b=PDLEZKRdFlS0oxZWcZt5HpmMM7U/gp7Mpbe6buV5/fR5q0x1Usoby2+Ymc9PdwEUSI kcbpzQffE7zcmo9ZabroZIzhIeIsc0NkcRMM1sZECkVn2KrKD462ZDJFG/Msea9qoXok 6GwJrsPxaQevqsOFBG32d86SjaEg/IdSKxfNqjx6DaP/mTxvFCcWDXZPCDh5UlOb3P13 tTJOftTtZiD9xHTpCpytlHcVi3BJBjq9WGEIvMS9tBfEkzr7c76pgBD7ixopW/PUx65u 14TaGk50K8XIdQSwffClPA/LJjEY38WxbiLDKeV3HQABgZGGxH7IqKs9Hvmp3YNLAhOs epig== 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=gr9HEsxvkhORqGpDxpOnjSaFaOUXWvJHYXoYUcexVM8=; b=t4DXJsbdXtOXrQxSrIJEBVI+O+Jve7qS+8tjVw0FycUWJfu3N1DhJj1tE8WuDU0ymI JqF0rzNqcFx8LFuPI3hs4H3FkojS7kKsCFOSk4doO3K2KSWKv0n7+XPdzeV6uWF+WSGd 9/uIGslPF2fwfhNe8MghEkJdEwCn7I3N5YCz36YZrJn41En/SqBg/A3ghb/hJYQ6jhgR hTe4uXUex4tCPZ3R7v2nTbrYznJ3TV7SoaoQ2dI6PpWkR8EKSJtmftTJJuH4K7P5STzU X3HnuRsWQDQpyuBK1ls7sgn9UeBclF+usjvYQSibKaP2wU+g2s06ovOi1BXAG5DtBY/N 082w== X-Gm-Message-State: APjAAAXL3cIOpAaue94tCarudBDzbiW/iptctrZF60mtswUfXGK5/kqN A3mD2n7+S4NGgsvQ2HuV50R4PQnjpcU= X-Google-Smtp-Source: APXvYqznQrPVQCyV2ImrTUJvwdAmMqoYeDXw2LkAX/GgKlAZrvdCHTH1yASDVKctaqmRfjdosup8aQ== X-Received: by 2002:a1c:dc46:: with SMTP id t67mr4968493wmg.159.1562762468492; Wed, 10 Jul 2019 05:41:08 -0700 (PDT) Received: from jhurley-Precision-Tower-3420.netronome.com ([80.76.204.157]) by smtp.gmail.com with ESMTPSA id z5sm1406759wmf.48.2019.07.10.05.41.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Jul 2019 05:41:07 -0700 (PDT) From: John Hurley To: netdev@vger.kernel.org Cc: davem@davemloft.net, jiri@mellanox.com, xiyou.wangcong@gmail.com, dsahern@gmail.com, willemdebruijn.kernel@gmail.com, stephen@networkplumber.org, simon.horman@netronome.com, jakub.kicinski@netronome.com, oss-drivers@netronome.com, John Hurley Subject: [PATCH iproute2-next v2 3/3] man: update man pages for TC MPLS actions Date: Wed, 10 Jul 2019 13:40:40 +0100 Message-Id: <1562762440-25656-4-git-send-email-john.hurley@netronome.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1562762440-25656-1-git-send-email-john.hurley@netronome.com> References: <1562762440-25656-1-git-send-email-john.hurley@netronome.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add a man page describing the newly added TC mpls manipulation actions. Signed-off-by: John Hurley Reviewed-by: Jakub Kicinski --- man/man8/tc-mpls.8 | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 man/man8/tc-mpls.8 diff --git a/man/man8/tc-mpls.8 b/man/man8/tc-mpls.8 new file mode 100644 index 0000000..84ef2ef --- /dev/null +++ b/man/man8/tc-mpls.8 @@ -0,0 +1,156 @@ +.TH "MPLS manipulation action in tc" 8 "22 May 2019" "iproute2" "Linux" + +.SH NAME +mpls - mpls manipulation module +.SH SYNOPSIS +.in +8 +.ti -8 +.BR tc " ... " "action mpls" " { " +.IR POP " | " PUSH " | " MODIFY " | " +.BR dec_ttl " } [ " +.IR CONTROL " ]" + +.ti -8 +.IR POP " := " +.BR pop " " protocol +.IR MPLS_PROTO + +.ti -8 +.IR PUSH " := " +.BR push " [ " protocol +.IR MPLS_PROTO " ]" +.RB " [ " tc +.IR MPLS_TC " ] " +.RB " [ " ttl +.IR MPLS_TTL " ] " +.RB " [ " bos +.IR MPLS_BOS " ] " +.BI label " MPLS_LABEL" + +.ti -8 +.IR MODIFY " := " +.BR modify " [ " label +.IR MPLS_LABEL " ]" +.RB " [ " tc +.IR MPLS_TC " ] " +.RB " [ " ttl +.IR MPLS_TTL " ] " + +.ti -8 +.IR CONTROL " := { " +.BR reclassify " | " pipe " | " drop " | " continue " | " pass " | " goto " " chain " " CHAIN_INDEX " }" +.SH DESCRIPTION +The +.B mpls +action performs mpls encapsulation or decapsulation on a packet, reflected by the +operation modes +.IR POP ", " PUSH ", " MODIFY " and " DEC_TTL . +The +.I POP +mode requires the ethertype of the header that follows the MPLS header (e.g. +IPv4 or another MPLS). It will remove the outer MPLS header and replace the +ethertype in the MAC header with that passed. The +.IR PUSH " and " MODIFY +modes update the current MPLS header information or add a new header. +.IR PUSH +requires at least an +.IR MPLS_LABEL ". " +.I DEC_TTL +requires no arguments and simply subtracts 1 from the MPLS header TTL field. + +.SH OPTIONS +.TP +.B pop +Decapsulation mode. Requires the protocol of the next header. +.TP +.B push +Encapsulation mode. Requires at least the +.B label +option. +.TP +.B modify +Replace mode. Existing MPLS tag is replaced. +.BR label ", " +.BR tc ", " +and +.B ttl +are all optional. +.TP +.B dec_ttl +Decrement the TTL field on the outer most MPLS header. +.TP +.BI label " MPLS_LABEL" +Specify the MPLS LABEL for the outer MPLS header. +.I MPLS_LABEL +is an unsigned 20bit integer, the format is detected automatically (e.g. prefix +with +.RB ' 0x ' +for hexadecimal interpretation, etc.). +.TP +.BI protocol " MPLS_PROTO" +Choose the protocol to use. For push actions this must be +.BR mpls_uc " or " mpls_mc " (" mpls_uc +is the default). For pop actions it should be the protocol of the next header. +This option cannot be used with modify. +.TP +.BI tc " MPLS_TC" +Choose the TC value for the outer MPLS header. Decimal number in range of 0-7. +Defaults to 0. +.TP +.BI ttl " MPLS_TTL" +Choose the TTL value for the outer MPLS header. Number in range of 0-255. A +non-zero default value will be selected if this is not explicitly set. +.TP +.BI bos " MPLS_BOS" +Manually configure the bottom of stack bit for an MPLS header push. The default +is for TC to automatically set (or unset) the bit based on the next header of +the packet. +.TP +.I CONTROL +How to continue after executing this action. +.RS +.TP +.B reclassify +Restarts classification by jumping back to the first filter attached to this +action's parent. +.TP +.B pipe +Continue with the next action, this is the default. +.TP +.B drop +Packet will be dropped without running further actions. +.TP +.B continue +Continue classification with next filter in line. +.TP +.B pass +Return to calling qdisc for packet processing. This ends the classification +process. +.RE +.SH EXAMPLES +The following example encapsulates incoming IP packets on eth0 into MPLS with +a label 123 and sends them out eth1: + +.RS +.EX +#tc qdisc add dev eth0 handle ffff: ingress +#tc filter add dev eth0 protocol ip parent ffff: flower \\ + action mpls push protocol mpls_uc label 123 \\ + action mirred egress redirect dev eth1 +.EE +.RE + +In this example, incoming MPLS unicast packets on eth0 are decapsulated and to +ip packets and output to eth1: + +.RS +.EX +#tc qdisc add dev eth0 handle ffff: ingress +#tc filter add dev eth0 protocol mpls_uc parent ffff: flower \\ + action mpls pop protocol ipv4 \\ + action mirred egress redirect dev eth0 +.EE +.RE + +.SH SEE ALSO +.BR tc (8)