From patchwork Sun Mar 4 12:20:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roi Dayan X-Patchwork-Id: 881170 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zvMky74KTz9s3Q for ; Sun, 4 Mar 2018 23:28:10 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4BDF8F64; Sun, 4 Mar 2018 12:27:34 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 3747EF4A for ; Sun, 4 Mar 2018 12:27:32 +0000 (UTC) X-Greylist: delayed 00:06:41 by SQLgrey-1.7.6 Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 50CBD5CF for ; Sun, 4 Mar 2018 12:27:31 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from roid@mellanox.com) with ESMTPS (AES256-SHA encrypted); 4 Mar 2018 14:21:12 +0200 Received: from r-vnc11.mtr.labs.mlnx (r-vnc11.mtr.labs.mlnx [10.208.0.123]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w24CKkqK012981; Sun, 4 Mar 2018 14:20:46 +0200 From: Roi Dayan To: dev@openvswitch.org Date: Sun, 4 Mar 2018 14:20:30 +0200 Message-Id: <1520166031-22709-2-git-send-email-roid@mellanox.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1520166031-22709-1-git-send-email-roid@mellanox.com> References: <1520166031-22709-1-git-send-email-roid@mellanox.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Shahar Klein Subject: [ovs-dev] [PATCH 1/2] lib/tc: Handle error parsing action in nl_parse_single_action X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Raise the error up instead of ignoring it. Before this commit beside an error an incorrect rule was also printed. Signed-off-by: Roi Dayan Reviewed-by: Paul Blakey --- lib/tc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/tc.c b/lib/tc.c index 914465a..b49bbe8 100644 --- a/lib/tc.c +++ b/lib/tc.c @@ -809,6 +809,7 @@ nl_parse_single_action(struct nlattr *action, struct tc_flower *flower) struct nlattr *stats_attrs[ARRAY_SIZE(stats_policy)]; struct ovs_flow_stats *stats = &flower->stats; const struct gnet_stats_basic *bs; + int err = 0; if (!nl_parse_nested(action, act_policy, action_attrs, ARRAY_SIZE(act_policy))) { @@ -821,20 +822,24 @@ nl_parse_single_action(struct nlattr *action, struct tc_flower *flower) act_cookie = action_attrs[TCA_ACT_COOKIE]; if (!strcmp(act_kind, "gact")) { - nl_parse_act_drop(act_options, flower); + err = nl_parse_act_drop(act_options, flower); } else if (!strcmp(act_kind, "mirred")) { - nl_parse_act_mirred(act_options, flower); + err = nl_parse_act_mirred(act_options, flower); } else if (!strcmp(act_kind, "vlan")) { - nl_parse_act_vlan(act_options, flower); + err = nl_parse_act_vlan(act_options, flower); } else if (!strcmp(act_kind, "tunnel_key")) { - nl_parse_act_tunnel_key(act_options, flower); + err = nl_parse_act_tunnel_key(act_options, flower); } else if (!strcmp(act_kind, "pedit")) { - nl_parse_act_pedit(act_options, flower); + err = nl_parse_act_pedit(act_options, flower); } else if (!strcmp(act_kind, "csum")) { nl_parse_act_csum(act_options, flower); } else { VLOG_ERR_RL(&error_rl, "unknown tc action kind: %s", act_kind); - return EINVAL; + err = EINVAL; + } + + if (err) { + return err; } if (act_cookie) { From patchwork Sun Mar 4 12:20:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roi Dayan X-Patchwork-Id: 881171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zvMlc0xLKz9s3Q for ; Sun, 4 Mar 2018 23:28:44 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 5FF65FA7; Sun, 4 Mar 2018 12:27:35 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 7D175F51 for ; Sun, 4 Mar 2018 12:27:32 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by smtp1.linuxfoundation.org (Postfix) with ESMTP id 70E2E5D4 for ; Sun, 4 Mar 2018 12:27:31 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from roid@mellanox.com) with ESMTPS (AES256-SHA encrypted); 4 Mar 2018 14:21:12 +0200 Received: from r-vnc11.mtr.labs.mlnx (r-vnc11.mtr.labs.mlnx [10.208.0.123]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id w24CKkqL012981; Sun, 4 Mar 2018 14:20:46 +0200 From: Roi Dayan To: dev@openvswitch.org Date: Sun, 4 Mar 2018 14:20:31 +0200 Message-Id: <1520166031-22709-3-git-send-email-roid@mellanox.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1520166031-22709-1-git-send-email-roid@mellanox.com> References: <1520166031-22709-1-git-send-email-roid@mellanox.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Shahar Klein Subject: [ovs-dev] [PATCH 2/2] netdev-tc-offloads: Add support for offloading ip frag no X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org TC flower only support frag yes/no while OVS support first/later/no. Currently we can only support offloading of frag no. Signed-off-by: Roi Dayan Reviewed-by: Shahar Klein --- lib/netdev-tc-offloads.c | 13 ++++++++++++- lib/tc.c | 28 ++++++++++++++++++++++++++++ lib/tc.h | 1 + 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/lib/netdev-tc-offloads.c b/lib/netdev-tc-offloads.c index 9364d94..b3e557f 100644 --- a/lib/netdev-tc-offloads.c +++ b/lib/netdev-tc-offloads.c @@ -428,6 +428,8 @@ parse_tc_flower_to_match(struct tc_flower *flower, match_set_nw_ttl_masked(match, key->ip_ttl, mask->ip_ttl); + match_set_nw_frag_masked(match, key->ip_frag, mask->ip_frag); + match_set_nw_src_masked(match, key->ipv4.ipv4_src, mask->ipv4.ipv4_src); match_set_nw_dst_masked(match, key->ipv4.ipv4_dst, mask->ipv4.ipv4_dst); @@ -932,6 +934,16 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, flower.key.ip_ttl = key->nw_ttl; flower.mask.ip_ttl = mask->nw_ttl; + if (mask->nw_frag) { + if (key->nw_frag) { + return EOPNOTSUPP; + } + + flower.key.ip_frag = key->nw_frag; + flower.mask.ip_frag = mask->nw_frag; + mask->nw_frag = 0; + } + if (key->nw_proto == IPPROTO_TCP) { flower.key.tcp_dst = key->tp_dst; flower.mask.tcp_dst = mask->tp_dst; @@ -958,7 +970,6 @@ netdev_tc_flow_put(struct netdev *netdev, struct match *match, mask->tp_dst = 0; } - mask->nw_frag = 0; mask->nw_tos = 0; mask->nw_proto = 0; mask->nw_ttl = 0; diff --git a/lib/tc.c b/lib/tc.c index b49bbe8..74dd8fc 100644 --- a/lib/tc.c +++ b/lib/tc.c @@ -281,6 +281,8 @@ static const struct nl_policy tca_flower_policy[] = { .optional = true, }, [TCA_FLOWER_KEY_ENC_UDP_DST_PORT] = { .type = NL_A_U16, .optional = true, }, + [TCA_FLOWER_KEY_FLAGS] = { .type = NL_A_BE32, .optional = true, }, + [TCA_FLOWER_KEY_FLAGS_MASK] = { .type = NL_A_BE32, .optional = true, }, [TCA_FLOWER_KEY_IP_TTL] = { .type = NL_A_U8, .optional = true, }, [TCA_FLOWER_KEY_IP_TTL_MASK] = { .type = NL_A_U8, @@ -374,6 +376,15 @@ nl_parse_flower_ip(struct nlattr **attrs, struct tc_flower *flower) { mask->ip_proto = UINT8_MAX; } + if (attrs[TCA_FLOWER_KEY_FLAGS_MASK]) { + uint32_t flags = ntohl(nl_attr_get_u32(attrs[TCA_FLOWER_KEY_FLAGS])); + uint32_t flags_mask = + ntohl(nl_attr_get_u32(attrs[TCA_FLOWER_KEY_FLAGS_MASK])); + + key->ip_frag = flags & TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT; + mask->ip_frag = flags_mask & TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT; + } + if (attrs[TCA_FLOWER_KEY_IPV4_SRC_MASK]) { key->ipv4.ipv4_src = nl_attr_get_be32(attrs[TCA_FLOWER_KEY_IPV4_SRC]); @@ -1490,11 +1501,28 @@ nl_msg_put_flower_options(struct ofpbuf *request, struct tc_flower *flower) FLOWER_PUT_MASKED_VALUE(src_mac, TCA_FLOWER_KEY_ETH_SRC); if (host_eth_type == ETH_P_IP || host_eth_type == ETH_P_IPV6) { + uint32_t flags = 0; + uint32_t flags_mask = 0; + if (flower->mask.ip_proto && flower->key.ip_proto) { nl_msg_put_u8(request, TCA_FLOWER_KEY_IP_PROTO, flower->key.ip_proto); } + if (flower->mask.ip_frag) { + flags_mask |= TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT; + + if (flower->key.ip_frag) { + flags |= TCA_FLOWER_KEY_FLAGS_IS_FRAGMENT; + } + } + + if (flags_mask) { + nl_msg_put_u32(request, TCA_FLOWER_KEY_FLAGS, htonl(flags)); + nl_msg_put_u32(request, TCA_FLOWER_KEY_FLAGS_MASK, + htonl(flags_mask)); + } + if (flower->key.ip_proto == IPPROTO_UDP) { FLOWER_PUT_MASKED_VALUE(udp_src, TCA_FLOWER_KEY_UDP_SRC); FLOWER_PUT_MASKED_VALUE(udp_dst, TCA_FLOWER_KEY_UDP_DST); diff --git a/lib/tc.h b/lib/tc.h index 6af51c6..b061829 100644 --- a/lib/tc.h +++ b/lib/tc.h @@ -93,6 +93,7 @@ struct tc_flower_key { ovs_be16 encap_eth_type; uint8_t ip_ttl; + uint8_t ip_frag; struct { ovs_be32 ipv4_src;