From patchwork Fri Jun 19 18:44:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Satish X-Patchwork-Id: 1313319 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=oneconvergence.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oneconvergence-com.20150623.gappssmtp.com header.i=@oneconvergence-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=CyeHXYeE; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49pT8g0sQpz9s6w for ; Sat, 20 Jun 2020 05:17:38 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id E375A868E5; Fri, 19 Jun 2020 19:17:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xpjDtJl1xaz1; Fri, 19 Jun 2020 19:17:34 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id C3E42867ED; Fri, 19 Jun 2020 19:17:34 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A1A40C07FF; Fri, 19 Jun 2020 19:17:34 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id AEAC0C016E for ; Fri, 19 Jun 2020 19:17:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id A368C899DE for ; Fri, 19 Jun 2020 19:17:32 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hLXZHrt-dleR for ; Fri, 19 Jun 2020 19:17:31 +0000 (UTC) X-Greylist: delayed 00:22:34 by SQLgrey-1.7.6 Received: from mail-oi1-f194.google.com (mail-oi1-f194.google.com [209.85.167.194]) by hemlock.osuosl.org (Postfix) with ESMTPS id 8378E899D2 for ; Fri, 19 Jun 2020 19:17:31 +0000 (UTC) Received: by mail-oi1-f194.google.com with SMTP id s21so9383712oic.9 for ; Fri, 19 Jun 2020 12:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oneconvergence-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=sI332s6pNtK5OemgOvJs4otIG3pxKzD+iHrpAmRhrbc=; b=CyeHXYeErvaH4d/EshGs40ChzM6TxKrO/JmKd/GOt7Hgx2UeHEhP2wLqxoZOqljTpE Aatva1AM3nak/KE2vMnrAMBgSlJqf7Fef6O+CTfkV1ox760hYPts69ITmryH7oTtVDuD SbmDY/+vUXIcvEuz5Zfq5rHWu1CoMnjfSBc2AS2Nck9EYtLkDNupCn+6qCi/KEBOa5qH 9tDlZF+//voslDKMRo9PZ0413dLK1bN4VR+00vJzVBF58LBpZXjLa8yqhXum07PhYYAR IHzp251lpyDd64aMysaTI5wt2uc6efDO/OlPb+bhIop3J3aCsXQ5VZFzBJJ6ySAWphMT E7BQ== 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=sI332s6pNtK5OemgOvJs4otIG3pxKzD+iHrpAmRhrbc=; b=daHHqKpYKija6yBDUtyPNxboGdw/DPlvHWc7uhnhiNIsl93vzHx/UsNShOWuOWh6SJ +6yF1hveGopGJdc9LQCxPwhCLS/30WhkC8EK7lUVdTWHjEQHxHktvbdH0gp45NqXZSvP IrMc8J9xdwJo0Ru7j46GT3WfnG1yNhEMO3XaCy/Mj18OJWNqP4p4Upe1vQ3aXBcMIC87 zexCiG3N/xtDIhx9S8GW4AvZavRRRlo2uf0CUrq9ZFcN0LIGfkTnIyjkwCarfkZcprUL WjfCBPd3IC00fJdDa8+4RGC8H8nkdcs0KY7YIUgnpH2TuTtDB78j+lheADbSRv26+FaO n+tA== X-Gm-Message-State: AOAM531SMfNETfgi4FaaZd8SNNDT6MXW4j0n4nTbGnUXnP9EYIlRx9Q8 SepX1XtEdh1+qbiwoc7ExkwfHL89Z+OH1w== X-Google-Smtp-Source: ABdhPJwq7YQDsg514RmVqrSZW1nCsvgyrPE4YnnN3JAcBtPX426X5/OjjzaTVg49a74LZTZQLtOonw== X-Received: by 2002:a17:90b:801:: with SMTP id bk1mr4821646pjb.28.1592592443217; Fri, 19 Jun 2020 11:47:23 -0700 (PDT) Received: from localhost.localdomain ([27.57.206.119]) by smtp.gmail.com with ESMTPSA id b5sm6630485pfg.191.2020.06.19.11.47.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 11:47:22 -0700 (PDT) From: dsatish To: dev@openvswitch.org Date: Sat, 20 Jun 2020 00:14:37 +0530 Message-Id: <20200619184437.20323-1-satish.d@oneconvergence.com> X-Mailer: git-send-email 2.17.1 Cc: jai.rana@oneconvergence.com, prathibha.nagooru@oneconvergence.com, simon.horman@netronome.com, satish.d@oneconvergence.com, intiyaz.basha@oneconvergence.com Subject: [ovs-dev] [PATCH v2] tc: Changes to netlink message population for OVS-TC Flower Offload X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Satish Dhote OVS-TC offload sends only fields that are not completely masked out to the TC kernel module. Some of the hardware we work with requires all fields extracted from the packet along with the mask to be sent to the driver. Hardware may optimize tables based on entire fields of packet and mask of fields, even though certain fields are masked out. OVS when offloading to ovs kernel datapath sends the entire key along with the mask. Proposal requests for similar behaviour in ovs-vswitchd in case of tc-offload. While constructing netlink messages, ovs-vswitchd is removing completely masked out fields. Sending additional masked fields should not impact existing drivers. TC internally uses dissectors to extract non masked fields, so it should not impact existing drivers in tc. Example: ovs-rule:ovs-ofctl add-flow br0 \ "table=0, dl_dst=00:a1:45:23:23:11/ff:ff:ff:ff:ff:ff, actions=1" If we have above rule in ovs and an icmp packet matching destination MAC 00:a1:45:23:23:11 arrives, ovs prepares the key and mask with all relevant fields. When sending to TC it removes fields which are completely masked out. In this case ethertype, and dst_mac fields are sent as part of netlink message to tc. OVS patch also requires minor fixes in TC. Patch to TC is submitted at following link. 1/3 patch has the fix for the same. http://patchwork.ozlabs.org/project/netdev/list/?series=184493 Co-authored-by: Chandra Kesava Co-authored-by: Prathibha Nagooru Signed-off-by: Chandra Kesava Signed-off-by: Prathibha Nagooru Signed-off-by: Satish Dhote --- v2: - Corrected From author name. - Added missing co-author detail. - Deleted unused variable. --- lib/tc.c | 111 +++++++++++++++++++++---------------------------------- 1 file changed, 42 insertions(+), 69 deletions(-) diff --git a/lib/tc.c b/lib/tc.c index c2ab77553..4d0232120 100644 --- a/lib/tc.c +++ b/lib/tc.c @@ -2648,9 +2648,6 @@ nl_msg_put_masked_value(struct ofpbuf *request, uint16_t type, const void *mask_data, size_t len) { if (mask_type != TCA_FLOWER_UNSPEC) { - if (is_all_zeros(mask_data, len)) { - return; - } nl_msg_put_unspec(request, mask_type, mask_data, len); } nl_msg_put_unspec(request, type, data, len); @@ -2705,17 +2702,16 @@ nl_msg_put_flower_tunnel(struct ofpbuf *request, struct tc_flower *flower) uint8_t ttl = flower->key.tunnel.ttl; uint8_t tos_mask = flower->mask.tunnel.tos; uint8_t ttl_mask = flower->mask.tunnel.ttl; - ovs_be64 id_mask = flower->mask.tunnel.id; - if (ipv4_dst_mask || ipv4_src_mask) { + if (ipv4_dst || ipv4_src) { nl_msg_put_be32(request, TCA_FLOWER_KEY_ENC_IPV4_DST_MASK, ipv4_dst_mask); nl_msg_put_be32(request, TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK, ipv4_src_mask); nl_msg_put_be32(request, TCA_FLOWER_KEY_ENC_IPV4_DST, ipv4_dst); nl_msg_put_be32(request, TCA_FLOWER_KEY_ENC_IPV4_SRC, ipv4_src); - } else if (ipv6_addr_is_set(ipv6_dst_mask) || - ipv6_addr_is_set(ipv6_src_mask)) { + } else if (ipv6_addr_is_set(ipv6_dst) || + ipv6_addr_is_set(ipv6_src)) { nl_msg_put_in6_addr(request, TCA_FLOWER_KEY_ENC_IPV6_DST_MASK, ipv6_dst_mask); nl_msg_put_in6_addr(request, TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK, @@ -2723,20 +2719,18 @@ nl_msg_put_flower_tunnel(struct ofpbuf *request, struct tc_flower *flower) nl_msg_put_in6_addr(request, TCA_FLOWER_KEY_ENC_IPV6_DST, ipv6_dst); nl_msg_put_in6_addr(request, TCA_FLOWER_KEY_ENC_IPV6_SRC, ipv6_src); } - if (tos_mask) { - nl_msg_put_u8(request, TCA_FLOWER_KEY_ENC_IP_TOS, tos); - nl_msg_put_u8(request, TCA_FLOWER_KEY_ENC_IP_TOS_MASK, tos_mask); - } - if (ttl_mask) { - nl_msg_put_u8(request, TCA_FLOWER_KEY_ENC_IP_TTL, ttl); - nl_msg_put_u8(request, TCA_FLOWER_KEY_ENC_IP_TTL_MASK, ttl_mask); - } + + nl_msg_put_u8(request, TCA_FLOWER_KEY_ENC_IP_TOS, tos); + nl_msg_put_u8(request, TCA_FLOWER_KEY_ENC_IP_TOS_MASK, tos_mask); + + nl_msg_put_u8(request, TCA_FLOWER_KEY_ENC_IP_TTL, ttl); + nl_msg_put_u8(request, TCA_FLOWER_KEY_ENC_IP_TTL_MASK, ttl_mask); + if (tp_dst) { nl_msg_put_be16(request, TCA_FLOWER_KEY_ENC_UDP_DST_PORT, tp_dst); } - if (id_mask) { - nl_msg_put_be32(request, TCA_FLOWER_KEY_ENC_KEY_ID, id); - } + + nl_msg_put_be32(request, TCA_FLOWER_KEY_ENC_KEY_ID, id); nl_msg_put_flower_tunnel_opts(request, TCA_FLOWER_KEY_ENC_OPTS, flower->key.tunnel.metadata); nl_msg_put_flower_tunnel_opts(request, TCA_FLOWER_KEY_ENC_OPTS_MASK, @@ -2796,12 +2790,10 @@ nl_msg_put_flower_options(struct ofpbuf *request, struct tc_flower *flower) flower->key.ip_proto); } - if (flower->mask.flags) { - nl_msg_put_be32(request, TCA_FLOWER_KEY_FLAGS, - htonl(flower->key.flags)); - nl_msg_put_be32(request, TCA_FLOWER_KEY_FLAGS_MASK, - htonl(flower->mask.flags)); - } + nl_msg_put_be32(request, TCA_FLOWER_KEY_FLAGS, + htonl(flower->key.flags)); + nl_msg_put_be32(request, TCA_FLOWER_KEY_FLAGS_MASK, + htonl(flower->mask.flags)); if (flower->key.ip_proto == IPPROTO_UDP) { FLOWER_PUT_MASKED_VALUE(udp_src, TCA_FLOWER_KEY_UDP_SRC); @@ -2815,10 +2807,12 @@ nl_msg_put_flower_options(struct ofpbuf *request, struct tc_flower *flower) FLOWER_PUT_MASKED_VALUE(sctp_dst, TCA_FLOWER_KEY_SCTP_DST); } - FLOWER_PUT_MASKED_VALUE(ct_state, TCA_FLOWER_KEY_CT_STATE); - FLOWER_PUT_MASKED_VALUE(ct_zone, TCA_FLOWER_KEY_CT_ZONE); - FLOWER_PUT_MASKED_VALUE(ct_mark, TCA_FLOWER_KEY_CT_MARK); - FLOWER_PUT_MASKED_VALUE(ct_label, TCA_FLOWER_KEY_CT_LABELS); + if (flower->mask.ct_state) { + FLOWER_PUT_MASKED_VALUE(ct_state, TCA_FLOWER_KEY_CT_STATE); + FLOWER_PUT_MASKED_VALUE(ct_zone, TCA_FLOWER_KEY_CT_ZONE); + FLOWER_PUT_MASKED_VALUE(ct_mark, TCA_FLOWER_KEY_CT_MARK); + FLOWER_PUT_MASKED_VALUE(ct_label, TCA_FLOWER_KEY_CT_LABELS); + } } if (host_eth_type == ETH_P_IP) { @@ -2832,51 +2826,30 @@ nl_msg_put_flower_options(struct ofpbuf *request, struct tc_flower *flower) nl_msg_put_be16(request, TCA_FLOWER_KEY_ETH_TYPE, flower->key.eth_type); if (is_mpls) { - if (mpls_lse_to_ttl(flower->mask.mpls_lse)) { - nl_msg_put_u8(request, TCA_FLOWER_KEY_MPLS_TTL, - mpls_lse_to_ttl(flower->key.mpls_lse)); - } - if (mpls_lse_to_tc(flower->mask.mpls_lse)) { - nl_msg_put_u8(request, TCA_FLOWER_KEY_MPLS_TC, - mpls_lse_to_tc(flower->key.mpls_lse)); - } - if (mpls_lse_to_bos(flower->mask.mpls_lse)) { - nl_msg_put_u8(request, TCA_FLOWER_KEY_MPLS_BOS, - mpls_lse_to_bos(flower->key.mpls_lse)); - } - if (mpls_lse_to_label(flower->mask.mpls_lse)) { - nl_msg_put_u32(request, TCA_FLOWER_KEY_MPLS_LABEL, - mpls_lse_to_label(flower->key.mpls_lse)); - } + nl_msg_put_u8(request, TCA_FLOWER_KEY_MPLS_TTL, + mpls_lse_to_ttl(flower->key.mpls_lse)); + nl_msg_put_u8(request, TCA_FLOWER_KEY_MPLS_TC, + mpls_lse_to_tc(flower->key.mpls_lse)); + nl_msg_put_u8(request, TCA_FLOWER_KEY_MPLS_BOS, + mpls_lse_to_bos(flower->key.mpls_lse)); + nl_msg_put_u32(request, TCA_FLOWER_KEY_MPLS_LABEL, + mpls_lse_to_label(flower->key.mpls_lse)); } if (is_vlan) { - if (flower->mask.vlan_id[0]) { - nl_msg_put_u16(request, TCA_FLOWER_KEY_VLAN_ID, - flower->key.vlan_id[0]); - } - if (flower->mask.vlan_prio[0]) { - nl_msg_put_u8(request, TCA_FLOWER_KEY_VLAN_PRIO, - flower->key.vlan_prio[0]); - } - if (flower->key.encap_eth_type[0]) { - nl_msg_put_be16(request, TCA_FLOWER_KEY_VLAN_ETH_TYPE, - flower->key.encap_eth_type[0]); - } - + nl_msg_put_u16(request, TCA_FLOWER_KEY_VLAN_ID, + flower->key.vlan_id[0]); + nl_msg_put_u8(request, TCA_FLOWER_KEY_VLAN_PRIO, + flower->key.vlan_prio[0]); + nl_msg_put_be16(request, TCA_FLOWER_KEY_VLAN_ETH_TYPE, + flower->key.encap_eth_type[0]); if (is_qinq) { - if (flower->mask.vlan_id[1]) { - nl_msg_put_u16(request, TCA_FLOWER_KEY_CVLAN_ID, - flower->key.vlan_id[1]); - } - if (flower->mask.vlan_prio[1]) { - nl_msg_put_u8(request, TCA_FLOWER_KEY_CVLAN_PRIO, - flower->key.vlan_prio[1]); - } - if (flower->key.encap_eth_type[1]) { - nl_msg_put_be16(request, TCA_FLOWER_KEY_CVLAN_ETH_TYPE, - flower->key.encap_eth_type[1]); - } + nl_msg_put_u16(request, TCA_FLOWER_KEY_CVLAN_ID, + flower->key.vlan_id[1]); + nl_msg_put_u8(request, TCA_FLOWER_KEY_CVLAN_PRIO, + flower->key.vlan_prio[1]); + nl_msg_put_be16(request, TCA_FLOWER_KEY_CVLAN_ETH_TYPE, + flower->key.encap_eth_type[1]); } }