Bug 2377

Summary: SocketIpTosTag and SocketIpv6TclassTag may be added twice
Product: ns-3 Reporter: Stefano Avallone <stavallo>
Component: internetAssignee: Tommaso Pecorella <tommaso.pecorella>
Status: RESOLVED FIXED    
Severity: enhancement CC: ns-bugs
Priority: P5    
Version: ns-3-dev   
Hardware: PC   
OS: Linux   
Attachments: Proposed fix
Proposed fix v2

Description Stefano Avallone 2016-04-19 12:59:02 UTC
Created attachment 2390 [details]
Proposed fix

int UdpSocketImpl::SendTo (Ptr<Packet> p, uint32_t flags, const Address &address) adds a SocketIpTosTag or a SocketIpv6TclassTag (depending on the IP protocol version) and then calls 
int UdpSocketImpl::DoSendTo (Ptr<Packet> p, Ipv{4|6}Address dest, uint16_t port), which add the same tags as well.

To verify the issue, I modified the udp test by adding txSocket->SetIpTos (10); in void UdpSocketImplTest::DoRun (void).

The test indeed crashed:

---------- begin standard err ----------
assert failed. cond="cur->tid != tag.GetInstanceTypeId ()", msg="Error: cannot add the same kind of tag twice.", file=../src/network/model/packet-tag-list.cc, line=250
terminate called without an active exception

---------- end standard err ----------
CRASH: TestSuite udp
0 of 1 tests passed (0 passed, 0 skipped, 0 failed, 1 crashed, 0 valgrind errors)

Attached is the proposed fix, which consists in only having the DoSendTo functions (which are ultimately called by all the other Send variants) add the tags. After applying the fix, the udp test passes again.
Comment 1 Stefano Avallone 2016-04-19 13:04:03 UTC
Created attachment 2391 [details]
Proposed fix v2

Clearly, the changes to the udp test are not part of the fix :-)
Comment 2 Tommaso Pecorella 2016-04-19 18:19:40 UTC
Thanks,

pushed in changeset: 12090:846fe53b77fc