Skip to content

net: Align interface numbering with POSIX/BSD/Linux #13084

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

Closed
pfalcon opened this issue Feb 6, 2019 · 6 comments
Closed

net: Align interface numbering with POSIX/BSD/Linux #13084

pfalcon opened this issue Feb 6, 2019 · 6 comments
Assignees
Labels
area: Networking area: Sockets Networking sockets bug The issue is a bug, or the PR is fixing a bug

Comments

@pfalcon
Copy link
Collaborator

pfalcon commented Feb 6, 2019

Currently, Zephyr uses natural 0-based numbering of networking interfaces (0 - first interface, 1 - next, etc.) However, the BSD networking API (which is the basis for POSIX, Linux, etc.) use a more adhoc numbering. E.g. quoting http://man7.org/linux/man-pages/man7/packet.7.html :

sll_ifindex is the interface index of the interface (see
netdevice(7)); 0 matches any interface (only permitted for bind‐
ing). sll_hatype is an ARP type as defined in the
<linux/if_arp.h> include file.

In other words, BSD numbering is 1-based, and 0 has a special meaning of "any"/"all" interfaces - and it's used consistently wherever an interface index appears, not just for packet sockets quoted above.

Based on the discussing in #12564 (comment) , the best way to deal with that would be to switch Zephyr to use the same numbering even on native level (vs for example trying to keep 0-based "native" index and convert it back and forth for Socket API level).

As we can't realistically do that change for 1.14, submitting this reminder ticket, and considering it's "ok" to use 0-based numbering in initial parts going into 1.14.

@pfalcon pfalcon added the bug The issue is a bug, or the PR is fixing a bug label Feb 6, 2019
@pfalcon
Copy link
Collaborator Author

pfalcon commented Feb 6, 2019

@jukkar, @tbursztyka, @rveerama1, @rlubos, @mike-scott : FYI.

@pfalcon pfalcon added this to the v1.15.0 milestone Feb 6, 2019
@tbursztyka
Copy link
Collaborator

@pfalcon will you propose a patch for it? The fix sounds rather trivial, as only the socket interface handles the iface index that way, no need to change how iface are indexed in the core side.

@pfalcon
Copy link
Collaborator Author

pfalcon commented Feb 6, 2019

as only the socket interface handles the iface index that way, no need to change how iface are indexed in the core side.

That's not what @jukkar said in the discussion linked above.

@tbursztyka
Copy link
Collaborator

well the net_if_get_by_index() etc.. doing the +1 and so on, is an easier solution actually

@tbursztyka
Copy link
Collaborator

However as 1.14 is going to be LTS, I would advise to fix that. It's a bug, so we have almost 2month of bug fix before the actual release.

@pfalcon
Copy link
Collaborator Author

pfalcon commented Feb 6, 2019

However as 1.14 is going to be LTS, I would advise to fix that. It's a bug, so we have almost 2month of bug fix before the actual release.

Well, I can only +1 such approach. Anyway, it comes from @rveerama1's #12564, where he asked for response whether this issue is blocking for that PR, and the consensus was that we shouldn't dump that on him, he already does a great work of resolving other matters as required by packet socket.

So, this is made a separate issue, and I'm all for resolving it for 1.14 whenever possible.

@pfalcon pfalcon removed this from the v1.15.0 milestone Feb 6, 2019
@jukkar jukkar self-assigned this Feb 14, 2019
jukkar added a commit to jukkar/zephyr that referenced this issue Feb 18, 2019
In order to follow the BSD socket numbering of the network
interfaces, start numbering from 1. The index 0 is reserved
to mean any interface in BSD socket code.

Fixes zephyrproject-rtos#13084

Signed-off-by: Jukka Rissanen <[email protected]>
nashif pushed a commit that referenced this issue Feb 18, 2019
In order to follow the BSD socket numbering of the network
interfaces, start numbering from 1. The index 0 is reserved
to mean any interface in BSD socket code.

Fixes #13084

Signed-off-by: Jukka Rissanen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Networking area: Sockets Networking sockets bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

No branches or pull requests

3 participants