Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 11893 - IP alias broadcasts/netmasks are not assigned correctly.
Summary: IP alias broadcasts/netmasks are not assigned correctly.
Status: RESOLVED DUPLICATE of bug 7407
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High minor (vote)
Assignee: Martin Schlemmer (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-12-10 06:53 UTC by clone-d
Modified: 2005-07-17 13:06 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description clone-d 2002-12-10 06:53:51 UTC
If an interface has more than one IP alias, then broadcasts/netmasks are not
assigned correctly.

--------------------------------------------------------------------------------

Example.
if /etc/conf.d/net file has following strings:

alias_eth0="ip01 ip02 ip03"
broadcast_eth0="bc01 bc02 bc03"
netmask_eth0="nm01 nm02 nm03"

then running /etc/init.d/net.eth0 will execute following:

/sbin/ifconfig eth0:0 ip01 broadcast bc01 bc02 bc03 netmask nm01 nm02 nm03
/sbin/ifconfig eth0:1 ip02 broadcast bc01 netmask nm01
/sbin/ifconfig eth0:2 ip03 broadcast bc02 netmask nm02

--------------------------------------------------------------------------------

This behavior is caused by using "awk '{ print $num }'" in /etc/init.d/net.eth0, where $num starts with "0", but awk's indexing starts with "1".

here is the fix(until "EOF"):

--- net.eth0.orig	2002-12-10 13:53:09.000000000 +0200
+++ net.eth0	2002-12-10 13:59:14.000000000 +0200
@@ -52,13 +52,13 @@
 		ebegin "  Adding aliases"
 		for x in $(eval echo \$\{alias_${IFACE}\})
 		do
-			aliasbcast="$(eval echo \$\{broadcast_${IFACE}\} \| awk \'\{ print \$${num} \}\')"
+			aliasbcast="$(eval echo \$\{broadcast_${IFACE}\} \| awk \'\{ print \$$((${num}+1)) \}\')"
 			if [ -n "${aliasbcast}" ]
 			then
 				aliasbcast="broadcast ${aliasbcast}"
 			fi
 
-			aliasnmask="$(eval echo \$\{netmask_${IFACE}\} \| awk \'\{ print \$${num} \}\')"
+			aliasnmask="$(eval echo \$\{netmask_${IFACE}\} \| awk \'\{ print \$$((${num}+1)) \}\')"
 			if [ -n "${aliasnmask}" ]
 			then
 				aliasnmask="netmask ${aliasnmask}" 
EOF

--------------------------------------------------------------------------------

or another fix, without using awk at all(until "EOF"):

--- net.eth0.orig	2002-12-10 13:53:09.000000000 +0200
+++ net.eth0	2002-12-10 14:06:15.000000000 +0200
@@ -52,13 +52,13 @@
 		ebegin "  Adding aliases"
 		for x in $(eval echo \$\{alias_${IFACE}\})
 		do
-			aliasbcast="$(eval echo \$\{broadcast_${IFACE}\} \| awk \'\{ print \$${num} \}\')"
+			aliasbcast="$(eval x=(\$\{broadcast_${IFACE}\}) \; echo \$\{x[${num}]\})"
 			if [ -n "${aliasbcast}" ]
 			then
 				aliasbcast="broadcast ${aliasbcast}"
 			fi
 
-			aliasnmask="$(eval echo \$\{netmask_${IFACE}\} \| awk \'\{ print \$${num} \}\')"
+			aliasnmask="$(eval x=(\$\{netmask_${IFACE}\}) \; echo \$\{x[${num}]\})"
 			if [ -n "${aliasnmask}" ]
 			then
 				aliasnmask="netmask ${aliasnmask}" 
EOF

--------------------------------------------------------------------------------
Comment 1 Martin Schlemmer (RETIRED) gentoo-dev 2002-12-10 12:31:48 UTC
This was already fixed, please update baselayout, or ._cfg files lying around.


*** This bug has been marked as a duplicate of 7407 ***