User complained they set static ip address in ifcfg-xx with IPADDR0, but that ip address is not set successfully. That's because the IPADDRn can not be recognized by dracut-module-setup.sh. Even though in initscript, ifup-eth can recognize IPADDDR[0-255], and if 2 IPADDRxx missed the latter will be skipped, that's enough to only respect IPADDR[0-3].
Signed-off-by: Baoquan He bhe@redhat.com --- dracut-module-setup.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index bdadf7c..738d304 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -70,11 +70,18 @@ kdump_setup_dns() { #checking /etc/sysconfig/network-scripts/ifcfg-$1, #if it use static ip echo it, or echo null kdump_static_ip() { + local _ipaddr + . /etc/sysconfig/network-scripts/ifcfg-$1 - if [ -n "$IPADDR" ]; then + _ipaddr=${IPADDR:-$IPADDR0} + _ipaddr=${_ipaddr:-$IPADDR1} + _ipaddr=${_ipaddr:-$IPADDR2} + _ipaddr=${_ipaddr:-$IPADDR3} + + if [ -n "$_ipaddr" ]; then [ -z "$NETMASK" -a -n "$PREFIX" ] && \ - NETMASK=$(ipcalc -m $IPADDR/$PREFIX | cut -d'=' -f2) - echo -n "${IPADDR}::${GATEWAY}:${NETMASK}::" + NETMASK=$(ipcalc -m $_ipaddr/$PREFIX | cut -d'=' -f2) + echo -n "${_ipaddr}::${GATEWAY}:${NETMASK}::" fi }
User complained they set static ip address in ifcfg-xx with IPADDR0, but that ip address is not set successfully. That's because the IPADDRn can not be recognized by dracut-module-setup.sh. Even though in initscript, ifup-eth can recognize IPADDDR[0-255], and if 2 IPADDRxx missed the latter will be skipped, that's enough to only respect IPADDR[0-3]. And take the predencence order as IPADDR, IPADDR0, IPADDR1~3.
Signed-off-by: Baoquan He bhe@redhat.com --- dracut-module-setup.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index bdadf7c..e8d660d 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -69,12 +69,21 @@ kdump_setup_dns() { #$1: netdev name #checking /etc/sysconfig/network-scripts/ifcfg-$1, #if it use static ip echo it, or echo null +#kdump only respect IPADDR[0-3] and take the predencence +#order as IPADDR, IPADDR0, IPADDR1~3 kdump_static_ip() { + local _ipaddr + . /etc/sysconfig/network-scripts/ifcfg-$1 - if [ -n "$IPADDR" ]; then + _ipaddr=${IPADDR:-$IPADDR0} + _ipaddr=${_ipaddr:-$IPADDR1} + _ipaddr=${_ipaddr:-$IPADDR2} + _ipaddr=${_ipaddr:-$IPADDR3} + + if [ -n "$_ipaddr" ]; then [ -z "$NETMASK" -a -n "$PREFIX" ] && \ - NETMASK=$(ipcalc -m $IPADDR/$PREFIX | cut -d'=' -f2) - echo -n "${IPADDR}::${GATEWAY}:${NETMASK}::" + NETMASK=$(ipcalc -m $_ipaddr/$PREFIX | cut -d'=' -f2) + echo -n "${_ipaddr}::${GATEWAY}:${NETMASK}::" fi }
On 03/21/2014 05:11 AM, Baoquan He wrote:
User complained they set static ip address in ifcfg-xx with IPADDR0, but that ip address is not set successfully. That's because the IPADDRn can not be recognized by dracut-module-setup.sh. Even though in initscript, ifup-eth can recognize IPADDDR[0-255], and if 2 IPADDRxx missed the latter will be skipped, that's enough to only respect IPADDR[0-3]. And take the predencence order as IPADDR, IPADDR0, IPADDR1~3.
Signed-off-by: Baoquan He bhe@redhat.com
dracut-module-setup.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index bdadf7c..e8d660d 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -69,12 +69,21 @@ kdump_setup_dns() { #$1: netdev name #checking /etc/sysconfig/network-scripts/ifcfg-$1, #if it use static ip echo it, or echo null +#kdump only respect IPADDR[0-3] and take the predencence +#order as IPADDR, IPADDR0, IPADDR1~3 kdump_static_ip() {
- local _ipaddr
. /etc/sysconfig/network-scripts/ifcfg-$1
- if [ -n "$IPADDR" ]; then
- _ipaddr=${IPADDR:-$IPADDR0}
- _ipaddr=${_ipaddr:-$IPADDR1}
- _ipaddr=${_ipaddr:-$IPADDR2}
- _ipaddr=${_ipaddr:-$IPADDR3}
- if [ -n "$_ipaddr" ]; then [ -z "$NETMASK" -a -n "$PREFIX" ] && \
NETMASK=$(ipcalc -m $IPADDR/$PREFIX | cut -d'=' -f2)
echo -n "${IPADDR}::${GATEWAY}:${NETMASK}::"
NETMASK=$(ipcalc -m $_ipaddr/$PREFIX | cut -d'=' -f2)
}echo -n "${_ipaddr}::${GATEWAY}:${NETMASK}::" fi
When Network Manager specifies IPADDR0, it also specifies PREFIX0 and GATEWAY0. Also, that number may be between 0 and 255.
Is there some reason that you are not using "ip addr show dev $1 permanent" in order to obtain the addresses?
NAK
Marc
On 05/09/14 at 11:06am, Marc Milgram wrote:
On 03/21/2014 05:11 AM, Baoquan He wrote:
+#kdump only respect IPADDR[0-3] and take the predencence +#order as IPADDR, IPADDR0, IPADDR1~3 kdump_static_ip() {
- local _ipaddr
- . /etc/sysconfig/network-scripts/ifcfg-$1
- if [ -n "$IPADDR" ]; then
- _ipaddr=${IPADDR:-$IPADDR0}
- _ipaddr=${_ipaddr:-$IPADDR1}
- _ipaddr=${_ipaddr:-$IPADDR2}
- _ipaddr=${_ipaddr:-$IPADDR3}
- if [ -n "$_ipaddr" ]; then [ -z "$NETMASK" -a -n "$PREFIX" ] && \
NETMASK=$(ipcalc -m $IPADDR/$PREFIX | cut -d'=' -f2)
echo -n "${IPADDR}::${GATEWAY}:${NETMASK}::"
NETMASK=$(ipcalc -m $_ipaddr/$PREFIX | cut -d'=' -f2)
fiecho -n "${_ipaddr}::${GATEWAY}:${NETMASK}::"
}
When Network Manager specifies IPADDR0, it also specifies PREFIX0 and GATEWAY0. Also, that number may be between 0 and 255.
Is there some reason that you are not using "ip addr show dev $1 permanent" in order to obtain the addresses?
I guess people would rather trust information stored in ifcfg-xxx which is persistent. About IPADDR0/PREFIX0/GATEWAY0, you are right. I didn't think of the other 2, they are triplet,
I saw your patch pasted in bugzilla, permanent may be a good idea, but it need be elaborated. Since changing this is a behavior change, I can't estimate its affect. And there's a case you didn't think of, it's like:
IPADDR0=X.X.X.X IPADDR1=Y.Y.Y.Y NETMASK1=.... GATEWAY1=....
Then you get 2 lines of permanent ip addr, for this triplet information, I didn't get a good idea to catch yet.
[bhe@ ~]$ ip addr show dev eth0 permanent | awk "/eth0$/ {print $2;}" inet 10.10.10.10/8 scope global eth0 inet 192.168.122.234/24 scope global eth0
Thanks Baoquan
NAK
Marc
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 05/11/2014 10:54 PM, Baoquan He wrote:
On 05/09/14 at 11:06am, Marc Milgram wrote:
On 03/21/2014 05:11 AM, Baoquan He wrote:
+#kdump only respect IPADDR[0-3] and take the predencence +#order as IPADDR, IPADDR0, IPADDR1~3 kdump_static_ip() {
- local _ipaddr
. /etc/sysconfig/network-scripts/ifcfg-$1
- if [ -n "$IPADDR" ]; then
- _ipaddr=${IPADDR:-$IPADDR0}
- _ipaddr=${_ipaddr:-$IPADDR1}
- _ipaddr=${_ipaddr:-$IPADDR2}
- _ipaddr=${_ipaddr:-$IPADDR3}
- if [ -n "$_ipaddr" ]; then [ -z "$NETMASK" -a -n "$PREFIX" ] && \
NETMASK=$(ipcalc -m $IPADDR/$PREFIX | cut -d'=' -f2)
echo -n "${IPADDR}::${GATEWAY}:${NETMASK}::"
NETMASK=$(ipcalc -m $_ipaddr/$PREFIX | cut -d'=' -f2)
}echo -n "${_ipaddr}::${GATEWAY}:${NETMASK}::" fi
When Network Manager specifies IPADDR0, it also specifies PREFIX0 and GATEWAY0. Also, that number may be between 0 and 255.
Is there some reason that you are not using "ip addr show dev $1 permanent" in order to obtain the addresses?
I guess people would rather trust information stored in ifcfg-xxx which is persistent. About IPADDR0/PREFIX0/GATEWAY0, you are right. I didn't think of the other 2, they are triplet,
I saw your patch pasted in bugzilla, permanent may be a good idea, but it need be elaborated. Since changing this is a behavior change, I can't estimate its affect. And there's a case you didn't think of, it's like:
IPADDR0=X.X.X.X IPADDR1=Y.Y.Y.Y NETMASK1=.... GATEWAY1=....
Then you get 2 lines of permanent ip addr, for this triplet information, I didn't get a good idea to catch yet.
[bhe@ ~]$ ip addr show dev eth0 permanent | awk "/eth0$/ {print $2;}" inet 10.10.10.10/8 scope global eth0 inet 192.168.122.234/24 scope global eth0
Thanks Baoquan
Baoquan,
Your code isn't handling that case either, and is not handling the basic case where IPADDR0 and NETMASK0 are set.
I updated the BZ with a patch that selects the correct source IP address (as well as the correct Netmask and gateway).
Regards,
Marc