From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp89.ord1c.emailsrvr.com (smtp89.ord1c.emailsrvr.com [108.166.43.89]) by dpdk.org (Postfix) with ESMTP id 6E87158E1 for ; Tue, 1 Jul 2014 16:13:58 +0200 (CEST) Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp4.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id 0974418194F; Tue, 1 Jul 2014 10:14:18 -0400 (EDT) X-Virus-Scanned: OK Received: by smtp4.relay.ord1c.emailsrvr.com (Authenticated sender: padam.singh-AT-inventum.net) with ESMTPSA id B96B61819AB; Tue, 1 Jul 2014 10:14:16 -0400 (EDT) From: Padam Jeet Singh To: dev@dpdk.org Date: Tue, 1 Jul 2014 19:44:12 +0530 Message-Id: <1404224052-9706-1-git-send-email-padam.singh@inventum.net> X-Mailer: git-send-email 1.8.5.2 (Apple Git-48) Subject: [dpdk-dev] [PATCH] kni: allow setting KNI device MAC address 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: Tue, 01 Jul 2014 14:13:59 -0000 Added relevant callback function to change a KNI device's MAC address Signed-off-by: Padam Jeet Singh --- lib/librte_eal/linuxapp/kni/kni_net.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c index d3c0190..15e81c1 100644 --- a/lib/librte_eal/linuxapp/kni/kni_net.c +++ b/lib/librte_eal/linuxapp/kni/kni_net.c @@ -612,6 +612,21 @@ kni_net_rebuild_header(struct sk_buff *skb) return 0; } +/** + * kni_net_set_mac - Change the Ethernet Address of the KNI NIC + * @netdev: network interface device structure + * @p: pointer to an address structure + * + * Returns 0 on success, negative on failure + **/ +static int kni_net_set_mac(struct net_device *netdev, void *p) +{ + struct sockaddr *addr = p; + if (!is_valid_ether_addr((unsigned char *)(addr->sa_data))) + return -EADDRNOTAVAIL; + memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); + return 0; +} static const struct header_ops kni_net_header_ops = { .create = kni_net_header, @@ -628,6 +643,7 @@ static const struct net_device_ops kni_net_netdev_ops = { .ndo_do_ioctl = kni_net_ioctl, .ndo_get_stats = kni_net_stats, .ndo_tx_timeout = kni_net_tx_timeout, + .ndo_set_mac_address = kni_net_set_mac, }; void -- 1.8.5.2 (Apple Git-48)