summaryrefslogtreecommitdiffstats
path: root/net
Commit message (Collapse)AuthorAgeFilesLines
* net: use dev_warn() when no MAC address is setVivien Didelot2018-05-221-1/+1
| | | | | | | | | | | | | | | | | | | When a SoC such as VF610 has no addresses programmed for both its interfaces, the "No MAC address set" warning can be confusing: booting 'net' WARNING: net: warning: No MAC address set. Using random address a2:e8:be:79:72:01 WARNING: net: warning: No MAC address set. Using random address aa:d5:d7:10:c0:42 This patch uses dev_warn() instead and removes the redundant "warning": booting 'net' WARNING: eth0: No MAC address set. Using random address a2:e8:be:79:72:01 WARNING: eth1: No MAC address set. Using random address 4e:be:c4:bc:ce:36 Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Acked-by: Sam Ravnborg <sam@ravnborg.org>
* net: on ifup -a only detect devices when necessarySascha Hauer2018-04-091-1/+20
| | | | | | | | | | | | | | | | For network boot we once used to hardcode eth0, but in latest changes this was changed to work with different network devices and the 'ifup eth0' was replaced with 'ifup -a' which lead to the result that we now detect all devices in order to eventually also bring up USB network adapters. In most of the cases this is not desired. When a board has internal network support this is likely to be used. With this patch we only detect all devices when we do not have a network device already. For the unusual case in which a USB network adapter shall be used even when an internal network interface is present we introduce the global variable "global.net.ifup_force_detect" which can be used to force detection of devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* DHCP: fix option 54 passingYegor Yefremov2018-02-221-5/+2
| | | | | | | | | | | | | | | Though variable net_dhcp_server_ip was declared and used as a function parameter it was never assigned. That's why a DHCP request was sent without option 54 set. Some DHCP server for example dnsmasq didn't accept such a packet. As both offered IP address and server IP are stored in the global dhcp_result structure we don't need either net_dhcp_server_ip or OfferedIP variables and can use the addresses from dhcp_result directly. Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: make struct bootp __packed to prevent unaligned store on MIPSAntony Pavlov2018-01-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | How to repropduce the unaligned store problem qemu-system-mips -nodefaults -M malta -m 256 \ -nographic -serial stdio -monitor null \ -bios barebox-flash-image \ -net user -net nic,model=rtl8139 ... barebox:/ dhcp Ooops, address error on store! $ 0 : 00000000 00000000 01010600 697f2a2e $ 4 : a0850000 00000000 0000001c a040c1b8 $ 8 : 00000000 00000002 00000002 00000000 $12 : 00000000 00000040 00000100 00000001 $16 : a040bba0 a0850000 a0850000 a0850000 $20 : 00000000 00000075 00000076 a040ba20 $24 : 00000002 a080f210 $28 : 00000000 a03ffce0 fffffffd a0833b8c Hi : 000154f8 Lo : 20000000 epc : a0833b84 ra : a0833b8c Status: 00000002 Cause : 80000414 Config: 80008482 ### ERROR ### Please RESET the board ### The unaligned store instruction is located in the bootp_request() from net/dhcp.c: a0833b50 <bootp_request>: .. a0833b7c: 3c020101 lui v0,0x101 a0833b80: 24420600 addiu v0,v0,1536 /* 0x1010600 -> v0 */ a0833b84: 0c20024a jal a0800928 <get_time_ns> a0833b88: ae02002a sw v0,42(s0) /* store 0x1010600 to addr s0 + 42 */ This assembler code is generated by mips-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0 from this: bp = (struct bootp *)payload; bp->bp_op = OP_BOOTREQUEST; /* 0x01 */ bp->bp_htype = HWT_ETHER; /* 0x01 */ bp->bp_hlen = HWL_ETHER; /* 0x06 */ bp->bp_hops = 0; Compiler replaces four 'store byte' instruction by one 'store 32-bit word' instruction. Alas sometimes this leads to unaligned store situation. Making struct bootp __packed prevents this optimization and fixes the problem. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Tested-by: Oleksij Rempel <linux@rempel-privat.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Add linuxdevname propertySascha Hauer2017-12-152-3/+13
| | | | | | | | | | | | | | | | | When you have a static network environment but more than one network device on your machine it is necessary to provide the <device> parameter to the ip parameter at kernel cmd line. The device name assigned by Linux cannot in general be predicted as it depends on driver bind order. This patch introduces a new property linux.devname to eth devices. The value is added to bootargs per interface and can be changed in env/network/INTF Based on patch by Gavin Schenk <g.schenk@eckelmann.de>. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Provide new way to configure network devicesSascha Hauer2017-12-142-88/+183
| | | | | | | | | | | | | | | | | | | This provides a new way to configure network interfaces based on nvvars. A network interface can now be configured with variables in the nv.dev.<ethname>.* namespace. There is a new network device parameter "mode" which specifies the mode used to obtain IP settings. The mode can be "dhcp", "static" or "disabled": nv.dev.eth0.mode=dhcp (ipaddr, netmask are ignored in this setting) nv.dev.eth0.mode=static nv.dev.eth0.ipaddr=192.168.0.17 nv.dev.eth0.netmask=255.255.0.0 nv.dev.eth0.mode=disabled Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ifup: Use dhcp C API rather than running commandSascha Hauer2017-12-141-4/+2
| | | | | | DHCP has a C API, so use it instead of running as command. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: ifup: Factor out a eth_discover functionSascha Hauer2017-12-141-12/+26
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: remove "current" network deviceSascha Hauer2017-12-142-19/+0
| | | | | | | Now that we can do routing we no longer need a "current" network device. Remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Pick network device based on IP settingsSascha Hauer2017-12-141-2/+28
| | | | | | | | | The IP/netmask/gateway settings contain all informations needed to pick the correct network device. This patch adds support for that and makes specifying the "current" network interface using the ethact command unnecessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: dhcp: reworkSascha Hauer2017-12-141-322/+210
| | | | | | | | | | | | | | | The DHCP code is a mess. It is not clear which options are sent to the server and which options are returned from the server. Also environment variables are read from and written to all over the place. This patch cleans this up. There now is struct dhcp_req_param which is used for options sent to the server and struct dhcp_result which contains the values sent from the server. The values from the server are written to the barebox variables in a single place. Also it's now possible to call the dhcp code without modifying barebox variables at all, storing the result only in the dhcp result struct. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: dhcp: Coding style fixesSascha Hauer2017-12-141-7/+6
| | | | | | | Fix some spaces-before-function-opening-brackets and duplicate empty lines. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: dhcp: avoid unnecessary castsSascha Hauer2017-12-141-10/+8
| | | | | | Drop explicit casts to/from void pointers. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: dhcp: Allow to specify network deviceSascha Hauer2017-12-143-16/+16
| | | | | | | | | Instead of allowing to DHCP only on the "current" network device, allow to specify the desired network device. This is a first step to get rid of the concept of a "current" network device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: allow udp connections on specified network deviceSascha Hauer2017-12-011-12/+20
| | | | | | | | This allows the DHCP code to configure specific network devices so that DHCP no longer depends on any "current" network device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Use a single gatewaySascha Hauer2017-12-013-6/+14
| | | | | | | | | | | | | | There is not much point in having a network device specific gateway. If barebox really is part of such a complicated network in which it needs multiple gateways, then we probably need a real routing table. Until this happens, a single gateway should be enough. This introduces global.net.gateway which holds the gateway ip. The previously used device specific <ethx>.gateway variables still exist, but are only aliases for the single gateway. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: dhcp: Do not overwrite serverip if it is validSascha Hauer2017-12-013-5/+16
| | | | | | | | | | | | | Some DHCP servers provide the wrong serverip in which case it is desired to specify it manually and won't let the dhcp command overwrite it. This has previously been done by setting the serverip again to the desired value after dhcp has been executed. With this patch we do not overwrite it in the first place if it is valid already. This is necessary when the serverip is not set via /env/network/eth* but via nv.net.server. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: introduce global.net.serverSascha Hauer2017-12-013-8/+14
| | | | | | | | | | | | The server to use is independent of the network device, there is not much point to make the server specific to a network device. This introduces global.net.server as the serverip which is used as standard NFS/tftp server. The previously used eth device specific parameters still exist, but are only aliases for the global single variable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Add functions to get/set nameserver and domainnameSascha Hauer2017-12-012-6/+26
| | | | | | | | | It's more convenient to have getter/setter functions for variables rather than using the detour around global vars which use string matching and all kinds of overhead in the background. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Make domainname and nameserver globalvarsSascha Hauer2017-12-013-19/+14
| | | | | | | | | Register domainname and nameserver as globalvars rather than attaching them to a dedicated net device. the global device already exists and already contains much of the barebox configuration, so no need to add an extra device for network config. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Add and use IP_BROADCASTSascha Hauer2017-12-012-4/+4
| | | | | | | Rather than using the hardcoded value 0xffffffff in several places add a define for the broadcast IP. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: use pr_* functions for messagesSascha Hauer2017-12-011-12/+14
| | | | | | | | Use pr_* functions in the networking code rather than printf() and debug(). Also Add a "net: " prefix to messages to give them some more context. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/parameter-types'Sascha Hauer2017-05-051-2/+9
|\
| * net: use dev_add_param_stringSascha Hauer2017-04-111-2/+9
| | | | | | | | | | | | | | dev_add_param_string allows to pass a priv * so that the device_d * argument is not needed and can be removed later. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: ifup needs to be able to run commandsLucas Stach2017-04-261-0/+1
|/ | | | | Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* console: replace set_active by open/closeBastian Stender2017-02-281-10/+17
| | | | | | | | | Opening and closing consoles should be independent from setting them active. This way it is possible to open e.g. a framebuffer console and display text on it without showing stdout/stderr. Signed-off-by: Bastian Stender <bst@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: add linux.bootarg parameter from ifup callEnrico Jorns2016-09-222-0/+11
| | | | | | | | | | | | | This sets a `ip=dhcp` or `ip=<clientip>:<serverip>:<gatewayip>:<netmaskip>::<iface>:` bootarg for the network device upon execution of 'ifup'. This is the only point where we can distinguish between a static ip and a dhcp-based network setup and thus set a valid bootarg options as it will be required for nfs boot, for example. Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* convert users to %pI4Sascha Hauer2016-09-225-29/+8
| | | | | | | Convert users of ip_to_string() and print_IPaddr() to %pI4 and remove the now unused functions. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: Pass network device to net_answer_arp()Sascha Hauer2016-07-141-3/+2
| | | | | | | | | The caller already has the correct network device, so pass it to net_answer_arp() rather than using eth_get_current() there. This is a step towards making a global current network device unnecessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: eth: add name to struct eth_deviceSascha Hauer2016-07-141-5/+7
| | | | | | | | | Using dev_name often is not a good idea since it's a statically allocated string which gets overwritten by later calls to dev_name. Add a devname string to struct eth_device to have the name available for later use. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: introduce for_each_netdev iteratorSascha Hauer2016-07-141-7/+7
| | | | | | | | for_each_netdev is nicer to read. Also export the list of network devices since it will be used by code outside of net/eth.c in later patches. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: eth: open correct edev in eth_check_openSascha Hauer2016-07-141-1/+1
| | | | | | | | eth_check_open gets the network device to check as parameter, so use it rather than using eth_current. Currently both are the same, so this currently does not fix anything. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ifup: fix handling when ip env is not givenAlexander Aring2016-06-151-0/+3
| | | | | | | | This patch handles the ip env to "" if no ip env is given. Otherwise we get a NULL pointer derefence. Signed-off-by: Alexander Aring <aar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* string: Fix (v)asprintf prototypesSascha Hauer2016-04-153-7/+7
| | | | | | | | | | Our asprintf and vasprintf have different prototypes than the glibc functions. This causes trouble when we want to share barebox code with userspace code. Change the prototypes for (v)asprintf to match the glibc prototypes. Since the current (v)asprintf are convenient to use change the existing functions to b(v)asprintf. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/rtc'Sascha Hauer2016-01-113-0/+176
|\
| * net: Add SNTP supportSascha Hauer2016-01-073-0/+176
| | | | | | | | | | | | | | | | This adds support for retrieving the time via Simple Network Time Protocol (SNTP). No fancy features are supported, only plainly getting the current time. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: resolv: Make argument constSascha Hauer2015-12-141-2/+2
| | | | | | | | | | | | resolv() is not allowed to change the hostname argument, make it const. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: dhcp: make unmodified variable constSascha Hauer2015-12-141-3/+3
| | | | | | | | | | | | | | 'str' in dhcp_set_string_options is never modified, so make it const. With this we no longer have to cast away the const returned from getenv. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: dhcp: simplify dhcp_options_processSascha Hauer2015-12-141-9/+6
| | | | | | | | | | | | | | | | | | | | dhcp_options_handle returns the index into the dhcp_options array. This is only to be able in the caller to print a debug message when the index returned from dhcp_options_handle is out of bounds. Simplify this by printing the debug message in dhcp_options_handle and not in the caller. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: dhcp: unify options and paramsSascha Hauer2015-12-141-77/+57
|/ | | | | | | | | The dhcp code distinguishes between options and params. If sent to the server they are params, if received from the server they are options. Unify them all to be options. If it has a handle_param callback it's a param, if it has a handle callback it's an option. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: eth: Remove ethaddr_paramJan Remmet2015-11-201-2/+2
| | | | | | | | commit d00db554 introduce ethaddr_param. But it is not initialized, so devinfo fails to show the mac. Remove it and use edev->ethaddr. Signed-off-by: Jan Remmet <j.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: eth: Fixup OF tree with registered MAC addresses tooTrent Piepho2015-10-221-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | The eth code registers an OF tree fixup that looks for any nodes in the Linux oftree that match eth devices loaded in barebox and sets the mac-address property in those nodes. The purpose is to pass MAC addresses to the Linux kernel for drivers that expect the MAC address to be in the device tree. If barebox does not have a driver for the network device, either because it has been disabled or because one does not exist, then the OF tree will not be fixed up to include a MAC address. The eth code also has a list of MAC addresses which board code has registered, usually done when it reads the address from an EEPROM or on-chip memory. If an eth device is created later in the boot, it will look here for an address. The registered MAC address list is not used for the OF tree fix up, and this patch changes that. This way barebox can place a MAC address in the device-tree without needing a driver for the network device. Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: eth: Refactor OF tree fixup of one node into new functionTrent Piepho2015-10-221-28/+34
| | | | | | | | Code that fixes up one node with a new MAC address is refactored into a new function that eth_of_fixup() calls in a loop. Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* net: dhcp: Fix CONFIG variable nameWadim Egorov2015-09-291-1/+1
| | | | | Signed-off-by: Wadim Egorov <w.egorov@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/net'Sascha Hauer2015-08-061-0/+8
|\
| * net: make eth_register_ethaddr work on registered network devicesSascha Hauer2015-07-281-0/+8
| | | | | | | | | | | | | | When eth_register_ethaddr is called after the device has been registered it should work aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | net: eth_send: Allow to use multiple network interfaces at onceAntony Pavlov2015-07-231-1/+1
|/ | | | | | | | | | | | | | | | | | | | The commit commit be0404c21f22da2d736168b2e56a9ae583cc3e95 Author: Sascha Hauer <s.hauer@pengutronix.de> Date: Wed May 14 16:08:04 2014 +0200 net: Allow to use multiple network interfaces at once changes the eth_send() function: - return eth_current->send(eth_current, packet, length); + return edev->send(eth_current, packet, length); But we have to change the both eth_current occurrences to edev here! Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/net'Sascha Hauer2015-07-031-4/+9
|\
| * dns: handle incoming packets in the separate dns_recv() functionAntony Pavlov2015-07-011-4/+9
| | | | | | | | | | | | | | | | The separation of incoming packets handling makes it much easier to run barebox dns client on top of picotcp network stack in the future. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | treewide: fix 'new blank line at EOF' formatting errorAntony Pavlov2015-07-022-2/+0
| | | | | | | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>