From 9916d3d12fc66b3cda7b3525e7df6b1439c8e81c Mon Sep 17 00:00:00 2001 From: Padam Jeet Singh Date: Tue, 1 Jul 2014 19:44:12 +0530 Subject: [PATCH] kni: allow setting MAC address Add relevant callback function to change a KNI device's MAC address. Signed-off-by: Padam Jeet Singh Reviewed-by: Helin Zhang --- 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 28cc5ab038..fa5fd3eaad 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