From patchwork Sat Jun 6 02:34:09 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David VomLehn X-Patchwork-Id: 28181 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id E9FCCB70A9 for ; Sat, 6 Jun 2009 13:01:45 +1000 (EST) Received: by ozlabs.org (Postfix) id DCAFEDDD1B; Sat, 6 Jun 2009 13:01:45 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 82EDEDDD0B for ; Sat, 6 Jun 2009 13:01:45 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754155AbZFFDBB (ORCPT ); Fri, 5 Jun 2009 23:01:01 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754196AbZFFDAv (ORCPT ); Fri, 5 Jun 2009 23:00:51 -0400 Received: from sj-iport-6.cisco.com ([171.71.176.117]:62814 "EHLO sj-iport-6.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753355AbZFFDAo (ORCPT ); Fri, 5 Jun 2009 23:00:44 -0400 X-IronPort-AV: E=Sophos;i="4.41,314,1241395200"; d="scan'208";a="317953862" Received: from sj-dkim-1.cisco.com ([171.71.179.21]) by sj-iport-6.cisco.com with ESMTP; 06 Jun 2009 02:34:09 +0000 Received: from sj-core-1.cisco.com (sj-core-1.cisco.com [171.71.177.237]) by sj-dkim-1.cisco.com (8.12.11/8.12.11) with ESMTP id n562Y97C018538; Fri, 5 Jun 2009 19:34:09 -0700 Received: from cuplxvomd02.corp.sa.net ([64.101.20.155]) by sj-core-1.cisco.com (8.13.8/8.13.8) with ESMTP id n562Y9UW011628; Sat, 6 Jun 2009 02:34:09 GMT Date: Fri, 5 Jun 2009 19:34:09 -0700 From: David VomLehn To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, linux-usb@vger.kernel.org, greg@kroah.com, linux-scsi@vger.kernel.org, netdev@vger.kernel.org, arjan@infradead.org Subject: [PATCH 4/7] initdev:kernel:Await network init device discovery, v3 Message-ID: <20090606023409.GA5721@cuplxvomd02.corp.sa.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; l=3470; t=1244255649; x=1245119649; c=relaxed/simple; s=sjdkim1004; h=Content-Type:From:Subject:Content-Transfer-Encoding:MIME-Version; d=cisco.com; i=dvomlehn@cisco.com; z=From:=20David=20VomLehn=20 |Subject:=20[PATCH=204/7]=20initdev=3Akernel=3AAwait=20netw ork=20init=20device=20discovery,=20v3 |Sender:=20; bh=OD6zIRoTQeLJ5FIj9Gk6B+AbMTw+IBL8/0GhrrWDTwc=; b=FmUyGaPlmjf0v17m+IdXSWbd/0zy/rytztEduzzDwqS3sDnea78WRx29nP gSfeeYrvqIivORAmp8jWy0CIjVum1QPsPeSJtCuPZjEHe3+v7u/HHwlcgDNJ z7/3XJ5MWqAzACdDJgTzCqeyg7w8CatrqPScMJwieJo5+EpIIUjTE=; Authentication-Results: sj-dkim-1; header.From=dvomlehn@cisco.com; dkim=pass ( sig from cisco.com/sjdkim1004 verified; ); Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Delay IP autoconfiguration until network boot devices have been initialized. This depends on the boot device discovery code and on the asynchronous function call infrastructure. History v3 Ignore return value from async_schedule call to ip_auto_config_async. Change BOOTDEV_* to INITDEV_*. v2 Change bootdev_* to initdev_* v1 Initial release Signed-off-by: David VomLehn --- net/core/dev.c | 2 + net/ipv4/ipconfig.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/core/dev.c b/net/core/dev.c index 308a7d0..2796764 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -93,6 +93,7 @@ #include #include #include +#include #include #include #include @@ -4497,6 +4498,7 @@ int register_netdevice(struct net_device *dev) dev->reg_state = NETREG_UNREGISTERED; } + initdev_registered(INITDEV_NETDEV_TYPE); out: return ret; diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 90d22ae..3b1a381 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -182,12 +183,48 @@ struct ic_device { static struct ic_device *ic_first_dev __initdata = NULL;/* List of open device */ static struct net_device *ic_dev __initdata = NULL; /* Selected device */ +/* + * Wait for required network devices to come up + * If the networking device name was specified on the kernel command line + * and that device is now registered, we have the device we want to configure + * and we return true. Otherwise, we return false. So, if no device was + * specified on the command line, we wait for all possible network devices to + * be initialized. + */ +static bool have_all_netdevs(void) +{ + struct net_device *dev; + bool result = false; + + rtnl_lock(); + + for_each_netdev(&init_net, dev) { + if (dev->flags & IFF_LOOPBACK) + continue; + + /* If a specific device name was specified and that name is + * registered, we have the device we need. */ + if (user_dev_name[0] && !strcmp(dev->name, user_dev_name)) { + result = true; + break; + } + } + + rtnl_unlock(); + + return result; + +} + static int __init ic_open_devs(void) { struct ic_device *d, **last; struct net_device *dev; unsigned short oflags; + /* Wait for networking devices */ + initdev_wait(INITDEV_NETDEV_TYPE, have_all_netdevs); + last = &ic_first_dev; rtnl_lock(); @@ -1263,6 +1300,7 @@ __be32 __init root_nfs_parse_addr(char *name) /* * IP Autoconfig dispatcher. + * Return zero on success, negative one on failure */ static int __init ip_auto_config(void) @@ -1397,7 +1435,22 @@ static int __init ip_auto_config(void) return 0; } -late_initcall(ip_auto_config); +static void __init ip_auto_config_async(void *data, async_cookie_t cookie) +{ + ip_auto_config(); +} + +/* + * Start a thread to do IP autoconfiguration + */ +static int __init ip_auto_configurator(void) +{ + async_schedule(ip_auto_config_async, NULL); + + return 0; +} + +late_initcall(ip_auto_configurator); /*