Bug 2785

Summary: TapBridge::ReceiveFromBridgedDevice(): Write error on Linux >= 4.4
Product: ns-3 Reporter: Piotr Jurkiewicz <piotr.jerzy.jurkiewicz>
Component: tap-bridgeAssignee: Tom Goff <tgoff>
Status: NEEDINFO ---    
Severity: normal CC: ns-bugs, tomh
Priority: P3    
Version: ns-3-dev   
Hardware: All   
OS: All   
Attachments: tap-bridge: Ignore EIO on write

Description Piotr Jurkiewicz 2017-09-25 19:10:49 EDT
Created attachment 2925 [details]
tap-bridge: Ignore EIO on write

Since Linux upstream commit 1bd4978a88ac("tun: honor IFF_UP in tun_get_user()"), included in 4.4, writing to a tap device that is not up sets errno to EIO.

Before 4.4 it did no result in error, packets written to an uninitialized tap device were silently dropped.

https://github.com/torvalds/linux/commit/1bd4978a88ac

Due to this change, ns-3 with TapBridge randomly crashes on startup when it tries to write to a device which is not yet UP with the following error:

aborted. cond="bytesWritten != p->GetSize ()", msg="TapBridge::ReceiveFromBridgedDevice(): Write error.", file=../src/tap-bridge/model/tap-bridge.cc, line=994

Similar problem: https://mail.openvswitch.org/pipermail/ovs-dev/2016-June/316261.html

The attached patch fixes the problem by ignoring EIO on write to tap interface. It also adds initialization for previously uninitialized m_linkUp variable.
Comment 1 Tom Henderson 2017-10-03 19:46:17 EDT
Piotr, should we be ignoring the error (is it masking a real failure to use the device)?