Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot change HW MAC for Vport netdevice #91

Closed
chaitanyalala opened this issue Oct 26, 2016 · 4 comments
Closed

Cannot change HW MAC for Vport netdevice #91

chaitanyalala opened this issue Oct 26, 2016 · 4 comments

Comments

@chaitanyalala
Copy link

chaitanyalala commented Oct 26, 2016

Right now we cannot use ifconfig to change mac address of vport device. This patch adds the ability for the same.

From c3d332ad87c96a4186421172738bd281bcff6eae Mon Sep 17 00:00:00 2001
From: Chaitanya Lala <clala@arista.com>
Date: Wed, 26 Oct 2016 15:59:24 -0700
Subject: [PATCH] bess_kmod_netdev: Add ability to change MAC for vport

Right now vport does not have the ability to have it's HW MAC 
changed via SIOC* ioctls. Add this ability.

---
 core/kmod/sn_netdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/core/kmod/sn_netdev.c b/core/kmod/sn_netdev.c
index 436880c..6a5041f 100644
--- a/core/kmod/sn_netdev.c
+++ b/core/kmod/sn_netdev.c
@@ -687,6 +687,8 @@ static const struct net_device_ops sn_netdev_ops = {
        .ndo_select_queue       = sn_select_queue,
        .ndo_get_stats64        = sn_get_stats64,
        .ndo_fix_features       = sn_fix_features,
+       .ndo_set_mac_address    = eth_mac_addr,
+       .ndo_validate_addr      = eth_validate_addr,
 };

 extern const struct ethtool_ops sn_ethtool_ops;
-- 
2.7.4
@chaitanyalala
Copy link
Author

[root@dhcp-swlab-561 kmod]# ifconfig vport0
vport0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 65535
        ether 2e:05:85:61:d4:4d  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 50  bytes 8485 (8.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@dhcp-swlab-561 kmod]# ifconfig vport0 down; ifconfig vport0 hw ether 56:23:79:68:e9:aa; ifconfig vport0 up 
[root@dhcp-swlab-561 kmod]# ifconfig vport0
vport0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 65535
        ether 56:23:79:68:e9:aa  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 50  bytes 8485 (8.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@dhcp-swlab-561 kmod]# 

@sangjinhan
Copy link
Member

sangjinhan commented Oct 28, 2016

Thanks! The patch was added to the develop branch. While the MAC address doesn't do anything special in the vport driver at the moment, the changed MAC address must be reflected to the bessd process. To implement this functionality we will need a custom handler rather than the generic eth_mac_addr() function.

@chaitanyalala
Copy link
Author

chaitanyalala commented Nov 1, 2016

Can you give a few pointers on what that custom function would do ? I mean would it communicate back to user-space and then ( like a proxy) something would relay that information to bessd ? Or is there some other communication channel we can use for this purpose ?

@sangjinhan
Copy link
Member

Oh, please ignore my previous comment. Since you are changing the MAC address of kernel-side interface (not the bess-side), bessd does not need to know the change.

Ideally, the kernel-side interface and the bess-side interface would need to have separate MAC addresses (especially for cases where bess is not running as a transparent bridge; e.g., IP router). Currently no interface is provided to do that, and BESS implicitly assumes those two sides of vport have the same MAC address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants