[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#836016: netcfg: Drop unnecessary loopback config in /etc/network/interfaces



Package: netcfg
Version: 1.139

Hello,

netcfg still configures a "lo" (loopback) device in
/etc/network/interfaces, although this hasn't been necessary since
ifupdown 0.7.41 in 2013:

  https://anonscm.debian.org/cgit/collab-maint/ifupdown.git/commit/?id=2127aa19d9416

Please drop it as this is unnecessary extra parsing work at boot. I
attach an untested (only build-tested) initial patch. The main thing
I'm not sure about is whether this actually needs to clear
/etc/network/interfaces when NetworkManager is installed -- would
anything write "real" interfaces to /e/n/i in this case?

OOI, how can an updated netcfg be tested locally?

In a more general vein, ifupdown creates an appropriate /e/n/i on
package installation already. It would be nicer if netcfg would not
completly overwrite this and instead just add files to
/etc/network/interfaces.d/

Thanks for considering,

Martin

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
>From 3f576e1f4f6068712c64988ec7b405cd890f989a Mon Sep 17 00:00:00 2001
From: Martin Pitt <martin.pitt@ubuntu.com>
Date: Tue, 30 Aug 2016 10:08:51 +0200
Subject: [PATCH] untested: Remove write_loopback

---
 base-installer.d/40netcfg             |  4 ----
 dhcp.c                                |  1 -
 finish-install.d/55netcfg-copy-config |  6 +-----
 netcfg-common.c                       | 17 -----------------
 netcfg.h                              |  1 -
 static.c                              |  1 -
 6 files changed, 1 insertion(+), 29 deletions(-)

diff --git a/base-installer.d/40netcfg b/base-installer.d/40netcfg
index f09b20a..da51feb 100755
--- a/base-installer.d/40netcfg
+++ b/base-installer.d/40netcfg
@@ -1,10 +1,6 @@
 #!/bin/sh -e
 # Copy all relevant networking-related files to /target.
 
-if [ ! -f /etc/network/interfaces ]; then
-	netcfg write_loopback
-fi
-
 for file in /etc/network/interfaces /etc/networks /etc/hostname /etc/resolv.conf /etc/hosts; do
 	if [ -f "$file" ]; then
 		mkdir /target/$(dirname $file) -p
diff --git a/dhcp.c b/dhcp.c
index fe06950..c3792d8 100644
--- a/dhcp.c
+++ b/dhcp.c
@@ -611,7 +611,6 @@ int netcfg_activate_dhcp (struct debconfclient *client, struct netcfg_interface
             else {
                 di_debug("Network config complete");
                 netcfg_write_common("", hostname, domain);
-                netcfg_write_loopback();
                 netcfg_write_interface(interface);
                 netcfg_write_resolv(domain, interface);
 #if !defined(__FreeBSD_kernel__)
diff --git a/finish-install.d/55netcfg-copy-config b/finish-install.d/55netcfg-copy-config
index 74e96a3..f727150 100755
--- a/finish-install.d/55netcfg-copy-config
+++ b/finish-install.d/55netcfg-copy-config
@@ -58,14 +58,10 @@ case $RET in
 	# Copy NM config file. First make sure the directory exists
 	mkdir -p /target/$FILE_PATH_NM_CONFIG
 	cp /$FILE_PATH_NM_CONFIG/* /target/$FILE_PATH_NM_CONFIG/
-
-	# Rewrite /etc/network/interfaces to contain only loopback
-	netcfg write_loopback
 	;;
 
     $CONFIG_LOOPBACK)
-	# Rewrite /etc/network/interfaces to contain only loopback
-	netcfg write_loopback
+	# no-op
 	;;
 esac
 
diff --git a/netcfg-common.c b/netcfg-common.c
index c6d1d8d..074c99c 100644
--- a/netcfg-common.c
+++ b/netcfg-common.c
@@ -1108,18 +1108,6 @@ int netcfg_get_domain(struct debconfclient *client,  char domain[])
     return 0;
 }
 
-void netcfg_write_loopback (void)
-{
-    struct netcfg_interface lo;
-    
-    netcfg_interface_init(&lo);
-    lo.name = LO_IF;
-    lo.loopback = 1;
-    
-    netcfg_write_interface(NULL);
-    netcfg_write_interface(&lo);
-}
-
 /*
  * ipaddress.s_addr may be 0
  * domain may be null
@@ -1348,11 +1336,6 @@ void parse_args (int argc, char ** argv)
                 exit(EXIT_SUCCESS);
             }
         }
-        if (!strcmp(argv[1], "write_loopback")) {
-            netcfg_write_loopback();
-            exit(EXIT_SUCCESS);
-        }
-
         exit(EXIT_FAILURE);
     }
 }
diff --git a/netcfg.h b/netcfg.h
index 00a2cea..e8eddda 100644
--- a/netcfg.h
+++ b/netcfg.h
@@ -200,7 +200,6 @@ extern void sigchld_handler (int sig __attribute__ ((unused)));
 
 extern int ask_dhcp_options (struct debconfclient *client, const char *if_name);
 
-extern void netcfg_write_loopback (void);
 extern void netcfg_write_common (const char *ipaddress, const char *hostname, const char *domain);
 
 void netcfg_nameservers_to_array(const char *nameservers, struct netcfg_interface *interface);
diff --git a/static.c b/static.c
index ea12fba..15682b4 100644
--- a/static.c
+++ b/static.c
@@ -679,7 +679,6 @@ int netcfg_get_static(struct debconfclient *client, struct netcfg_interface *ifa
                     netcfg_write_etc_networks(NULL);
                 }
                 netcfg_write_common(iface->ipaddress, hostname, domain);
-                netcfg_write_loopback();
                 netcfg_write_interface(iface);
                 netcfg_write_resolvconf_options(domain, iface);
                 netcfg_write_resolv(domain, iface);
-- 
2.9.3


Reply to: