Bug#646860: netcfg: do not place network and broadcast lines in /etc/network/interfaces
Package: netcfg
Severity: wishlist
Hello, it's 2011 and not 1984. Broadcast and network addresses are standardized today.
'network' and 'broadcast' lines do not need to be written to /etc/network/interfaces
any more. They are at best redundant, and at worst confusing users. ifconfig
calculates broadcast and network addresses correctly so they can be removed
safely from the config. Attached is a patch against netcfg-1.59.
Regards,
Oskar Liljeblad
-- System Information:
Debian Release: 6.0.3
APT prefers stable
APT policy: (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.39.4 (SMP w/2 CPU cores)
Locale: LANG=POSIX, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
diff -u -p static.c.v0 static.c
--- static.c.v0 2011-10-27 21:55:11.000000000 +0200
+++ static.c 2011-10-27 21:59:00.000000000 +0200
@@ -12,7 +12,6 @@
struct in_addr old_ipaddress = { 0 };
struct in_addr network = { 0 };
-struct in_addr broadcast = { 0 };
struct in_addr netmask = { 0 };
struct in_addr pointopoint = { 0 };
@@ -107,7 +106,6 @@ int netcfg_get_netmask(struct debconfcli
netmask.s_addr != old_netmask.s_addr
) {
network.s_addr = ipaddress.s_addr & netmask.s_addr;
- broadcast.s_addr = (network.s_addr | ~netmask.s_addr);
/* Preseed gateway */
gateway.s_addr = ipaddress.s_addr & netmask.s_addr;
@@ -189,8 +187,6 @@ static int netcfg_write_static(char *dom
fprintf(fp, "iface %s inet static\n", interface);
fprintf(fp, "\taddress %s\n", inet_ntop (AF_INET, &ipaddress, ptr1, sizeof (ptr1)));
fprintf(fp, "\tnetmask %s\n", inet_ntop (AF_INET, &netmask, ptr1, sizeof (ptr1)));
- fprintf(fp, "\tnetwork %s\n", inet_ntop (AF_INET, &network, ptr1, sizeof (ptr1)));
- fprintf(fp, "\tbroadcast %s\n", inet_ntop (AF_INET, &broadcast, ptr1, sizeof (ptr1)));
if (gateway.s_addr)
fprintf(fp, "\tgateway %s\n", inet_ntop (AF_INET, &gateway, ptr1, sizeof (ptr1)));
if (pointopoint.s_addr)
@@ -311,10 +307,6 @@ int netcfg_activate_static(struct debcon
di_snprintfcat(buf, sizeof(buf), " netmask %s",
inet_ntop (AF_INET, &netmask, ptr1, sizeof (ptr1)));
- /* avoid using a third buffer */
- di_snprintfcat(buf, sizeof(buf), " broadcast %s",
- inet_ntop (AF_INET, &broadcast, ptr1, sizeof (ptr1)));
-
di_info("executing: %s", buf);
rv |= di_exec_shell_log(buf);
@@ -350,11 +342,6 @@ int netcfg_activate_static(struct debcon
inet_ntop (AF_INET, &ipaddress, ptr1, sizeof (ptr1)),
masksize);
- /* avoid using a second buffer */
- di_snprintfcat(buf, sizeof(buf), "broadcast %s dev %s",
- inet_ntop (AF_INET, &broadcast, ptr1, sizeof (ptr1)),
- interface);
-
if (pointopoint.s_addr)
di_snprintfcat(buf, sizeof(buf), " peer %s",
inet_ntop (AF_INET, &pointopoint, ptr1, sizeof (ptr1)));
@@ -396,7 +383,7 @@ int netcfg_get_static(struct debconfclie
GET_DOMAIN, QUIT }
state = GET_IPADDRESS;
- ipaddress.s_addr = network.s_addr = broadcast.s_addr = netmask.s_addr = gateway.s_addr = pointopoint.s_addr =
+ ipaddress.s_addr = network.s_addr = netmask.s_addr = gateway.s_addr = pointopoint.s_addr =
0;
debconf_metaget(client, "netcfg/internal-none", "description");
Reply to: