License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 14:07:57 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Automatic Configuration of IP -- use DHCP, BOOTP, RARP, or
|
|
|
|
* user-supplied information to configure own IP address and routes.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1996-1998 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
|
|
|
|
*
|
|
|
|
* Derived from network configuration code in fs/nfs/nfsroot.c,
|
|
|
|
* originally Copyright (C) 1995, 1996 Gero Kuhlmann and me.
|
|
|
|
*
|
|
|
|
* BOOTP rewritten to construct and analyse packets itself instead
|
|
|
|
* of misusing the IP layer. num_bugs_causing_wrong_arp_replies--;
|
|
|
|
* -- MJ, December 1998
|
2007-02-09 14:24:47 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
* Fixed ip_auto_config_setup calling at startup in the new "Linker Magic"
|
|
|
|
* initialization scheme.
|
|
|
|
* - Arnaldo Carvalho de Melo <acme@conectiva.com.br>, 08/11/1999
|
|
|
|
*
|
|
|
|
* DHCP support added. To users this looks like a whole separate
|
|
|
|
* protocol, but we know it's just a bag on the side of BOOTP.
|
|
|
|
* -- Chip Salzenberg <chip@valinux.com>, May 2000
|
|
|
|
*
|
|
|
|
* Ported DHCP support from 2.2.16 to 2.4.0-test4
|
|
|
|
* -- Eric Biederman <ebiederman@lnxi.com>, 30 Aug 2000
|
|
|
|
*
|
|
|
|
* Merged changes from 2.2.19 into 2.4.3
|
|
|
|
* -- Eric Biederman <ebiederman@lnxi.com>, 22 April Aug 2001
|
|
|
|
*
|
|
|
|
* Multiple Nameservers in /proc/net/pnp
|
|
|
|
* -- Josef Siemes <jsiemes@web.de>, Aug 2002
|
2018-04-24 02:56:39 +00:00
|
|
|
*
|
|
|
|
* NTP servers in /proc/net/ipconfig/ntp_servers
|
|
|
|
* -- Chris Novakovic <chris@chrisn.me.uk>, April 2018
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/jiffies.h>
|
|
|
|
#include <linux/random.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/utsname.h>
|
|
|
|
#include <linux/in.h>
|
|
|
|
#include <linux/if.h>
|
|
|
|
#include <linux/inet.h>
|
2005-12-27 04:43:12 +00:00
|
|
|
#include <linux/inetdevice.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/if_arp.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/ip.h>
|
|
|
|
#include <linux/socket.h>
|
|
|
|
#include <linux/route.h>
|
|
|
|
#include <linux/udp.h>
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <linux/major.h>
|
|
|
|
#include <linux/root_dev.h>
|
|
|
|
#include <linux/delay.h>
|
2005-09-06 01:05:52 +00:00
|
|
|
#include <linux/nfs_fs.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2011-07-15 15:47:34 +00:00
|
|
|
#include <linux/export.h>
|
2007-09-12 10:01:34 +00:00
|
|
|
#include <net/net_namespace.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <net/arp.h>
|
|
|
|
#include <net/ip.h>
|
|
|
|
#include <net/ipconfig.h>
|
2005-12-27 04:43:12 +00:00
|
|
|
#include <net/route.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2016-12-24 19:46:01 +00:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <net/checksum.h>
|
|
|
|
#include <asm/processor.h>
|
|
|
|
|
|
|
|
#if defined(CONFIG_IP_PNP_DHCP)
|
|
|
|
#define IPCONFIG_DHCP
|
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_IP_PNP_BOOTP) || defined(CONFIG_IP_PNP_DHCP)
|
|
|
|
#define IPCONFIG_BOOTP
|
|
|
|
#endif
|
|
|
|
#if defined(CONFIG_IP_PNP_RARP)
|
|
|
|
#define IPCONFIG_RARP
|
|
|
|
#endif
|
|
|
|
#if defined(IPCONFIG_BOOTP) || defined(IPCONFIG_RARP)
|
|
|
|
#define IPCONFIG_DYNAMIC
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Define the friendly delay before and after opening net devices */
|
2011-05-19 10:14:06 +00:00
|
|
|
#define CONF_POST_OPEN 10 /* After opening: 10 msecs */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Define the timeout for waiting for a DHCP/BOOTP/RARP reply */
|
|
|
|
#define CONF_OPEN_RETRIES 2 /* (Re)open devices twice */
|
|
|
|
#define CONF_SEND_RETRIES 6 /* Send six requests per open */
|
|
|
|
#define CONF_BASE_TIMEOUT (HZ*2) /* Initial timeout: 2 seconds */
|
|
|
|
#define CONF_TIMEOUT_RANDOM (HZ) /* Maximum amount of randomization */
|
|
|
|
#define CONF_TIMEOUT_MULT *7/4 /* Rate of timeout growth */
|
|
|
|
#define CONF_TIMEOUT_MAX (HZ*30) /* Maximum allowed timeout */
|
2007-02-09 14:24:47 +00:00
|
|
|
#define CONF_NAMESERVERS_MAX 3 /* Maximum number of nameservers
|
|
|
|
- '3' from resolv.h */
|
2018-04-24 02:56:39 +00:00
|
|
|
#define CONF_NTP_SERVERS_MAX 3 /* Maximum number of NTP servers */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-02-01 08:45:17 +00:00
|
|
|
#define NONE cpu_to_be32(INADDR_NONE)
|
|
|
|
#define ANY cpu_to_be32(INADDR_ANY)
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2019-01-31 10:14:18 +00:00
|
|
|
/* Wait for carrier timeout default in seconds */
|
|
|
|
static unsigned int carrier_timeout = 120;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* Public IP configuration
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* This is used by platforms which might be able to set the ipconfig
|
|
|
|
* variables using firmware environment vars. If this is set, it will
|
|
|
|
* ignore such firmware variables.
|
|
|
|
*/
|
|
|
|
int ic_set_manually __initdata = 0; /* IPconfig parameters set manually */
|
|
|
|
|
2014-11-04 19:37:46 +00:00
|
|
|
static int ic_enable __initdata; /* IP config enabled? */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Protocol choice */
|
|
|
|
int ic_proto_enabled __initdata = 0
|
|
|
|
#ifdef IPCONFIG_BOOTP
|
|
|
|
| IC_BOOTP
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_IP_PNP_DHCP
|
|
|
|
| IC_USE_DHCP
|
|
|
|
#endif
|
|
|
|
#ifdef IPCONFIG_RARP
|
|
|
|
| IC_RARP
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
2014-11-04 19:37:46 +00:00
|
|
|
static int ic_host_name_set __initdata; /* Host name set by us? */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-11-08 08:19:38 +00:00
|
|
|
__be32 ic_myaddr = NONE; /* My IP address */
|
|
|
|
static __be32 ic_netmask = NONE; /* Netmask for local subnet */
|
|
|
|
__be32 ic_gateway = NONE; /* Gateway IP address */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2016-06-12 03:40:24 +00:00
|
|
|
#ifdef IPCONFIG_DYNAMIC
|
2016-06-10 11:11:06 +00:00
|
|
|
static __be32 ic_addrservaddr = NONE; /* IP Address of the IP addresses'server */
|
2016-06-12 03:40:24 +00:00
|
|
|
#endif
|
2013-01-03 18:02:12 +00:00
|
|
|
|
2006-11-08 08:19:38 +00:00
|
|
|
__be32 ic_servaddr = NONE; /* Boot server IP address */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-11-08 08:19:38 +00:00
|
|
|
__be32 root_server_addr = NONE; /* Address of NFS server */
|
2005-04-16 22:20:36 +00:00
|
|
|
u8 root_server_path[256] = { 0, }; /* Path to mount as root */
|
|
|
|
|
2007-11-20 05:56:16 +00:00
|
|
|
/* vendor class identifier */
|
|
|
|
static char vendor_class_identifier[253] __initdata;
|
2007-11-14 10:18:39 +00:00
|
|
|
|
2015-10-15 08:54:36 +00:00
|
|
|
#if defined(CONFIG_IP_PNP_DHCP)
|
|
|
|
static char dhcp_client_identifier[253] __initdata;
|
|
|
|
#endif
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Persistent data: */
|
|
|
|
|
2016-01-28 16:39:24 +00:00
|
|
|
#ifdef IPCONFIG_DYNAMIC
|
2005-04-16 22:20:36 +00:00
|
|
|
static int ic_proto_used; /* Protocol used, if any */
|
2016-01-28 16:39:24 +00:00
|
|
|
#else
|
|
|
|
#define ic_proto_used 0
|
|
|
|
#endif
|
2006-11-08 08:19:38 +00:00
|
|
|
static __be32 ic_nameservers[CONF_NAMESERVERS_MAX]; /* DNS Server IP addresses */
|
2018-04-24 02:56:39 +00:00
|
|
|
static __be32 ic_ntp_servers[CONF_NTP_SERVERS_MAX]; /* NTP server IP addresses */
|
2005-04-16 22:20:36 +00:00
|
|
|
static u8 ic_domain[64]; /* DNS (not NIS) domain name */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Private state.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Name of user-selected boot device */
|
|
|
|
static char user_dev_name[IFNAMSIZ] __initdata = { 0, };
|
|
|
|
|
|
|
|
/* Protocols supported by available interfaces */
|
2014-11-04 19:37:46 +00:00
|
|
|
static int ic_proto_have_if __initdata;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-05-19 22:31:50 +00:00
|
|
|
/* MTU for boot device */
|
2014-11-04 19:37:46 +00:00
|
|
|
static int ic_dev_mtu __initdata;
|
2009-05-19 22:31:50 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef IPCONFIG_DYNAMIC
|
|
|
|
static DEFINE_SPINLOCK(ic_recv_lock);
|
2014-11-04 19:37:46 +00:00
|
|
|
static volatile int ic_got_reply __initdata; /* Proto(s) that replied */
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
#ifdef IPCONFIG_DHCP
|
2014-11-04 19:37:46 +00:00
|
|
|
static int ic_dhcp_msgtype __initdata; /* DHCP msg type received */
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Network devices
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct ic_device {
|
|
|
|
struct ic_device *next;
|
|
|
|
struct net_device *dev;
|
|
|
|
unsigned short flags;
|
|
|
|
short able;
|
2006-11-08 08:19:38 +00:00
|
|
|
__be32 xid;
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2014-11-04 19:37:46 +00:00
|
|
|
static struct ic_device *ic_first_dev __initdata; /* List of open device */
|
2016-07-29 09:30:38 +00:00
|
|
|
static struct ic_device *ic_dev __initdata; /* Selected device */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2011-05-19 10:14:06 +00:00
|
|
|
static bool __init ic_is_init_dev(struct net_device *dev)
|
2010-03-12 08:00:17 +00:00
|
|
|
{
|
2011-05-19 10:14:06 +00:00
|
|
|
if (dev->flags & IFF_LOOPBACK)
|
|
|
|
return false;
|
|
|
|
return user_dev_name[0] ? !strcmp(dev->name, user_dev_name) :
|
2010-03-12 08:00:17 +00:00
|
|
|
(!(dev->flags & IFF_LOOPBACK) &&
|
|
|
|
(dev->flags & (IFF_POINTOPOINT|IFF_BROADCAST)) &&
|
2011-05-19 10:14:06 +00:00
|
|
|
strncmp(dev->name, "dummy", 5));
|
2010-03-12 08:00:17 +00:00
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static int __init ic_open_devs(void)
|
|
|
|
{
|
|
|
|
struct ic_device *d, **last;
|
|
|
|
struct net_device *dev;
|
|
|
|
unsigned short oflags;
|
2013-04-02 13:58:25 +00:00
|
|
|
unsigned long start, next_msg;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
last = &ic_first_dev;
|
2006-03-21 06:23:58 +00:00
|
|
|
rtnl_lock();
|
2005-04-16 22:20:36 +00:00
|
|
|
|
Revert "net: ipv4: handle DSA enabled master network devices"
This reverts commit 728c02089a0e3eefb02e9927bfae50490f40e72e.
Since 2015 DSA has gained more integration with the network stack, we
can now have the same functionality without explicitly open-coding for
it:
- It now opens the DSA master netdevice automatically whenever a user
netdevice is opened.
- The master and switch interfaces are coupled in an upper/lower
hierarchy using the netdev adjacency lists.
In the nfsroot example below, the interface chosen by autoconfig was
swp3, and every interface except that and the DSA master, eth1, was
brought down afterwards:
[ 8.714215] mscc_felix 0000:00:00.5 swp0 (uninitialized): PHY [0000:00:00.3:10] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 8.978041] mscc_felix 0000:00:00.5 swp1 (uninitialized): PHY [0000:00:00.3:11] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.246134] mscc_felix 0000:00:00.5 swp2 (uninitialized): PHY [0000:00:00.3:12] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.486203] mscc_felix 0000:00:00.5 swp3 (uninitialized): PHY [0000:00:00.3:13] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.512827] mscc_felix 0000:00:00.5: configuring for fixed/internal link mode
[ 9.521047] mscc_felix 0000:00:00.5: Link is Up - 2.5Gbps/Full - flow control off
[ 9.530382] device eth1 entered promiscuous mode
[ 9.535452] DSA: tree 0 setup
[ 9.539777] printk: console [netcon0] enabled
[ 9.544504] netconsole: network logging started
[ 9.555047] fsl_enetc 0000:00:00.2 eth1: configuring for fixed/internal link mode
[ 9.562790] fsl_enetc 0000:00:00.2 eth1: Link is Up - 1Gbps/Full - flow control off
[ 9.564661] 8021q: adding VLAN 0 to HW filter on device bond0
[ 9.637681] fsl_enetc 0000:00:00.0 eth0: PHY [0000:00:00.0:02] driver [Qualcomm Atheros AR8031/AR8033] (irq=POLL)
[ 9.655679] fsl_enetc 0000:00:00.0 eth0: configuring for inband/sgmii link mode
[ 9.666611] mscc_felix 0000:00:00.5 swp0: configuring for inband/qsgmii link mode
[ 9.676216] 8021q: adding VLAN 0 to HW filter on device swp0
[ 9.682086] mscc_felix 0000:00:00.5 swp1: configuring for inband/qsgmii link mode
[ 9.690700] 8021q: adding VLAN 0 to HW filter on device swp1
[ 9.696538] mscc_felix 0000:00:00.5 swp2: configuring for inband/qsgmii link mode
[ 9.705131] 8021q: adding VLAN 0 to HW filter on device swp2
[ 9.710964] mscc_felix 0000:00:00.5 swp3: configuring for inband/qsgmii link mode
[ 9.719548] 8021q: adding VLAN 0 to HW filter on device swp3
[ 9.747811] Sending DHCP requests ..
[ 12.742899] mscc_felix 0000:00:00.5 swp1: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.743828] mscc_felix 0000:00:00.5 swp0: Link is Up - 1Gbps/Full - flow control off
[ 12.747062] IPv6: ADDRCONF(NETDEV_CHANGE): swp1: link becomes ready
[ 12.755216] fsl_enetc 0000:00:00.0 eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.766603] IPv6: ADDRCONF(NETDEV_CHANGE): swp0: link becomes ready
[ 12.783188] mscc_felix 0000:00:00.5 swp2: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.785354] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 12.799535] IPv6: ADDRCONF(NETDEV_CHANGE): swp2: link becomes ready
[ 13.803141] mscc_felix 0000:00:00.5 swp3: Link is Up - 1Gbps/Full - flow control rx/tx
[ 13.811646] IPv6: ADDRCONF(NETDEV_CHANGE): swp3: link becomes ready
[ 15.452018] ., OK
[ 15.470336] IP-Config: Got DHCP answer from 10.0.0.1, my address is 10.0.0.39
[ 15.477887] IP-Config: Complete:
[ 15.481330] device=swp3, hwaddr=00:04:9f:05:de:0a, ipaddr=10.0.0.39, mask=255.255.255.0, gw=10.0.0.1
[ 15.491846] host=10.0.0.39, domain=(none), nis-domain=(none)
[ 15.498429] bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath=
[ 15.498481] nameserver0=8.8.8.8
[ 15.627542] fsl_enetc 0000:00:00.0 eth0: Link is Down
[ 15.690903] mscc_felix 0000:00:00.5 swp0: Link is Down
[ 15.745216] mscc_felix 0000:00:00.5 swp1: Link is Down
[ 15.800498] mscc_felix 0000:00:00.5 swp2: Link is Down
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-02-05 13:37:13 +00:00
|
|
|
/* bring loopback device up first */
|
2007-09-27 05:10:06 +00:00
|
|
|
for_each_netdev(&init_net, dev) {
|
Revert "net: ipv4: handle DSA enabled master network devices"
This reverts commit 728c02089a0e3eefb02e9927bfae50490f40e72e.
Since 2015 DSA has gained more integration with the network stack, we
can now have the same functionality without explicitly open-coding for
it:
- It now opens the DSA master netdevice automatically whenever a user
netdevice is opened.
- The master and switch interfaces are coupled in an upper/lower
hierarchy using the netdev adjacency lists.
In the nfsroot example below, the interface chosen by autoconfig was
swp3, and every interface except that and the DSA master, eth1, was
brought down afterwards:
[ 8.714215] mscc_felix 0000:00:00.5 swp0 (uninitialized): PHY [0000:00:00.3:10] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 8.978041] mscc_felix 0000:00:00.5 swp1 (uninitialized): PHY [0000:00:00.3:11] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.246134] mscc_felix 0000:00:00.5 swp2 (uninitialized): PHY [0000:00:00.3:12] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.486203] mscc_felix 0000:00:00.5 swp3 (uninitialized): PHY [0000:00:00.3:13] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.512827] mscc_felix 0000:00:00.5: configuring for fixed/internal link mode
[ 9.521047] mscc_felix 0000:00:00.5: Link is Up - 2.5Gbps/Full - flow control off
[ 9.530382] device eth1 entered promiscuous mode
[ 9.535452] DSA: tree 0 setup
[ 9.539777] printk: console [netcon0] enabled
[ 9.544504] netconsole: network logging started
[ 9.555047] fsl_enetc 0000:00:00.2 eth1: configuring for fixed/internal link mode
[ 9.562790] fsl_enetc 0000:00:00.2 eth1: Link is Up - 1Gbps/Full - flow control off
[ 9.564661] 8021q: adding VLAN 0 to HW filter on device bond0
[ 9.637681] fsl_enetc 0000:00:00.0 eth0: PHY [0000:00:00.0:02] driver [Qualcomm Atheros AR8031/AR8033] (irq=POLL)
[ 9.655679] fsl_enetc 0000:00:00.0 eth0: configuring for inband/sgmii link mode
[ 9.666611] mscc_felix 0000:00:00.5 swp0: configuring for inband/qsgmii link mode
[ 9.676216] 8021q: adding VLAN 0 to HW filter on device swp0
[ 9.682086] mscc_felix 0000:00:00.5 swp1: configuring for inband/qsgmii link mode
[ 9.690700] 8021q: adding VLAN 0 to HW filter on device swp1
[ 9.696538] mscc_felix 0000:00:00.5 swp2: configuring for inband/qsgmii link mode
[ 9.705131] 8021q: adding VLAN 0 to HW filter on device swp2
[ 9.710964] mscc_felix 0000:00:00.5 swp3: configuring for inband/qsgmii link mode
[ 9.719548] 8021q: adding VLAN 0 to HW filter on device swp3
[ 9.747811] Sending DHCP requests ..
[ 12.742899] mscc_felix 0000:00:00.5 swp1: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.743828] mscc_felix 0000:00:00.5 swp0: Link is Up - 1Gbps/Full - flow control off
[ 12.747062] IPv6: ADDRCONF(NETDEV_CHANGE): swp1: link becomes ready
[ 12.755216] fsl_enetc 0000:00:00.0 eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.766603] IPv6: ADDRCONF(NETDEV_CHANGE): swp0: link becomes ready
[ 12.783188] mscc_felix 0000:00:00.5 swp2: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.785354] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 12.799535] IPv6: ADDRCONF(NETDEV_CHANGE): swp2: link becomes ready
[ 13.803141] mscc_felix 0000:00:00.5 swp3: Link is Up - 1Gbps/Full - flow control rx/tx
[ 13.811646] IPv6: ADDRCONF(NETDEV_CHANGE): swp3: link becomes ready
[ 15.452018] ., OK
[ 15.470336] IP-Config: Got DHCP answer from 10.0.0.1, my address is 10.0.0.39
[ 15.477887] IP-Config: Complete:
[ 15.481330] device=swp3, hwaddr=00:04:9f:05:de:0a, ipaddr=10.0.0.39, mask=255.255.255.0, gw=10.0.0.1
[ 15.491846] host=10.0.0.39, domain=(none), nis-domain=(none)
[ 15.498429] bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath=
[ 15.498481] nameserver0=8.8.8.8
[ 15.627542] fsl_enetc 0000:00:00.0 eth0: Link is Down
[ 15.690903] mscc_felix 0000:00:00.5 swp0: Link is Down
[ 15.745216] mscc_felix 0000:00:00.5 swp1: Link is Down
[ 15.800498] mscc_felix 0000:00:00.5 swp2: Link is Down
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-02-05 13:37:13 +00:00
|
|
|
if (!(dev->flags & IFF_LOOPBACK))
|
2007-09-27 05:10:06 +00:00
|
|
|
continue;
|
2018-12-06 17:05:42 +00:00
|
|
|
if (dev_change_flags(dev, dev->flags | IFF_UP, NULL) < 0)
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("IP-Config: Failed to open %s\n", dev->name);
|
2007-09-27 05:10:06 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-09-17 18:56:21 +00:00
|
|
|
for_each_netdev(&init_net, dev) {
|
2011-05-19 10:14:06 +00:00
|
|
|
if (ic_is_init_dev(dev)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
int able = 0;
|
|
|
|
if (dev->mtu >= 364)
|
|
|
|
able |= IC_BOOTP;
|
|
|
|
else
|
2015-11-13 10:40:34 +00:00
|
|
|
pr_warn("DHCP/BOOTP: Ignoring device %s, MTU %d too small\n",
|
2012-03-11 18:36:11 +00:00
|
|
|
dev->name, dev->mtu);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!(dev->flags & IFF_NOARP))
|
|
|
|
able |= IC_RARP;
|
|
|
|
able &= ic_proto_enabled;
|
|
|
|
if (ic_proto_enabled && !able)
|
|
|
|
continue;
|
|
|
|
oflags = dev->flags;
|
2018-12-06 17:05:42 +00:00
|
|
|
if (dev_change_flags(dev, oflags | IFF_UP, NULL) < 0) {
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("IP-Config: Failed to open %s\n",
|
|
|
|
dev->name);
|
2005-04-16 22:20:36 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!(d = kmalloc(sizeof(struct ic_device), GFP_KERNEL))) {
|
2006-03-21 06:23:58 +00:00
|
|
|
rtnl_unlock();
|
2010-03-12 08:00:17 +00:00
|
|
|
return -ENOMEM;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
d->dev = dev;
|
|
|
|
*last = d;
|
|
|
|
last = &d->next;
|
|
|
|
d->flags = oflags;
|
|
|
|
d->able = able;
|
|
|
|
if (able & IC_BOOTP)
|
2006-11-08 08:19:38 +00:00
|
|
|
get_random_bytes(&d->xid, sizeof(__be32));
|
2005-04-16 22:20:36 +00:00
|
|
|
else
|
|
|
|
d->xid = 0;
|
|
|
|
ic_proto_have_if |= able;
|
2015-11-13 10:40:34 +00:00
|
|
|
pr_debug("IP-Config: %s UP (able=%d, xid=%08x)\n",
|
|
|
|
dev->name, able, d->xid);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
2011-05-19 10:14:06 +00:00
|
|
|
|
2011-12-19 22:58:04 +00:00
|
|
|
/* no point in waiting if we could not bring up at least one device */
|
|
|
|
if (!ic_first_dev)
|
|
|
|
goto have_carrier;
|
|
|
|
|
2011-05-19 10:14:06 +00:00
|
|
|
/* wait for a carrier on at least one device */
|
|
|
|
start = jiffies;
|
2019-01-31 10:14:18 +00:00
|
|
|
next_msg = start + msecs_to_jiffies(20000);
|
2014-08-20 17:44:10 +00:00
|
|
|
while (time_before(jiffies, start +
|
2019-01-31 10:14:18 +00:00
|
|
|
msecs_to_jiffies(carrier_timeout * 1000))) {
|
2013-04-02 13:58:25 +00:00
|
|
|
int wait, elapsed;
|
|
|
|
|
2011-05-19 10:14:06 +00:00
|
|
|
for_each_netdev(&init_net, dev)
|
|
|
|
if (ic_is_init_dev(dev) && netif_carrier_ok(dev))
|
|
|
|
goto have_carrier;
|
|
|
|
|
|
|
|
msleep(1);
|
2013-04-02 13:58:25 +00:00
|
|
|
|
2014-02-10 15:46:54 +00:00
|
|
|
if (time_before(jiffies, next_msg))
|
2013-04-02 13:58:25 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
elapsed = jiffies_to_msecs(jiffies - start);
|
2019-01-31 10:14:18 +00:00
|
|
|
wait = (carrier_timeout * 1000 - elapsed + 500) / 1000;
|
2013-04-02 13:58:25 +00:00
|
|
|
pr_info("Waiting up to %d more seconds for network.\n", wait);
|
2019-01-31 10:14:18 +00:00
|
|
|
next_msg = jiffies + msecs_to_jiffies(20000);
|
2011-05-19 10:14:06 +00:00
|
|
|
}
|
|
|
|
have_carrier:
|
2006-03-21 06:23:58 +00:00
|
|
|
rtnl_unlock();
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
*last = NULL;
|
|
|
|
|
|
|
|
if (!ic_first_dev) {
|
|
|
|
if (user_dev_name[0])
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("IP-Config: Device `%s' not found\n",
|
|
|
|
user_dev_name);
|
2005-04-16 22:20:36 +00:00
|
|
|
else
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("IP-Config: No network devices available\n");
|
2010-03-12 08:00:17 +00:00
|
|
|
return -ENODEV;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Revert "net: ipv4: handle DSA enabled master network devices"
This reverts commit 728c02089a0e3eefb02e9927bfae50490f40e72e.
Since 2015 DSA has gained more integration with the network stack, we
can now have the same functionality without explicitly open-coding for
it:
- It now opens the DSA master netdevice automatically whenever a user
netdevice is opened.
- The master and switch interfaces are coupled in an upper/lower
hierarchy using the netdev adjacency lists.
In the nfsroot example below, the interface chosen by autoconfig was
swp3, and every interface except that and the DSA master, eth1, was
brought down afterwards:
[ 8.714215] mscc_felix 0000:00:00.5 swp0 (uninitialized): PHY [0000:00:00.3:10] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 8.978041] mscc_felix 0000:00:00.5 swp1 (uninitialized): PHY [0000:00:00.3:11] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.246134] mscc_felix 0000:00:00.5 swp2 (uninitialized): PHY [0000:00:00.3:12] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.486203] mscc_felix 0000:00:00.5 swp3 (uninitialized): PHY [0000:00:00.3:13] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.512827] mscc_felix 0000:00:00.5: configuring for fixed/internal link mode
[ 9.521047] mscc_felix 0000:00:00.5: Link is Up - 2.5Gbps/Full - flow control off
[ 9.530382] device eth1 entered promiscuous mode
[ 9.535452] DSA: tree 0 setup
[ 9.539777] printk: console [netcon0] enabled
[ 9.544504] netconsole: network logging started
[ 9.555047] fsl_enetc 0000:00:00.2 eth1: configuring for fixed/internal link mode
[ 9.562790] fsl_enetc 0000:00:00.2 eth1: Link is Up - 1Gbps/Full - flow control off
[ 9.564661] 8021q: adding VLAN 0 to HW filter on device bond0
[ 9.637681] fsl_enetc 0000:00:00.0 eth0: PHY [0000:00:00.0:02] driver [Qualcomm Atheros AR8031/AR8033] (irq=POLL)
[ 9.655679] fsl_enetc 0000:00:00.0 eth0: configuring for inband/sgmii link mode
[ 9.666611] mscc_felix 0000:00:00.5 swp0: configuring for inband/qsgmii link mode
[ 9.676216] 8021q: adding VLAN 0 to HW filter on device swp0
[ 9.682086] mscc_felix 0000:00:00.5 swp1: configuring for inband/qsgmii link mode
[ 9.690700] 8021q: adding VLAN 0 to HW filter on device swp1
[ 9.696538] mscc_felix 0000:00:00.5 swp2: configuring for inband/qsgmii link mode
[ 9.705131] 8021q: adding VLAN 0 to HW filter on device swp2
[ 9.710964] mscc_felix 0000:00:00.5 swp3: configuring for inband/qsgmii link mode
[ 9.719548] 8021q: adding VLAN 0 to HW filter on device swp3
[ 9.747811] Sending DHCP requests ..
[ 12.742899] mscc_felix 0000:00:00.5 swp1: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.743828] mscc_felix 0000:00:00.5 swp0: Link is Up - 1Gbps/Full - flow control off
[ 12.747062] IPv6: ADDRCONF(NETDEV_CHANGE): swp1: link becomes ready
[ 12.755216] fsl_enetc 0000:00:00.0 eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.766603] IPv6: ADDRCONF(NETDEV_CHANGE): swp0: link becomes ready
[ 12.783188] mscc_felix 0000:00:00.5 swp2: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.785354] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 12.799535] IPv6: ADDRCONF(NETDEV_CHANGE): swp2: link becomes ready
[ 13.803141] mscc_felix 0000:00:00.5 swp3: Link is Up - 1Gbps/Full - flow control rx/tx
[ 13.811646] IPv6: ADDRCONF(NETDEV_CHANGE): swp3: link becomes ready
[ 15.452018] ., OK
[ 15.470336] IP-Config: Got DHCP answer from 10.0.0.1, my address is 10.0.0.39
[ 15.477887] IP-Config: Complete:
[ 15.481330] device=swp3, hwaddr=00:04:9f:05:de:0a, ipaddr=10.0.0.39, mask=255.255.255.0, gw=10.0.0.1
[ 15.491846] host=10.0.0.39, domain=(none), nis-domain=(none)
[ 15.498429] bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath=
[ 15.498481] nameserver0=8.8.8.8
[ 15.627542] fsl_enetc 0000:00:00.0 eth0: Link is Down
[ 15.690903] mscc_felix 0000:00:00.5 swp0: Link is Down
[ 15.745216] mscc_felix 0000:00:00.5 swp1: Link is Down
[ 15.800498] mscc_felix 0000:00:00.5 swp2: Link is Down
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-02-05 13:37:13 +00:00
|
|
|
/* Close all network interfaces except the one we've autoconfigured, and its
|
|
|
|
* lowers, in case it's a stacked virtual interface.
|
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
static void __init ic_close_devs(void)
|
|
|
|
{
|
2021-03-22 00:26:37 +00:00
|
|
|
struct net_device *selected_dev = ic_dev ? ic_dev->dev : NULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct ic_device *d, *next;
|
|
|
|
struct net_device *dev;
|
|
|
|
|
2006-03-21 06:23:58 +00:00
|
|
|
rtnl_lock();
|
2005-04-16 22:20:36 +00:00
|
|
|
next = ic_first_dev;
|
|
|
|
while ((d = next)) {
|
Revert "net: ipv4: handle DSA enabled master network devices"
This reverts commit 728c02089a0e3eefb02e9927bfae50490f40e72e.
Since 2015 DSA has gained more integration with the network stack, we
can now have the same functionality without explicitly open-coding for
it:
- It now opens the DSA master netdevice automatically whenever a user
netdevice is opened.
- The master and switch interfaces are coupled in an upper/lower
hierarchy using the netdev adjacency lists.
In the nfsroot example below, the interface chosen by autoconfig was
swp3, and every interface except that and the DSA master, eth1, was
brought down afterwards:
[ 8.714215] mscc_felix 0000:00:00.5 swp0 (uninitialized): PHY [0000:00:00.3:10] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 8.978041] mscc_felix 0000:00:00.5 swp1 (uninitialized): PHY [0000:00:00.3:11] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.246134] mscc_felix 0000:00:00.5 swp2 (uninitialized): PHY [0000:00:00.3:12] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.486203] mscc_felix 0000:00:00.5 swp3 (uninitialized): PHY [0000:00:00.3:13] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.512827] mscc_felix 0000:00:00.5: configuring for fixed/internal link mode
[ 9.521047] mscc_felix 0000:00:00.5: Link is Up - 2.5Gbps/Full - flow control off
[ 9.530382] device eth1 entered promiscuous mode
[ 9.535452] DSA: tree 0 setup
[ 9.539777] printk: console [netcon0] enabled
[ 9.544504] netconsole: network logging started
[ 9.555047] fsl_enetc 0000:00:00.2 eth1: configuring for fixed/internal link mode
[ 9.562790] fsl_enetc 0000:00:00.2 eth1: Link is Up - 1Gbps/Full - flow control off
[ 9.564661] 8021q: adding VLAN 0 to HW filter on device bond0
[ 9.637681] fsl_enetc 0000:00:00.0 eth0: PHY [0000:00:00.0:02] driver [Qualcomm Atheros AR8031/AR8033] (irq=POLL)
[ 9.655679] fsl_enetc 0000:00:00.0 eth0: configuring for inband/sgmii link mode
[ 9.666611] mscc_felix 0000:00:00.5 swp0: configuring for inband/qsgmii link mode
[ 9.676216] 8021q: adding VLAN 0 to HW filter on device swp0
[ 9.682086] mscc_felix 0000:00:00.5 swp1: configuring for inband/qsgmii link mode
[ 9.690700] 8021q: adding VLAN 0 to HW filter on device swp1
[ 9.696538] mscc_felix 0000:00:00.5 swp2: configuring for inband/qsgmii link mode
[ 9.705131] 8021q: adding VLAN 0 to HW filter on device swp2
[ 9.710964] mscc_felix 0000:00:00.5 swp3: configuring for inband/qsgmii link mode
[ 9.719548] 8021q: adding VLAN 0 to HW filter on device swp3
[ 9.747811] Sending DHCP requests ..
[ 12.742899] mscc_felix 0000:00:00.5 swp1: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.743828] mscc_felix 0000:00:00.5 swp0: Link is Up - 1Gbps/Full - flow control off
[ 12.747062] IPv6: ADDRCONF(NETDEV_CHANGE): swp1: link becomes ready
[ 12.755216] fsl_enetc 0000:00:00.0 eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.766603] IPv6: ADDRCONF(NETDEV_CHANGE): swp0: link becomes ready
[ 12.783188] mscc_felix 0000:00:00.5 swp2: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.785354] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 12.799535] IPv6: ADDRCONF(NETDEV_CHANGE): swp2: link becomes ready
[ 13.803141] mscc_felix 0000:00:00.5 swp3: Link is Up - 1Gbps/Full - flow control rx/tx
[ 13.811646] IPv6: ADDRCONF(NETDEV_CHANGE): swp3: link becomes ready
[ 15.452018] ., OK
[ 15.470336] IP-Config: Got DHCP answer from 10.0.0.1, my address is 10.0.0.39
[ 15.477887] IP-Config: Complete:
[ 15.481330] device=swp3, hwaddr=00:04:9f:05:de:0a, ipaddr=10.0.0.39, mask=255.255.255.0, gw=10.0.0.1
[ 15.491846] host=10.0.0.39, domain=(none), nis-domain=(none)
[ 15.498429] bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath=
[ 15.498481] nameserver0=8.8.8.8
[ 15.627542] fsl_enetc 0000:00:00.0 eth0: Link is Down
[ 15.690903] mscc_felix 0000:00:00.5 swp0: Link is Down
[ 15.745216] mscc_felix 0000:00:00.5 swp1: Link is Down
[ 15.800498] mscc_felix 0000:00:00.5 swp2: Link is Down
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-02-05 13:37:13 +00:00
|
|
|
bool bring_down = (d != ic_dev);
|
2021-03-22 00:26:37 +00:00
|
|
|
struct net_device *lower;
|
Revert "net: ipv4: handle DSA enabled master network devices"
This reverts commit 728c02089a0e3eefb02e9927bfae50490f40e72e.
Since 2015 DSA has gained more integration with the network stack, we
can now have the same functionality without explicitly open-coding for
it:
- It now opens the DSA master netdevice automatically whenever a user
netdevice is opened.
- The master and switch interfaces are coupled in an upper/lower
hierarchy using the netdev adjacency lists.
In the nfsroot example below, the interface chosen by autoconfig was
swp3, and every interface except that and the DSA master, eth1, was
brought down afterwards:
[ 8.714215] mscc_felix 0000:00:00.5 swp0 (uninitialized): PHY [0000:00:00.3:10] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 8.978041] mscc_felix 0000:00:00.5 swp1 (uninitialized): PHY [0000:00:00.3:11] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.246134] mscc_felix 0000:00:00.5 swp2 (uninitialized): PHY [0000:00:00.3:12] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.486203] mscc_felix 0000:00:00.5 swp3 (uninitialized): PHY [0000:00:00.3:13] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.512827] mscc_felix 0000:00:00.5: configuring for fixed/internal link mode
[ 9.521047] mscc_felix 0000:00:00.5: Link is Up - 2.5Gbps/Full - flow control off
[ 9.530382] device eth1 entered promiscuous mode
[ 9.535452] DSA: tree 0 setup
[ 9.539777] printk: console [netcon0] enabled
[ 9.544504] netconsole: network logging started
[ 9.555047] fsl_enetc 0000:00:00.2 eth1: configuring for fixed/internal link mode
[ 9.562790] fsl_enetc 0000:00:00.2 eth1: Link is Up - 1Gbps/Full - flow control off
[ 9.564661] 8021q: adding VLAN 0 to HW filter on device bond0
[ 9.637681] fsl_enetc 0000:00:00.0 eth0: PHY [0000:00:00.0:02] driver [Qualcomm Atheros AR8031/AR8033] (irq=POLL)
[ 9.655679] fsl_enetc 0000:00:00.0 eth0: configuring for inband/sgmii link mode
[ 9.666611] mscc_felix 0000:00:00.5 swp0: configuring for inband/qsgmii link mode
[ 9.676216] 8021q: adding VLAN 0 to HW filter on device swp0
[ 9.682086] mscc_felix 0000:00:00.5 swp1: configuring for inband/qsgmii link mode
[ 9.690700] 8021q: adding VLAN 0 to HW filter on device swp1
[ 9.696538] mscc_felix 0000:00:00.5 swp2: configuring for inband/qsgmii link mode
[ 9.705131] 8021q: adding VLAN 0 to HW filter on device swp2
[ 9.710964] mscc_felix 0000:00:00.5 swp3: configuring for inband/qsgmii link mode
[ 9.719548] 8021q: adding VLAN 0 to HW filter on device swp3
[ 9.747811] Sending DHCP requests ..
[ 12.742899] mscc_felix 0000:00:00.5 swp1: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.743828] mscc_felix 0000:00:00.5 swp0: Link is Up - 1Gbps/Full - flow control off
[ 12.747062] IPv6: ADDRCONF(NETDEV_CHANGE): swp1: link becomes ready
[ 12.755216] fsl_enetc 0000:00:00.0 eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.766603] IPv6: ADDRCONF(NETDEV_CHANGE): swp0: link becomes ready
[ 12.783188] mscc_felix 0000:00:00.5 swp2: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.785354] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 12.799535] IPv6: ADDRCONF(NETDEV_CHANGE): swp2: link becomes ready
[ 13.803141] mscc_felix 0000:00:00.5 swp3: Link is Up - 1Gbps/Full - flow control rx/tx
[ 13.811646] IPv6: ADDRCONF(NETDEV_CHANGE): swp3: link becomes ready
[ 15.452018] ., OK
[ 15.470336] IP-Config: Got DHCP answer from 10.0.0.1, my address is 10.0.0.39
[ 15.477887] IP-Config: Complete:
[ 15.481330] device=swp3, hwaddr=00:04:9f:05:de:0a, ipaddr=10.0.0.39, mask=255.255.255.0, gw=10.0.0.1
[ 15.491846] host=10.0.0.39, domain=(none), nis-domain=(none)
[ 15.498429] bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath=
[ 15.498481] nameserver0=8.8.8.8
[ 15.627542] fsl_enetc 0000:00:00.0 eth0: Link is Down
[ 15.690903] mscc_felix 0000:00:00.5 swp0: Link is Down
[ 15.745216] mscc_felix 0000:00:00.5 swp1: Link is Down
[ 15.800498] mscc_felix 0000:00:00.5 swp2: Link is Down
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-02-05 13:37:13 +00:00
|
|
|
struct list_head *iter;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
next = d->next;
|
|
|
|
dev = d->dev;
|
Revert "net: ipv4: handle DSA enabled master network devices"
This reverts commit 728c02089a0e3eefb02e9927bfae50490f40e72e.
Since 2015 DSA has gained more integration with the network stack, we
can now have the same functionality without explicitly open-coding for
it:
- It now opens the DSA master netdevice automatically whenever a user
netdevice is opened.
- The master and switch interfaces are coupled in an upper/lower
hierarchy using the netdev adjacency lists.
In the nfsroot example below, the interface chosen by autoconfig was
swp3, and every interface except that and the DSA master, eth1, was
brought down afterwards:
[ 8.714215] mscc_felix 0000:00:00.5 swp0 (uninitialized): PHY [0000:00:00.3:10] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 8.978041] mscc_felix 0000:00:00.5 swp1 (uninitialized): PHY [0000:00:00.3:11] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.246134] mscc_felix 0000:00:00.5 swp2 (uninitialized): PHY [0000:00:00.3:12] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.486203] mscc_felix 0000:00:00.5 swp3 (uninitialized): PHY [0000:00:00.3:13] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.512827] mscc_felix 0000:00:00.5: configuring for fixed/internal link mode
[ 9.521047] mscc_felix 0000:00:00.5: Link is Up - 2.5Gbps/Full - flow control off
[ 9.530382] device eth1 entered promiscuous mode
[ 9.535452] DSA: tree 0 setup
[ 9.539777] printk: console [netcon0] enabled
[ 9.544504] netconsole: network logging started
[ 9.555047] fsl_enetc 0000:00:00.2 eth1: configuring for fixed/internal link mode
[ 9.562790] fsl_enetc 0000:00:00.2 eth1: Link is Up - 1Gbps/Full - flow control off
[ 9.564661] 8021q: adding VLAN 0 to HW filter on device bond0
[ 9.637681] fsl_enetc 0000:00:00.0 eth0: PHY [0000:00:00.0:02] driver [Qualcomm Atheros AR8031/AR8033] (irq=POLL)
[ 9.655679] fsl_enetc 0000:00:00.0 eth0: configuring for inband/sgmii link mode
[ 9.666611] mscc_felix 0000:00:00.5 swp0: configuring for inband/qsgmii link mode
[ 9.676216] 8021q: adding VLAN 0 to HW filter on device swp0
[ 9.682086] mscc_felix 0000:00:00.5 swp1: configuring for inband/qsgmii link mode
[ 9.690700] 8021q: adding VLAN 0 to HW filter on device swp1
[ 9.696538] mscc_felix 0000:00:00.5 swp2: configuring for inband/qsgmii link mode
[ 9.705131] 8021q: adding VLAN 0 to HW filter on device swp2
[ 9.710964] mscc_felix 0000:00:00.5 swp3: configuring for inband/qsgmii link mode
[ 9.719548] 8021q: adding VLAN 0 to HW filter on device swp3
[ 9.747811] Sending DHCP requests ..
[ 12.742899] mscc_felix 0000:00:00.5 swp1: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.743828] mscc_felix 0000:00:00.5 swp0: Link is Up - 1Gbps/Full - flow control off
[ 12.747062] IPv6: ADDRCONF(NETDEV_CHANGE): swp1: link becomes ready
[ 12.755216] fsl_enetc 0000:00:00.0 eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.766603] IPv6: ADDRCONF(NETDEV_CHANGE): swp0: link becomes ready
[ 12.783188] mscc_felix 0000:00:00.5 swp2: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.785354] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 12.799535] IPv6: ADDRCONF(NETDEV_CHANGE): swp2: link becomes ready
[ 13.803141] mscc_felix 0000:00:00.5 swp3: Link is Up - 1Gbps/Full - flow control rx/tx
[ 13.811646] IPv6: ADDRCONF(NETDEV_CHANGE): swp3: link becomes ready
[ 15.452018] ., OK
[ 15.470336] IP-Config: Got DHCP answer from 10.0.0.1, my address is 10.0.0.39
[ 15.477887] IP-Config: Complete:
[ 15.481330] device=swp3, hwaddr=00:04:9f:05:de:0a, ipaddr=10.0.0.39, mask=255.255.255.0, gw=10.0.0.1
[ 15.491846] host=10.0.0.39, domain=(none), nis-domain=(none)
[ 15.498429] bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath=
[ 15.498481] nameserver0=8.8.8.8
[ 15.627542] fsl_enetc 0000:00:00.0 eth0: Link is Down
[ 15.690903] mscc_felix 0000:00:00.5 swp0: Link is Down
[ 15.745216] mscc_felix 0000:00:00.5 swp1: Link is Down
[ 15.800498] mscc_felix 0000:00:00.5 swp2: Link is Down
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-02-05 13:37:13 +00:00
|
|
|
|
2021-03-22 00:26:37 +00:00
|
|
|
if (selected_dev) {
|
|
|
|
netdev_for_each_lower_dev(selected_dev, lower, iter) {
|
|
|
|
if (dev == lower) {
|
|
|
|
bring_down = false;
|
|
|
|
break;
|
|
|
|
}
|
Revert "net: ipv4: handle DSA enabled master network devices"
This reverts commit 728c02089a0e3eefb02e9927bfae50490f40e72e.
Since 2015 DSA has gained more integration with the network stack, we
can now have the same functionality without explicitly open-coding for
it:
- It now opens the DSA master netdevice automatically whenever a user
netdevice is opened.
- The master and switch interfaces are coupled in an upper/lower
hierarchy using the netdev adjacency lists.
In the nfsroot example below, the interface chosen by autoconfig was
swp3, and every interface except that and the DSA master, eth1, was
brought down afterwards:
[ 8.714215] mscc_felix 0000:00:00.5 swp0 (uninitialized): PHY [0000:00:00.3:10] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 8.978041] mscc_felix 0000:00:00.5 swp1 (uninitialized): PHY [0000:00:00.3:11] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.246134] mscc_felix 0000:00:00.5 swp2 (uninitialized): PHY [0000:00:00.3:12] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.486203] mscc_felix 0000:00:00.5 swp3 (uninitialized): PHY [0000:00:00.3:13] driver [Microsemi GE VSC8514 SyncE] (irq=POLL)
[ 9.512827] mscc_felix 0000:00:00.5: configuring for fixed/internal link mode
[ 9.521047] mscc_felix 0000:00:00.5: Link is Up - 2.5Gbps/Full - flow control off
[ 9.530382] device eth1 entered promiscuous mode
[ 9.535452] DSA: tree 0 setup
[ 9.539777] printk: console [netcon0] enabled
[ 9.544504] netconsole: network logging started
[ 9.555047] fsl_enetc 0000:00:00.2 eth1: configuring for fixed/internal link mode
[ 9.562790] fsl_enetc 0000:00:00.2 eth1: Link is Up - 1Gbps/Full - flow control off
[ 9.564661] 8021q: adding VLAN 0 to HW filter on device bond0
[ 9.637681] fsl_enetc 0000:00:00.0 eth0: PHY [0000:00:00.0:02] driver [Qualcomm Atheros AR8031/AR8033] (irq=POLL)
[ 9.655679] fsl_enetc 0000:00:00.0 eth0: configuring for inband/sgmii link mode
[ 9.666611] mscc_felix 0000:00:00.5 swp0: configuring for inband/qsgmii link mode
[ 9.676216] 8021q: adding VLAN 0 to HW filter on device swp0
[ 9.682086] mscc_felix 0000:00:00.5 swp1: configuring for inband/qsgmii link mode
[ 9.690700] 8021q: adding VLAN 0 to HW filter on device swp1
[ 9.696538] mscc_felix 0000:00:00.5 swp2: configuring for inband/qsgmii link mode
[ 9.705131] 8021q: adding VLAN 0 to HW filter on device swp2
[ 9.710964] mscc_felix 0000:00:00.5 swp3: configuring for inband/qsgmii link mode
[ 9.719548] 8021q: adding VLAN 0 to HW filter on device swp3
[ 9.747811] Sending DHCP requests ..
[ 12.742899] mscc_felix 0000:00:00.5 swp1: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.743828] mscc_felix 0000:00:00.5 swp0: Link is Up - 1Gbps/Full - flow control off
[ 12.747062] IPv6: ADDRCONF(NETDEV_CHANGE): swp1: link becomes ready
[ 12.755216] fsl_enetc 0000:00:00.0 eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.766603] IPv6: ADDRCONF(NETDEV_CHANGE): swp0: link becomes ready
[ 12.783188] mscc_felix 0000:00:00.5 swp2: Link is Up - 1Gbps/Full - flow control rx/tx
[ 12.785354] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 12.799535] IPv6: ADDRCONF(NETDEV_CHANGE): swp2: link becomes ready
[ 13.803141] mscc_felix 0000:00:00.5 swp3: Link is Up - 1Gbps/Full - flow control rx/tx
[ 13.811646] IPv6: ADDRCONF(NETDEV_CHANGE): swp3: link becomes ready
[ 15.452018] ., OK
[ 15.470336] IP-Config: Got DHCP answer from 10.0.0.1, my address is 10.0.0.39
[ 15.477887] IP-Config: Complete:
[ 15.481330] device=swp3, hwaddr=00:04:9f:05:de:0a, ipaddr=10.0.0.39, mask=255.255.255.0, gw=10.0.0.1
[ 15.491846] host=10.0.0.39, domain=(none), nis-domain=(none)
[ 15.498429] bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath=
[ 15.498481] nameserver0=8.8.8.8
[ 15.627542] fsl_enetc 0000:00:00.0 eth0: Link is Down
[ 15.690903] mscc_felix 0000:00:00.5 swp0: Link is Down
[ 15.745216] mscc_felix 0000:00:00.5 swp1: Link is Down
[ 15.800498] mscc_felix 0000:00:00.5 swp2: Link is Down
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-02-05 13:37:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (bring_down) {
|
2015-11-13 10:40:34 +00:00
|
|
|
pr_debug("IP-Config: Downing %s\n", dev->name);
|
2018-12-06 17:05:42 +00:00
|
|
|
dev_change_flags(dev, d->flags, NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
kfree(d);
|
|
|
|
}
|
2006-03-21 06:23:58 +00:00
|
|
|
rtnl_unlock();
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interface to various network functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline void
|
2006-11-08 08:19:38 +00:00
|
|
|
set_sockaddr(struct sockaddr_in *sin, __be32 addr, __be16 port)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
sin->sin_family = AF_INET;
|
|
|
|
sin->sin_addr.s_addr = addr;
|
|
|
|
sin->sin_port = port;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up interface addresses and routes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int __init ic_setup_if(void)
|
|
|
|
{
|
|
|
|
struct ifreq ir;
|
|
|
|
struct sockaddr_in *sin = (void *) &ir.ifr_ifru.ifru_addr;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
memset(&ir, 0, sizeof(ir));
|
2016-07-29 09:30:38 +00:00
|
|
|
strcpy(ir.ifr_ifrn.ifrn_name, ic_dev->dev->name);
|
2005-04-16 22:20:36 +00:00
|
|
|
set_sockaddr(sin, ic_myaddr, 0);
|
2017-07-01 11:53:12 +00:00
|
|
|
if ((err = devinet_ioctl(&init_net, SIOCSIFADDR, &ir)) < 0) {
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("IP-Config: Unable to set interface address (%d)\n",
|
|
|
|
err);
|
2005-04-16 22:20:36 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
set_sockaddr(sin, ic_netmask, 0);
|
2017-07-01 11:53:12 +00:00
|
|
|
if ((err = devinet_ioctl(&init_net, SIOCSIFNETMASK, &ir)) < 0) {
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("IP-Config: Unable to set interface netmask (%d)\n",
|
|
|
|
err);
|
2005-04-16 22:20:36 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
set_sockaddr(sin, ic_myaddr | ~ic_netmask, 0);
|
2017-07-01 11:53:12 +00:00
|
|
|
if ((err = devinet_ioctl(&init_net, SIOCSIFBRDADDR, &ir)) < 0) {
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("IP-Config: Unable to set interface broadcast address (%d)\n",
|
|
|
|
err);
|
2005-04-16 22:20:36 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2009-05-19 22:31:50 +00:00
|
|
|
/* Handle the case where we need non-standard MTU on the boot link (a network
|
|
|
|
* using jumbo frames, for instance). If we can't set the mtu, don't error
|
|
|
|
* out, we'll try to muddle along.
|
|
|
|
*/
|
|
|
|
if (ic_dev_mtu != 0) {
|
2017-10-02 00:27:01 +00:00
|
|
|
rtnl_lock();
|
|
|
|
if ((err = dev_set_mtu(ic_dev->dev, ic_dev_mtu)) < 0)
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("IP-Config: Unable to set interface mtu to %d (%d)\n",
|
|
|
|
ic_dev_mtu, err);
|
2017-10-02 00:27:01 +00:00
|
|
|
rtnl_unlock();
|
2009-05-19 22:31:50 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init ic_setup_routes(void)
|
|
|
|
{
|
|
|
|
/* No need to setup device routes, only the default route... */
|
|
|
|
|
2006-11-08 08:19:38 +00:00
|
|
|
if (ic_gateway != NONE) {
|
2005-04-16 22:20:36 +00:00
|
|
|
struct rtentry rm;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
memset(&rm, 0, sizeof(rm));
|
|
|
|
if ((ic_gateway ^ ic_myaddr) & ic_netmask) {
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("IP-Config: Gateway not on directly connected network\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
set_sockaddr((struct sockaddr_in *) &rm.rt_dst, 0, 0);
|
|
|
|
set_sockaddr((struct sockaddr_in *) &rm.rt_genmask, 0, 0);
|
|
|
|
set_sockaddr((struct sockaddr_in *) &rm.rt_gateway, ic_gateway, 0);
|
|
|
|
rm.rt_flags = RTF_UP | RTF_GATEWAY;
|
2017-07-01 12:03:10 +00:00
|
|
|
if ((err = ip_rt_ioctl(&init_net, SIOCADDRT, &rm)) < 0) {
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("IP-Config: Cannot add default route (%d)\n",
|
|
|
|
err);
|
2005-04-16 22:20:36 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill in default values for all missing parameters.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int __init ic_defaults(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* At this point we have no userspace running so need not
|
|
|
|
* claim locks on system_utsname
|
|
|
|
*/
|
2007-02-09 14:24:47 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!ic_host_name_set)
|
2008-10-31 07:53:57 +00:00
|
|
|
sprintf(init_utsname()->nodename, "%pI4", &ic_myaddr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-11-08 08:19:38 +00:00
|
|
|
if (root_server_addr == NONE)
|
2005-04-16 22:20:36 +00:00
|
|
|
root_server_addr = ic_servaddr;
|
|
|
|
|
2006-11-08 08:19:38 +00:00
|
|
|
if (ic_netmask == NONE) {
|
2005-04-16 22:20:36 +00:00
|
|
|
if (IN_CLASSA(ntohl(ic_myaddr)))
|
|
|
|
ic_netmask = htonl(IN_CLASSA_NET);
|
|
|
|
else if (IN_CLASSB(ntohl(ic_myaddr)))
|
|
|
|
ic_netmask = htonl(IN_CLASSB_NET);
|
|
|
|
else if (IN_CLASSC(ntohl(ic_myaddr)))
|
|
|
|
ic_netmask = htonl(IN_CLASSC_NET);
|
2018-12-11 23:30:34 +00:00
|
|
|
else if (IN_CLASSE(ntohl(ic_myaddr)))
|
|
|
|
ic_netmask = htonl(IN_CLASSE_NET);
|
2005-04-16 22:20:36 +00:00
|
|
|
else {
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("IP-Config: Unable to guess netmask for address %pI4\n",
|
|
|
|
&ic_myaddr);
|
2005-04-16 22:20:36 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2015-11-13 10:40:34 +00:00
|
|
|
pr_notice("IP-Config: Guessing netmask %pI4\n",
|
|
|
|
&ic_netmask);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RARP support.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef IPCONFIG_RARP
|
|
|
|
|
2005-08-10 02:34:12 +00:00
|
|
|
static int ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static struct packet_type rarp_packet_type __initdata = {
|
2009-02-01 08:45:17 +00:00
|
|
|
.type = cpu_to_be16(ETH_P_RARP),
|
2005-04-16 22:20:36 +00:00
|
|
|
.func = ic_rarp_recv,
|
|
|
|
};
|
|
|
|
|
2008-04-30 03:58:15 +00:00
|
|
|
static inline void __init ic_rarp_init(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
dev_add_pack(&rarp_packet_type);
|
|
|
|
}
|
|
|
|
|
2008-04-30 03:58:15 +00:00
|
|
|
static inline void __init ic_rarp_cleanup(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
dev_remove_pack(&rarp_packet_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Process received RARP packet.
|
|
|
|
*/
|
|
|
|
static int __init
|
2005-08-10 02:34:12 +00:00
|
|
|
ic_rarp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct arphdr *rarp;
|
|
|
|
unsigned char *rarp_ptr;
|
2006-11-08 08:19:38 +00:00
|
|
|
__be32 sip, tip;
|
2014-10-27 18:03:22 +00:00
|
|
|
unsigned char *tha; /* t for "target" */
|
2005-04-16 22:20:36 +00:00
|
|
|
struct ic_device *d;
|
|
|
|
|
2008-07-20 05:34:43 +00:00
|
|
|
if (!net_eq(dev_net(dev), &init_net))
|
2007-09-17 18:53:39 +00:00
|
|
|
goto drop;
|
|
|
|
|
2015-04-03 08:17:26 +00:00
|
|
|
skb = skb_share_check(skb, GFP_ATOMIC);
|
|
|
|
if (!skb)
|
2005-04-16 22:20:36 +00:00
|
|
|
return NET_RX_DROP;
|
|
|
|
|
|
|
|
if (!pskb_may_pull(skb, sizeof(struct arphdr)))
|
|
|
|
goto drop;
|
|
|
|
|
|
|
|
/* Basic sanity checks can be done without the lock. */
|
2007-04-26 01:04:18 +00:00
|
|
|
rarp = (struct arphdr *)skb_transport_header(skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* If this test doesn't pass, it's not IP, or we should
|
|
|
|
* ignore it anyway.
|
|
|
|
*/
|
|
|
|
if (rarp->ar_hln != dev->addr_len || dev->type != ntohs(rarp->ar_hrd))
|
|
|
|
goto drop;
|
|
|
|
|
|
|
|
/* If it's not a RARP reply, delete it. */
|
|
|
|
if (rarp->ar_op != htons(ARPOP_RREPLY))
|
|
|
|
goto drop;
|
|
|
|
|
|
|
|
/* If it's not Ethernet, delete it. */
|
|
|
|
if (rarp->ar_pro != htons(ETH_P_IP))
|
|
|
|
goto drop;
|
|
|
|
|
2008-03-03 20:20:57 +00:00
|
|
|
if (!pskb_may_pull(skb, arp_hdr_len(dev)))
|
2005-04-16 22:20:36 +00:00
|
|
|
goto drop;
|
|
|
|
|
|
|
|
/* OK, it is all there and looks valid, process... */
|
2007-04-26 01:04:18 +00:00
|
|
|
rarp = (struct arphdr *)skb_transport_header(skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
rarp_ptr = (unsigned char *) (rarp + 1);
|
|
|
|
|
|
|
|
/* One reply at a time, please. */
|
|
|
|
spin_lock(&ic_recv_lock);
|
|
|
|
|
|
|
|
/* If we already have a reply, just drop the packet */
|
|
|
|
if (ic_got_reply)
|
|
|
|
goto drop_unlock;
|
|
|
|
|
|
|
|
/* Find the ic_device that the packet arrived on */
|
|
|
|
d = ic_first_dev;
|
|
|
|
while (d && d->dev != dev)
|
|
|
|
d = d->next;
|
|
|
|
if (!d)
|
|
|
|
goto drop_unlock; /* should never happen */
|
|
|
|
|
|
|
|
/* Extract variable-width fields */
|
|
|
|
rarp_ptr += dev->addr_len;
|
|
|
|
memcpy(&sip, rarp_ptr, 4);
|
|
|
|
rarp_ptr += 4;
|
|
|
|
tha = rarp_ptr;
|
|
|
|
rarp_ptr += dev->addr_len;
|
|
|
|
memcpy(&tip, rarp_ptr, 4);
|
|
|
|
|
|
|
|
/* Discard packets which are not meant for us. */
|
|
|
|
if (memcmp(tha, dev->dev_addr, dev->addr_len))
|
|
|
|
goto drop_unlock;
|
|
|
|
|
|
|
|
/* Discard packets which are not from specified server. */
|
2006-11-08 08:19:38 +00:00
|
|
|
if (ic_servaddr != NONE && ic_servaddr != sip)
|
2005-04-16 22:20:36 +00:00
|
|
|
goto drop_unlock;
|
|
|
|
|
|
|
|
/* We have a winner! */
|
2016-07-29 09:30:38 +00:00
|
|
|
ic_dev = d;
|
2006-11-08 08:19:38 +00:00
|
|
|
if (ic_myaddr == NONE)
|
2005-04-16 22:20:36 +00:00
|
|
|
ic_myaddr = tip;
|
|
|
|
ic_servaddr = sip;
|
2013-01-03 18:02:12 +00:00
|
|
|
ic_addrservaddr = sip;
|
2005-04-16 22:20:36 +00:00
|
|
|
ic_got_reply = IC_RARP;
|
|
|
|
|
|
|
|
drop_unlock:
|
|
|
|
/* Show's over. Nothing to see here. */
|
|
|
|
spin_unlock(&ic_recv_lock);
|
|
|
|
|
|
|
|
drop:
|
|
|
|
/* Throw the packet out. */
|
|
|
|
kfree_skb(skb);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send RARP request packet over a single interface.
|
|
|
|
*/
|
|
|
|
static void __init ic_rarp_send_if(struct ic_device *d)
|
|
|
|
{
|
|
|
|
struct net_device *dev = d->dev;
|
|
|
|
arp_send(ARPOP_RREQUEST, ETH_P_RARP, 0, dev, 0, NULL,
|
|
|
|
dev->dev_addr, dev->dev_addr);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-09-24 22:09:58 +00:00
|
|
|
/*
|
|
|
|
* Predefine Nameservers
|
|
|
|
*/
|
|
|
|
static inline void __init ic_nameservers_predef(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < CONF_NAMESERVERS_MAX; i++)
|
|
|
|
ic_nameservers[i] = NONE;
|
|
|
|
}
|
|
|
|
|
2018-04-24 02:56:39 +00:00
|
|
|
/* Predefine NTP servers */
|
|
|
|
static inline void __init ic_ntp_servers_predef(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < CONF_NTP_SERVERS_MAX; i++)
|
|
|
|
ic_ntp_servers[i] = NONE;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* DHCP/BOOTP support.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef IPCONFIG_BOOTP
|
|
|
|
|
|
|
|
struct bootp_pkt { /* BOOTP packet format */
|
|
|
|
struct iphdr iph; /* IP header */
|
|
|
|
struct udphdr udph; /* UDP header */
|
|
|
|
u8 op; /* 1=request, 2=reply */
|
|
|
|
u8 htype; /* HW address type */
|
|
|
|
u8 hlen; /* HW address length */
|
|
|
|
u8 hops; /* Used only by gateways */
|
2006-11-08 08:19:38 +00:00
|
|
|
__be32 xid; /* Transaction ID */
|
|
|
|
__be16 secs; /* Seconds since we started */
|
|
|
|
__be16 flags; /* Just what it says */
|
|
|
|
__be32 client_ip; /* Client's IP address if known */
|
|
|
|
__be32 your_ip; /* Assigned IP address */
|
|
|
|
__be32 server_ip; /* (Next, e.g. NFS) Server's IP address */
|
|
|
|
__be32 relay_ip; /* IP address of BOOTP relay */
|
2005-04-16 22:20:36 +00:00
|
|
|
u8 hw_addr[16]; /* Client's HW address */
|
|
|
|
u8 serv_name[64]; /* Server host name */
|
|
|
|
u8 boot_file[128]; /* Name of boot file */
|
|
|
|
u8 exten[312]; /* DHCP options / BOOTP vendor extensions */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* packet ops */
|
|
|
|
#define BOOTP_REQUEST 1
|
|
|
|
#define BOOTP_REPLY 2
|
|
|
|
|
|
|
|
/* DHCP message types */
|
|
|
|
#define DHCPDISCOVER 1
|
|
|
|
#define DHCPOFFER 2
|
|
|
|
#define DHCPREQUEST 3
|
|
|
|
#define DHCPDECLINE 4
|
|
|
|
#define DHCPACK 5
|
|
|
|
#define DHCPNAK 6
|
|
|
|
#define DHCPRELEASE 7
|
|
|
|
#define DHCPINFORM 8
|
|
|
|
|
2005-08-10 02:34:12 +00:00
|
|
|
static int ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static struct packet_type bootp_packet_type __initdata = {
|
2009-02-01 08:45:17 +00:00
|
|
|
.type = cpu_to_be16(ETH_P_IP),
|
2005-04-16 22:20:36 +00:00
|
|
|
.func = ic_bootp_recv,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize DHCP/BOOTP extension fields in the request.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static const u8 ic_bootp_cookie[4] = { 99, 130, 83, 99 };
|
|
|
|
|
|
|
|
#ifdef IPCONFIG_DHCP
|
|
|
|
|
|
|
|
static void __init
|
2016-07-29 09:30:37 +00:00
|
|
|
ic_dhcp_init_options(u8 *options, struct ic_device *d)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-11-08 08:19:38 +00:00
|
|
|
u8 mt = ((ic_servaddr == NONE)
|
2005-04-16 22:20:36 +00:00
|
|
|
? DHCPDISCOVER : DHCPREQUEST);
|
|
|
|
u8 *e = options;
|
2007-11-14 10:18:39 +00:00
|
|
|
int len;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2016-07-29 09:30:37 +00:00
|
|
|
pr_debug("DHCP: Sending message type %d (%s)\n", mt, d->dev->name);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
memcpy(e, ic_bootp_cookie, 4); /* RFC1048 Magic Cookie */
|
|
|
|
e += 4;
|
|
|
|
|
|
|
|
*e++ = 53; /* DHCP message type */
|
|
|
|
*e++ = 1;
|
|
|
|
*e++ = mt;
|
|
|
|
|
|
|
|
if (mt == DHCPREQUEST) {
|
|
|
|
*e++ = 54; /* Server ID (IP address) */
|
|
|
|
*e++ = 4;
|
|
|
|
memcpy(e, &ic_servaddr, 4);
|
|
|
|
e += 4;
|
|
|
|
|
|
|
|
*e++ = 50; /* Requested IP address */
|
|
|
|
*e++ = 4;
|
|
|
|
memcpy(e, &ic_myaddr, 4);
|
|
|
|
e += 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* always? */
|
|
|
|
{
|
|
|
|
static const u8 ic_req_params[] = {
|
|
|
|
1, /* Subnet mask */
|
|
|
|
3, /* Default gateway */
|
|
|
|
6, /* DNS server */
|
|
|
|
12, /* Host name */
|
|
|
|
15, /* Domain name */
|
|
|
|
17, /* Boot path */
|
2009-05-19 22:31:50 +00:00
|
|
|
26, /* MTU */
|
2005-04-16 22:20:36 +00:00
|
|
|
40, /* NIS domain name */
|
2018-04-24 02:56:39 +00:00
|
|
|
42, /* NTP servers */
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
*e++ = 55; /* Parameter request list */
|
|
|
|
*e++ = sizeof(ic_req_params);
|
|
|
|
memcpy(e, ic_req_params, sizeof(ic_req_params));
|
|
|
|
e += sizeof(ic_req_params);
|
2007-11-14 10:18:39 +00:00
|
|
|
|
2010-05-30 17:19:53 +00:00
|
|
|
if (ic_host_name_set) {
|
|
|
|
*e++ = 12; /* host-name */
|
|
|
|
len = strlen(utsname()->nodename);
|
|
|
|
*e++ = len;
|
|
|
|
memcpy(e, utsname()->nodename, len);
|
|
|
|
e += len;
|
|
|
|
}
|
2007-11-14 10:18:39 +00:00
|
|
|
if (*vendor_class_identifier) {
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_info("DHCP: sending class identifier \"%s\"\n",
|
|
|
|
vendor_class_identifier);
|
2007-11-14 10:18:39 +00:00
|
|
|
*e++ = 60; /* Class-identifier */
|
|
|
|
len = strlen(vendor_class_identifier);
|
|
|
|
*e++ = len;
|
|
|
|
memcpy(e, vendor_class_identifier, len);
|
|
|
|
e += len;
|
|
|
|
}
|
2015-10-15 08:54:36 +00:00
|
|
|
len = strlen(dhcp_client_identifier + 1);
|
|
|
|
/* the minimum length of identifier is 2, include 1 byte type,
|
|
|
|
* and can not be larger than the length of options
|
|
|
|
*/
|
|
|
|
if (len >= 1 && len < 312 - (e - options) - 1) {
|
|
|
|
*e++ = 61;
|
|
|
|
*e++ = len + 1;
|
|
|
|
memcpy(e, dhcp_client_identifier, len + 1);
|
|
|
|
e += len + 1;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*e++ = 255; /* End of the list */
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* IPCONFIG_DHCP */
|
|
|
|
|
|
|
|
static void __init ic_bootp_init_ext(u8 *e)
|
|
|
|
{
|
|
|
|
memcpy(e, ic_bootp_cookie, 4); /* RFC1048 Magic Cookie */
|
|
|
|
e += 4;
|
|
|
|
*e++ = 1; /* Subnet mask request */
|
|
|
|
*e++ = 4;
|
|
|
|
e += 4;
|
|
|
|
*e++ = 3; /* Default gateway request */
|
|
|
|
*e++ = 4;
|
|
|
|
e += 4;
|
2018-04-24 02:56:35 +00:00
|
|
|
#if CONF_NAMESERVERS_MAX > 0
|
2018-04-24 02:56:34 +00:00
|
|
|
*e++ = 6; /* (DNS) name server request */
|
2018-04-24 02:56:35 +00:00
|
|
|
*e++ = 4 * CONF_NAMESERVERS_MAX;
|
|
|
|
e += 4 * CONF_NAMESERVERS_MAX;
|
|
|
|
#endif
|
2005-04-16 22:20:36 +00:00
|
|
|
*e++ = 12; /* Host name request */
|
|
|
|
*e++ = 32;
|
|
|
|
e += 32;
|
|
|
|
*e++ = 40; /* NIS Domain name request */
|
|
|
|
*e++ = 32;
|
|
|
|
e += 32;
|
|
|
|
*e++ = 17; /* Boot path */
|
|
|
|
*e++ = 40;
|
|
|
|
e += 40;
|
|
|
|
|
2007-02-09 14:24:47 +00:00
|
|
|
*e++ = 57; /* set extension buffer size for reply */
|
2005-04-16 22:20:36 +00:00
|
|
|
*e++ = 2;
|
2007-02-09 14:24:47 +00:00
|
|
|
*e++ = 1; /* 128+236+8+20+14, see dhcpd sources */
|
2005-04-16 22:20:36 +00:00
|
|
|
*e++ = 150;
|
|
|
|
|
|
|
|
*e++ = 255; /* End of the list */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-21 08:31:19 +00:00
|
|
|
/*
|
|
|
|
* Initialize the DHCP/BOOTP mechanism.
|
|
|
|
*/
|
|
|
|
static inline void __init ic_bootp_init(void)
|
|
|
|
{
|
2018-04-24 02:56:39 +00:00
|
|
|
/* Re-initialise all name servers and NTP servers to NONE, in case any
|
|
|
|
* were set via the "ip=" or "nfsaddrs=" kernel command line parameters:
|
|
|
|
* any IP addresses specified there will already have been decoded but
|
|
|
|
* are no longer needed
|
2018-04-24 02:56:37 +00:00
|
|
|
*/
|
2012-09-21 08:31:19 +00:00
|
|
|
ic_nameservers_predef();
|
2018-04-24 02:56:39 +00:00
|
|
|
ic_ntp_servers_predef();
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
dev_add_pack(&bootp_packet_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DHCP/BOOTP cleanup.
|
|
|
|
*/
|
2008-04-30 03:58:15 +00:00
|
|
|
static inline void __init ic_bootp_cleanup(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
dev_remove_pack(&bootp_packet_type);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send DHCP/BOOTP request to single interface.
|
|
|
|
*/
|
|
|
|
static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_diff)
|
|
|
|
{
|
|
|
|
struct net_device *dev = d->dev;
|
|
|
|
struct sk_buff *skb;
|
|
|
|
struct bootp_pkt *b;
|
|
|
|
struct iphdr *h;
|
2011-11-18 02:20:04 +00:00
|
|
|
int hlen = LL_RESERVED_SPACE(dev);
|
|
|
|
int tlen = dev->needed_tailroom;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Allocate packet */
|
2011-11-18 02:20:04 +00:00
|
|
|
skb = alloc_skb(sizeof(struct bootp_pkt) + hlen + tlen + 15,
|
2008-05-13 03:48:31 +00:00
|
|
|
GFP_KERNEL);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!skb)
|
|
|
|
return;
|
2011-11-18 02:20:04 +00:00
|
|
|
skb_reserve(skb, hlen);
|
networking: convert many more places to skb_put_zero()
There were many places that my previous spatch didn't find,
as pointed out by yuan linyu in various patches.
The following spatch found many more and also removes the
now unnecessary casts:
@@
identifier p, p2;
expression len;
expression skb;
type t, t2;
@@
(
-p = skb_put(skb, len);
+p = skb_put_zero(skb, len);
|
-p = (t)skb_put(skb, len);
+p = skb_put_zero(skb, len);
)
... when != p
(
p2 = (t2)p;
-memset(p2, 0, len);
|
-memset(p, 0, len);
)
@@
type t, t2;
identifier p, p2;
expression skb;
@@
t *p;
...
(
-p = skb_put(skb, sizeof(t));
+p = skb_put_zero(skb, sizeof(t));
|
-p = (t *)skb_put(skb, sizeof(t));
+p = skb_put_zero(skb, sizeof(t));
)
... when != p
(
p2 = (t2)p;
-memset(p2, 0, sizeof(*p));
|
-memset(p, 0, sizeof(*p));
)
@@
expression skb, len;
@@
-memset(skb_put(skb, len), 0, len);
+skb_put_zero(skb, len);
Apply it to the tree (with one manual fixup to keep the
comment in vxlan.c, which spatch removed.)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 12:29:19 +00:00
|
|
|
b = skb_put_zero(skb, sizeof(struct bootp_pkt));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Construct IP header */
|
2007-03-10 22:27:27 +00:00
|
|
|
skb_reset_network_header(skb);
|
2007-04-21 05:47:35 +00:00
|
|
|
h = ip_hdr(skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
h->version = 4;
|
|
|
|
h->ihl = 5;
|
|
|
|
h->tot_len = htons(sizeof(struct bootp_pkt));
|
|
|
|
h->frag_off = htons(IP_DF);
|
|
|
|
h->ttl = 64;
|
|
|
|
h->protocol = IPPROTO_UDP;
|
2006-11-08 08:19:38 +00:00
|
|
|
h->daddr = htonl(INADDR_BROADCAST);
|
2005-04-16 22:20:36 +00:00
|
|
|
h->check = ip_fast_csum((unsigned char *) h, h->ihl);
|
|
|
|
|
|
|
|
/* Construct UDP header */
|
|
|
|
b->udph.source = htons(68);
|
|
|
|
b->udph.dest = htons(67);
|
|
|
|
b->udph.len = htons(sizeof(struct bootp_pkt) - sizeof(struct iphdr));
|
|
|
|
/* UDP checksum not calculated -- explicitly allowed in BOOTP RFC */
|
|
|
|
|
|
|
|
/* Construct DHCP/BOOTP header */
|
|
|
|
b->op = BOOTP_REQUEST;
|
|
|
|
if (dev->type < 256) /* check for false types */
|
|
|
|
b->htype = dev->type;
|
|
|
|
else if (dev->type == ARPHRD_FDDI)
|
|
|
|
b->htype = ARPHRD_ETHER;
|
|
|
|
else {
|
2015-11-13 10:40:34 +00:00
|
|
|
pr_warn("Unknown ARP type 0x%04x for device %s\n", dev->type,
|
|
|
|
dev->name);
|
2005-04-16 22:20:36 +00:00
|
|
|
b->htype = dev->type; /* can cause undefined behavior */
|
|
|
|
}
|
2008-03-05 01:03:49 +00:00
|
|
|
|
|
|
|
/* server_ip and your_ip address are both already zero per RFC2131 */
|
2005-04-16 22:20:36 +00:00
|
|
|
b->hlen = dev->addr_len;
|
|
|
|
memcpy(b->hw_addr, dev->dev_addr, dev->addr_len);
|
|
|
|
b->secs = htons(jiffies_diff / HZ);
|
|
|
|
b->xid = d->xid;
|
|
|
|
|
|
|
|
/* add DHCP options or BOOTP extensions */
|
|
|
|
#ifdef IPCONFIG_DHCP
|
|
|
|
if (ic_proto_enabled & IC_USE_DHCP)
|
2016-07-29 09:30:37 +00:00
|
|
|
ic_dhcp_init_options(b->exten, d);
|
2005-04-16 22:20:36 +00:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
ic_bootp_init_ext(b->exten);
|
|
|
|
|
|
|
|
/* Chain packet down the line... */
|
|
|
|
skb->dev = dev;
|
|
|
|
skb->protocol = htons(ETH_P_IP);
|
2007-10-09 08:36:32 +00:00
|
|
|
if (dev_hard_header(skb, dev, ntohs(skb->protocol),
|
2011-11-14 19:37:24 +00:00
|
|
|
dev->broadcast, dev->dev_addr, skb->len) < 0) {
|
|
|
|
kfree_skb(skb);
|
|
|
|
printk("E");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dev_queue_xmit(skb) < 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
printk("E");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2021-06-02 01:38:41 +00:00
|
|
|
* Copy BOOTP-supplied string
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
static int __init ic_bootp_string(char *dest, char *src, int len, int max)
|
|
|
|
{
|
|
|
|
if (!len)
|
|
|
|
return 0;
|
|
|
|
if (len > max-1)
|
|
|
|
len = max-1;
|
|
|
|
memcpy(dest, src, len);
|
|
|
|
dest[len] = '\0';
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Process BOOTP extensions.
|
|
|
|
*/
|
|
|
|
static void __init ic_do_bootp_ext(u8 *ext)
|
|
|
|
{
|
2012-01-16 19:27:39 +00:00
|
|
|
u8 servers;
|
|
|
|
int i;
|
|
|
|
__be16 mtu;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
u8 *c;
|
|
|
|
|
2015-11-13 10:40:34 +00:00
|
|
|
pr_debug("DHCP/BOOTP: Got extension %d:", *ext);
|
2007-03-09 04:44:43 +00:00
|
|
|
for (c=ext+2; c<ext+2+ext[1]; c++)
|
2015-11-13 10:40:34 +00:00
|
|
|
pr_debug(" %02x", *c);
|
|
|
|
pr_debug("\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
switch (*ext++) {
|
2011-07-01 09:43:05 +00:00
|
|
|
case 1: /* Subnet mask */
|
|
|
|
if (ic_netmask == NONE)
|
|
|
|
memcpy(&ic_netmask, ext+1, 4);
|
|
|
|
break;
|
|
|
|
case 3: /* Default gateway */
|
|
|
|
if (ic_gateway == NONE)
|
|
|
|
memcpy(&ic_gateway, ext+1, 4);
|
|
|
|
break;
|
|
|
|
case 6: /* DNS server */
|
|
|
|
servers= *ext/4;
|
|
|
|
if (servers > CONF_NAMESERVERS_MAX)
|
|
|
|
servers = CONF_NAMESERVERS_MAX;
|
|
|
|
for (i = 0; i < servers; i++) {
|
|
|
|
if (ic_nameservers[i] == NONE)
|
|
|
|
memcpy(&ic_nameservers[i], ext+1+4*i, 4);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 12: /* Host name */
|
2021-06-02 01:38:41 +00:00
|
|
|
if (!ic_host_name_set) {
|
|
|
|
ic_bootp_string(utsname()->nodename, ext+1, *ext,
|
|
|
|
__NEW_UTS_LEN);
|
|
|
|
ic_host_name_set = 1;
|
|
|
|
}
|
2011-07-01 09:43:05 +00:00
|
|
|
break;
|
|
|
|
case 15: /* Domain name (DNS) */
|
2021-06-02 01:38:41 +00:00
|
|
|
if (!ic_domain[0])
|
|
|
|
ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain));
|
2011-07-01 09:43:05 +00:00
|
|
|
break;
|
|
|
|
case 17: /* Root path */
|
|
|
|
if (!root_server_path[0])
|
|
|
|
ic_bootp_string(root_server_path, ext+1, *ext,
|
|
|
|
sizeof(root_server_path));
|
|
|
|
break;
|
|
|
|
case 26: /* Interface MTU */
|
|
|
|
memcpy(&mtu, ext+1, sizeof(mtu));
|
|
|
|
ic_dev_mtu = ntohs(mtu);
|
|
|
|
break;
|
|
|
|
case 40: /* NIS Domain name (_not_ DNS) */
|
|
|
|
ic_bootp_string(utsname()->domainname, ext+1, *ext,
|
|
|
|
__NEW_UTS_LEN);
|
|
|
|
break;
|
2018-04-24 02:56:39 +00:00
|
|
|
case 42: /* NTP servers */
|
|
|
|
servers = *ext / 4;
|
|
|
|
if (servers > CONF_NTP_SERVERS_MAX)
|
|
|
|
servers = CONF_NTP_SERVERS_MAX;
|
|
|
|
for (i = 0; i < servers; i++) {
|
|
|
|
if (ic_ntp_servers[i] == NONE)
|
|
|
|
memcpy(&ic_ntp_servers[i], ext+1+4*i, 4);
|
|
|
|
}
|
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Receive BOOTP reply.
|
|
|
|
*/
|
2005-08-10 02:34:12 +00:00
|
|
|
static int __init ic_bootp_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct bootp_pkt *b;
|
|
|
|
struct iphdr *h;
|
|
|
|
struct ic_device *d;
|
|
|
|
int len, ext_len;
|
|
|
|
|
2008-07-20 05:34:43 +00:00
|
|
|
if (!net_eq(dev_net(dev), &init_net))
|
2007-09-17 18:53:39 +00:00
|
|
|
goto drop;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Perform verifications before taking the lock. */
|
|
|
|
if (skb->pkt_type == PACKET_OTHERHOST)
|
|
|
|
goto drop;
|
|
|
|
|
2015-04-03 08:17:26 +00:00
|
|
|
skb = skb_share_check(skb, GFP_ATOMIC);
|
|
|
|
if (!skb)
|
2005-04-16 22:20:36 +00:00
|
|
|
return NET_RX_DROP;
|
|
|
|
|
|
|
|
if (!pskb_may_pull(skb,
|
|
|
|
sizeof(struct iphdr) +
|
|
|
|
sizeof(struct udphdr)))
|
|
|
|
goto drop;
|
|
|
|
|
2007-04-21 05:47:35 +00:00
|
|
|
b = (struct bootp_pkt *)skb_network_header(skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
h = &b->iph;
|
|
|
|
|
|
|
|
if (h->ihl != 5 || h->version != 4 || h->protocol != IPPROTO_UDP)
|
|
|
|
goto drop;
|
|
|
|
|
|
|
|
/* Fragments are not supported */
|
2011-06-22 03:33:34 +00:00
|
|
|
if (ip_is_fragment(h)) {
|
2012-05-13 21:56:26 +00:00
|
|
|
net_err_ratelimited("DHCP/BOOTP: Ignoring fragmented reply\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
goto drop;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (skb->len < ntohs(h->tot_len))
|
|
|
|
goto drop;
|
|
|
|
|
|
|
|
if (ip_fast_csum((char *) h, h->ihl))
|
|
|
|
goto drop;
|
|
|
|
|
|
|
|
if (b->udph.source != htons(67) || b->udph.dest != htons(68))
|
|
|
|
goto drop;
|
|
|
|
|
|
|
|
if (ntohs(h->tot_len) < ntohs(b->udph.len) + sizeof(struct iphdr))
|
|
|
|
goto drop;
|
|
|
|
|
|
|
|
len = ntohs(b->udph.len) - sizeof(struct udphdr);
|
|
|
|
ext_len = len - (sizeof(*b) -
|
|
|
|
sizeof(struct iphdr) -
|
|
|
|
sizeof(struct udphdr) -
|
|
|
|
sizeof(b->exten));
|
|
|
|
if (ext_len < 0)
|
|
|
|
goto drop;
|
|
|
|
|
|
|
|
/* Ok the front looks good, make sure we can get at the rest. */
|
|
|
|
if (!pskb_may_pull(skb, skb->len))
|
|
|
|
goto drop;
|
|
|
|
|
2007-04-21 05:47:35 +00:00
|
|
|
b = (struct bootp_pkt *)skb_network_header(skb);
|
2005-04-16 22:20:36 +00:00
|
|
|
h = &b->iph;
|
|
|
|
|
|
|
|
/* One reply at a time, please. */
|
|
|
|
spin_lock(&ic_recv_lock);
|
|
|
|
|
|
|
|
/* If we already have a reply, just drop the packet */
|
|
|
|
if (ic_got_reply)
|
|
|
|
goto drop_unlock;
|
|
|
|
|
|
|
|
/* Find the ic_device that the packet arrived on */
|
|
|
|
d = ic_first_dev;
|
|
|
|
while (d && d->dev != dev)
|
|
|
|
d = d->next;
|
|
|
|
if (!d)
|
|
|
|
goto drop_unlock; /* should never happen */
|
|
|
|
|
|
|
|
/* Is it a reply to our BOOTP request? */
|
|
|
|
if (b->op != BOOTP_REPLY ||
|
|
|
|
b->xid != d->xid) {
|
2016-07-29 09:30:37 +00:00
|
|
|
net_err_ratelimited("DHCP/BOOTP: Reply not for us on %s, op[%x] xid[%x]\n",
|
|
|
|
d->dev->name, b->op, b->xid);
|
2005-04-16 22:20:36 +00:00
|
|
|
goto drop_unlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Parse extensions */
|
|
|
|
if (ext_len >= 4 &&
|
|
|
|
!memcmp(b->exten, ic_bootp_cookie, 4)) { /* Check magic cookie */
|
2007-02-09 14:24:47 +00:00
|
|
|
u8 *end = (u8 *) b + ntohs(b->iph.tot_len);
|
2005-04-16 22:20:36 +00:00
|
|
|
u8 *ext;
|
|
|
|
|
|
|
|
#ifdef IPCONFIG_DHCP
|
|
|
|
if (ic_proto_enabled & IC_USE_DHCP) {
|
2006-11-08 08:19:38 +00:00
|
|
|
__be32 server_id = NONE;
|
2005-04-16 22:20:36 +00:00
|
|
|
int mt = 0;
|
|
|
|
|
|
|
|
ext = &b->exten[4];
|
|
|
|
while (ext < end && *ext != 0xff) {
|
|
|
|
u8 *opt = ext++;
|
|
|
|
if (*opt == 0) /* Padding */
|
|
|
|
continue;
|
|
|
|
ext += *ext + 1;
|
|
|
|
if (ext >= end)
|
|
|
|
break;
|
|
|
|
switch (*opt) {
|
|
|
|
case 53: /* Message type */
|
|
|
|
if (opt[1])
|
|
|
|
mt = opt[2];
|
|
|
|
break;
|
|
|
|
case 54: /* Server ID (IP address) */
|
|
|
|
if (opt[1] >= 4)
|
|
|
|
memcpy(&server_id, opt + 2, 4);
|
|
|
|
break;
|
2007-04-21 00:09:22 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2016-07-29 09:30:37 +00:00
|
|
|
pr_debug("DHCP: Got message type %d (%s)\n", mt, d->dev->name);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
switch (mt) {
|
|
|
|
case DHCPOFFER:
|
|
|
|
/* While in the process of accepting one offer,
|
|
|
|
* ignore all others.
|
|
|
|
*/
|
2006-11-08 08:19:38 +00:00
|
|
|
if (ic_myaddr != NONE)
|
2005-04-16 22:20:36 +00:00
|
|
|
goto drop_unlock;
|
|
|
|
|
|
|
|
/* Let's accept that offer. */
|
|
|
|
ic_myaddr = b->your_ip;
|
|
|
|
ic_servaddr = server_id;
|
2015-11-13 10:40:34 +00:00
|
|
|
pr_debug("DHCP: Offered address %pI4 by server %pI4\n",
|
|
|
|
&ic_myaddr, &b->iph.saddr);
|
2005-04-16 22:20:36 +00:00
|
|
|
/* The DHCP indicated server address takes
|
|
|
|
* precedence over the bootp header one if
|
|
|
|
* they are different.
|
|
|
|
*/
|
2006-11-08 08:19:38 +00:00
|
|
|
if ((server_id != NONE) &&
|
2005-04-16 22:20:36 +00:00
|
|
|
(b->server_ip != server_id))
|
|
|
|
b->server_ip = ic_servaddr;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DHCPACK:
|
|
|
|
if (memcmp(dev->dev_addr, b->hw_addr, dev->addr_len) != 0)
|
|
|
|
goto drop_unlock;
|
|
|
|
|
|
|
|
/* Yeah! */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* Urque. Forget it*/
|
2006-11-08 08:19:38 +00:00
|
|
|
ic_myaddr = NONE;
|
|
|
|
ic_servaddr = NONE;
|
2005-04-16 22:20:36 +00:00
|
|
|
goto drop_unlock;
|
2007-04-21 00:09:22 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
ic_dhcp_msgtype = mt;
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif /* IPCONFIG_DHCP */
|
|
|
|
|
|
|
|
ext = &b->exten[4];
|
|
|
|
while (ext < end && *ext != 0xff) {
|
|
|
|
u8 *opt = ext++;
|
|
|
|
if (*opt == 0) /* Padding */
|
|
|
|
continue;
|
|
|
|
ext += *ext + 1;
|
|
|
|
if (ext < end)
|
|
|
|
ic_do_bootp_ext(opt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We have a winner! */
|
2016-07-29 09:30:38 +00:00
|
|
|
ic_dev = d;
|
2005-04-16 22:20:36 +00:00
|
|
|
ic_myaddr = b->your_ip;
|
|
|
|
ic_servaddr = b->server_ip;
|
2013-01-03 18:02:12 +00:00
|
|
|
ic_addrservaddr = b->iph.saddr;
|
2006-11-08 08:19:38 +00:00
|
|
|
if (ic_gateway == NONE && b->relay_ip)
|
2005-04-16 22:20:36 +00:00
|
|
|
ic_gateway = b->relay_ip;
|
2006-11-08 08:19:38 +00:00
|
|
|
if (ic_nameservers[0] == NONE)
|
2005-04-16 22:20:36 +00:00
|
|
|
ic_nameservers[0] = ic_servaddr;
|
|
|
|
ic_got_reply = IC_BOOTP;
|
|
|
|
|
|
|
|
drop_unlock:
|
|
|
|
/* Show's over. Nothing to see here. */
|
|
|
|
spin_unlock(&ic_recv_lock);
|
|
|
|
|
|
|
|
drop:
|
|
|
|
/* Throw the packet out. */
|
|
|
|
kfree_skb(skb);
|
|
|
|
|
|
|
|
return 0;
|
2007-02-09 14:24:47 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Dynamic IP configuration -- DHCP, BOOTP, RARP.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef IPCONFIG_DYNAMIC
|
|
|
|
|
|
|
|
static int __init ic_dynamic(void)
|
|
|
|
{
|
|
|
|
int retries;
|
|
|
|
struct ic_device *d;
|
|
|
|
unsigned long start_jiffies, timeout, jiff;
|
|
|
|
int do_bootp = ic_proto_have_if & IC_BOOTP;
|
|
|
|
int do_rarp = ic_proto_have_if & IC_RARP;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If none of DHCP/BOOTP/RARP was selected, return with an error.
|
|
|
|
* This routine gets only called when some pieces of information
|
|
|
|
* are missing, and without DHCP/BOOTP/RARP we are unable to get it.
|
|
|
|
*/
|
|
|
|
if (!ic_proto_enabled) {
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("IP-Config: Incomplete network configuration information\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef IPCONFIG_BOOTP
|
|
|
|
if ((ic_proto_enabled ^ ic_proto_have_if) & IC_BOOTP)
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("DHCP/BOOTP: No suitable device found\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
#ifdef IPCONFIG_RARP
|
|
|
|
if ((ic_proto_enabled ^ ic_proto_have_if) & IC_RARP)
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("RARP: No suitable device found\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!ic_proto_have_if)
|
|
|
|
/* Error message already printed */
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Setup protocols
|
|
|
|
*/
|
|
|
|
#ifdef IPCONFIG_BOOTP
|
|
|
|
if (do_bootp)
|
|
|
|
ic_bootp_init();
|
|
|
|
#endif
|
|
|
|
#ifdef IPCONFIG_RARP
|
|
|
|
if (do_rarp)
|
|
|
|
ic_rarp_init();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send requests and wait, until we get an answer. This loop
|
|
|
|
* seems to be a terrible waste of CPU time, but actually there is
|
|
|
|
* only one process running at all, so we don't need to use any
|
|
|
|
* scheduler functions.
|
2007-02-09 14:24:47 +00:00
|
|
|
* [Actually we could now, but the nothing else running note still
|
2005-04-16 22:20:36 +00:00
|
|
|
* applies.. - AC]
|
|
|
|
*/
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_notice("Sending %s%s%s requests .",
|
|
|
|
do_bootp
|
|
|
|
? ((ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP") : "",
|
|
|
|
(do_bootp && do_rarp) ? " and " : "",
|
|
|
|
do_rarp ? "RARP" : "");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
start_jiffies = jiffies;
|
|
|
|
d = ic_first_dev;
|
|
|
|
retries = CONF_SEND_RETRIES;
|
|
|
|
get_random_bytes(&timeout, sizeof(timeout));
|
2012-04-15 05:58:06 +00:00
|
|
|
timeout = CONF_BASE_TIMEOUT + (timeout % (unsigned int) CONF_TIMEOUT_RANDOM);
|
2007-03-09 04:44:43 +00:00
|
|
|
for (;;) {
|
2014-07-10 05:25:18 +00:00
|
|
|
#ifdef IPCONFIG_BOOTP
|
2005-04-16 22:20:36 +00:00
|
|
|
if (do_bootp && (d->able & IC_BOOTP))
|
|
|
|
ic_bootp_send_if(d, jiffies - start_jiffies);
|
|
|
|
#endif
|
|
|
|
#ifdef IPCONFIG_RARP
|
|
|
|
if (do_rarp && (d->able & IC_RARP))
|
|
|
|
ic_rarp_send_if(d);
|
|
|
|
#endif
|
|
|
|
|
2016-07-29 09:30:39 +00:00
|
|
|
if (!d->next) {
|
|
|
|
jiff = jiffies + timeout;
|
|
|
|
while (time_before(jiffies, jiff) && !ic_got_reply)
|
|
|
|
schedule_timeout_uninterruptible(1);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef IPCONFIG_DHCP
|
|
|
|
/* DHCP isn't done until we get a DHCPACK. */
|
2009-11-23 18:41:23 +00:00
|
|
|
if ((ic_got_reply & IC_BOOTP) &&
|
|
|
|
(ic_proto_enabled & IC_USE_DHCP) &&
|
|
|
|
ic_dhcp_msgtype != DHCPACK) {
|
2005-04-16 22:20:36 +00:00
|
|
|
ic_got_reply = 0;
|
2016-07-29 09:30:38 +00:00
|
|
|
/* continue on device that got the reply */
|
|
|
|
d = ic_dev;
|
2015-11-24 13:08:23 +00:00
|
|
|
pr_cont(",");
|
2005-04-16 22:20:36 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
#endif /* IPCONFIG_DHCP */
|
|
|
|
|
|
|
|
if (ic_got_reply) {
|
2015-11-24 13:08:23 +00:00
|
|
|
pr_cont(" OK\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((d = d->next))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (! --retries) {
|
2015-11-24 13:08:23 +00:00
|
|
|
pr_cont(" timed out!\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
d = ic_first_dev;
|
|
|
|
|
|
|
|
timeout = timeout CONF_TIMEOUT_MULT;
|
|
|
|
if (timeout > CONF_TIMEOUT_MAX)
|
|
|
|
timeout = CONF_TIMEOUT_MAX;
|
|
|
|
|
2015-11-24 13:08:23 +00:00
|
|
|
pr_cont(".");
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef IPCONFIG_BOOTP
|
|
|
|
if (do_bootp)
|
|
|
|
ic_bootp_cleanup();
|
|
|
|
#endif
|
|
|
|
#ifdef IPCONFIG_RARP
|
|
|
|
if (do_rarp)
|
|
|
|
ic_rarp_cleanup();
|
|
|
|
#endif
|
|
|
|
|
2005-06-28 20:21:12 +00:00
|
|
|
if (!ic_got_reply) {
|
2006-11-08 08:19:38 +00:00
|
|
|
ic_myaddr = NONE;
|
2005-04-16 22:20:36 +00:00
|
|
|
return -1;
|
2005-06-28 20:21:12 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2015-11-24 13:08:23 +00:00
|
|
|
pr_info("IP-Config: Got %s answer from %pI4, my address is %pI4\n",
|
2007-02-09 14:24:47 +00:00
|
|
|
((ic_got_reply & IC_RARP) ? "RARP"
|
2015-11-13 10:40:34 +00:00
|
|
|
: (ic_proto_enabled & IC_USE_DHCP) ? "DHCP" : "BOOTP"),
|
2015-11-24 13:08:23 +00:00
|
|
|
&ic_addrservaddr, &ic_myaddr);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* IPCONFIG_DYNAMIC */
|
|
|
|
|
|
|
|
#ifdef CONFIG_PROC_FS
|
2018-05-13 19:48:30 +00:00
|
|
|
/* proc_dir_entry for /proc/net/ipconfig */
|
|
|
|
static struct proc_dir_entry *ipconfig_dir;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-04-24 02:56:39 +00:00
|
|
|
/* Name servers: */
|
2005-04-16 22:20:36 +00:00
|
|
|
static int pnp_seq_show(struct seq_file *seq, void *v)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (ic_proto_used & IC_PROTO)
|
|
|
|
seq_printf(seq, "#PROTO: %s\n",
|
|
|
|
(ic_proto_used & IC_RARP) ? "RARP"
|
|
|
|
: (ic_proto_used & IC_USE_DHCP) ? "DHCP" : "BOOTP");
|
|
|
|
else
|
|
|
|
seq_puts(seq, "#MANUAL\n");
|
|
|
|
|
|
|
|
if (ic_domain[0])
|
|
|
|
seq_printf(seq,
|
|
|
|
"domain %s\n", ic_domain);
|
|
|
|
for (i = 0; i < CONF_NAMESERVERS_MAX; i++) {
|
2006-11-08 08:19:38 +00:00
|
|
|
if (ic_nameservers[i] != NONE)
|
2008-10-31 07:53:57 +00:00
|
|
|
seq_printf(seq, "nameserver %pI4\n",
|
|
|
|
&ic_nameservers[i]);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2006-11-08 08:19:38 +00:00
|
|
|
if (ic_servaddr != NONE)
|
2008-10-31 07:53:57 +00:00
|
|
|
seq_printf(seq, "bootserver %pI4\n",
|
|
|
|
&ic_servaddr);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-04-24 02:56:38 +00:00
|
|
|
/* Create the /proc/net/ipconfig directory */
|
2018-04-24 02:56:39 +00:00
|
|
|
static int __init ipconfig_proc_net_init(void)
|
2018-04-24 02:56:38 +00:00
|
|
|
{
|
|
|
|
ipconfig_dir = proc_net_mkdir(&init_net, "ipconfig", init_net.proc_net);
|
|
|
|
if (!ipconfig_dir)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2018-04-24 02:56:39 +00:00
|
|
|
|
|
|
|
/* Create a new file under /proc/net/ipconfig */
|
|
|
|
static int ipconfig_proc_net_create(const char *name,
|
2020-02-04 01:37:17 +00:00
|
|
|
const struct proc_ops *proc_ops)
|
2018-04-24 02:56:39 +00:00
|
|
|
{
|
|
|
|
char *pname;
|
|
|
|
struct proc_dir_entry *p;
|
|
|
|
|
|
|
|
if (!ipconfig_dir)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
pname = kasprintf(GFP_KERNEL, "%s%s", "ipconfig/", name);
|
|
|
|
if (!pname)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2020-02-04 01:37:17 +00:00
|
|
|
p = proc_create(pname, 0444, init_net.proc_net, proc_ops);
|
2018-04-24 02:56:39 +00:00
|
|
|
kfree(pname);
|
|
|
|
if (!p)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write NTP server IP addresses to /proc/net/ipconfig/ntp_servers */
|
2020-02-04 01:37:17 +00:00
|
|
|
static int ntp_servers_show(struct seq_file *seq, void *v)
|
2018-04-24 02:56:39 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < CONF_NTP_SERVERS_MAX; i++) {
|
|
|
|
if (ic_ntp_servers[i] != NONE)
|
|
|
|
seq_printf(seq, "%pI4\n", &ic_ntp_servers[i]);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2020-02-04 01:37:17 +00:00
|
|
|
DEFINE_PROC_SHOW_ATTRIBUTE(ntp_servers);
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* CONFIG_PROC_FS */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Extract IP address from the parameter string if needed. Note that we
|
|
|
|
* need to have root_server_addr set _before_ IPConfig gets called as it
|
|
|
|
* can override it.
|
|
|
|
*/
|
2006-11-08 08:19:38 +00:00
|
|
|
__be32 __init root_nfs_parse_addr(char *name)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-11-08 08:19:38 +00:00
|
|
|
__be32 addr;
|
2005-04-16 22:20:36 +00:00
|
|
|
int octets = 0;
|
|
|
|
char *cp, *cq;
|
|
|
|
|
|
|
|
cp = cq = name;
|
|
|
|
while (octets < 4) {
|
|
|
|
while (*cp >= '0' && *cp <= '9')
|
|
|
|
cp++;
|
|
|
|
if (cp == cq || cp - cq > 3)
|
|
|
|
break;
|
|
|
|
if (*cp == '.' || octets == 3)
|
|
|
|
octets++;
|
|
|
|
if (octets < 4)
|
|
|
|
cp++;
|
|
|
|
cq = cp;
|
|
|
|
}
|
|
|
|
if (octets == 4 && (*cp == ':' || *cp == '\0')) {
|
|
|
|
if (*cp == ':')
|
|
|
|
*cp++ = '\0';
|
|
|
|
addr = in_aton(name);
|
|
|
|
memmove(name, cp, strlen(cp) + 1);
|
|
|
|
} else
|
2006-11-08 08:19:38 +00:00
|
|
|
addr = NONE;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
2010-03-12 08:00:17 +00:00
|
|
|
#define DEVICE_WAIT_MAX 12 /* 12 seconds */
|
|
|
|
|
|
|
|
static int __init wait_for_devices(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < DEVICE_WAIT_MAX; i++) {
|
|
|
|
struct net_device *dev;
|
|
|
|
int found = 0;
|
|
|
|
|
2019-11-20 16:02:36 +00:00
|
|
|
/* make sure deferred device probes are finished */
|
|
|
|
wait_for_device_probe();
|
|
|
|
|
2010-03-12 08:00:17 +00:00
|
|
|
rtnl_lock();
|
|
|
|
for_each_netdev(&init_net, dev) {
|
2011-05-19 10:14:06 +00:00
|
|
|
if (ic_is_init_dev(dev)) {
|
2010-03-12 08:00:17 +00:00
|
|
|
found = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rtnl_unlock();
|
|
|
|
if (found)
|
|
|
|
return 0;
|
|
|
|
ssleep(1);
|
|
|
|
}
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* IP Autoconfig dispatcher.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int __init ip_auto_config(void)
|
|
|
|
{
|
2006-11-08 08:19:38 +00:00
|
|
|
__be32 addr;
|
2009-01-30 00:19:13 +00:00
|
|
|
#ifdef IPCONFIG_DYNAMIC
|
|
|
|
int retries = CONF_OPEN_RETRIES;
|
|
|
|
#endif
|
2010-03-12 08:00:17 +00:00
|
|
|
int err;
|
2020-11-10 07:37:57 +00:00
|
|
|
unsigned int i, count;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2018-04-24 02:56:39 +00:00
|
|
|
/* Initialise all name servers and NTP servers to NONE (but only if the
|
|
|
|
* "ip=" or "nfsaddrs=" kernel command line parameters weren't decoded,
|
|
|
|
* otherwise we'll overwrite the IP addresses specified there)
|
2018-04-24 02:56:37 +00:00
|
|
|
*/
|
2018-04-24 02:56:39 +00:00
|
|
|
if (ic_set_manually == 0) {
|
2018-04-24 02:56:37 +00:00
|
|
|
ic_nameservers_predef();
|
2018-04-24 02:56:39 +00:00
|
|
|
ic_ntp_servers_predef();
|
|
|
|
}
|
2018-04-24 02:56:37 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef CONFIG_PROC_FS
|
2018-05-15 13:57:23 +00:00
|
|
|
proc_create_single("pnp", 0444, init_net.proc_net, pnp_seq_show);
|
2018-04-24 02:56:38 +00:00
|
|
|
|
2018-04-24 02:56:39 +00:00
|
|
|
if (ipconfig_proc_net_init() == 0)
|
2020-02-04 01:37:17 +00:00
|
|
|
ipconfig_proc_net_create("ntp_servers", &ntp_servers_proc_ops);
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* CONFIG_PROC_FS */
|
|
|
|
|
|
|
|
if (!ic_enable)
|
|
|
|
return 0;
|
|
|
|
|
2015-11-13 10:40:34 +00:00
|
|
|
pr_debug("IP-Config: Entered.\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef IPCONFIG_DYNAMIC
|
|
|
|
try_try_again:
|
|
|
|
#endif
|
2010-03-12 08:00:17 +00:00
|
|
|
/* Wait for devices to appear */
|
|
|
|
err = wait_for_devices();
|
|
|
|
if (err)
|
|
|
|
return err;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Setup all network devices */
|
2010-03-12 08:00:17 +00:00
|
|
|
err = ic_open_devs();
|
|
|
|
if (err)
|
|
|
|
return err;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Give drivers a chance to settle */
|
2011-05-19 10:14:06 +00:00
|
|
|
msleep(CONF_POST_OPEN);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the config information is insufficient (e.g., our IP address or
|
|
|
|
* IP address of the boot server is missing or we have multiple network
|
|
|
|
* interfaces and no default was set), use BOOTP or RARP to get the
|
|
|
|
* missing values.
|
|
|
|
*/
|
2006-11-08 08:19:38 +00:00
|
|
|
if (ic_myaddr == NONE ||
|
2019-10-01 17:10:28 +00:00
|
|
|
#if defined(CONFIG_ROOT_NFS) || defined(CONFIG_CIFS_ROOT)
|
2009-11-23 18:41:23 +00:00
|
|
|
(root_server_addr == NONE &&
|
|
|
|
ic_servaddr == NONE &&
|
2019-10-01 17:10:28 +00:00
|
|
|
(ROOT_DEV == Root_NFS || ROOT_DEV == Root_CIFS)) ||
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
ic_first_dev->next) {
|
|
|
|
#ifdef IPCONFIG_DYNAMIC
|
|
|
|
if (ic_dynamic() < 0) {
|
|
|
|
ic_close_devs();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* I don't know why, but sometimes the
|
|
|
|
* eepro100 driver (at least) gets upset and
|
|
|
|
* doesn't work the first time it's opened.
|
|
|
|
* But then if you close it and reopen it, it
|
|
|
|
* works just fine. So we need to try that at
|
|
|
|
* least once before giving up.
|
|
|
|
*
|
|
|
|
* Also, if the root will be NFS-mounted, we
|
|
|
|
* have nowhere to go if DHCP fails. So we
|
|
|
|
* just have to keep trying forever.
|
|
|
|
*
|
|
|
|
* -- Chip
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_ROOT_NFS
|
|
|
|
if (ROOT_DEV == Root_NFS) {
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("IP-Config: Retrying forever (NFS root)...\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
goto try_try_again;
|
|
|
|
}
|
|
|
|
#endif
|
2019-10-01 17:10:28 +00:00
|
|
|
#ifdef CONFIG_CIFS_ROOT
|
|
|
|
if (ROOT_DEV == Root_CIFS) {
|
|
|
|
pr_err("IP-Config: Retrying forever (CIFS root)...\n");
|
|
|
|
goto try_try_again;
|
|
|
|
}
|
|
|
|
#endif
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (--retries) {
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("IP-Config: Reopening network devices...\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
goto try_try_again;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Oh, well. At least we tried. */
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("IP-Config: Auto-configuration of network failed\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#else /* !DYNAMIC */
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_err("IP-Config: Incomplete network configuration information\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
ic_close_devs();
|
|
|
|
return -1;
|
|
|
|
#endif /* IPCONFIG_DYNAMIC */
|
|
|
|
} else {
|
|
|
|
/* Device selected manually or only one device -> use it */
|
2016-07-29 09:30:38 +00:00
|
|
|
ic_dev = ic_first_dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
addr = root_nfs_parse_addr(root_server_path);
|
2006-11-08 08:19:38 +00:00
|
|
|
if (root_server_addr == NONE)
|
2005-04-16 22:20:36 +00:00
|
|
|
root_server_addr = addr;
|
|
|
|
|
|
|
|
/*
|
2011-03-31 01:57:33 +00:00
|
|
|
* Use defaults wherever applicable.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
if (ic_defaults() < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Record which protocol was actually used.
|
|
|
|
*/
|
|
|
|
#ifdef IPCONFIG_DYNAMIC
|
|
|
|
ic_proto_used = ic_got_reply | (ic_proto_enabled & IC_USE_DHCP);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef IPCONFIG_SILENT
|
|
|
|
/*
|
|
|
|
* Clue in the operator.
|
|
|
|
*/
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_info("IP-Config: Complete:\n");
|
2012-10-25 01:15:43 +00:00
|
|
|
|
|
|
|
pr_info(" device=%s, hwaddr=%*phC, ipaddr=%pI4, mask=%pI4, gw=%pI4\n",
|
2016-07-29 09:30:38 +00:00
|
|
|
ic_dev->dev->name, ic_dev->dev->addr_len, ic_dev->dev->dev_addr,
|
2012-10-25 01:15:43 +00:00
|
|
|
&ic_myaddr, &ic_netmask, &ic_gateway);
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_info(" host=%s, domain=%s, nis-domain=%s\n",
|
|
|
|
utsname()->nodename, ic_domain, utsname()->domainname);
|
|
|
|
pr_info(" bootserver=%pI4, rootserver=%pI4, rootpath=%s",
|
|
|
|
&ic_servaddr, &root_server_addr, root_server_path);
|
2009-05-19 22:31:50 +00:00
|
|
|
if (ic_dev_mtu)
|
2012-03-11 18:36:11 +00:00
|
|
|
pr_cont(", mtu=%d", ic_dev_mtu);
|
ipconfig: Tidy up reporting of name servers
Commit 5e953778a2aab04929a5e7b69f53dc26e39b079e ("ipconfig: add
nameserver IPs to kernel-parameter ip=") adds the IP addresses of
discovered name servers to the summary printed by ipconfig when
configuration is complete. It appears the intention in ip_auto_config()
was to print the name servers on a new line (especially given the
spacing and lack of comma before "nameserver0="), but they're actually
printed on the same line as the NFS root filesystem configuration
summary:
[ 0.686186] IP-Config: Complete:
[ 0.686226] device=eth0, hwaddr=xx:xx:xx:xx:xx:xx, ipaddr=10.0.0.2, mask=255.255.255.0, gw=10.0.0.1
[ 0.686328] host=test, domain=example.com, nis-domain=(none)
[ 0.686386] bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath= nameserver0=10.0.0.1
This makes it harder to read and parse ipconfig's output. Instead, print
the name servers on a separate line:
[ 0.791250] IP-Config: Complete:
[ 0.791289] device=eth0, hwaddr=xx:xx:xx:xx:xx:xx, ipaddr=10.0.0.2, mask=255.255.255.0, gw=10.0.0.1
[ 0.791407] host=test, domain=example.com, nis-domain=(none)
[ 0.791475] bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath=
[ 0.791476] nameserver0=10.0.0.1
Signed-off-by: Chris Novakovic <chris@chrisn.me.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-04-24 02:56:33 +00:00
|
|
|
/* Name servers (if any): */
|
2020-11-10 07:37:57 +00:00
|
|
|
for (i = 0, count = 0; i < CONF_NAMESERVERS_MAX; i++) {
|
2012-09-21 08:31:19 +00:00
|
|
|
if (ic_nameservers[i] != NONE) {
|
ipconfig: Tidy up reporting of name servers
Commit 5e953778a2aab04929a5e7b69f53dc26e39b079e ("ipconfig: add
nameserver IPs to kernel-parameter ip=") adds the IP addresses of
discovered name servers to the summary printed by ipconfig when
configuration is complete. It appears the intention in ip_auto_config()
was to print the name servers on a new line (especially given the
spacing and lack of comma before "nameserver0="), but they're actually
printed on the same line as the NFS root filesystem configuration
summary:
[ 0.686186] IP-Config: Complete:
[ 0.686226] device=eth0, hwaddr=xx:xx:xx:xx:xx:xx, ipaddr=10.0.0.2, mask=255.255.255.0, gw=10.0.0.1
[ 0.686328] host=test, domain=example.com, nis-domain=(none)
[ 0.686386] bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath= nameserver0=10.0.0.1
This makes it harder to read and parse ipconfig's output. Instead, print
the name servers on a separate line:
[ 0.791250] IP-Config: Complete:
[ 0.791289] device=eth0, hwaddr=xx:xx:xx:xx:xx:xx, ipaddr=10.0.0.2, mask=255.255.255.0, gw=10.0.0.1
[ 0.791407] host=test, domain=example.com, nis-domain=(none)
[ 0.791475] bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath=
[ 0.791476] nameserver0=10.0.0.1
Signed-off-by: Chris Novakovic <chris@chrisn.me.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-04-24 02:56:33 +00:00
|
|
|
if (i == 0)
|
|
|
|
pr_info(" nameserver%u=%pI4",
|
|
|
|
i, &ic_nameservers[i]);
|
|
|
|
else
|
|
|
|
pr_cont(", nameserver%u=%pI4",
|
|
|
|
i, &ic_nameservers[i]);
|
2020-11-10 07:37:57 +00:00
|
|
|
|
|
|
|
count++;
|
2012-09-21 08:31:19 +00:00
|
|
|
}
|
2020-11-10 07:37:57 +00:00
|
|
|
if ((i + 1 == CONF_NAMESERVERS_MAX) && count > 0)
|
ipconfig: Tidy up reporting of name servers
Commit 5e953778a2aab04929a5e7b69f53dc26e39b079e ("ipconfig: add
nameserver IPs to kernel-parameter ip=") adds the IP addresses of
discovered name servers to the summary printed by ipconfig when
configuration is complete. It appears the intention in ip_auto_config()
was to print the name servers on a new line (especially given the
spacing and lack of comma before "nameserver0="), but they're actually
printed on the same line as the NFS root filesystem configuration
summary:
[ 0.686186] IP-Config: Complete:
[ 0.686226] device=eth0, hwaddr=xx:xx:xx:xx:xx:xx, ipaddr=10.0.0.2, mask=255.255.255.0, gw=10.0.0.1
[ 0.686328] host=test, domain=example.com, nis-domain=(none)
[ 0.686386] bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath= nameserver0=10.0.0.1
This makes it harder to read and parse ipconfig's output. Instead, print
the name servers on a separate line:
[ 0.791250] IP-Config: Complete:
[ 0.791289] device=eth0, hwaddr=xx:xx:xx:xx:xx:xx, ipaddr=10.0.0.2, mask=255.255.255.0, gw=10.0.0.1
[ 0.791407] host=test, domain=example.com, nis-domain=(none)
[ 0.791475] bootserver=10.0.0.1, rootserver=10.0.0.1, rootpath=
[ 0.791476] nameserver0=10.0.0.1
Signed-off-by: Chris Novakovic <chris@chrisn.me.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-04-24 02:56:33 +00:00
|
|
|
pr_cont("\n");
|
|
|
|
}
|
2018-04-24 02:56:39 +00:00
|
|
|
/* NTP servers (if any): */
|
2020-11-10 07:37:57 +00:00
|
|
|
for (i = 0, count = 0; i < CONF_NTP_SERVERS_MAX; i++) {
|
2018-04-24 02:56:39 +00:00
|
|
|
if (ic_ntp_servers[i] != NONE) {
|
|
|
|
if (i == 0)
|
|
|
|
pr_info(" ntpserver%u=%pI4",
|
|
|
|
i, &ic_ntp_servers[i]);
|
|
|
|
else
|
|
|
|
pr_cont(", ntpserver%u=%pI4",
|
|
|
|
i, &ic_ntp_servers[i]);
|
2020-11-10 07:37:57 +00:00
|
|
|
|
|
|
|
count++;
|
2018-04-24 02:56:39 +00:00
|
|
|
}
|
2020-11-10 07:37:57 +00:00
|
|
|
if ((i + 1 == CONF_NTP_SERVERS_MAX) && count > 0)
|
2018-04-24 02:56:39 +00:00
|
|
|
pr_cont("\n");
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* !SILENT */
|
|
|
|
|
2016-08-10 09:44:17 +00:00
|
|
|
/*
|
|
|
|
* Close all network devices except the device we've
|
|
|
|
* autoconfigured and set up routes.
|
|
|
|
*/
|
|
|
|
if (ic_setup_if() < 0 || ic_setup_routes() < 0)
|
2016-08-16 14:45:38 +00:00
|
|
|
err = -1;
|
|
|
|
else
|
|
|
|
err = 0;
|
2016-08-10 09:44:17 +00:00
|
|
|
|
2016-08-16 14:45:38 +00:00
|
|
|
ic_close_devs();
|
2016-08-10 09:44:17 +00:00
|
|
|
|
2016-08-16 14:45:38 +00:00
|
|
|
return err;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
late_initcall(ip_auto_config);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Decode any IP configuration options in the "ip=" or "nfsaddrs=" kernel
|
2020-02-12 18:13:32 +00:00
|
|
|
* command line parameter. See Documentation/admin-guide/nfs/nfsroot.rst.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
static int __init ic_proto_name(char *name)
|
|
|
|
{
|
|
|
|
if (!strcmp(name, "on") || !strcmp(name, "any")) {
|
|
|
|
return 1;
|
|
|
|
}
|
2007-12-26 04:54:42 +00:00
|
|
|
if (!strcmp(name, "off") || !strcmp(name, "none")) {
|
2008-01-06 07:23:06 +00:00
|
|
|
return 0;
|
2007-12-26 04:54:42 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef CONFIG_IP_PNP_DHCP
|
2015-10-15 08:54:36 +00:00
|
|
|
else if (!strncmp(name, "dhcp", 4)) {
|
|
|
|
char *client_id;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
ic_proto_enabled &= ~IC_RARP;
|
2015-10-15 08:54:36 +00:00
|
|
|
client_id = strstr(name, "dhcp,");
|
|
|
|
if (client_id) {
|
|
|
|
char *v;
|
|
|
|
|
|
|
|
client_id = client_id + 5;
|
|
|
|
v = strchr(client_id, ',');
|
|
|
|
if (!v)
|
|
|
|
return 1;
|
|
|
|
*v = 0;
|
|
|
|
if (kstrtou8(client_id, 0, dhcp_client_identifier))
|
2015-11-13 10:40:34 +00:00
|
|
|
pr_debug("DHCP: Invalid client identifier type\n");
|
2015-10-15 08:54:36 +00:00
|
|
|
strncpy(dhcp_client_identifier + 1, v + 1, 251);
|
|
|
|
*v = ',';
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_IP_PNP_BOOTP
|
|
|
|
else if (!strcmp(name, "bootp")) {
|
|
|
|
ic_proto_enabled &= ~(IC_RARP | IC_USE_DHCP);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_IP_PNP_RARP
|
|
|
|
else if (!strcmp(name, "rarp")) {
|
|
|
|
ic_proto_enabled &= ~(IC_BOOTP | IC_USE_DHCP);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef IPCONFIG_DYNAMIC
|
|
|
|
else if (!strcmp(name, "both")) {
|
|
|
|
ic_proto_enabled &= ~IC_USE_DHCP; /* backward compat :-( */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int __init ip_auto_config_setup(char *addrs)
|
|
|
|
{
|
|
|
|
char *cp, *ip, *dp;
|
|
|
|
int num = 0;
|
|
|
|
|
|
|
|
ic_set_manually = 1;
|
2007-12-28 05:19:10 +00:00
|
|
|
ic_enable = 1;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-01-06 07:23:06 +00:00
|
|
|
/*
|
|
|
|
* If any dhcp, bootp etc options are set, leave autoconfig on
|
|
|
|
* and skip the below static IP processing.
|
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ic_proto_name(addrs))
|
|
|
|
return 1;
|
|
|
|
|
2008-01-06 07:23:06 +00:00
|
|
|
/* If no static IP is given, turn off autoconfig and bail. */
|
|
|
|
if (*addrs == 0 ||
|
|
|
|
strcmp(addrs, "off") == 0 ||
|
|
|
|
strcmp(addrs, "none") == 0) {
|
|
|
|
ic_enable = 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-04-24 02:56:39 +00:00
|
|
|
/* Initialise all name servers and NTP servers to NONE */
|
2012-09-21 08:31:19 +00:00
|
|
|
ic_nameservers_predef();
|
2018-04-24 02:56:39 +00:00
|
|
|
ic_ntp_servers_predef();
|
2012-09-21 08:31:19 +00:00
|
|
|
|
2008-01-06 07:23:06 +00:00
|
|
|
/* Parse string for static IP assignment. */
|
2005-04-16 22:20:36 +00:00
|
|
|
ip = addrs;
|
|
|
|
while (ip && *ip) {
|
|
|
|
if ((cp = strchr(ip, ':')))
|
|
|
|
*cp++ = '\0';
|
|
|
|
if (strlen(ip) > 0) {
|
2015-11-13 10:40:34 +00:00
|
|
|
pr_debug("IP-Config: Parameter #%d: `%s'\n", num, ip);
|
2005-04-16 22:20:36 +00:00
|
|
|
switch (num) {
|
|
|
|
case 0:
|
2008-03-18 05:44:53 +00:00
|
|
|
if ((ic_myaddr = in_aton(ip)) == ANY)
|
2006-11-08 08:19:38 +00:00
|
|
|
ic_myaddr = NONE;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2008-03-18 05:44:53 +00:00
|
|
|
if ((ic_servaddr = in_aton(ip)) == ANY)
|
2006-11-08 08:19:38 +00:00
|
|
|
ic_servaddr = NONE;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2008-03-18 05:44:53 +00:00
|
|
|
if ((ic_gateway = in_aton(ip)) == ANY)
|
2006-11-08 08:19:38 +00:00
|
|
|
ic_gateway = NONE;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2008-03-18 05:44:53 +00:00
|
|
|
if ((ic_netmask = in_aton(ip)) == ANY)
|
2006-11-08 08:19:38 +00:00
|
|
|
ic_netmask = NONE;
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if ((dp = strchr(ip, '.'))) {
|
|
|
|
*dp++ = '\0';
|
2006-10-02 09:18:11 +00:00
|
|
|
strlcpy(utsname()->domainname, dp,
|
|
|
|
sizeof(utsname()->domainname));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2006-10-02 09:18:11 +00:00
|
|
|
strlcpy(utsname()->nodename, ip,
|
|
|
|
sizeof(utsname()->nodename));
|
2005-04-16 22:20:36 +00:00
|
|
|
ic_host_name_set = 1;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
strlcpy(user_dev_name, ip, sizeof(user_dev_name));
|
|
|
|
break;
|
|
|
|
case 6:
|
2008-01-06 07:23:06 +00:00
|
|
|
if (ic_proto_name(ip) == 0 &&
|
|
|
|
ic_myaddr == NONE) {
|
|
|
|
ic_enable = 0;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
2012-09-21 08:31:19 +00:00
|
|
|
case 7:
|
|
|
|
if (CONF_NAMESERVERS_MAX >= 1) {
|
|
|
|
ic_nameservers[0] = in_aton(ip);
|
|
|
|
if (ic_nameservers[0] == ANY)
|
|
|
|
ic_nameservers[0] = NONE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
if (CONF_NAMESERVERS_MAX >= 2) {
|
|
|
|
ic_nameservers[1] = in_aton(ip);
|
|
|
|
if (ic_nameservers[1] == ANY)
|
|
|
|
ic_nameservers[1] = NONE;
|
|
|
|
}
|
|
|
|
break;
|
2018-04-24 02:56:39 +00:00
|
|
|
case 9:
|
|
|
|
if (CONF_NTP_SERVERS_MAX >= 1) {
|
|
|
|
ic_ntp_servers[0] = in_aton(ip);
|
|
|
|
if (ic_ntp_servers[0] == ANY)
|
|
|
|
ic_ntp_servers[0] = NONE;
|
|
|
|
}
|
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ip = cp;
|
|
|
|
num++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
2012-05-19 14:04:39 +00:00
|
|
|
__setup("ip=", ip_auto_config_setup);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static int __init nfsaddrs_config_setup(char *addrs)
|
|
|
|
{
|
|
|
|
return ip_auto_config_setup(addrs);
|
|
|
|
}
|
2012-05-19 14:04:39 +00:00
|
|
|
__setup("nfsaddrs=", nfsaddrs_config_setup);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2007-11-14 10:18:39 +00:00
|
|
|
static int __init vendor_class_identifier_setup(char *addrs)
|
|
|
|
{
|
|
|
|
if (strlcpy(vendor_class_identifier, addrs,
|
|
|
|
sizeof(vendor_class_identifier))
|
|
|
|
>= sizeof(vendor_class_identifier))
|
2015-11-13 10:40:34 +00:00
|
|
|
pr_warn("DHCP: vendorclass too long, truncated to \"%s\"\n",
|
2012-03-11 18:36:11 +00:00
|
|
|
vendor_class_identifier);
|
2007-11-14 10:18:39 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
__setup("dhcpclass=", vendor_class_identifier_setup);
|
2019-01-31 10:14:18 +00:00
|
|
|
|
|
|
|
static int __init set_carrier_timeout(char *str)
|
|
|
|
{
|
|
|
|
ssize_t ret;
|
|
|
|
|
|
|
|
if (!str)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ret = kstrtouint(str, 0, &carrier_timeout);
|
|
|
|
if (ret)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
__setup("carrier_timeout=", set_carrier_timeout);
|