summaryrefslogtreecommitdiffstats
path: root/discover/network.c
Commit message (Collapse)AuthorAgeFilesLines
* discover: Wait for net interfaces to be marked readySamuel Mendoza-Jonas2017-07-111-0/+72
| | | | | | | | | | | | | | | | | | | | | | | If pb-discover is started before udev has settled there is a race between Petitboot configuring interfaces and udev renaming them. If an interface is set "up" the name change will fail and interfaces can be inconsistently named, eg: Device: (*) eth0 [0c:c4:7a:f4:1c:50, link up] ( ) enP1p9s0f1 [0c:c4:7a:f4:1c:51, link down] ( ) enP1p9s0f2 [0c:c4:7a:f4:1c:52, link down] ( ) enP1p9s0f3 [0c:c4:7a:f4:1c:53, link down] Add "net" devices to the udev filter and wait for them to be announced by udev before configuring them. udev_enumerate_add_match_is_initialized() ensures that by the time an interface appears via udev its name will be consistent. This also swaps the network and udev init order, but since interfaces now will not be configured until after udev is ready this should not have a user-visible effect. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/paths: Add network jobs to queueSamuel Mendoza-Jonas2017-07-111-0/+3
| | | | | | | | | Load tasks that start before the network is available will fail. Rather than just fail these tasks, add them to a queue that is processed once the network is ready. This helps users who try to request files early in setup, as well as very early running load tasks. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/network: Ignore interfaces with pre-existing MAC addressSamuel Mendoza-Jonas2017-01-311-1/+11
| | | | | | | | | | | | Petitboot uses the MAC address of network interfaces as a unique identifier. This can cause a crash in pb-discover on a machine that has multiple interfaces with the same MAC address. While duplicate MAC addresses are rare and imply an issue with the larger system configuration Petitboot should handle this gracefully, so log a warning and ignore any interfaces other than the first to appear that share a MAC address. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/network: Ensure interfaces have device before configuringSamuel Mendoza-Jonas2017-01-121-3/+6
| | | | | | | | | | Reorganise network_handle_nlmsg() slightly to create interface->dev just before calling configure_interface() rather than only for brand new interfaces. This ensures existing interfaces which have had ->dev removed but receive a new configure event do not access a NULL pointer during the configuration process. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/network: Search by UUID only if availableSamuel Mendoza-Jonas2017-01-121-1/+4
| | | | | | | | | When registering a new discover device it is possible the device does not have an associated UUID, for example when created via device_handler_process_url(). Fall back to find_interface_by_name() in this case. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Record IP address of network interfacesSamuel Mendoza-Jonas2016-12-201-0/+4
| | | | | | | | If an interface has a valid IP address (either via DHCP or static config) store it in the interface_info struct so it can be referenced later. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/status: report status on link configurationJeremy Kerr2016-12-201-2/+11
| | | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/network: Add find_interface_by_uuidSamuel Mendoza-Jonas2016-09-081-21/+40
| | | | | | | | | | Currently in network_register_device() and network_unregister_device() the appropriate interface is searched for by name. However it is possible in some scenarios for multiple interfaces to have the same name, so instead search by UUID to be sure that the correct interface is being selected. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: Pass UUID to discover_device_create()Samuel Mendoza-Jonas2016-09-081-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently discover_device_create() will search for existing discover devices by id to determine if a new device is required. However it is possible under some circumstances for distinct devices to have the same name. This is especially troublesome if the following network events are seen in network_handle_nlmsg(): - New interface, 'foo' with uuid x:x:x:x:x:x -> new discover device created with dev->device->id = 'foo' dev->uuid = x:x:x:x:x:x - New interface, 'foo' with uuid y:y:y:y:y:y -> existing device 'foo' found dev->uuid = y:y:y:y:y:y This can occur if an interface rename event arrives *after* an old name is reused, where temporarily Petitboot will see two distinct network interfaces with the same name. Now the two interfaces point to the same discover device, which can quickly result in a segfault if a 'remove' event occurs for one of the interfaces and the discover device is freed. To generally avoid this a 'uuid' parameter is added to discover_device_create(), which if present allows existing devices to be looked up by UUID rather than just their name. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/network: Ignore tun devicesv1.2.3Samuel Mendoza-Jonas2016-08-231-0/+3
| | | | | | | | In some environments a default 'tun' device is created. Petitboot doesn't use this and it clutters up the list of network devices, so ignore it if it is encountered. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover/network: Mark interfaces configured once configuredSamuel Mendoza-Jonas2016-07-141-1/+6
| | | | | | | | | | In some cases additional netlink messages can be received for an already-configured interface without any relevant changes. This can result in multiple DHCP requests for the same interface. Once an interface has been configured mark it as IFSTATE_CONFIGURED to avoid configuring it again. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
* discover: extend URL in UI to support auto-discoveryNishanth Aravamudan2015-12-181-1/+5
| | | | | | | | | | | | | The URL field currently only supports loading a particular file for static network configurations. But it makes sense in certain static network configurations to 'auto-discover' a file like petitboot does with DHCP -- based off the MAC address and IP. Extend device_handler_process_url to take those as parameters, and toggle off the URL ending in a '/' to indicate whether to 'auto-discover' or directly load the specified URL. Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com> Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* ui: add URL for static configurations to load a specified fileNishanth Aravamudan2015-12-181-2/+9
| | | | | | | | | | | | In certain configurations, e.g. automation, we want to use static networking but load a particular file, automatically and parse it as a pxelinux config file. Currently, we support something like this for DHCP based booting, but not static. Add a URL field to the UI for static configurations and reuse the logic from device_handler_process_url() to load the specified file. Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com> Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* discover: Recognise renamed network interfacesSamuel Mendoza-Jonas2015-03-261-0/+9
| | | | | | | | | | Udev may change the name of network interfaces if persistent interface naming is used. It is important to recognise this since udev may re-use the old name for a different interface. If we receive an RTM_NEWLINK message for an existing interface, check if the name has been updated. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
* discover/pxe: Format IPAPPEND mac addresses correctlySamuel Mendoza-Jonas2014-12-031-0/+13
| | | | | | | | | | | | | | | | | | | | | The SYSAPPEND/IPAPPEND option 2 in PXE configs requires the MAC address of the booting interface to be appended to the boot options. Previously we formatted this as "BOOTIF=01:02:03:04:05:06", but syslinux/pxelinux implementation use this format: "BOOTIF=01-01-02-03-04-05-06", where the leading '01' represents the hardware type. The relevant part of the pxelinux doc is at: http://www.syslinux.org/wiki/index.php/SYSLINUX#SYSAPPEND_bitmask Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib: Move generic file-handling code to lib/Jeremy Kerr2014-08-051-1/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: allow separate lifetimes for network interfaces and discover devicesJeremy Kerr2014-07-211-1/+40
| | | | | | | | | | | | | We want the network code's network interfaces to (potentially) persist remove events. For example, discover devices may be removed by a user event (this happens during a udhcpc deconfig). In this case, we want the boot options to be removed, but the struct interface needs to stay present. This change adds network_(un)_register_device functions, to allow the device handler to detach from and attach to interfaces. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Set UUID for network interface devicesJeremy Kerr2014-07-171-0/+21
| | | | | | | We want to lookup network (as well as block) devices by UUID, so set one based on the MAC address. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: leave udhcpc processes runningJeremy Kerr2014-06-301-2/+1
| | | | | | | | | | Currently, we start udhcpc with the '-n' argument, which means they'll exit if no lease is obtained. We'd prefer to leave the DHCP client running, so that any slow-to-initialise links are not left deconfigured. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: Fix incorrect udhcpc command if we have no platform definitionJeremy Kerr2014-06-301-1/+1
| | | | | | | | | | If we don't have a platform defined, we generate an invalid uchdpc command, as we've NULL-ed out the interface name. This change fixes the no-platform case to terminate *after* the interface name. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: run udhcpc process in foreground modeJeremy Kerr2014-04-031-0/+1
| | | | | | | We don't want udhcpc processes to detach, otherwise we aren't able to stop the spawned background process, which we need to do on reinit. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: flush addresses when bringing an interface downJeremy Kerr2014-04-021-0/+9
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: add reinit pathJeremy Kerr2014-04-021-1/+0
| | | | | | | | | | | | | Currently, changes to settings doesn't take effect while the discover server is running. This means we need to reboot for any changes (eg, to network settings) to take effect. This change introduces a reinit path. Triggered by a configuration update, this will cause the device handler to drop all of its devices (and boot options), and restart the discovery process from the device sources. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: Fix incorrect static DNS servers in resolv.confJeremy Kerr2014-02-251-1/+1
| | | | | | | | | | | | | | | | We currently have a bug where we write NUL characters into /etc/resolv.conf, when using static DNS server configurations: With a network setting of: dns,9.0.6.11,9.0.7.1 We generate a resolv.conf containing: nameserver 9.0.6.11^@nameserver 9.0.7.1^@ This is due to an off-by-one bug when terminating the nameserver entries. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: Use platform definition for DHCP architecture IDJeremy Kerr2014-01-301-2/+10
| | | | | | | Allow a platform to specify a DHCP architecture ID, as this is platform-specific. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* pb-config: Move config storage modules to "platform" modules in discover codeJeremy Kerr2014-01-301-1/+1
| | | | | | | | | | | | | | | | | | There's no need to include the config storage code in lib/ as only the discover server should be using it. This change moves the config-storage code to discover/, with the platform-specific parts moved to a 'struct platform'. Each platform has a probe function, which is called during init. The first probe function to return a platform is used. At present we only have the one platform, but it's now non-intrusive to add others. We keep an array of platform pointers in a separate ("platforms") section, to allow the test module to drop-in its own test "platform". Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: Send DHCP client architecture typeJeremy Kerr2014-01-171-0/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Support DHCP "pathprefix" configuration optionJeremy Kerr2014-01-171-0/+1
| | | | | | | | | | | | | | | | | This change implements support for the DHCP "pathprefix" option. We use the following logic: - If pathprefix is present and a full URL, we base the config file location on pathprefix + conffile - If pathprefix is present but not a full URL, we use it as the path component of the URL, and pick up the host from other parameters in the DHCP response - If no pathprefix is present, we determine the configuration prefix from the DHCP bootfile parameter. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Bring down configured interfaces on discover server exit.Jeremy Kerr2014-01-171-1/+6
| | | | | | | | We want to down the interfaces that we brought up, so hook up the network_shutdown function to the discover exit path. Also, we only want to down interfaces that we've configured, and exclude lo. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* sysinfo: Add interface link status to sysinfo dataJeremy Kerr2013-12-181-6/+7
| | | | | | | | This changes adds a 'link' parameter to the interface information sent in sysinfo messages. The discover network code populates this from the incoming netlink messages. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: In static config mode, only configure defined interfacesJeremy Kerr2013-11-271-1/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Use pxeconffile for udhcpc option nameJeremy Kerr2013-11-221-0/+1
| | | | | | | | | | | | The patch that went upstream for udhcpc's option 209 handling uses the option name 'pxeconffile' rather than 'conffile', and it was added as a non-default option: http://git.busybox.net/busybox/commit/?id=d3092c99ae90f This change uses the new name, and explicilty requests this option. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/types: use unsigned int for interface, dns and prio countsJeremy Kerr2013-11-131-2/+3
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Fix potentially-uninitialised variablesJeremy Kerr2013-11-131-0/+1
| | | | | | | We've been compiling with --enable-debug; this change fixes some problems exposed by the optimiser. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* logging: Clean up debug logsJeremy Kerr2013-11-011-1/+1
| | | | | | | We have quite a few pb_logs which should be pb_debug. This change moves developer-specific info to pb_debug. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: Allow for arbitrary-sized netlink messagesJeremy Kerr2013-11-011-5/+41
| | | | | | | | | | | Currently, we drop any netlink data beyond our 4096-byte buffer. This means that we can only parse a limited number of network interfaces. This change uses recvmsg with MSG_PEEK to determine the size of an incoming netlink message before doing the actual recvmsg. This way, we can realloc our buffer to suit. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: Ensure dns config buffer contains a trailling nulJeremy Kerr2013-10-211-1/+2
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* Add system info messagesJeremy Kerr2013-10-091-0/+7
| | | | | | | | Add a little infrastructure for communicating information about the system to the petitboot UIs. We just send some identifying info (type and identifier), as well as the interfaces. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: register network devices with the device handlerJeremy Kerr2013-09-191-9/+21
| | | | | | | We'd like to correlate incoming network boot options with a device, so register the interface with the device hander. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: Manage network->interfaces with {add,remove}_interfaceJeremy Kerr2013-09-191-2/+14
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: ignore devices with zero MTUJeremy Kerr2013-09-191-1/+6
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* lib/process: replace pb_run_cmdJeremy Kerr2013-08-191-50/+59
| | | | | | | This change replaces the pb_run_cmd() function with proper usage of the process API. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: free buffers from resolv.conf updateJeremy Kerr2013-08-161-7/+8
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover/network: fix incorrect nameserver directive in resolv.confJeremy Kerr2013-08-161-1/+1
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* network: handle DNS configJeremy Kerr2013-08-081-0/+57
| | | | | | If we have a dns config option, update resolv.conf Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* config: Split interface configuration from network configurationJeremy Kerr2013-08-081-7/+7
| | | | | | | | This change moves the interface configuration into its own 'struct interface_config'. We also remove the _config suffix from the network and interface members. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: bring network interfaces down in network_shutdownJeremy Kerr2013-06-241-3/+24
| | | | Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
* discover: Add network handlingJeremy Kerr2013-06-241-0/+426
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
OpenPOWER on IntegriCloud