Re: [PATCH 4/5] vlan: create NMDeviceEthernet for vlan device



On 11/22/2011 01:19 PM, Dan Williams wrote:
On Mon, 2011-11-21 at 08:20 -0500, Weiping Pan wrote:
A vlan device is like a virtual ethernet device.
So we reuse NMDeviceEthernet insead of creating another NMDeviceVlan,
and we add some special handling to detect vlan connections.

V3:
1 call nm_system_add_vlan_device() to create vlan device in kernel

V2:
1 delete NMDeviceVlan, just use NMDeviceEthernet

Signed-off-by: Weiping Pan<wpan redhat com>
---
  src/nm-device-ethernet.c   |   34 +++++++++++++++++++++++++++++++---
  src/nm-device-ethernet.h   |    1 +
  src/nm-manager.c           |   11 +++++++++++
  src/nm-udev-manager.c      |    4 +++-
  src/settings/nm-settings.c |    9 +++++++++
  5 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/src/nm-device-ethernet.c b/src/nm-device-ethernet.c
index b64a1da..0dd3992 100644
--- a/src/nm-device-ethernet.c
+++ b/src/nm-device-ethernet.c
@@ -56,6 +56,7 @@
  #include "nm-setting-8021x.h"
  #include "nm-setting-pppoe.h"
  #include "nm-setting-bond.h"
+#include "nm-setting-vlan.h"
  #include "ppp-manager/nm-ppp-manager.h"
  #include "nm-logging.h"
  #include "nm-properties-changed-signal.h"
@@ -616,6 +617,22 @@ nm_device_bond_connection_matches (NMDevice *device, NMConnection *connection)
  	return FALSE;
  }

+gboolean
+nm_device_vlan_connection_matches (NMDevice *device, NMConnection *connection)
+{
+	NMSettingVlan *s_vlan;
+	const char *devname;
+
+	devname = nm_device_get_iface (device);
+	g_assert(devname);
+
+	s_vlan = nm_connection_get_setting_vlan (connection);
+	if (s_vlan&&  !strcmp (devname, nm_setting_vlan_get_interface_name (s_vlan)))
Can use g_strcmp0() here and save some code.  (it's NULL safe).

Also for this patch, some of Thomas' bond cleanups touch this code and
make things easier for both bond and vlan, so maybe I should apply those
first and then you can rebase on top of them?

Dan

Hi, Dan,

It would be better to merge Thomas' bonding patches first,
then I will rebase on on top of them and sent V4.

Thanks for all your clear and detailed comments!
Weiping Pan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]