/[baselayout]/trunk/net-scripts/net.modules.d/ifconfig
Gentoo

Diff of /trunk/net-scripts/net.modules.d/ifconfig

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1456 Revision 1457
323# Adds the given address to the interface 323# Adds the given address to the interface
324ifconfig_add_address() { 324ifconfig_add_address() {
325 local iface="$1" i=0 r e 325 local iface="$1" i=0 r e
326 326
327 ifconfig_exists "${iface}" true || return 1 327 ifconfig_exists "${iface}" true || return 1
328 ifconfig_up "${iface}"
329 328
330 # Extract the config 329 # Extract the config
331 local -a config=( "$@" ) 330 local -a config=( "$@" )
332 config=( ${config[@]:1} ) 331 config=( ${config[@]:1} )
333 332
358 config=( ${r//brd +/} ) 357 config=( ${r//brd +/} )
359 config=( "${config[@]//brd/broadcast}" ) 358 config=( "${config[@]//brd/broadcast}" )
360 config=( "${config[@]//peer/pointtopoint}" ) 359 config=( "${config[@]//peer/pointtopoint}" )
361 fi 360 fi
362 361
362 # Ensure that the interface is up so we can add IPv6 addresses
363 interface_up "${iface}"
364
363 # Some kernels like to apply lo with an address when they are brought up 365 # Some kernels like to apply lo with an address when they are brought up
364 if [[ ${iface} == "lo" \ 366 if [[ ${iface} == "lo" && ${config[@]} == "127.0.0.1 netmask 255.0.0.0 broadcast 127.255.255.255" ]]; then
365 || ${config[@]} == "127.0.0.1/8 broadcast 127.255.255.255" ]]; then 367 ifconfig "${iface}" 0.0.0.0
368 fi
369
366 ifconfig "${iface}" ${config[@]} 2>/dev/null 370 ifconfig "${iface}" ${config[@]}
367 r="0"
368 else
369 e=$( ifconfig "${iface}" ${config[@]} 2>&1 )
370 r="$?" 371 r="$?"
371 [[ ${r} != "0" ]] && echo "${e}" > /dev/stderr 372 [[ ${r} != "0" ]] && return ${r}
372 fi
373
374 [[ ${r} != "0" || ${config[0]} == "inet6"* || ${iface} == *:* ]] \
375 && return ${r}
376 373
377 local metric ifvar=$( bash_variable "${iface}" ) 374 local metric ifvar=$( bash_variable "${iface}" )
378 # Remove the newly added route and replace with our metric 375 # Remove the newly added route and replace with our metric
379 eval metric=\"\$\{metric_${ifvar}\}\" 376 eval metric=\"\$\{metric_${ifvar}\}\"
380 [[ ${metric} == "0" || ${RC_AUTO_INTERFACE} != "yes" ]] && return ${r} 377 [[ ${metric} == "0" || ${RC_AUTO_INTERFACE} != "yes" ]] && return ${r}

Legend:
Removed from v.1456  
changed lines
  Added in v.1457

  ViewVC Help
Powered by ViewVC 1.1.20