forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
VLAN support #6
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
VLAN support #6
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create infrastructure that allows ethernet device driver to tell if it supports network packet checksum offloading. This applies only to IPv4, UDP or TCP checksums. The driver can enable/disable checksum offloading separately for Tx and Rx network packets. If the device (ethernet in this case) can calculate the network packet checksum for IPv4, UDP or TCP, then do not calculate the corresponding checksum by the stack itself. Fixes zephyrproject-rtos#2987 Signed-off-by: Jukka Rissanen <[email protected]>
Test that if the checksum offloading is enabled, then we do not calculate the checksum. Also the normal case, where offloading is disabled and we need to calculate the checksum, is tested. Signed-off-by: Jukka Rissanen <[email protected]>
Move IP address settings from net_if to separate structs. This is needed for VLAN support. Signed-off-by: Jukka Rissanen <[email protected]>
Instead of always allocating both IPv6 and IPv4 address information to every network interface, allow more fine grained address configuration. So it is possible to have IPv6 or IPv4 only network interfaces. This commit introduces two new config options: CONFIG_NET_IF_MAX_IPV4_COUNT and CONFIG_NET_IF_MAX_IPV6_COUNT which tell how many IP address information structs are allocated statically. At runtime when network interface is setup, it is then possible to attach this IP address info struct to a specific network interface. This can save considerable amount of memory as the IP address information struct can be quite large (depends on how many IP addresses user configures in the system). Note that the value of CONFIG_NET_IF_MAX_IPV4_COUNT and CONFIG_NET_IF_MAX_IPV6_COUNT should reflect the estimated number of network interfaces in the system. So if if CONFIG_NET_IF_MAX_IPV6_COUNT is set to 1 and there are two network interfaces that need IPv6 addresses, then the system will not be able to setup IPv6 addresses to the second network interface in this case. This scenario might be just fine if the second network interface is IPv4 only. The net_if.c will print a warning during startup if mismatch about the counts and the actual number of network interface is detected. Signed-off-by: Jukka Rissanen <[email protected]>
Add context option support and implement PRIORITY option that can be used to classify the network traffic to different trafic classes according to said priority value. Signed-off-by: Jukka Rissanen <[email protected]>
Allow caller to create array of thread stacks using NET_STACK_ARRAY_DEFINE() macro. This allows more debug information to be printed by "net stacks" command. Signed-off-by: Jukka Rissanen <[email protected]>
With this commit it is possible to add priority to sent or received network packets. So user is able to send or receive higher priority packets faster than lower level packets. The traffic class support is activated by CONFIG_NET_TC_COUNT option. The TC support uses work queues to separate the traffic. The priority of the work queue thread specifies the ordering of the network traffic. Each work queue thread handles traffic to one specific work queue. Note that you should not enable traffic classes unless you really need them by your application. Each TC thread needs stack so this feature requires more memory. It is possible to disable transmit traffic class support and keep the receive traffic class support, or vice versa. If both RX and TX traffic classes are enabled, then both will use the same number of queues defined by CONFIG_NET_TC_COUNT option. Fixes zephyrproject-rtos#6588 Signed-off-by: Jukka Rissanen <[email protected]>
Test that we can set the priority of the network packet and that high priority packets are sent before low priority ones. Signed-off-by: Jukka Rissanen <[email protected]>
Calculate network packet total length once and then use that value instead of calculating it many times in a row. Signed-off-by: Jukka Rissanen <[email protected]>
Add statistics for number of packets and bytes to each traffic class. Print this information in net-shell. Signed-off-by: Jukka Rissanen <[email protected]>
The "net stacks" command was printing TX or RX thread values so that it was not possible to use the values in debugging easily. Add traffic class value when printing the info so that it is easy to see what TX or RX queue is doing. Signed-off-by: Jukka Rissanen <[email protected]>
This demostrates how to classify the network traffic when sending data. The application will create similar functionality as echo-client so user can use echo-server running in remote host to test this sample application. Signed-off-by: Jukka Rissanen <[email protected]>
As the config file disables ARC we can use its RAM and ROM in x86 side. Signed-off-by: Jukka Rissanen <[email protected]>
As the config file disables ARC we can use its RAM and ROM in x86 side. Signed-off-by: Jukka Rissanen <[email protected]>
This avoids this crashing in qemu_x86 ***** Stack Check Fail! ***** Current thread ID = 0x004015e0 Faulting segment:address = 0x0008:0x00003593 eax: 0x0041e930, ebx: 0x00000000, ecx: 0x004170bc, edx: 0x0000dff8 esi: 0xffffffff, edi: 0x0041e930, ebp: 0x00417010, esp: 0x00416ffc eflags: 0x216 Fatal fault in essential thread! Spinning... Terminate emulator due to fatal kernel error Signed-off-by: Jukka Rissanen <[email protected]>
This allows creation of virtual lan (VLAN) networks. VLAN support is only available for ethernet network technology. Fixes zephyrproject-rtos#3234 Signed-off-by: Jukka Rissanen <[email protected]>
Add tests to verify the bit manipulation functions in net/vlan.h file. Also check that we can check if given network interface has VLAN enabled or not. Verify also that received network packet contains correct VLAN tag. Signed-off-by: Jukka Rissanen <[email protected]>
Add commands to add, remove or get information about VLANs attached to network interfaces. Signed-off-by: Jukka Rissanen <[email protected]>
This application just enables VLAN tag for ethernet interface. Set CONFIG_SAMPLE_VLAN_TAG option to define the desired VLAN tag. Signed-off-by: Jukka Rissanen <[email protected]>
This enables / fixes VLAN support in mcux ethernet driver. The commit contains these changes for enabling VLAN: * Increase the size of the ethernet frame if VLAN is enabled. * Enable VLAN in chip if VLAN is enabled * If VLAN is enabled, then the iface in context struct should not be used directly as there can be multiple VLAN iface related to this physical device. Signed-off-by: Jukka Rissanen <[email protected]>
Support also virtual LAN (VLAN) with native_posix ethernet driver. Signed-off-by: Jukka Rissanen <[email protected]>
This enables VLAN support in gmac ethernet driver. Signed-off-by: Jukka Rissanen <[email protected]>
Allow multiple VLANs to be configured for SLIP. Signed-off-by: Jukka Rissanen <[email protected]>
When sending packet add the VLAN priority to the ethernet header. Signed-off-by: Jukka Rissanen <[email protected]>
Currently the VLAN priority is the same as packet priority but if such conversion is needed, then this function can be used for such conversion. Signed-off-by: Jukka Rissanen <[email protected]>
Set the received network packet priority according to VLAN priority. Currently this mapping is 1:1 but can be changed if needed. Signed-off-by: Jukka Rissanen <[email protected]>
The DEVICE_NAME_GET() macro should be used instead of fixed string when creating a device pointer in net_if_dev structure. Signed-off-by: Jukka Rissanen <[email protected]>
If we have multiple network interfaces and we want to send a IPv4 network packet to certain destination, then this new helper can be used to figure out what network interface to use. Signed-off-by: Jukka Rissanen <[email protected]>
Instead of always using default interface, use the IPv4 target address to select the correct network interface when sending IPv4 ping request. Signed-off-by: Jukka Rissanen <[email protected]>
If we have multiple network interface (like in VLAN), then we need to select the proper local interface based on destination address. Signed-off-by: Jukka Rissanen <[email protected]>
As the l2_data section might contain different size context elements like "struct ethernet_context" for Ethernet and "void *" for Dummy L2, remove the __net_l2_start and __net_l2_end variables so that user does not accidentally try to use them as that would not work. Signed-off-by: Jukka Rissanen <[email protected]>
In IPv4 we need to select the network interface, where the packet is to be sent, using the IPv4 address instead of default network interface. Signed-off-by: Jukka Rissanen <[email protected]>
User is able to take a network interface down or bring it up. The command syntax is "net iface [up|down] [index]" Signed-off-by: Jukka Rissanen <[email protected]>
Although very unlikely, make sure that if the net_recv_data() is called with NULL network interface or packet, we recover that and return error to the caller. Signed-off-by: Jukka Rissanen <[email protected]>
jukkar
pushed a commit
that referenced
this pull request
Jun 22, 2020
This makes the gatt metrics also available for gatt write-without-rsp-cb so it now prints the rate of each write: uart:~$ gatt write-without-response-cb 1e ff 10 10 Write #1: 16 bytes (0 bps) Write #2: 32 bytes (3445948416 bps) Write #3: 48 bytes (2596929536 bps) Write #4: 64 bytes (6400 bps) Write #5: 80 bytes (8533 bps) Write #6: 96 bytes (10666 bps) Write #7: 112 bytes (8533 bps) Write #8: 128 bytes (9955 bps) Write #9: 144 bytes (11377 bps) Write #10: 160 bytes (7680 bps) Write #11: 176 bytes (8533 bps) Write #12: 192 bytes (9386 bps) Write Complete (err 0) Write #13: 208 bytes (8533 bps) Write #14: 224 bytes (9244 bps) Write #15: 240 bytes (9955 bps) Write #16: 256 bytes (8000 bps) Signed-off-by: Luiz Augusto von Dentz <[email protected]>
jukkar
pushed a commit
that referenced
this pull request
Oct 25, 2024
hci_packet_complete(buf, buf_size) should check whether buf_size is
enough.
For instance, hci_packet_complete can receive buf with buf_size 1,
leading to the buffer overflow in cmd->param_len, which is buf[3].
This can happen when rx_thread() receives two frames in 512 bytes
and the first frame size is 511. Then, rx_thread() will call
hci_packet_complete() with 1.
==5==ERROR: AddressSanitizer: global-buffer-overflow on address
0x000000ad81c2 at pc 0x0000005279b3 bp 0x7fffe74f5b70 sp 0x7fffe74f5b68
READ of size 2 at 0x000000ad81c2 thread T6
#0 0x5279b2 (/root/zephyr.exe+0x5279b2)
#1 0x4d697d (/root/zephyr.exe+0x4d697d)
#2 0x7ffff60e5daa (/lib/x86_64-linux-gnu/libc.so.6+0x89daa)
(BuildId: 2e01923fea4ad9f7fa50fe24e0f3385a45a6cd1c)
0x000000ad81c2 is located 2 bytes to the right of global variable
'rx_thread.frame' defined in 'zephyr/drivers/bluetooth/hci/userchan.c'
(0xad7fc0) of size 512
SUMMARY: AddressSanitizer: global-buffer-overflow
(/root/zephyr.exe+0x5279b2)
Thread T6 created by T2 here:
#0 0x48c17c (/root/zephyr.exe+0x48c17c)
#1 0x530192 (/root/zephyr.exe+0x530192)
#2 0x4dcc22 (/root/zephyr.exe+0x4dcc22)
Thread T2 created by T1 here:
#0 0x48c17c (/root/zephyr.exe+0x48c17c)
#1 0x530192 (/root/zephyr.exe+0x530192)
#2 0x4dcc22 (/root/zephyr.exe+0x4dcc22)
Thread T1 created by T0 here:
#0 0x48c17c (/root/zephyr.exe+0x48c17c)
#1 0x52f36c (/root/zephyr.exe+0x52f36c)
#2 0x5371dc (/root/zephyr.exe+0x5371dc)
#3 0x5312a6 (/root/zephyr.exe+0x5312a6)
#4 0x52ed7b (/root/zephyr.exe+0x52ed7b)
#5 0x52eddd (/root/zephyr.exe+0x52eddd)
#6 0x7ffff6083c89 (/lib/x86_64-linux-gnu/libc.so.6+0x27c89)
(BuildId: 2e01923fea4ad9f7fa50fe24e0f3385a45a6cd1c)
==5==ABORTING
Signed-off-by: Sungwoo Kim <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This set provides VLAN support for ethernet networks. Works when connecting to Linux host with both IPv4 and IPv6 and with multiple VLAN tags.
To enable VLAN support one needs to set CONFIG_NET_VLAN=y in config file.
To enable VLAN traffic, currently this needs to be enabled at runtime in net-shell with "net vlan add 100 0" command. This will add VLAN tag 100 to first network interface (index 0). Multiple tags can be enabled simultaneously, one just needs to set CONFIG_NET_VLAN_COUNT=xxx to proper value (default is 1). The sample app will automatically enable configured VLANs.