babeld: Take interface name from "option ifname"
authorBaptiste Jonglez <baptiste--git@jonglez.org>
Fri, 29 Aug 2014 06:43:17 +0000 (08:43 +0200)
committerBaptiste Jonglez <baptiste--git@jonglez.org>
Fri, 29 Aug 2014 08:19:42 +0000 (10:19 +0200)
Previously, we were using the name of the section as the interface name,
but this has several drawbacks:

- no "-" or other special characters are allowed in a section name,
  preventing some physical interface names to be specified this way
  (e.g. "tun-topeka" would not work)
- it is harder to support default interface options (no interface name)

This change is not backward compatible, but a later commit will fix that.

babeld/files/babeld.init

index ea4b348f97d7ca35cf3696bd8b2e817f61ca5746..cb98e391d9519fcdda0b50dd6c62b39b2f2e0536 100755 (executable)
@@ -102,11 +102,17 @@ babel_config_cb() {
                }
        ;;
        "interface")
                }
        ;;
        "interface")
+               local _ifname
+               config_get _ifname "$section" 'ifname'
+               # Try to resolve the logical interface name
                unset interface
                unset interface
-               network_get_device interface "$section" || interface="$section"
+               network_get_device interface "$_ifname" || interface="$_ifname"
                option_cb() {
                        local option="$1"
                        local value="$2"
                option_cb() {
                        local option="$1"
                        local value="$2"
+                       # "option ifname" is a special option, don't actually
+                       # generate configuration for it.
+                       [ "$option" = "ifname" ] && return
                        cfg_append "interface $interface ${option//_/-} $value"
                }
                # Handle ignore options.
                        cfg_append "interface $interface ${option//_/-} $value"
                }
                # Handle ignore options.