From patchwork Mon Jun 20 16:18:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 70468 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1590540qgy; Mon, 20 Jun 2016 09:19:51 -0700 (PDT) X-Received: by 10.55.72.88 with SMTP id v85mr22489692qka.44.1466439534615; Mon, 20 Jun 2016 09:18:54 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id w192si48504133qkb.33.2016.06.20.09.18.54; Mon, 20 Jun 2016 09:18:54 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id D75E4635C5; Mon, 20 Jun 2016 16:18:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 1986762EB7; Mon, 20 Jun 2016 16:18:50 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 8DD2C62EC5; Mon, 20 Jun 2016 16:18:47 +0000 (UTC) Received: from mail-lf0-f46.google.com (mail-lf0-f46.google.com [209.85.215.46]) by lists.linaro.org (Postfix) with ESMTPS id 90499622E9 for ; Mon, 20 Jun 2016 16:18:46 +0000 (UTC) Received: by mail-lf0-f46.google.com with SMTP id f6so41081313lfg.0 for ; Mon, 20 Jun 2016 09:18:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=M+vHey03ub2eVIXy2wLwSh7FMq/jk3zpyNrcf7SAjfE=; b=VsjvwN70gjuFlAg6X113D4bs1bhmxy4JQNYYKi5XBSNlHYcOq89TC/cxmv3prQ9mjT Xb5l73zo2vA/xysmJE8/fzDlyjJ4r36zZJfWBwbZZuOvDTpk2yVtcdw5nIHylAL783lw iAAcg9Z40QsZcmF9og2EI8OW9LcTPuVSyCtofwvMnrkW7veA/cMMwjXctK5Afm/rImAf Sen6SGcCyQmSxKTbiyP5UPmgcL17k35qbqCDhLQLbEEkyx8rbKBrPwDM1PBGLYDLIqoI fUQeU99Tjr7GpwZz0kBh+iL32NrHq4+5PeiLabkp3NojoFoHS9b0Z/5CJWN4FXvHKPgy QRhA== X-Gm-Message-State: ALyK8tLbQ4cIfABgDhvF8al5IRd1MbWJXIEcu+UzEyI8HmjhFiapmRuY2hIo1d7aMOsVncfgSJ4= X-Received: by 10.25.160.75 with SMTP id j72mr4693267lfe.109.1466439525372; Mon, 20 Jun 2016 09:18:45 -0700 (PDT) Received: from localhost.localdomain ([83.220.239.96]) by smtp.gmail.com with ESMTPSA id h4sm5713302ljh.27.2016.06.20.09.18.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Jun 2016 09:18:44 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Mon, 20 Jun 2016 19:18:38 +0300 Message-Id: <1466439518-6539-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 X-Topics: patch Subject: [lng-odp] [PATCH] test: pktio: correct mac addr len check X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Signed-off-by: Maxim Uvarov Reviewed-by: Bill Fischofer --- test/validation/pktio/pktio.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/validation/pktio/pktio.c b/test/validation/pktio/pktio.c index 5922ba5..d53a419 100644 --- a/test/validation/pktio/pktio.c +++ b/test/validation/pktio/pktio.c @@ -143,11 +143,13 @@ static void pktio_pkt_set_macs(odp_packet_t pkt, odph_ethhdr_t *eth = (odph_ethhdr_t *)odp_packet_l2_ptr(pkt, &len); int ret; - ret = odp_pktio_mac_addr(src, ð->src, sizeof(eth->src)); + ret = odp_pktio_mac_addr(src, ð->src, ODP_PKTIO_MACADDR_MAXSIZE); CU_ASSERT(ret == ODPH_ETHADDR_LEN); + CU_ASSERT(ret <= ODP_PKTIO_MACADDR_MAXSIZE); - ret = odp_pktio_mac_addr(dst, ð->dst, sizeof(eth->dst)); + ret = odp_pktio_mac_addr(dst, ð->dst, ODP_PKTIO_MACADDR_MAXSIZE); CU_ASSERT(ret == ODPH_ETHADDR_LEN); + CU_ASSERT(ret <= ODP_PKTIO_MACADDR_MAXSIZE); } static uint32_t pktio_pkt_set_seq(odp_packet_t pkt) @@ -239,7 +241,7 @@ static uint32_t pktio_init_packet(odp_packet_t pkt) odph_udphdr_t *udp; char *buf; uint16_t seq; - uint8_t mac[ODPH_ETHADDR_LEN] = {0}; + uint8_t mac[ODP_PKTIO_MACADDR_MAXSIZE] = {0}; int pkt_len = odp_packet_len(pkt); buf = odp_packet_data(pkt); @@ -1036,7 +1038,7 @@ void pktio_test_promisc(void) void pktio_test_mac(void) { - unsigned char mac_addr[ODPH_ETHADDR_LEN]; + unsigned char mac_addr[ODP_PKTIO_MACADDR_MAXSIZE]; int mac_len; int ret; odp_pktio_t pktio; @@ -1047,8 +1049,10 @@ void pktio_test_mac(void) printf("testing mac for %s\n", iface_name[0]); - mac_len = odp_pktio_mac_addr(pktio, mac_addr, sizeof(mac_addr)); + mac_len = odp_pktio_mac_addr(pktio, mac_addr, + ODP_PKTIO_MACADDR_MAXSIZE); CU_ASSERT(ODPH_ETHADDR_LEN == mac_len); + CU_ASSERT(ODP_PKTIO_MACADDR_MAXSIZE >= mac_len); printf(" %X:%X:%X:%X:%X:%X ", mac_addr[0], mac_addr[1], mac_addr[2],