From f708bb1465f60bd80fb0722671ce7010d601b3b0 Mon Sep 17 00:00:00 2001 From: Maximilian Wilhelm Date: Fri, 25 Sep 2020 22:04:53 +0200 Subject: [PATCH] link executor: Add support for veth interfaces Signed-off-by: Maximilian Wilhelm --- doc/interfaces.scd | 7 +++++++ executor-scripts/linux/link | 15 ++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/doc/interfaces.scd b/doc/interfaces.scd index f8ba926..8600b4e 100644 --- a/doc/interfaces.scd +++ b/doc/interfaces.scd @@ -73,6 +73,13 @@ the system will only respond to certain keywords by default: *link-type* _link-type_ Denotes the link-type of the interface. When set to _dummy_, the interface is created as a virtual dummy interfaces. + When set to _veth_ the interface is created as virtual veth + interface (pair). + +*veth-peer-name* _peer-name_ + Denotes the name of the veth peer interfaces. If not set + the kernel will name the veth peer interface as _vethN_ + with N being an integer number. *alias* _alias_ Sets the given alias on the interface. diff --git a/executor-scripts/linux/link b/executor-scripts/linux/link index 02633ef..24db96f 100755 --- a/executor-scripts/linux/link +++ b/executor-scripts/linux/link @@ -39,9 +39,18 @@ create) fi ${MOCK} ip link add "${IFACE}" type dummy - fi - if is_vlan; then + elif [ "${IF_LINK_TYPE}" = "veth" ]; then + if [ ! -d "/sys/class/net/${IFACE}" ]; then + ARGS="" + if [ "${IF_VETH_PEER_NAME}" ]; then + ARGS="peer ${IF_VETH_PEER_NAME}" + fi + + ${MOCK} ip link add "${IFACE}" type veth ${ARGS} + fi + + elif is_vlan; then if [ -d "/sys/class/net/${IFACE}" ]; then exit 0 fi @@ -77,7 +86,7 @@ down) ${MOCK} ip link set down dev "${IFACE}" ;; destroy) - if [ "${IF_LINK_TYPE}" = "dummy" ] || is_vlan; then + if [ "${IF_LINK_TYPE}" = "dummy" ] || [ "${IF_LINK_TYPE}" = "veth" ] || is_vlan; then if [ -z "${MOCK}" -a ! -d "/sys/class/net/${IFACE}" ]; then exit 0 fi