Bug 2377 - SocketIpTosTag and SocketIpv6TclassTag may be added twice
SocketIpTosTag and SocketIpv6TclassTag may be added twice
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: internet
ns-3-dev
PC Linux
: P5 enhancement
Assigned To: Tommaso Pecorella
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-04-19 12:59 UTC by Stefano Avallone
Modified: 2016-04-19 18:19 UTC (History)
1 user (show)

See Also:


Attachments
Proposed fix (1.74 KB, patch)
2016-04-19 12:59 UTC, Stefano Avallone
Details | Diff
Proposed fix v2 (1.27 KB, patch)
2016-04-19 13:04 UTC, Stefano Avallone
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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