* [dpdk-dev] [PATCH] kni: allow setting KNI device MAC address
@ 2014-07-01 14:14 Padam Jeet Singh
2014-07-03 6:26 ` Zhang, Helin
0 siblings, 1 reply; 3+ messages in thread
From: Padam Jeet Singh @ 2014-07-01 14:14 UTC (permalink / raw)
To: dev
Added relevant callback function to change a KNI device's MAC address
Signed-off-by: Padam Jeet Singh <padam.singh@inventum.net>
---
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)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] kni: allow setting KNI device MAC address
2014-07-01 14:14 [dpdk-dev] [PATCH] kni: allow setting KNI device MAC address Padam Jeet Singh
@ 2014-07-03 6:26 ` Zhang, Helin
2014-07-19 0:05 ` Thomas Monjalon
0 siblings, 1 reply; 3+ messages in thread
From: Zhang, Helin @ 2014-07-03 6:26 UTC (permalink / raw)
To: Padam Jeet Singh, dev
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Padam Jeet Singh
> Sent: Tuesday, July 1, 2014 10:14 PM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] kni: allow setting KNI device MAC address
>
> Added relevant callback function to change a KNI device's MAC address
>
> Signed-off-by: Padam Jeet Singh <padam.singh@inventum.net>
> ---
> 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)
Reviewed-by: Helin Zhang <helin.zhang@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] kni: allow setting KNI device MAC address
2014-07-03 6:26 ` Zhang, Helin
@ 2014-07-19 0:05 ` Thomas Monjalon
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2014-07-19 0:05 UTC (permalink / raw)
To: Padam Jeet Singh; +Cc: dev
> > Added relevant callback function to change a KNI device's MAC address
> >
> > Signed-off-by: Padam Jeet Singh <padam.singh@inventum.net>
>
> Reviewed-by: Helin Zhang <helin.zhang@intel.com>
Applied for version 1.7.1
Thanks
--
Thomas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-07-19 0:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-01 14:14 [dpdk-dev] [PATCH] kni: allow setting KNI device MAC address Padam Jeet Singh
2014-07-03 6:26 ` Zhang, Helin
2014-07-19 0:05 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).