Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed IPv4 to IPv6 mapping in CIPAddress::pton(..) #1664

Merged
merged 2 commits into from
Nov 24, 2020

Conversation

maxsharabayko
Copy link
Collaborator

@maxsharabayko maxsharabayko commented Nov 18, 2020

While converting IPv4 mapped to IPv6 there was an error in the IPv4 index.

Fixes #1663

Added unit test for the case.

TODO

  • Unit test to get 100% coverage of CIPAddress::pton(..)

@maxsharabayko maxsharabayko added Type: Bug Indicates an unexpected problem or unintended behavior [core] Area: Changes in SRT library core labels Nov 18, 2020
@maxsharabayko maxsharabayko added this to the v1.4.3 milestone Nov 18, 2020
@maxsharabayko maxsharabayko self-assigned this Nov 18, 2020
@Haivision Haivision deleted a comment from codecov bot Nov 18, 2020
@maxsharabayko maxsharabayko marked this pull request as ready for review November 19, 2020 08:20
@Haivision Haivision deleted a comment from codecov bot Nov 19, 2020
@maxsharabayko
Copy link
Collaborator Author

maxsharabayko commented Nov 19, 2020

TestIPv6.v4_calls_v6_mapped

Listener

# On HS Conclusion Request:
# CUDT::acceptAndRespond(..)
 
agent_family: IPv6 (m_SelfAddr.family)
peer: "::ffff:127.0.0.1:64888"
ip[4]: 16777343, 0, 0, 0

# After CIPAddress::pton():
m_SelfAddr: "::ffff:127.0.0.1:4200"

# CIPAddress::ntop(peer, (w_hs.m_piPeerIP));
# Goes to HS Conclusion Response
w_hs.m_piPeerIP[4]: 0, 0, 0xFF, 16777343

Caller

# On HS Conclusion Response:
# CUDT::postConnect(..)

m_SelfAddr.family() (agent_family): IPv4 (AF_INET)
ip[4]: 0, 0, 0xFF, 16777343
peer: "127.0.0.1:4200"

Resulting m_SelfAddr: "0.0.0.0:52872"

@maxsharabayko maxsharabayko self-assigned this Nov 19, 2020
@maxsharabayko maxsharabayko marked this pull request as draft November 19, 2020 15:50
@maxsharabayko
Copy link
Collaborator Author

TestIPv6.v6_calls_v4

Caller Sends HS Induction Request

Peer IP Address[4]: 0, 0, 0xFF, 16777343

Listener Sends HS Induction Response:

Peer IP Address[4]: 0, 0, 0xFF, 16777343

Caller Sends HS Conclusion Request

Peer IP Address[4]: 0, 0, 0xFF, 16777343

Listener Sends HS Conclusion Response ❗

Peer IP Address[4]: 16777343, 0, 0xFF, 16777343

@Haivision Haivision deleted a comment from codecov bot Nov 19, 2020

bool is_mapped_ipv4 = (std::mismatch(mbegin, mend, peeraddr16).first == mend);
bool is_mapped_ipv4 = (std::mismatch(mbegin, mend, peeraddr16).first == mend);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const bool is_mapped_ipv4 = std::equal(mbegin, mend, peeraddr16);

srtcore/common.cpp Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Nov 19, 2020

Codecov Report

Merging #1664 (d09ea96) into master (6e25e48) will increase coverage by 0.26%.
The diff coverage is 92.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1664      +/-   ##
==========================================
+ Coverage   60.37%   60.63%   +0.26%     
==========================================
  Files          77       78       +1     
  Lines       17389    17436      +47     
==========================================
+ Hits        10498    10572      +74     
+ Misses       6891     6864      -27     
Impacted Files Coverage Δ
srtcore/common.h 84.55% <ø> (ø)
srtcore/common.cpp 29.43% <86.48%> (+7.76%) ⬆️
srtcore/api.cpp 48.40% <100.00%> (-0.27%) ⬇️
srtcore/core.cpp 55.28% <100.00%> (+0.20%) ⬆️
test/test_common.cpp 100.00% <100.00%> (ø)
srtcore/congctl.cpp 82.05% <0.00%> (-2.06%) ⬇️
test/test_bonding.cpp 98.26% <0.00%> (-0.58%) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6e25e48...d09ea96. Read the comment docs.

Copy link
Collaborator

@ethouris ethouris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor fixes

.github/workflows/cxx11-win.yaml Outdated Show resolved Hide resolved
srtcore/common.cpp Outdated Show resolved Hide resolved
ethouris and others added 2 commits November 23, 2020 11:00
Co-authored-by: Maxim Sharabayko <maxsharabayko@haivision.com>
Co-authored-by: Mathieu Poux <mathieu.poux@gmail.com>
@maxsharabayko
Copy link
Collaborator Author

Due to CI failures, IPv6 connection tests were extracted to PR #1670 for further fixes, while the bug fix can go within this PR.

@maxsharabayko maxsharabayko marked this pull request as ready for review November 23, 2020 15:18
@maxsharabayko maxsharabayko merged commit 3bc810b into Haivision:master Nov 24, 2020
@maxsharabayko maxsharabayko deleted the hotfix/ipv6-pton branch November 24, 2020 06:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[core] Area: Changes in SRT library core Type: Bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix a wrong IP4-mapped-IP6 assignation in CIPAddress::pton
2 participants