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