summaryrefslogtreecommitdiff
path: root/src/devices/nm-device-vlan.c
Commit message (Collapse)AuthorAgeFilesLines
...
* core: add an NMExportedObject base classDan Winship2015-07-241-3/+1
| | | | | | | | | | | | | | | Add NMExportedObject, make it the base class of all D-Bus-exported types, and move the nm-properties-changed-signal logic into it. (Also, make NMSettings use the same properties-changed code as everything else, which it was not previously doing, presumably for historical reasons). (This is mostly just shuffling code around at this point, but NMExportedObject will be more important in the gdbus port, since gdbus-codegen doesn't do a very good job of supporting objects that export multiple interfaces [as each NMDevice subclass does, for example], so we will need more glue/helper code in NMExportedObject then.)
* all: rename nm-glib-compat.h to nm-glib.h, use everywhereDan Winship2015-07-241-1/+1
| | | | | | | | | | | | | | | | Rather than randomly including one or more of <glib.h>, <glib-object.h>, and <gio/gio.h> everywhere (and forgetting to include "nm-glib-compat.h" most of the time), rename nm-glib-compat.h to nm-glib.h, include <gio/gio.h> from there, and then change all .c files in NM to include "nm-glib.h" rather than including the glib headers directly. (Public headers files still have to include the real glib headers, since nm-glib.h isn't installed...) Also, remove glib includes from header files that are already including a base object header file (which must itself already include the glib headers).
* platform: return NMPlatformError from link-add functionsThomas Haller2015-06-171-4/+5
| | | | | | | | | Later remove nm_platform_get_error() and signal errors via return error codes. Also, fix nm_platform_infiniband_partition_add() and nm_platform_vlan_add() to check the type of the existing link and fail with WRONG_TYPE otherwise.
* core: rearrange some VLAN code and clean up dispose()Dan Williams2015-05-191-44/+33
| | | | | Move parent-related stuff before its callers and clean up dispose so that we no longer need priv->disposed.
* core: earlier software capability detectionDan Williams2015-05-191-1/+1
| | | | | | | We need to know whether we can create interfaces of any given NMDevice subclass or not. So don't rely on just the NMPlatformLink for that information, because we won't have a platform link for software devices before we create them.
* core: let plugins indicate links which should be ignoreddcbw/dfa-earlyDan Williams2015-05-061-1/+1
| | | | | | Instead of hacky stuff in the Manager, let plugins themselves indicate which links should be ignored (because they are really child links that are controlled by a different device that the plugin handles).
* core: move permanent and initial MAC address reading to NMDevice and NMPlatformDan Williams2015-05-061-30/+2
| | | | | | | | Ethernet, WiFi, and VLAN used the same implementation for initial address. Ethernet and WiFi used the same implementation (and duplicated code) for permanent MAC address, plus they both used ethtool in what should be generic code, which is better done in the platform.
* platform: return link objects from add functionsDan Williams2015-05-061-1/+2
|
* core: move virtual interface name handling into device pluginsDan Williams2015-05-061-0/+53
| | | | | | Instead of having a bunch of logic in the Manager for determining the VLAN and Infiniband virtual interface names, move the type-specific logic into the plugins themselves.
* core: let device plugins advertise supported link and setting typesDan Williams2015-05-061-26/+24
| | | | | | Instead of looping over all plugins and asking each plugin whether it can handle a link or a connection, have them advertise the link and connection types they support, and use that when creating new devices.
* vlan: don't fail if parent isn't found at construct time for existing devicesDan Williams2015-05-061-25/+83
| | | | | | | | | | | | | For existing devices, depending on the order that netlink sends interfaces to us, the parent may be found after the VLAN interface and not be available when the VLAN interface is constructed. Instead of failing construction, when a NMDeviceVlan has no parent keep it unavailable for activation. Then have the Manager notify existing devices when a new device is found, and let NMDeviceVlan find the parent later and become available via that mechanism. This doesn't apply to VLANs created by NM itself, because the kernel requires a parent ifindex when creating a VLAN device. Thus this fix only applies to VLANs created outside NetworkManager, or existing when NM starts up.
* trivial: move codeDan Williams2015-05-061-44/+39
|
* platform: add self argument to platform functionsThomas Haller2015-04-211-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most nm_platform_*() functions operate on the platform singleton nm_platform_get(). That made sense because the NMPlatform instance was mainly to hook fake platform for testing. While the implicit argument saved some typing, I think explicit is better. Especially, because NMPlatform could become a more usable object then just a hook for testing. With this change, NMPlatform instances can be used individually, not only as a singleton instance. Before this change, the constructor of NMLinuxPlatform could not call any nm_platform_*() functions because the singleton was not yet initialized. We could only instantiate an incomplete instance, register it via nm_platform_setup(), and then complete initialization via singleton->setup(). With this change, we can create and fully initialize NMPlatform instances before/without setting them up them as singleton. Also, currently there is no clear distinction between functions that operate on the NMPlatform instance, and functions that can be used stand-alone (e.g. nm_platform_ip4_address_to_string()). The latter can not be mocked for testing. With this change, the distinction becomes obvious. That is also useful because it becomes clearer which functions make use of the platform cache and which not. Inside nm-linux-platform.c, continue the pattern that the self instance is named @platform. That makes sense because its type is NMPlatform, and not NMLinuxPlatform what we would expect from a paramter named @self. This is a major diff that causes some pain when rebasing. Try to rebase to the parent commit of this commit as a first step. Then rebase on top of this commit using merge-strategy "ours".
* device: use NMDeviceCapabilities enum for device capabilitiesThomas Haller2015-04-181-1/+1
|
* device: Deal with links that vanish during initializationLubomir Rintel2014-12-021-1/+2
| | | | | | | | | | | | | | | | | | | | | nm_device_get_hw_address() may return NULL and nm_platform_link_get_type may return NM_LINK_TYPE_NONE. While it might be a good idea to check for such cases at the init time it seems easier to just ignore it and prevent blowing up in subsequent deactivation. A quick test case: # while :; do ip link add moo0 type veth peer moo1; ip link del moo0 ; done Yields: NetworkManager:ERROR:devices/nm-device-ethernet.c:268:constructor: assertion failed: (link_type == NM_LINK_TYPE_ETHERNET || link_type == NM_LINK_TYPE_VETH) nm_device_set_hw_addr: assertion 'addr != NULL' failed https://bugzilla.gnome.org/show_bug.cgi?id=740992
* core: add NM_UNMANAGED_PARENT flag for a dependency on parent deviceJiří Klimeš2014-11-241-10/+9
| | | | | VLAN device depends on its parent, for instance. If the parent is not managed, then the VLAN can't be either.
* vlan: export parent device for VLANs as D-Bus propertyJiří Klimeš2014-11-241-7/+23
| | | | and use the internal construct-time parent property for VLAN creation.
* libnm-core: add nm-core-types.h, remove cross-includesDan Winship2014-10-281-1/+1
| | | | | | | | | | | | | | Add nm-core-types.h, typedefing all of the GObject types in libnm-core; this is needed so that nm-setting.h can reference NMConnection in addition to nm-connection.h referencing NMSetting. Removing the cross-includes from the various headers causes lots of fallout elsewhere. (In particular, nm-utils.h used to include nm-connection.h, which included every setting header, so any file that included nm-utils.h automatically got most of the rest of libnm-core without needing to pay attention to specifics.) Fix this up by including nm-core-internal.h from those files that are now missing includes.
* devices: drop device-type-specific error domainsDan Winship2014-10-221-17/+2
| | | | | | Most NMDevice types defined their own error domain but then never used it. A few did use their errors, but some of those errors are redundant with NMDeviceError, and others can be added to it.
* core: track origin of MTULubomir Rintel2014-10-201-1/+1
| | | | | Only override MTU if it came from a source of higher priority or is of equal priority but of lower value.
* vlan: port to internal device factoryDan Williams2014-09-111-69/+105
|
* libnm-core: change all mac-address properties to G_TYPE_STRINGDan Winship2014-09-041-13/+22
| | | | | | | | | | Make all mac-address properties (including NMSettingBluetooth:bdaddr, NMSettingOlpcMesh:dhcp-anycast-addr, and NMSettingWireless:bssid) be strings, using _nm_setting_class_transform_property() to handle translating to/from binary form when dealing with D-Bus. Update everything accordingly for the change, and also add a test for transformed setting properties to test-general.
* core: abstract out the duplicated default-ifname-generating codeDan Winship2014-09-041-0/+1
| | | | | | NMDeviceBond, NMDeviceBridge, and NMDeviceTeam all used basically the same code to generate a default interface name. Move it into nm_utils_complete_generic().
* all: stop using virtual interface-name propertiesDan Winship2014-09-041-1/+0
| | | | | | | | | | | | The virtual :interface-name properties (eg, NMDeviceBond:interface-name) are deprecated in favor of NMSettingConnection:interface-name, and nm_connection_verify() ensures that their values are kept in sync. So (a) there is no need to set those properties when we can just set NMSettingConnection:interface-name instead, and (b) we can replace any calls to the setting-specific get_interface_name() methods with nm_connection_get_interface_name() or nm_setting_connection_get_interface_name().
* libnm-core: drop nm_{setting,connection}_get_virtual_iface_name()Dan Winship2014-09-041-2/+2
| | | | | | | | | | | | | | | | | | Since we enforce the fact that bond, bridge, team, and vlan interface-name properties match NMSettingConnection:interface-name, nm_connection_get_virtual_iface_name() can be replaced with nm_connection_get_interface_name() basically everywhere. The one place this doesn't work is with InfiniBand partitions (where get_virtual_iface_name() was actually computing the name), but for the most part we only need to care about the interface names of InfiniBand partitions in places where we also already need to do some other InfiniBand-specific handling as well, so we can use an InfiniBand-specific method (nm_setting_infiniband_get_virtual_interface_name()) to get it. (Also, while updating nm_device_get_virtual_device_description(), fix it to handle InfiniBand partitions too.)
* core: refactor nm_utils_complete_generic() not to use a dynamic format stringThomas Haller2014-08-251-1/+1
| | | | | | | | For NMDeviceWifi and NMDeviceWimax, the printf format string for nm_utils_complete_generic() was created based on ssid/nsp. Since these input strings are untrusted, this is a serious bug. Signed-off-by: Thomas Haller <thaller@redhat.com>
* core: update data types of some hwaddr propertiesDan Winship2014-08-071-8/+7
| | | | | | | | | | | | | | Now that we have nm_utils_hwaddr_matches() for comparing addresses (even when one is a string and the other binary), there are now places where it's more convenient to store hardware addresses as strings rather than binary, since we want them in string form for most non-comparison purposes. So update for that. In particular, this also changes nm_device_get_hw_address() to return a string. Also, simplify the update_permanent_hw_address() implementations by assuming that they will only be called once. (Since they will.)
* libnm-core, etc: add nm_utils_hwaddr_matches()Dan Winship2014-08-071-2/+1
| | | | | | | Add nm_utils_hwaddr_matches(), for comparing hardware addresses for equality, allowing either binary or ASCII hardware addresses to be passed, and handling the special rules for InfiniBand hardware addresses automatically. Update code to use it.
* libnm-core: include ETH_ALEN/INFINIBAND_ALEN defines in nm-utils.hDan Winship2014-08-071-2/+0
| | | | | | | | Include <linux/if_ether.h> and <linux/if_infiniband.h> from nm-utils.h, to get ETH_ALEN and INFINIBAND_ALEN, and remove those includes (as well as <net/ethernet.h> and <netinet/ether.h>, and various headers that had been included to get the ARPHRD_* constants) from other files where they're not needed now.
* libnm-core, etc: drop type-based hwaddr funcs, port to length-based onesDan Winship2014-08-071-1/+1
| | | | | | | | | | Drop the arptype-based nm_utils_hwaddr funcs, and rename the length-based ones to no longer have _len in their names. This also switches nm_utils_hwaddr_atoba() to using a length rather than an arptype, and adds a length argument to nm_utils_hwaddr_valid() (making nm_utils_hwaddr_valid() now a replacement for nm_utils_hwaddr_aton() in some places, where we were only using aton() to do validity checking).
* logging: use new logging macros in NMDevice subclassesth/bgo734230_device_loggingThomas Haller2014-08-061-20/+18
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* core: fill in nm-types.h, clean out other headersDan Winship2014-07-231-0/+3
| | | | | | | | | | | | | | Clean up some of the cross-includes between headers (which made it so that, eg, if you included NetworkManagerUtils.h in a test program, you would need to build the test with -I$(top_srcdir)/src/platform, and if you included nm-device.h you'd need $(POLKIT_CFLAGS)) by moving all GObject struct definitions for src/ and src/settings/ into nm-types.h (which already existed to solve the NMDevice/NMActRequest circular references). Update various .c files to explicitly include the headers they used to get implicitly, and remove some now-unnecessary -I options from Makefiles.
* all: remove remaining GParamSpec name/blurb stringsDan Winship2014-06-191-8/+6
| | | | | | Remove all remaining GParamSpec name and blurb strings (and fix indentation while we're there), and add G_PARAM_STATIC_STRINGS to all paramspecs that were lacking it.
* core: remove unused 'error' argument to check_connection_compatible()Dan Williams2014-05-301-39/+14
| | | | | Nothing uses the error, so simplify some code and save 5K (0.45%) in binary size.
* core: add nm_connection_provider_get()Dan Williams2014-03-031-2/+1
| | | | | | | | In reality the connection provider (NMSettings) is always the same object, and some device plugins need access to it. Instead of cluttering up the device plugin API by passing the provider into every plugin regardless of whether the plugin needs it, create a getter function.
* coverity: fix various warnings detected with Coverity (fixup)Thomas Haller2013-11-131-1/+6
| | | | | | | I missed to implement the remarks from https://bugzilla.redhat.com/show_bug.cgi?id=1025894#c4 Signed-off-by: Thomas Haller <thaller@redhat.com>
* coverity: fix various warnings detected with CoverityThomas Haller2013-11-131-1/+1
| | | | | | | | | | | | | These are (most likely) only warnings and not severe bugs. Some of these changes are mostly made to get a clean run of Coverity without any warnings. Error found by running Coverity scan https://bugzilla.redhat.com/show_bug.cgi?id=1025894 Co-Authored-By: Jiří Klimeš <jklimes@redhat.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* core: implement update_connection() for VLANsPavel Šimerda2013-11-081-32/+72
|
* core: implement :mtu and :cloned-mac-address for VLANDan Winship2013-09-121-0/+58
|
* all: standardize on NMSettingWired:mac-address for all VLANsDan Winship2013-09-121-17/+30
| | | | | | | | | | | | | | | | | | | | | | Currently, ethernet-based VLANs can specify the hardware address of the parent device (and, in theory, the cloned hardware address and MTU of the VLAN device) by using an NMSettingWired in addition to the NMSettingVlan. The theory was that non-ethernet-based VLANs, when we eventually supported them, would likewise use the setting type corresponding to their parent device. However, this turns out to be both complicated (the settings plugins and connection editor would have a hard-to-impossible time figuring out which setting type to use in some cases) and incorrect (for most L2 settings [eg, BSSID, bond mode, etc], the VLAN can't have its own values separate from the parent device). What we should have done was just have :mac-address, :cloned-mac-address, and :mtu properties on NMSettingVlan. However, at this point, for backward-compatibility, we will just stick with using a combination of NMSettingVlan and NMSettingWired, but we will use NMSettingWired regardless of the underlying hardware type.
* core: move software device creation logic out of NMManagerDan Winship2013-09-121-38/+114
| | | | | | | Rather than having NMManager know how to parse various settings to create each kind of software device, add a _new_for_connection() constructor to each of them and let them call NMPlatform to create the device correctly themselves.
* core: set VLAN ingress/egress maps at activation timeDan Winship2013-09-121-0/+42
| | | | | | | | | Rather than setting the VLAN maps when the device is created, set them at activation time, which is more in line with how other device types work. Like the old code, this doesn't attempt to reset any existing ingress/egress mappings on the device.
* core: update UDI when it's availableDan Williams2013-08-071-3/+1
| | | | | | | | | | | | | | | | | | | Software devices don't have a UDI until udev finds them, and since we need to know about the software devices before udev finds them the UDI will be missing. Instead of requiring a UDI on NMDevice creation, update the property from the NMPlatform link change signal when udev does find the device. Now that a UDI is no longer required for device creation, software devices added by NM would be created in the platform_link_added_cb() signal handler triggered by the various software device creation methods in system_create_virtual_device() (eg nm_platform_bridge_add() etc). Then the NMDevice created in system_create_virtual_device() would be a duplicate and cause problems when it was added. Since system_create_virtual_device() needs to do setup on some devices, suppress the device creation from the platform link added handler in this function. Much of this is a hack which should be cleaned up later.
* trivial: remove unused system.h includeslPavel Šimerda2013-07-051-1/+0
|
* core: rename nm_device_hw_* to nm_device_*Dan Williams2013-06-141-3/+3
| | | | | Now that we only have one set of is_up/bring_up/take_down functions lets rename the _hw_ variants.
* core: use nm-platform for link managementPavel Šimerda2013-05-241-32/+5
|
* core: clean up and simplify device capabilities handlingDan Williams2013-05-201-1/+1
| | | | | | | | | | | | | This is really, really old 2007-era code. Any NMDevice that gets created is already supported, so there's no reason to have every device set NM_DEVICE_CAP_NM_SUPPORTED. For those subclasses that only set that capability, we can remove the subclass method entirely. Next, it turns out that the "type capabilities" code wasn't used anywhere, so remove that too. Lastly, "cipsec" interfaces haven't been used on linux in about 5 years (they were created by the Cisco binary-only IPSec kernel module for Cisco VPNs long before vpnc and openswan came around) so we can remove that code too.
* core: move carrier handling to NMDeviceDan Winship2013-05-201-132/+22
| | | | | | Move carrier handling for most device types into NMDevice. Based on an earlier patch by Pavel Šimerda.
* core: make nm-properties-changed-signal always export the right propertiesDan Winship2013-05-201-16/+4
| | | | | | | | | | Change the way that nm-properties-changed-signal works, and parse the dbus-binding-tool-generated info to get the exact list of properties that it's expected to export. This makes NM_PROPERTY_PARAM_NO_EXPORT unnecessary, and also fixes the problem of properties like NMDevice:hw-address being exported on classes where it shouldn't be.
* core: move devices into a subdirectoryDan Winship2013-05-081-0/+603
We have lots of device types and will soon have lots more, so let's put them in their own directory.