On 08/10/2010 01:58 AM, Johannes Schlatow wrote: > On 08/09/2010 10:01 PM, Felix Fietkau wrote: >> On 2010-08-09 9:36 PM, Johannes Schlatow wrote: >>> 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 >> I don't like the arbitrary naming pattern and the config format >> ambiguities that it introduces. Could you please change the config >> format to make the distinction between macvlan and other stuff more >> clear, and also allow the user to specify macvlan interface name and >> base interface name separately. >> >> - Felix > > Okay. I suppose you would expect something like this: > > $ uci show network.dmz > network.dmz.proto=dhcp > network.dmz.ifname=myvlan0 > network.dmz.type=macvlan > network.dmz.basedev=eth0 > network.dmz.macaddr=01:23:45:67:89:ab > > --- > > 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) > @@ -154,11 +154,30 @@ > > # Setup VLAN interfaces > add_vlan "$iface" && return 1 > - ifconfig "$iface" 2>/dev/null >/dev/null || return 0 > > - # Setup bridging > local iftype > config_get iftype "$config" type > + > + [ "$iftype" = "macvlan" ] && { > + local macaddr > + local basedev > + > + config_get macaddr "$config" macaddr > + config_get basedev "$config" basedev > + > + [ -z "$macaddr" ] || { > + macaddr="address $macaddr " > + } > + > + [ -z "$basedev" ] || { > + $DEBUG ip link add link ${basedev} name ${iface} ${macaddr}type > macvlan > + return 1 > + } > + } > + > + ifconfig "$iface" 2>/dev/null >/dev/null || return 0 > + > + # Setup bridging > case "$iftype" in > bridge) > local macaddr
I just realized, that there are two issues with this patch. Firstly, the return statement after 'ip link..' has to be 'return 0' instead of 'return 1'. Secondly, the interfaces are not created during boot, because ifup needs to be called for this. A few lines in /etc/config/network:boot() will fix this. Sorry for that. I think in the future I shouldn't propose a patch on 2.00 am ;) I could email the appropriate patches, if you like to add this feature to OpenWrt. /Johannes _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel