-
Notifications
You must be signed in to change notification settings - Fork 7.3k
net: ethernet: strip vlan headers if id is zero #83734
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: ethernet: strip vlan headers if id is zero #83734
Conversation
3908ebd
to
a1d8cbc
Compare
It might be a good idea to have this behavior behind a Kconfig and not by default. What do the others think? |
I do not have a copy of the standard at hand. But it is my understanding, that this is the ieee 802.1q standardized behavior. Can someone confirm? If so, I believe it should be the hard-coded option and not behind a feature flag. |
This would also fix issue #83277 for me. |
I could not locate the spec where this is described. The feature is called We should enable this unconditionally so no Kconfig option for this is needed. |
Does someone have time to help with the tests? |
include/zephyr/net/ethernet.h
Outdated
#if defined(CONFIG_NET_VLAN) | ||
#define _NET_ETH_MAX_HDR_SIZE (sizeof(struct net_eth_vlan_hdr)) | ||
#else | ||
#define _NET_ETH_MAX_HDR_SIZE (sizeof(struct net_eth_hdr)) | ||
#endif |
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 do we need this? If VLAN is disabled, then we only support normal Ethernet header lengths.
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.
The hole point of this PR is to allow to receive VLAN 0 priority tag
ged frames, even if VLAN is disabled. This can only be achieved, if there is enough space in the header for the priority tagged header.
In practice, if this is not adjusted, the frames with maximum length can not be received (see linked issue in stm driver).
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.
I reverted this. Users, who want to receive priority tagged frames need to enable CONFIG_NET_VLAN
now.
subsys/net/l2/ethernet/ethernet.c
Outdated
enum net_verdict verdict; | ||
|
||
net_pkt_set_vlan_tci(pkt, ntohs(hdr_vlan->vlan.tci)); | ||
if (type == NET_ETH_PTYPE_VLAN) { |
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.
If VLAN is disabled, then we should never receive VLAN frames. So with this in mind, I think we do need to have the config option check, no?
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.
I have assumed, that we want to receive priority tagged VLAN
even if it is disabled.
An alternative approach would be, that it has to be enabled, but the VLAN_COUNT=0
of actual virtual interfaces is zero. Is this what you have in mind?
Ie. If someone whats to receive priority tagged vlan
headers, they need to enable CONFIG_NET_VLAN
but they will not have any actual virtual LAN interface?
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.
As mentioned above. I reverted this logic. User must now enable CONFIG_NET_VLAN
to receive priority tagged frames.
@jukkar If someone whats to receive
? Also |
@jukkar One reason, that speaks against that solution is, that we do not actually need/want I am curious about your preferred way forward? |
a1d8cbc
to
68ff9bf
Compare
Idea is now, that configuration to receive only priority tagged frames without actually enabling a virtual interface looks like:
I will have to test, if this actually works. Feedback is welcome :) |
Testing it leads to a problem.
With
Why does it say |
I am not really sure if my understanding of this feature is correct, but I thought about VLAN 0 like this:
WDYT? |
subsys/net/l2/ethernet/Kconfig
Outdated
@@ -41,7 +41,7 @@ config NET_VLAN | |||
config NET_VLAN_COUNT | |||
int "Max VLAN tags supported in the system" | |||
default 1 | |||
range 1 $(UINT8_MAX) | |||
range 0 $(UINT8_MAX) |
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.
IMHO this is not needed because it basically disables VLAN
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.
See my explenation: #83734 (comment)
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.
I try to find a way to make room for the use case of receiving VLAN 0 frames without having an actual virtual interface enabled. This is my use case.
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.
Hmm, I am not sure you need to enable the VLAN virtual interface. I mean the enabled indicates that the interface has a tag assigned to it. But to receive tag 0, this is not needed.
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.
Hmm, I am not sure you need to enable the VLAN virtual interface. I mean the enabled indicates that the interface has a tag assigned to it. But to receive tag 0, this is not needed.
Are you saying, that I should go back to initial draft of always (without CONFIG_VLAN
enabled) forwarding tag 0 to the native interface?
This would be my preferred solution. But it has other consequences. It requires, the increase in the expected header size as in the initial draft for example.
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.
I have reverted. Solution no longer requires CONFIG_VLAN
.
Fair enough. My initial draft wanted to not require the user to select
Agree.
Agree.
Disagree. How else is the user supposed to express their interest in selecting VLAN 0 without having any virtual interface for normal VLAN traffic (tags > 0). This is my usecase. I.E. They want VLAN 0 traffic but no actual proper virtual interface. |
I don't think this is really feasible without major changes (not fully sure about this). Fortunately you do not need to enable the virtual interface to support VLAN 0. |
Ok, will revert to initial draft about this respect. 👍 |
e5f6721
to
1fc86fe
Compare
I have reverted this aspect. Now everyone will be able to receive vlan frames with id |
Is it not compliant to reference a config ( |
include/zephyr/net/ethernet.h
Outdated
#if defined(CONFIG_NET_VLAN) | ||
/* | ||
* Leave enough space in the header for vlan, even if CONFIG_VLAN is not enabled, | ||
* so that frames with a vlan-header and vlan-id NET_VLAN_ID_NATIVE can be | ||
* forwarded to the native interface. | ||
*/ | ||
#define _NET_ETH_MAX_HDR_SIZE (sizeof(struct net_eth_vlan_hdr)) | ||
#else | ||
#define _NET_ETH_MAX_HDR_SIZE (sizeof(struct net_eth_hdr)) | ||
#endif |
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.
If we do this change (which I think is not needed), then the net_pkt tests would need to be fixed as they are failing because of this.
If CONFIG_NET_VLAN
is disabled, then we should not be able to receive Ethernet frames that have the VLAN information in it. So we should not increase the max frame size in that case.
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.
Hmm, I am not sure you need to enable the VLAN virtual interface. I mean the enabled indicates that the interface has a tag assigned to it. But to receive tag 0, this is not needed.
It is needed. Otherwise id 0 frames can not be received.
I can try to fix, but I would like to get your approval on the approach first.
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.
reverted and created separate issue: #84023
1fc86fe
to
da5842f
Compare
As discussed in discord, have reverted to more basic solution and added issue for optimized solution here: #84023 |
da5842f
to
5903359
Compare
5903359
to
3ce3777
Compare
Packets are forwarded to the native interface or in other words, the vlan header is simply stripped and ignored. This feature is called 'priority tagging'. Signed-off-by: Cla Mattia Galliard <[email protected]> Signed-off-by: Jukka Rissanen <[email protected]>
3ce3777
to
16c4735
Compare
|
Make sure we are able to receive VLAN tag 0 packet, and verify that reply packet is sent correctly. Signed-off-by: Jukka Rissanen <[email protected]>
16c4735
to
b918a3b
Compare
Allow to receive vlan frames with id zero even when the vlan interface is disabled. They are forwarded to the native interface or in other words, the vlan header is simply stripped and ignored.
#83662