diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2012-01-13 15:54:10 -0800 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2012-01-13 15:57:22 -0800 |
commit | 380752f4e0726ecd5267fc3d86b87923714c6d07 (patch) | |
tree | 5a7c660dcee847efeeb9af203314bffe77ee563b | |
parent | e7649f117af827a855baeaa2fc72a5cf1a09f31c (diff) |
net: allow parameters to a single address config
In the case of a single line of configuration, where the address has
parameters, the parameters were being treated as seperate addresses.
Eg:
config_eth0="4321:0:1:2:3:4:567:89ab/64 nodad home preferred_lft 0"
Also document usage of parameters in the net example, and note that
multiple addresses on a single line cannot be mixed with parameters.
Newlines are required to seperate the addresses.
X-Gentoo-Bug: 398827
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=398827
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rw-r--r-- | doc/net.example.Linux.in | 9 | ||||
-rw-r--r-- | init.d/net.lo.in | 14 |
2 files changed, 17 insertions, 6 deletions
diff --git a/doc/net.example.Linux.in b/doc/net.example.Linux.in index fd141349..666b44fd 100644 --- a/doc/net.example.Linux.in +++ b/doc/net.example.Linux.in @@ -68,6 +68,7 @@ # NOTE: ifconfig creates an aliased device for each extra IPv4 address # (eth0:1, eth0:2, etc) # iproute2 does not do this as there is no need to +# WARNING: You cannot mix multiple addresses on a line with other parameters! #config_eth0="192.168.0.2/24 192.168.0.3/24 192.168.0.4/24" # However, that only works with CIDR addresses, so you can't use netmask. @@ -85,6 +86,14 @@ # If you don't want ANY address (only useful when calling for advanced stuff) #config_eth0="null" +# If you need to pass parameters to go with an address, you can do so on the +# same line as the address. You should split multiple addresses with newlines. +# WARNING: You cannot mix multiple addresses on a line with other parameters! +#config_eth0="192.168.0.2/24 scope host" +#config_eth0="4321:0:1:2:3:4:567:89ab/64 nodad home preferred_lft 0" +#config_eth0="192.168.0.2/24 scope host +#4321:0:1:2:3:4:567:89ab/64 nodad home preferred_lft 0" + # Here's how to do routing if you need it # We add an IPv4 default route, IPv4 subnet route and an IPv6 unicast route #routes_eth0="default via 192.168.0.1 diff --git a/init.d/net.lo.in b/init.d/net.lo.in index 29135614..9fdeaba1 100644 --- a/init.d/net.lo.in +++ b/init.d/net.lo.in @@ -431,16 +431,18 @@ _load_config() set -- ${config} # We should support a space separated array for cidr configs + # But only as long as they do not contain other parameters for the address if [ $# = 1 ]; then unset IFS set -- ${config} # Of course, we may have a single address added old style. - case "$2" in - netmask|broadcast|brd|brd+|peer|pointopoint) - local IFS="$__IFS" - set -- ${config} - ;; - esac + # If the NEXT argument is a v4 or v6 address, it's the next config. + # Otherwise, it's arguments to the first config... + if [ "${2#*.*}" = "${2}" -a "${2#*:*}" = "${2}" ]; then + # Not an IPv4/IPv6 + local IFS="$__IFS" + set -- ${config} + fi fi # Ensure that loopback has the correct address |