From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by dpdk.org (Postfix) with ESMTP id 8807F91E4 for ; Mon, 5 Oct 2015 19:50:32 +0200 (CEST) Received: by wicfx3 with SMTP id fx3so131656582wic.1 for ; Mon, 05 Oct 2015 10:50:32 -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:in-reply-to :references; bh=8pthJi688M5B6tvHfOZiRFKQVu89NJNKvQDmMstK4QI=; b=eROJKyx2El23DvO+jGYbcw+CHu4IGs+qLQB+tdYLojDJ4n/MiTvInWFU+xFqNJD6d/ U7kiIIgrZe0GS5/dhVOAi8q1rd6mCEBko/a8gEts+uCDTeESv2lahdcMcdfyUijJiPMg PXFbhLcKk/EnbnN4DSQ+NIdbDlRxzL6O58AYUXuAkRZuoE6Gw6LjFzMFnun875NYZrxV Zzs70tMMYeTkrxleRJkqsF7Q+irZCNvXnPrGOhO/LC6SdO0pz6GceZoB6TaglXywxGOO 0H8ldWBe84Ityshuv9M0bT320NuCU8PR6ZGypNuiUARrttEFfDWorZ6S2jDwiR1nMTIs gIgg== X-Gm-Message-State: ALoCoQmr3aQOjF0ASoF5zlTesBn9VxzniKA7aDmJSrAfxdsguQ8ZvMjoGnAKfhBIvM0gFRvgel7T X-Received: by 10.194.249.100 with SMTP id yt4mr38356266wjc.74.1444067432179; Mon, 05 Oct 2015 10:50:32 -0700 (PDT) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id s2sm15772734wib.15.2015.10.05.10.50.31 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 05 Oct 2015 10:50:31 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Date: Mon, 5 Oct 2015 19:50:08 +0200 Message-Id: <1444067408-29329-3-git-send-email-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1444067408-29329-1-git-send-email-adrien.mazarguil@6wind.com> References: <1444067408-29329-1-git-send-email-adrien.mazarguil@6wind.com> Subject: [dpdk-dev] [PATCH 3/3] mlx4: do not expose broadcast address in MAC list X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Oct 2015 17:50:32 -0000 From: Didier Pallard Use the last array entry to store the broadcast address and keep it hidden by not reporting the entire array size. This is done to prevent DPDK applications from attempting to modify or remove it. Signed-off-by: Didier Pallard --- drivers/net/mlx4/mlx4.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index 9614471..af31573 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -3836,7 +3836,8 @@ mlx4_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *info) max = 65535; info->max_rx_queues = max; info->max_tx_queues = max; - info->max_mac_addrs = elemof(priv->mac); + /* Last array entry is reserved for broadcast. */ + info->max_mac_addrs = (elemof(priv->mac) - 1); info->rx_offload_capa = (priv->hw_csum ? (DEV_RX_OFFLOAD_IPV4_CKSUM | @@ -3969,11 +3970,8 @@ mlx4_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) priv_lock(priv); DEBUG("%p: removing MAC address from index %" PRIu32, (void *)dev, index); - if (index >= MLX4_MAX_MAC_ADDRESSES) - goto end; - /* Refuse to remove the broadcast address, this one is special. */ - if (!memcmp(priv->mac[index].addr_bytes, "\xff\xff\xff\xff\xff\xff", - ETHER_ADDR_LEN)) + /* Last array entry is reserved for broadcast. */ + if (index >= (elemof(priv->mac) - 1)) goto end; priv_mac_addr_del(priv, index); end: @@ -4002,11 +4000,8 @@ mlx4_mac_addr_add(struct rte_eth_dev *dev, struct ether_addr *mac_addr, priv_lock(priv); DEBUG("%p: adding MAC address at index %" PRIu32, (void *)dev, index); - if (index >= MLX4_MAX_MAC_ADDRESSES) - goto end; - /* Refuse to add the broadcast address, this one is special. */ - if (!memcmp(mac_addr->addr_bytes, "\xff\xff\xff\xff\xff\xff", - ETHER_ADDR_LEN)) + /* Last array entry is reserved for broadcast. */ + if (index >= (elemof(priv->mac) - 1)) goto end; priv_mac_addr_add(priv, index, (const uint8_t (*)[ETHER_ADDR_LEN]) @@ -4943,7 +4938,7 @@ mlx4_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) claim_zero(priv_mac_addr_add(priv, 0, (const uint8_t (*)[ETHER_ADDR_LEN]) mac.addr_bytes)); - claim_zero(priv_mac_addr_add(priv, 1, + claim_zero(priv_mac_addr_add(priv, (elemof(priv->mac) - 1), &(const uint8_t [ETHER_ADDR_LEN]) { "\xff\xff\xff\xff\xff\xff" })); #ifndef NDEBUG -- 2.1.0