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
net: ip: Introduce mesh_local flag #12731
net: ip: Introduce mesh_local flag #12731
Conversation
@mike-scott @aurel32 Note that though the concept remained similar in this solution, the implementation is slightly different to what you've tested yesterday. It'd be good if you could give it a try with your use-cases. |
@rlubos Do you have a reference in an RFC? Could be nice to add it in the commit message then. |
Codecov Report
@@ Coverage Diff @@
## master #12731 +/- ##
==========================================
- Coverage 54.06% 54.06% -0.01%
==========================================
Files 239 239
Lines 26922 26924 +2
Branches 6505 6506 +1
==========================================
Hits 14556 14556
- Misses 9701 9702 +1
- Partials 2665 2666 +1
Continue to review full report at Codecov.
|
@tbursztyka Not exactly a RFC, the concept was more or less introduced by Thread, which differentiates between mesh-local addresses and global addresses (I'm not aware of RFC covering that). And the former ones should only be used within a mesh. In Thread specification. ch. 5.2.2.5, we have:
And later in ch. 9.2.4:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good. Any idea why there is *
char in front of the address as the shell is not printing those, or did you add them manually in this example?
*fdde:ad00:beef:0:1bc2:6311:f1e7:31a4 autoconf preferred infinite meshlocal
fe80::28a6:a531:967d:9660 autoconf preferred infinite
*fdde:ad00:beef::2 manual preferred infinite meshlocal
It seems the mesh-local addresses concept from Thread is a bit similar to the site-local addresses that was deprecated by RFC3879. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good to me. I have tested it here on a OT network where I haven't attributed GUA addresses, and it works fine. I am able to use COAP with the nodes using the ML-EID addresses.
@jukkar It was manual addition, sorry for confusion. |
@aurel32 I'd say it's a Realm-Local scope, which was introduced in rfc7346 for multicast purposes. It has specialized definition for 15.4 networks:
|
@rlubos The IP range used for mesh-local addresses by Thread corresponds to the unique local address (ULA) range, as defined by RFC4193. |
@aurel32 Yes, you are right. The point is, the same IP range (ULA) is used in prefixes distributed by Border Routers (see unstarred unicast addresses in my example), and these prefixes (and therefore addresses created with them) are allowed to be used outside of the mesh (and to be honest that's why they are assigned). Hence we need more information to differentiate these. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First commit message has "addresss" (3 "s").
But most importantly, let's say again (in commit message I guess), what happens if we add NET_ADDR_MESH_LOCAL instead?
NET_ADDR_AUTOCONF, 0); | ||
|
||
if (if_addr == NULL) { | ||
NET_WARN("Not enough buffers to register OpenThread's" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why "buffers"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this is not NET_WARN I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why "buffers"?
Because of lack of better word for "IP address placeholder"
And this is not NET_WARN I guess.
And what exactly is wrong with NET_WARN?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of lack of better word for "IP address placeholder"
The right word would be "entry", but the whole message is problematic. That message is printed when net_if_ipv6_addr_add() returns NULL. Are you sure that the only condition when it does that is when there're no free address entries? Are you sure it'll stay like that in the future? "Cannot add OpenThread <if possible, type> address" is the message which will never lie. (I'm all for more detailed error messages, but as I said, there're limits to it all.)
And what exactly is wrong with NET_WARN?
Because it's error. Unless that address is not used for anything useful, and we add it just for fun ;-).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll update this piece
if (if_addr == NULL) { | ||
NET_WARN("Not enough buffers to register OpenThread's" | ||
" IP address. Increase " | ||
"CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I absolutely love self-diagnosing software. But as other things I love, I also like to know limits on them. For example, I do it like this (explicitly hint user that by enabling some config var they can get more info) in the shell. But that's because shell is a debugging feature. Speaking of error messages, this one would be first of such nature. (So, do we need such a long error message?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I don't follow this comment (beside of the last sentence).
I'm not convinced about writing "what if" statements in commit message. But to answer you question, I did not reuse |
Ok, please add a short paragraph describing this situation to the commit message, so it can be found by someone who'll investigate it in the future. |
This commit introduces a concept of mesh-local IPv6 addresses. Such addresses should only be used for mesh-local communication, therefore should not be used to communicate with different subnets (i. e. destinations outside the mesh). As `addr_type` field already holds different kind of information (whether address was created automatically/manually) it was not used in this case. Instead a mesh_local flag was added, so that we do not lose information on how address was created. Address with such flag set will only be selected as a source address automatically if the destination address is within the same subnet it belongs to. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Mark automatically and statically configured mesh-local addresses with mesh_local flag, so that they are not used as a source for off-mesh destinations. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
8054cef
to
d79034a
Compare
Updated the commit message and error message. |
Sorry for the delay, the depreciation changes are making it semi- difficult to swap back and forth between dev trees and master at the moment. I tested this today using #12781
Works great, thanks @rlubos |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I'm not sure if the test_select sanity failure is due to this commit. Might want to re-run. |
This PR introduces a concept of mesh-local address. Such addresses (used for instance by Thread) are fine to use for on-mesh communication, but should not be used when sending packets off-mesh.
Source address selection algorithm needs to distinguish between addresses that have mesh-local (or Realm-local in IPv6 nomenclature) scope and other addresses. As they all have form of ULA, it cannot be distinguished on the address format itself, which lead to erroneous source address assignment. Therfore, an additional flag was added to the
net_if_addr
structure that can store this information.Mesh-local addresses will only be used as a source address for destinations placed within the same subnet (mesh).
A sample interface configuration is shown below. Starred addresses were marked as
meshlocal
, therefore they'll only be selected for on-mesh communication.Resolves #12203