From patchwork Mon Mar 15 15:46:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 400489 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3536682jai; Mon, 15 Mar 2021 08:47:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZCOqh5mVN+BsWkRlWYBSP5z8nbdbtnIt66MGJm11UBjdQxx4fR8rUx162z0OVxfJ33S8k X-Received: by 2002:a05:6402:3096:: with SMTP id de22mr30685644edb.141.1615823236677; Mon, 15 Mar 2021 08:47:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615823236; cv=none; d=google.com; s=arc-20160816; b=aLhsBUVEw3exhtx75vGL1zZtNcYpkv3vIa7aGy++zF1NhyYkQGzsuLjMpv58hCgkLz cfAMAYCTP95efkKSP3aHkMOnkGnJDC160a7XPXmSfMfzB1DteVE4gWStsBPzam4BAGRM X98AdHMMsSU2N4Y8qGfi91nQ/Ye74i1JksWFpuCy2jMdvWcHgj0jOh2fLY6+JhQ3QydJ 2NQMmuIoNpaoOe67msjMy7gI4ROAx+3a9uBRLXXZaAZl+4wTnnFbOCLHHL/cTgCAZIx8 wAMk/FH7CcWoVoJL7TQhl0ODFlkTw26k6+Msg9m2qwjhNQBph7fz6cErYS9GJLeNglFp FHGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=4fl+whUwXBcMIK42PoE39zhmZsaj/uqEpkjHXU4Fi7g=; b=BnMZQKI8f5CcB6GfRxDhgwwy9Cjm/poKqneCa7yuKD+7axWRP5MXpkpCgxCMcL2/is lcsK/ZaCU6BSGMfa3xYWzoKzOoCZOGEwB5tPQ9fNPEfK2n+L/8vBNXTbu9myMZ51AGtV 8fit/UDSlE/iUmfjzyHlxQthRpeFxUQO9okqtSoTUSOZq+/4TcbqFjajOFsrjjd3NW+0 i1JEGVeXnNz371WB86DForTnXCBdVYcMZWb3czgAc3LiOp5gsNq9vedE3xPXmSMVsEGB YDB4aI8xpmorEEAbd3vyiBCBHhVdXJRK3VkvDEgYb//YX3Sff77YRhBYMfLumoBkGjRj 5wVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LONPaLYa; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rs13si11293102ejb.31.2021.03.15.08.47.16; Mon, 15 Mar 2021 08:47:16 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LONPaLYa; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231938AbhCOPqo (ORCPT + 8 others); Mon, 15 Mar 2021 11:46:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232155AbhCOPqe (ORCPT ); Mon, 15 Mar 2021 11:46:34 -0400 Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09DEFC06175F for ; Mon, 15 Mar 2021 08:46:34 -0700 (PDT) Received: by mail-ot1-x32b.google.com with SMTP id j8so7234632otc.0 for ; Mon, 15 Mar 2021 08:46:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4fl+whUwXBcMIK42PoE39zhmZsaj/uqEpkjHXU4Fi7g=; b=LONPaLYauvyl3qOugYhtN94Mdpzvg5xwHf489IwaeeZWa+OV7sOTeFSq7vjx0OuxtH czmjwpaF/U+Ir7MKjmLzzzU/f41J3/1ACXAvWk05P/h2YaBaiIYpFYO472H0KpQjBn0v kOzvWnZCt8tCZjznBekiChvq+NKPGmJckHGnUAUCEui/mj5tbp2eTVb9SgEa730Q0y7D Eo3WqLi4JOwPY3fYZAzzJ5ga3pjNbrEtxPagGawEVZ7z9SetwlbT1+fTbTDYO+Z1t7wu QJUo4cyeYCJ0eWKEkhVtWs1QztfYxunsELAK4qRrLBwHtPe++5JH9GDy6H/flLO57aLR zA1w== 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:mime-version :content-transfer-encoding; bh=4fl+whUwXBcMIK42PoE39zhmZsaj/uqEpkjHXU4Fi7g=; b=WpKqOgPhyKgBUKDR2wfRYSwoskr8UYWYpHCUMsQOPFyPBnRSZ4Y9aHk/Chsp7sn8N+ DZoByN9dKjrTZaQt+YJIvColfo0fYbtoDbGwsDAvbHEJPANYogzb4K6L8j4tbFhTgMRw AobyUyFbD1b8t53yMjQqKoGhvXTCfAQT2kQOM/c1ui7A+cjqCmE6piZLBY4yQZto3jTJ YXtk4KTApRGo6ElqP2EaFdEVsXtUGeVw+ZeCzyfErLLaBOLJnMeNCm6gAJd0CPIp2/kd XZBjSqhCqnqG8onZIN61jL5cN3+IQbMMlGQOSI7S2yGYxU/4+zuOHtCad94hbtDmY4pw vfTw== X-Gm-Message-State: AOAM530j5ZUacnzMVmNOmEuwWOpyr3q+YhEO/FWJl5LzF5uifCZT80/K TlTjClnZkYSplj9oRR9reAwMujllY25q7g== X-Received: by 2002:a9d:63d6:: with SMTP id e22mr12810911otl.188.1615823193144; Mon, 15 Mar 2021 08:46:33 -0700 (PDT) Received: from localhost.localdomain (104-57-184-186.lightspeed.austtx.sbcglobal.net. [104.57.184.186]) by smtp.gmail.com with ESMTPSA id h2sm7230243otn.43.2021.03.15.08.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 08:46:32 -0700 (PDT) From: Bjorn Andersson To: netdev@vger.kernel.org Cc: Daniele Palmas , Alex Elder Subject: [PATCH v2] iplink_rmnet: Allow passing IFLA_RMNET_FLAGS Date: Mon, 15 Mar 2021 10:46:29 -0500 Message-Id: <20210315154629.652824-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Parse and pass IFLA_RMNET_FLAGS to the kernel, to allow changing the flags from the default of ingress-aggregate only. Signed-off-by: Bjorn Andersson --- Changes since v1: - s/ifla_vlan_flags/ifla_rmnet_flags/ in print_opt ip/iplink_rmnet.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) -- 2.28.0 diff --git a/ip/iplink_rmnet.c b/ip/iplink_rmnet.c index 1d16440c6900..a847c838def2 100644 --- a/ip/iplink_rmnet.c +++ b/ip/iplink_rmnet.c @@ -16,6 +16,10 @@ static void print_explain(FILE *f) { fprintf(f, "Usage: ... rmnet mux_id MUXID\n" + " [ingress-deaggregation]\n" + " [ingress-commands]\n" + " [ingress-chksumv4]\n" + " [egress-chksumv4]\n" "\n" "MUXID := 1-254\n" ); @@ -29,6 +33,7 @@ static void explain(void) static int rmnet_parse_opt(struct link_util *lu, int argc, char **argv, struct nlmsghdr *n) { + struct ifla_rmnet_flags flags = { }; __u16 mux_id; while (argc > 0) { @@ -37,6 +42,18 @@ static int rmnet_parse_opt(struct link_util *lu, int argc, char **argv, if (get_u16(&mux_id, *argv, 0)) invarg("mux_id is invalid", *argv); addattr16(n, 1024, IFLA_RMNET_MUX_ID, mux_id); + } else if (matches(*argv, "ingress-deaggregation") == 0) { + flags.mask = ~0; + flags.flags |= RMNET_FLAGS_INGRESS_DEAGGREGATION; + } else if (matches(*argv, "ingress-commands") == 0) { + flags.mask = ~0; + flags.flags |= RMNET_FLAGS_INGRESS_MAP_COMMANDS; + } else if (matches(*argv, "ingress-chksumv4") == 0) { + flags.mask = ~0; + flags.flags |= RMNET_FLAGS_INGRESS_MAP_CKSUMV4; + } else if (matches(*argv, "egress-chksumv4") == 0) { + flags.mask = ~0; + flags.flags |= RMNET_FLAGS_EGRESS_MAP_CKSUMV4; } else if (matches(*argv, "help") == 0) { explain(); return -1; @@ -48,11 +65,28 @@ static int rmnet_parse_opt(struct link_util *lu, int argc, char **argv, argc--, argv++; } + if (flags.mask) + addattr_l(n, 1024, IFLA_RMNET_FLAGS, &flags, sizeof(flags)); + return 0; } +static void rmnet_print_flags(FILE *fp, __u32 flags) +{ + if (flags & RMNET_FLAGS_INGRESS_DEAGGREGATION) + print_string(PRINT_ANY, NULL, "%s ", "ingress-deaggregation"); + if (flags & RMNET_FLAGS_INGRESS_MAP_COMMANDS) + print_string(PRINT_ANY, NULL, "%s ", "ingress-commands"); + if (flags & RMNET_FLAGS_INGRESS_MAP_CKSUMV4) + print_string(PRINT_ANY, NULL, "%s ", "ingress-chksumv4"); + if (flags & RMNET_FLAGS_EGRESS_MAP_CKSUMV4) + print_string(PRINT_ANY, NULL, "%s ", "egress-cksumv4"); +} + static void rmnet_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) { + struct ifla_rmnet_flags *flags; + if (!tb) return; @@ -64,6 +98,14 @@ static void rmnet_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) "mux_id", "mux_id %u ", rta_getattr_u16(tb[IFLA_RMNET_MUX_ID])); + + if (tb[IFLA_RMNET_FLAGS]) { + if (RTA_PAYLOAD(tb[IFLA_RMNET_FLAGS]) < sizeof(*flags)) + return; + flags = RTA_DATA(tb[IFLA_RMNET_FLAGS]); + + rmnet_print_flags(f, flags->flags); + } } static void rmnet_print_help(struct link_util *lu, int argc, char **argv,