Vivek,
Comment inline:
On 05/13/2014 09:40 PM, Vivek Goyal wrote:
On Tue, May 13, 2014 at 03:51:39PM -0400, Marc Milgram wrote:
> NetworkManager changed the format of ifcfg-device files. They may define
> static IP addresses with the following format:
> IPADDR0=192.168.122.100
> PREFIX0=24
So is this part of IP aliasing stuff? Or what does it mean to define
multiple IP addresses in single ifcfg-device file?
The terminology is changing. According to the ip(8) man page,
Each device must have at least one address to use the
corresponding protocol. It is possible to have several different
addresses attached to one device. These addresses are not
discriminated, so that the term *alias* is not quite appropriate for
them.
>
> There may be up to 255 ip addresses for a network device - each with a unique
> number tagged to the end of IPADDR and PREFIX.
So if multiple IPs are defined in a file say IPADDR0, IPADDR1, then we
are looking for a specific IP and PREFIX associated with it so that we
can calculate the netmask?
Each IP address has its own netmask. With this fix, we don't read the
ifcfg file to obtain the address and netmask, we get it from "ip addr
show dev <netdev>" commands.
-Marc
Apart from these basic queries, patch looks good to me. Thanks Marc.
Acked-by: Vivek Goyal <vgoyal(a)redhat.com>
Vivek
>
> Prior to this fix, kdump only handled static ip addresses defined with
> IPADDR=192.168.122.100
> PREFIX=24
>
> ie. without the number.
>
> The solution is to use "ip" commands to find the correct network
information.
>
> Tested with both static and dynamic IP addresses.
>
> Signed-off-by: Marc Milgram <mmilgram(a)redhat.com>
>
> diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
> index 2a16900..9309853 100755
> --- a/dracut-module-setup.sh
> +++ b/dracut-module-setup.sh
> @@ -67,14 +67,17 @@ kdump_setup_dns() {
> }
>
> #$1: netdev name
> -#checking /etc/sysconfig/network-scripts/ifcfg-$1,
> +#$2: srcaddr
> #if it use static ip echo it, or echo null
> kdump_static_ip() {
> - . /etc/sysconfig/network-scripts/ifcfg-$1
> - if [ -n "$IPADDR" ]; then
> - [ -z "$NETMASK" -a -n "$PREFIX" ] && \
> - NETMASK=$(ipcalc -m $IPADDR/$PREFIX | cut -d'=' -f2)
> - echo -n "${IPADDR}::${GATEWAY}:${NETMASK}::"
> + local _netmask _gateway
> + local _netdev="$1" _srcaddr="$2"
> + local _ipaddr=$(ip addr show dev $_netdev permanent | \
> + awk "/ $_srcaddr\/.* $_netdev\$/{print \$2}")
> + if [ -n "$_ipaddr" ]; then
> + _netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
> + _gateway=$(ip route list dev $_netdev | awk '/^default /{print $3}')
> + echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
> fi
> }
>
> @@ -181,7 +184,7 @@ kdump_setup_znet() {
>
> # Setup dracut to bringup a given network interface
> kdump_setup_netdev() {
> - local _netdev=$1
> + local _netdev=$1 $_srcaddr=$2
> local _static _proto _ip_conf _ip_opts _ifname_opts
>
> if [ "$(uname -m)" = "s390x" ]; then
> @@ -189,7 +192,7 @@ kdump_setup_netdev() {
> fi
>
> _netmac=$(kdump_get_mac_addr $_netdev)
> - _static=$(kdump_static_ip $_netdev)
> + _static=$(kdump_static_ip $_netdev $_srcaddr)
> if [ -n "$_static" ]; then
> _proto=none
> else
> @@ -223,8 +226,9 @@ kdump_setup_netdev() {
>
> #Function:kdump_install_net
> #$1: config values of net line in kdump.conf
> +#$2: srcaddr of network device
> kdump_install_net() {
> - local _server _netdev
> + local _server _netdev _srcaddr
> local config_val="$1"
>
> _server=`echo $config_val | sed 's/.*@//' | cut -d':' -f1`
> @@ -239,13 +243,15 @@ kdump_install_net() {
> if [ -n "`echo $_netdev | grep via`" ]
> then
> # we are going to a different subnet
> + _srcaddr=`echo $_netdev|awk '{print $7}'|head -n 1`
> _netdev=`echo $_netdev|awk '{print $5;}'|head -n 1`
> else
> # we are on the same subnet
> + _srcaddr=`echo $_netdev|awk '{print $5}'|head -n 1`
> _netdev=`echo $_netdev|awk '{print $3}'|head -n 1`
> fi
>
> - kdump_setup_netdev "${_netdev}"
> + kdump_setup_netdev "${_netdev}" "${_srcaddr}"
>
> #save netdev used for kdump as cmdline
> # Whoever calling kdump_install_net() is setting up the default gateway,
> _______________________________________________
> kexec mailing list
> kexec(a)lists.fedoraproject.org
>
https://lists.fedoraproject.org/mailman/listinfo/kexec