Message ID | 1339228087-14870-1-git-send-email-scott@scottnz.com |
---|---|
State | RFC, archived |
Delegated to: | David Miller |
Headers | show |
Hi David, Can you please deliver this patch (my apologies if you have already). We have been running it for several months on ~80 x86 machines (against 3.3.0-gentoo) and have had no issues related to it. It applied cleanly to tovalds.git and net.git when I created it. Please let me know if it requires any changes, I believe I complied with the coding style present in the file. Kind Regards, Scott On Sat, 2012-06-09 at 19:48 +1200, Scott Parlane wrote: > From: Scott Parlane <scott.parlane@alliedtelesis.co.nz> > > if IP_PNP_RENAME_DEV is set, the first interface to be configured > automatically by the kernel during boot will be renamed. > > IP_PNP_DEV_NEWNAME is the name to give the autoconfigured device. > > No changes will be made to any interface that is not autoconfigured. > > This allows the assurance of the boot device name, without the need > for an initramfs. > > Signed-off-by: Scott Parlane <scott.parlane@alliedtelesis.co.nz> > --- > net/ipv4/Kconfig | 17 +++++++++++++++++ > net/ipv4/ipconfig.c | 35 +++++++++++++++++++++++++++++++++++ > 2 files changed, 52 insertions(+), 0 deletions(-) > > diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig > index 20f1cb5..c85c654 100644 > --- a/net/ipv4/Kconfig > +++ b/net/ipv4/Kconfig > @@ -163,6 +163,23 @@ config IP_PNP_RARP > operating on your network. Read > <file:Documentation/filesystems/nfs/nfsroot.txt> for details. > > +config IP_PNP_RENAME_DEV > + bool "IP: Rename boot device" > + depends on IP_PNP > + help > + If you want to rename the network device you are booting from > + to something other than eth%d enable this option, and choose the name > + below. This is helpful if you want to use udev to keep > + persistent naming of your other interfaces. > + > +config IP_PNP_DEV_NEWNAME > + string "IP: New name of boot device" > + depends on IP_PNP_RENAME_DEV > + default "bootnet" > + help > + The name to assign to the network device you are booting from > + when using ip autoconfigure > + > config NET_IPIP > tristate "IP: tunneling" > select INET_TUNNEL > diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c > index 67e8a6b..a4b052a 100644 > --- a/net/ipv4/ipconfig.c > +++ b/net/ipv4/ipconfig.c > @@ -86,6 +86,10 @@ > #if defined(IPCONFIG_BOOTP) || defined(IPCONFIG_RARP) > #define IPCONFIG_DYNAMIC > #endif > +#if defined(CONFIG_IP_PNP_RENAME_DEV) > +#define IPCONFIG_RENAME_DEV > +#define IPCONFIG_DEV_NEWNAME CONFIG_IP_PNP_DEV_NEWNAME > +#endif > > /* Define the friendly delay before and after opening net devices */ > #define CONF_POST_OPEN 10 /* After opening: 10 msecs */ > @@ -360,6 +364,37 @@ static int __init ic_setup_if(void) > > memset(&ir, 0, sizeof(ir)); > strcpy(ir.ifr_ifrn.ifrn_name, ic_dev->name); > +#ifdef IPCONFIG_RENAME_DEV > + if ((err = ic_dev_ioctl(SIOCGIFFLAGS, &ir)) < 0) { > + pr_err("IP-Config: Unable to get interface flags (1,%d).\n", > + err); > + return -1; > + } > + ir.ifr_flags &= ~IFF_UP; > + if ((err = ic_dev_ioctl(SIOCSIFFLAGS, &ir)) < 0) { > + pr_err("IP-Config: Unable to set interface flags (1,%d).\n", > + err); > + return -1; > + } > + strcpy(ir.ifr_newname, IPCONFIG_DEV_NEWNAME); > + if ((err = ic_dev_ioctl(SIOCSIFNAME, &ir)) < 0) { > + pr_err("IP-Config: Unable to change boot interface name to %s (%d).\n", > + IPCONFIG_DEV_NEWNAME, err); > + return -1; > + } > + strcpy(ir.ifr_ifrn.ifrn_name, IPCONFIG_DEV_NEWNAME); > + if ((err = ic_dev_ioctl(SIOCGIFFLAGS, &ir)) < 0) { > + pr_err("IP-Config: Unable to get interface flags (2,%d).\n", > + err); > + return -1; > + } > + ir.ifr_flags |= IFF_UP; > + if ((err = ic_dev_ioctl(SIOCSIFFLAGS, &ir)) < 0) { > + pr_err("IP-Config: Unable to set interface flags (2,%d).\n", > + err); > + return -1; > + } > +#endif > set_sockaddr(sin, ic_myaddr, 0); > if ((err = ic_devinet_ioctl(SIOCSIFADDR, &ir)) < 0) { > pr_err("IP-Config: Unable to set interface address (%d)\n", -- 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
On 06/10/2012 05:53 PM, Scott Parlane wrote: > Hi David, > > Can you please deliver this patch (my apologies if you have already). Scott, Be patient, you posted your patch yesterday. Check patchwork for current status: http://patchwork.ozlabs.org/patch/163892/ Jan -- 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
From: Scott Parlane <scott@scottnz.com> Date: Mon, 11 Jun 2012 03:53:39 +1200 > We have been running it for several months on ~80 x86 machines The number of people already running a patch is not the criteria use to determine if a patch gets added or not. -- 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
From: Scott Parlane <scott@scottnz.com> Date: Sat, 9 Jun 2012 19:48:07 +1200 > From: Scott Parlane <scott.parlane@alliedtelesis.co.nz> > > if IP_PNP_RENAME_DEV is set, the first interface to be configured > automatically by the kernel during boot will be renamed. > > IP_PNP_DEV_NEWNAME is the name to give the autoconfigured device. > > No changes will be made to any interface that is not autoconfigured. > > This allows the assurance of the boot device name, without the need > for an initramfs. > > Signed-off-by: Scott Parlane <scott.parlane@alliedtelesis.co.nz> Making this a compile time option makes absolutely no sense at all. Assuming this feature is desirable at all (which is a big IF), it should be a kernel command line option. -- 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
> From: Scott Parlane <scott@scottnz.com> > Date: Sat, 9 Jun 2012 19:48:07 +1200 > >> From: Scott Parlane <scott.parlane@alliedtelesis.co.nz> >> >> if IP_PNP_RENAME_DEV is set, the first interface to be configured >> automatically by the kernel during boot will be renamed. >> >> IP_PNP_DEV_NEWNAME is the name to give the autoconfigured device. >> >> No changes will be made to any interface that is not autoconfigured. >> >> This allows the assurance of the boot device name, without the need >> for an initramfs. >> >> Signed-off-by: Scott Parlane <scott.parlane@alliedtelesis.co.nz> > > Making this a compile time option makes absolutely no sense at all. > > Assuming this feature is desirable at all (which is a big IF), it > should be a kernel command line option. My comment re how many devices was a reference to the level of testing, not the usage, however I see it was probably moot given any person with sufficient knowledge of the area would see it works as described. (unless I did something i haven't seen yet) [background of this solution] In our configuration we load the same kernel on to a number of testboxes, each of which has several ethernet interfaces and serial ports (for communicating with our devices under test) They use nfsroot which prevents udev rules from working correctly (because you cant take down the interface to rename it) Previously we were using an initramfs that would rename the interface, just before mounting the real root. However a recent change to glibc prevents busybox's nfs utils from working, so I made this patch to get the kernel to do it, and remove the need for the initramfs (which just slows our boot process anyways) In our case, we run a custom kernel, and have this option turned on, with a suitable name so that we can identify the boot interface. While I agree that being able to configure it from the command line would be useful, I would rather that I could (if I wanted) configure it at compile time to default, purely because it means there is one less thing my admins need to deal worry about or can change in the pxelinux config. (every testbox has a unique cmdline, because of how our nfsroot mount points work) Please let me know if you want me to extend it to support command line configuration, and what configuration you would like to trigger it. Kind Regards, Scott -- 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
From: scott@scottnz.com Date: Mon, 11 Jun 2012 21:58:45 +1200 > They use nfsroot which prevents udev rules from working correctly > (because you cant take down the interface to rename it) This is why I hate nfsroot as implemented in the kernel. Do this right and use an initial ramdisk, then you won't have this huge disconnect between different device names due to lack of udev. Thanks, you've confirmed that this patch is totally inappropriate. -- 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
> From: scott@scottnz.com > Date: Mon, 11 Jun 2012 21:58:45 +1200 > >> They use nfsroot which prevents udev rules from working correctly >> (because you cant take down the interface to rename it) > > This is why I hate nfsroot as implemented in the kernel. > The same is true for root over nfs as configured by the initramfs, conviently there is a small window where you can interfere with it (at the initramfs stage), or I should say there-was, its not available anymore, specifically because glibc dropped the sunrpc code. (This is probably an artifact of gentoo's initramfs more than anything, but it was the last distro that I could find to network boot without fully RYO) > Do this right and use an initial ramdisk, then you won't have > this huge disconnect between different device names due to > lack of udev. > > Thanks, you've confirmed that this patch is totally inappropriate. So be it, we will continue to run it, because its the simpliest way to get what we want done (and most of our software developers can deal with kernel code, more so than libc) Regards, Scott -- 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/ipv4/Kconfig b/net/ipv4/Kconfig index 20f1cb5..c85c654 100644 --- a/net/ipv4/Kconfig +++ b/net/ipv4/Kconfig @@ -163,6 +163,23 @@ config IP_PNP_RARP operating on your network. Read <file:Documentation/filesystems/nfs/nfsroot.txt> for details. +config IP_PNP_RENAME_DEV + bool "IP: Rename boot device" + depends on IP_PNP + help + If you want to rename the network device you are booting from + to something other than eth%d enable this option, and choose the name + below. This is helpful if you want to use udev to keep + persistent naming of your other interfaces. + +config IP_PNP_DEV_NEWNAME + string "IP: New name of boot device" + depends on IP_PNP_RENAME_DEV + default "bootnet" + help + The name to assign to the network device you are booting from + when using ip autoconfigure + config NET_IPIP tristate "IP: tunneling" select INET_TUNNEL diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c index 67e8a6b..a4b052a 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c @@ -86,6 +86,10 @@ #if defined(IPCONFIG_BOOTP) || defined(IPCONFIG_RARP) #define IPCONFIG_DYNAMIC #endif +#if defined(CONFIG_IP_PNP_RENAME_DEV) +#define IPCONFIG_RENAME_DEV +#define IPCONFIG_DEV_NEWNAME CONFIG_IP_PNP_DEV_NEWNAME +#endif /* Define the friendly delay before and after opening net devices */ #define CONF_POST_OPEN 10 /* After opening: 10 msecs */ @@ -360,6 +364,37 @@ static int __init ic_setup_if(void) memset(&ir, 0, sizeof(ir)); strcpy(ir.ifr_ifrn.ifrn_name, ic_dev->name); +#ifdef IPCONFIG_RENAME_DEV + if ((err = ic_dev_ioctl(SIOCGIFFLAGS, &ir)) < 0) { + pr_err("IP-Config: Unable to get interface flags (1,%d).\n", + err); + return -1; + } + ir.ifr_flags &= ~IFF_UP; + if ((err = ic_dev_ioctl(SIOCSIFFLAGS, &ir)) < 0) { + pr_err("IP-Config: Unable to set interface flags (1,%d).\n", + err); + return -1; + } + strcpy(ir.ifr_newname, IPCONFIG_DEV_NEWNAME); + if ((err = ic_dev_ioctl(SIOCSIFNAME, &ir)) < 0) { + pr_err("IP-Config: Unable to change boot interface name to %s (%d).\n", + IPCONFIG_DEV_NEWNAME, err); + return -1; + } + strcpy(ir.ifr_ifrn.ifrn_name, IPCONFIG_DEV_NEWNAME); + if ((err = ic_dev_ioctl(SIOCGIFFLAGS, &ir)) < 0) { + pr_err("IP-Config: Unable to get interface flags (2,%d).\n", + err); + return -1; + } + ir.ifr_flags |= IFF_UP; + if ((err = ic_dev_ioctl(SIOCSIFFLAGS, &ir)) < 0) { + pr_err("IP-Config: Unable to set interface flags (2,%d).\n", + err); + return -1; + } +#endif set_sockaddr(sin, ic_myaddr, 0); if ((err = ic_devinet_ioctl(SIOCSIFADDR, &ir)) < 0) { pr_err("IP-Config: Unable to set interface address (%d)\n",