From fd14aa033e218392676fb892416611bef25bd8bb Mon Sep 17 00:00:00 2001 From: Nikolay Martynov Date: Sun, 21 May 2017 17:07:17 -0400 Subject: [PATCH] nmtui: add support for cloned mac in bond interfaces This is useful because bond gets its mac from first slave and order of slave attachement is not guaranteed. For example if we have bond with wifi and ethernet we want mac from wifi to be use by bond interface because many wifi defices do now allow one to send data with spoofed macs. Signed-off-by: Nikolay Martynov --- clients/tui/nmt-page-bond.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/clients/tui/nmt-page-bond.c b/clients/tui/nmt-page-bond.c index 48070dbf17..e39a4c96a6 100644 --- a/clients/tui/nmt-page-bond.c +++ b/clients/tui/nmt-page-bond.c @@ -29,6 +29,7 @@ #include "nmt-page-bond.h" +#include "nmt-mac-entry.h" #include "nmt-address-list.h" #include "nmt-slave-list.h" @@ -336,6 +337,7 @@ nmt_page_bond_constructed (GObject *object) NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE (bond); NmtEditorSection *section; NmtEditorGrid *grid; + NMSettingWired *s_wired; NMSettingBond *s_bond; NmtNewtWidget *widget, *label; NMConnection *conn; @@ -348,6 +350,12 @@ nmt_page_bond_constructed (GObject *object) } priv->s_bond = s_bond; + s_wired = nm_connection_get_setting_wired (conn); + if (!s_wired) { + nm_connection_add_setting (conn, nm_setting_wired_new ()); + s_wired = nm_connection_get_setting_wired (conn); + } + section = nmt_editor_section_new (_("BOND"), NULL, TRUE); grid = nmt_editor_section_get_body (section); @@ -413,6 +421,12 @@ nmt_page_bond_constructed (GObject *object) nmt_editor_grid_append (grid, _("ARP targets"), widget, NULL); priv->arp_ip_target = NMT_ADDRESS_LIST (widget); + widget = nmt_mac_entry_new (40, ETH_ALEN, NMT_MAC_ENTRY_TYPE_CLONED); + g_object_bind_property (s_wired, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, + widget, "mac-address", + G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); + nmt_editor_grid_append (grid, _("Cloned MAC address"), widget, NULL); + g_signal_connect (s_bond, "notify::" NM_SETTING_BOND_OPTIONS, G_CALLBACK (bond_options_changed), bond); bond_options_changed (G_OBJECT (s_bond), NULL, bond);