From patchwork Thu Feb 16 12:29:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Fleytman X-Patchwork-Id: 9577013 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 69C66600C5 for ; Thu, 16 Feb 2017 12:30:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5006E28516 for ; Thu, 16 Feb 2017 12:30:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4307928583; Thu, 16 Feb 2017 12:30:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BC69928516 for ; Thu, 16 Feb 2017 12:30:23 +0000 (UTC) Received: from localhost ([::1]:46115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceLCY-000325-PW for patchwork-qemu-devel@patchwork.kernel.org; Thu, 16 Feb 2017 07:30:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47570) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceLCB-00030O-Qo for qemu-devel@nongnu.org; Thu, 16 Feb 2017 07:30:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceLCA-0007pU-QG for qemu-devel@nongnu.org; Thu, 16 Feb 2017 07:29:59 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:33406) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceLCA-0007pI-J7 for qemu-devel@nongnu.org; Thu, 16 Feb 2017 07:29:58 -0500 Received: by mail-wm0-x241.google.com with SMTP id v77so2902748wmv.0 for ; Thu, 16 Feb 2017 04:29:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8GnPpQyQatfZ6HZ5l4lUJOSaR/QPPqTAJjw7ByqtXSA=; b=hNsD2mYdimmKMjAoESow7+42wrgx0Y3WVQCYpOkCkHol33x4LcUGTZPWJ32XrO8mZU /UYD2p67rYcw8tzsAflVUjHhKT3M4vkdc132CaJu2ajyTJN0M67a4n3evRNfch7++h/1 AQdxZ9g6myv1pvWBFjnKbAXtBIkiQhFOgAscIza8jTiy2hYVeEZsSjSAf9CXOM2glWIb O71P0RzqL1imJcmeGuG/UEHQQYLsjrkdbCMjpAHRZkcqAriwZTJdshi8xOTZPmZW+ySE 2fAICSGmrgFMEYrx4SAW/KOiiG7gK/Snbn+dsPmhU2i0QqC0movepRMxtDgITtKFPmK1 6TIA== 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=8GnPpQyQatfZ6HZ5l4lUJOSaR/QPPqTAJjw7ByqtXSA=; b=OjnHlwtdajhWwbI1qOBsBRtDwniHcQyT4HhpOTLsAO5LO6KIUSyd0GUUiIBnlILwue BeXzQ76goMoOCQMnKXqBtRaBTsnypfcq2spPFN9/oytwQWiniyTTktE1oXzNQkV0HdIY k6St+oHynS3Al0NSjzf8iYT+J/fO91MEoncArviwzu2MLSXXf09T05ZgHLReW5HMcUdD biutc7EwueRxi7Za5SHD+dJJ8eaU/2xT0jNIKjfUk4TqnAYqDp6Rbl5pWmQWp+71nWW2 b56tgHSBmvKryv4I+iPM/U8nQYPboWlWSZObSLVjp7HmfHLdHqhXdUXsrJN65e+MijRh VmMA== X-Gm-Message-State: AMke39kndvWT1hZ6h4t6rcjw3umyEYO5ZHWkl+iipIcBb92hMgtJrgYSNDsg27Od/Rs+Vg== X-Received: by 10.28.203.6 with SMTP id b6mr11958607wmg.2.1487248197592; Thu, 16 Feb 2017 04:29:57 -0800 (PST) Received: from bark.daynix ([141.226.163.173]) by smtp.gmail.com with ESMTPSA id b51sm8827365wrd.39.2017.02.16.04.29.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 04:29:56 -0800 (PST) From: Dmitry Fleytman To: qemu-devel@nongnu.org Date: Thu, 16 Feb 2017 14:29:32 +0200 Message-Id: <1487248176-29602-2-git-send-email-dmitry@daynix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487248176-29602-1-git-send-email-dmitry@daynix.com> References: <1487248176-29602-1-git-send-email-dmitry@daynix.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PATCH 1/5] eth: Extend vlan stripping functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yan Vugenfirer , Dmitry Fleytman , Jason Wang , P J P Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Make VLAN stripping functions return number of bytes copied to given Ethernet header buffer. This information should be used to re-compose packet IOV after VLAN stripping. Signed-off-by: Dmitry Fleytman Reviewed-by: Philippe Mathieu-Daudé --- include/net/eth.h | 4 ++-- net/eth.c | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/include/net/eth.h b/include/net/eth.h index 2013175..afeb45b 100644 --- a/include/net/eth.h +++ b/include/net/eth.h @@ -331,12 +331,12 @@ eth_get_pkt_tci(const void *p) } } -bool +size_t eth_strip_vlan(const struct iovec *iov, int iovcnt, size_t iovoff, uint8_t *new_ehdr_buf, uint16_t *payload_offset, uint16_t *tci); -bool +size_t eth_strip_vlan_ex(const struct iovec *iov, int iovcnt, size_t iovoff, uint16_t vet, uint8_t *new_ehdr_buf, uint16_t *payload_offset, uint16_t *tci); diff --git a/net/eth.c b/net/eth.c index df81efb..5b9ba26 100644 --- a/net/eth.c +++ b/net/eth.c @@ -232,7 +232,7 @@ void eth_get_protocols(const struct iovec *iov, int iovcnt, } } -bool +size_t eth_strip_vlan(const struct iovec *iov, int iovcnt, size_t iovoff, uint8_t *new_ehdr_buf, uint16_t *payload_offset, uint16_t *tci) @@ -244,7 +244,7 @@ eth_strip_vlan(const struct iovec *iov, int iovcnt, size_t iovoff, new_ehdr, sizeof(*new_ehdr)); if (copied < sizeof(*new_ehdr)) { - return false; + return 0; } switch (be16_to_cpu(new_ehdr->h_proto)) { @@ -254,7 +254,7 @@ eth_strip_vlan(const struct iovec *iov, int iovcnt, size_t iovoff, &vlan_hdr, sizeof(vlan_hdr)); if (copied < sizeof(vlan_hdr)) { - return false; + return 0; } new_ehdr->h_proto = vlan_hdr.h_proto; @@ -268,18 +268,21 @@ eth_strip_vlan(const struct iovec *iov, int iovcnt, size_t iovoff, PKT_GET_VLAN_HDR(new_ehdr), sizeof(vlan_hdr)); if (copied < sizeof(vlan_hdr)) { - return false; + return 0; } *payload_offset += sizeof(vlan_hdr); + + return sizeof(struct eth_header) + sizeof(struct vlan_header); + } else { + return sizeof(struct eth_header); } - return true; default: - return false; + return 0; } } -bool +size_t eth_strip_vlan_ex(const struct iovec *iov, int iovcnt, size_t iovoff, uint16_t vet, uint8_t *new_ehdr_buf, uint16_t *payload_offset, uint16_t *tci) @@ -291,7 +294,7 @@ eth_strip_vlan_ex(const struct iovec *iov, int iovcnt, size_t iovoff, new_ehdr, sizeof(*new_ehdr)); if (copied < sizeof(*new_ehdr)) { - return false; + return 0; } if (be16_to_cpu(new_ehdr->h_proto) == vet) { @@ -299,17 +302,17 @@ eth_strip_vlan_ex(const struct iovec *iov, int iovcnt, size_t iovoff, &vlan_hdr, sizeof(vlan_hdr)); if (copied < sizeof(vlan_hdr)) { - return false; + return 0; } new_ehdr->h_proto = vlan_hdr.h_proto; *tci = be16_to_cpu(vlan_hdr.h_tci); *payload_offset = iovoff + sizeof(*new_ehdr) + sizeof(vlan_hdr); - return true; + return sizeof(struct eth_header); } - return false; + return 0; } void