Commit 89473be8 authored by Jose A. Lopes's avatar Jose A. Lopes
Browse files

Add TAP interface name as argument in '_OpenTap'



This is necessary in order to create TAP interfaces for the
communication mechanism, which are named 'gnt.com.%d', where '%d' is a
unique number within a given node.
Signed-off-by: default avatarJose A. Lopes <jabolopes@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent 3af1359f
......@@ -283,7 +283,7 @@ def _ProbeTapVnetHdr(fd, _features_fn=_GetTunFeatures):
return result
def _OpenTap(vnet_hdr=True):
def _OpenTap(vnet_hdr=True, name=""):
"""Open a new tap device and return its file descriptor.
This is intended to be used by a qemu-type hypervisor together with the -net
......@@ -291,6 +291,11 @@ def _OpenTap(vnet_hdr=True):
@type vnet_hdr: boolean
@param vnet_hdr: Enable the VNET Header
@type name: string
@param name: name for the TAP interface being created; if an empty
string is passed, the OS will generate a unique name
@return: (ifname, tapfd)
@rtype: tuple
......@@ -306,7 +311,7 @@ def _OpenTap(vnet_hdr=True):
flags |= IFF_VNET_HDR
# The struct ifreq ioctl request (see netdevice(7))
ifr = struct.pack("16sh", "", flags)
ifr = struct.pack("16sh", name, flags)
try:
res = fcntl.ioctl(tapfd, TUNSETIFF, ifr)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment