2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2012 IPFire Network Development Team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 MACVLAN_PORT_INTERFIX
="mv"
24 function macvlan_create
() {
34 # Check if the parent device exists.
35 if ! device_exists
${parent}; then
36 log ERROR
"macvlan: parent device '${parent}' does not exist"
40 # Check if the device we want to create does not already exist.
41 if device_exists
${device}; then
42 log ERROR
"macvlan: device '${device}' already exists"
46 # The macvlan device cannot be created, when the parent device
47 # is attached to a bridge. So we detach the parent device and
50 if device_is_bridge_attached
${parent}; then
51 bridge
=$
(device_get_bridge
${parent})
53 # Detach the parent device.
54 bridge_detach_device
${bridge} ${parent}
57 # Actually create the device.
58 cmd_quiet ip link add link
${parent} name ${device} address ${address} \
62 if [ ${ret} -eq ${EXIT_OK} ]; then
63 log DEBUG
"macvlan device '${device}' has been created"
65 log ERROR
"Could not create macvlan device '${device}': ${ret}"
70 bridge_attach_device
${bridge} ${parent}
76 function macvlan_remove
() {
80 device_delete
${device}