From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 380FEA054E; Sat, 15 Feb 2020 20:20:25 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 331E1DE3; Sat, 15 Feb 2020 20:20:24 +0100 (CET) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id 5687B374 for ; Sat, 15 Feb 2020 20:20:22 +0100 (CET) Received: by mail-pl1-f194.google.com with SMTP id d9so5131246plo.11 for ; Sat, 15 Feb 2020 11:20:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3qrplHtnxZ1YDY1CSr2PxDsNkd3EYJS+5t6MOQEc8vs=; b=1JhNMPngJDoW5LF+Yv4PLfqfU/2qMt5uuw4Mc9gFenkIDiaKjXrM2JlKpCLqoMqahl +CLtc2rXYTHg9+rqiwGEBZuBaY3SMFktXcQXdIYliNWTAbNpArTtpnpH6WGgx+03PgSE 6YitWzvgqlsIYDcq5Aj7XkHCUNwjmnMJ+CyGublRBpT+/0JE+l0pvYgP/hHZ2wmvLMvs 9eI/KQPKwAm/mv6YNrlvxsmuNdRgOrVz6pGX0uvOEvvE05NtWcvMGFRJpzxgL9SJLl// ooh7AX03eW9ah1uSUX7tGPFtxD4S1LmwmWx1wy1fNYJunK2zla6DkT7xwzug2YSqMexH ZVWg== 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:mime-version :content-transfer-encoding; bh=3qrplHtnxZ1YDY1CSr2PxDsNkd3EYJS+5t6MOQEc8vs=; b=dmS3B/TmYOK6dSciglJXffbcQp2hXT3cN+G7X99qRgkIqmNMxCx0Fx4I/9otK+5uaO 04kY5nzysyRmnoKavrdR57oSzephlpQzZQnZygQEx0iodtbfElP3oq0nkPKpjBTnM/hp wmt1gTO56O3ejBg4bC5OeSvx8g0hKP9O21SNqwVYVV+PDK7QN4wecuqyty1MYRtFrttv c4ooW1zK1FOq8DSDn1QqPHP5N0cDLUYCQzCBRe33KY/epqKLSqG8MwcyfRRzy4FypVLt 162o1SA5zKgX4EbsArpwDPR00bdFHYZFItYqZ1XaVVoKudDgkDWxhsxqywXq12t+1NZu eYsQ== X-Gm-Message-State: APjAAAU7P5mxYD13SPoblcdfoGWTKKKUksOwe3RD00QubRihlGXhfu35 GlofXmGS0tp0CcjIWegMwGPwAA== X-Google-Smtp-Source: APXvYqyiTjkQDJBre803TgBsBYOQoWW78Tjdtx3P19S2l6vB0ktfCqobck7JW4tg971MvmsBFvZZXA== X-Received: by 2002:a17:902:b714:: with SMTP id d20mr8885011pls.272.1581794421243; Sat, 15 Feb 2020 11:20:21 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id j4sm10989178pfh.152.2020.02.15.11.20.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Feb 2020 11:20:20 -0800 (PST) From: Stephen Hemminger To: linville@tuxdriver.com Cc: dev@dpdk.org, Stephen Hemminger Date: Sat, 15 Feb 2020 11:20:12 -0800 Message-Id: <20200215192012.31707-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 20.05] net/af_packet: support default mac address change X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Since packet is talking to a network device (probably tap) it is possible for the device driver to change the hardware address by making an ioctl to kernel. Signed-off-by: Stephen Hemminger --- drivers/net/af_packet/rte_eth_af_packet.c | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index f5806bf42c46..ae3c25f2b619 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -468,6 +469,32 @@ eth_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) return 0; } +static int +eth_dev_macaddr_set(struct rte_eth_dev *dev, struct rte_ether_addr *addr) +{ + struct pmd_internals *internals = dev->data->dev_private; + struct ifreq ifr = { }; + int sockfd = internals->rx_queue[0].sockfd; + int ret; + + if (sockfd == -1) { + PMD_LOG(ERR, "receive socket not found"); + return -EINVAL; + } + + strlcpy(ifr.ifr_name, internals->if_name, IFNAMSIZ); + ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; + memcpy(ifr.ifr_hwaddr.sa_data, addr, sizeof(*addr)); + ret = ioctl(sockfd, SIOCSIFHWADDR, &ifr); + + if (ret < 0) { + PMD_LOG_ERRNO(ERR, "ioctl(SIOCSIFHWADDR) failed"); + return -EINVAL; + } + + return 0; +} + static int eth_dev_change_flags(char *if_name, uint32_t flags, uint32_t mask) { @@ -517,6 +544,7 @@ static const struct eth_dev_ops ops = { .dev_close = eth_dev_close, .dev_configure = eth_dev_configure, .dev_infos_get = eth_dev_info, + .mac_addr_set = eth_dev_macaddr_set, .mtu_set = eth_dev_mtu_set, .promiscuous_enable = eth_dev_promiscuous_enable, .promiscuous_disable = eth_dev_promiscuous_disable, -- 2.20.1