summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFlavio Leitner <fbl@redhat.com>2017-05-29 16:40:22 -0300
committerBen Pfaff <blp@ovn.org>2017-06-06 17:11:07 -0700
commit0f28164be02ac007f5b5884002b2eaaa945dd18c (patch)
treef040abaac115845a884a20ad8a4cc85dce74522e /lib
parent74fd3cdb6eab5f7661e1921d55d30b1998039297 (diff)
downloadopenvswitch-0f28164be02ac007f5b5884002b2eaaa945dd18c.tar.gz
netdev-linux: make tap devices persistent.
When using data path type "netdev", bridge port is a tun device and when OVS restarts, that device and its network configuration is lost. This patch enables the tap device to persist instead. Signed-off-by: Flavio Leitner <fbl@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/netdev-linux.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 8ae740a17..4763f7428 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -866,6 +866,13 @@ netdev_linux_construct_tap(struct netdev *netdev_)
goto error_close;
}
+ if (ioctl(netdev->tap_fd, TUNSETPERSIST, 1)) {
+ VLOG_WARN("%s: creating tap device failed (persist): %s", name,
+ ovs_strerror(errno));
+ error = errno;
+ goto error_close;
+ }
+
return 0;
error_close:
@@ -885,6 +892,7 @@ netdev_linux_destruct(struct netdev *netdev_)
if (netdev_get_class(netdev_) == &netdev_tap_class
&& netdev->tap_fd >= 0)
{
+ ioctl(netdev->tap_fd, TUNSETPERSIST, 0);
close(netdev->tap_fd);
}