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

issue: 3382805 Fixing incorrect handling of src field of IPv4 routing #126

Open
wants to merge 5 commits into
base: vNext
Choose a base branch
from

Conversation

AlexanderGrissik
Copy link
Collaborator

Description

Fix usage of src routing field of IPv4

What

The src field should be used for src address selection only (As done for IPv6) and not as identifying interfaces or routing decisions.
This eliminates incorrect behavior and warnings such as "could not figure out source ip for rtv".

Why ?

Functionality

Change type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Tests
  • Other

Check list

  • Code follows the style de facto guidelines of this project
  • Comments have been inserted in hard to understand places
  • Documentation has been updated (if necessary)
  • Test has been added (if possible)

Instead of using src address of the routing resolution result to identify interface, especially in IPv4 multicast case,
use the if_index of the routing result.

Signed-off-by: Alexander Grissik <agrissik@nvidia.com>
In case of IPv4 bind to any ip avoid trying to register dst_entry as observer with routing src field
which should be used for outgoing address selection and not for routing rule decisions.

What was happening: If we found routing for any IP, we looked if that routing has src-ip field.
In case of IPv4, if routing entry has no src-ip (which is common), we forcefully set it to the first address of the device related to this routing entry.
And so, we go and look for another routing entry by giving now the src field of the routing we found.
That src field affects the routing rule selection. Appart the fact this is not hte goal of the src routing field,
in most cases it ends up with the same device we dicovered at first place.

Signed-off-by: Alexander Grissik <agrissik@nvidia.com>
Route entry src field should be used for src addr selection algorithm.
Forcing src addr based on interface IPs may lead to wrong src addr selection.

Signed-off-by: Alexander Grissik <agrissik@nvidia.com>
Registering a route entry per device is not used. The entry does not track device up/down events.

Signed-off-by: Alexander Grissik <agrissik@nvidia.com>
The m_src_addr field can be used now. No need for special one.

Signed-off-by: Alexander Grissik <agrissik@nvidia.com>
Copy link
Member

@pasis pasis left a comment

Choose a reason for hiding this comment

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

Review is not finished yet

}

si_udp_logdbg("IPPROTO_IP, %s=%d.%d.%d.%d, mc_if:%d.%d.%d.%d mc_if:%d.%d.%d.%d",
Copy link
Member

Choose a reason for hiding this comment

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

Inconsistency between format and arguments.

Also, you can use ip_address object to print pretty to_str() which is IP version independent. You already need to wrap mc_grp with ip_address for resolve_if_ip().

@@ -1127,31 +1127,16 @@ int sockinfo_udp::setsockopt(int __level, int __optname, __const void *__optval,
break;
}

// Find local interface IP address
// Find local if for this MC ADD/DROP
Copy link
Member

Choose a reason for hiding this comment

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

[suggestion] local interface instead of local if.

Comment on lines 438 to +442
rt_mgr_logdbg("dst ip '%s' resolved to if_index: %d, src-addr: %s, gw-addr: %s, "
"route-mtu: %" PRIu32,
dst_addr.to_str(family).c_str(), res.if_index,
res.src.to_str(family).c_str(), res.gw.to_str(family).c_str(), res.mtu);
p_val->get_src_addr().to_str(family).c_str(),
p_val->get_gw_addr().to_str(family).c_str(), res.mtu);
Copy link
Member

Choose a reason for hiding this comment

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

[suggestion] Mix of res and p_val in the arguments can lead to inconvenient changes in the future. I'd suggest to use a single object consistently (p_val in this case). Not critical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants