This patch adds support for macvlan interfaces to uci.
 * ifname pattern is ethXvY, where ethX is the physical interface, Y is 
arbitrary
 * you can specify a mac address
 * dependencies: kmod-macvlan, ip

e.g.:

$ uci show network.dmz
network.dmz=interface
network.dmz.proto=dhcp
network.dmz.ifname=eth0v2
network.dmz.macaddr=01:23:45:67:89:ab

Signed-off-by: Johannes Schlatow <[email protected]>

---

Index: package/base-files/files/lib/network/config.sh
===================================================================
--- package/base-files/files/lib/network/config.sh (revision 22530)
+++ package/base-files/files/lib/network/config.sh (working copy)
@@ -66,6 +66,22 @@
   return 1
 }

+add_macvlan() {
+  local vif="${1%v*}"
+  local config=$2
+  +  [ "$1" = "$vif" ] || ifconfig "$1" >/dev/null 2>/dev/null || [ ! -x 
/usr/sbin/ip ] || {
+     ifconfig "$vif" up 2>/dev/null >/dev/null || add_macvlan "$vif" "$config"
+     config_get macaddr $config macaddr
+     [ -z "$macaddr" ] || {
+        macaddr="address $macaddr "
+     }
+     $DEBUG ip link add link "$vif" name "$1" "$macaddr"type macvlan
+     return 0
+  }
+  return 1
+}
+
 # add dns entries if they are not in resolv.conf yet
 add_dns() {
   local cfg="$1"; shift
@@ -154,6 +170,7 @@

   # Setup VLAN interfaces
   add_vlan "$iface" && return 1
+  add_macvlan "$iface" "$config" && return 1
   ifconfig "$iface" 2>/dev/null >/dev/null || return 0

   # Setup bridging
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to