[PATCH] realtek: fix VLAN 0 tag at egress on port 0
Birger Koblitz
mail at birger-koblitz.de
Thu Jun 9 04:30:43 PDT 2022
Hi Arinc,
very well spotted! If I could make a suggestion, the RTL93xx tag generation
functions have the opposite problem, i.e. rtl930x_decode_tag() and
rtl931x_decode_tag() do not do the check for the destination port being >= 0,
i.e. defined and the packet not being a broadcast packet.
So I would suggest to remove the
if (dest_port >= 0) {
in rtl838x_create_tx_header and rtl839x_create_tx_header() entirely
and do the check for all 4 SoC families directly in rtl838x_eth_tx():
if (dest_port >= 0)
priv->r->create_tx_header(h, dest_port, skb->priority >> 1);
this will fix all 4 cases.
Cheers,
Birger
On 09.06.22 10:32, Arinc UNAL (Xeront) wrote:
> There is a bug on the ethernet driver where the checks for the DSA tag and
> creating the tx header don't include port 0. This causes any frame
> egressing from the first port of the switch to have a VLAN 0 tag.
>
> Fix this by extending the checks to include port 0.
>
> Signed-off-by: Arınç ÜNAL <arinc.unal at xeront.com>
> ---
> .../realtek/files-5.10/drivers/net/ethernet/rtl838x_eth.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/target/linux/realtek/files-5.10/drivers/net/ethernet/rtl838x_eth.c b/target/linux/realtek/files-5.10/drivers/net/ethernet/rtl838x_eth.c
> index cf6aabc614..88a27e78ab 100644
> --- a/target/linux/realtek/files-5.10/drivers/net/ethernet/rtl838x_eth.c
> +++ b/target/linux/realtek/files-5.10/drivers/net/ethernet/rtl838x_eth.c
> @@ -96,7 +96,7 @@ static void rtl838x_create_tx_header(struct p_hdr *h, int dest_port, int prio)
> {
> prio &= 0x7;
>
> - if (dest_port > 0) {
> + if (dest_port >= 0) {
> // cpu_tag[0] is reserved on the RTL83XX SoCs
> h->cpu_tag[1] = 0x0401; // BIT 10: RTL8380_CPU_TAG, BIT0: L2LEARNING on
> h->cpu_tag[2] = 0x0200; // Set only AS_DPM, to enable DPM settings below
> @@ -113,7 +113,7 @@ static void rtl839x_create_tx_header(struct p_hdr *h, int dest_port, int prio)
> {
> prio &= 0x7;
>
> - if (dest_port > 0) {
> + if (dest_port >= 0) {
> // cpu_tag[0] is reserved on the RTL83XX SoCs
> h->cpu_tag[1] = 0x0100; // RTL8390_CPU_TAG marker
> h->cpu_tag[2] = h->cpu_tag[3] = h->cpu_tag[4] = h->cpu_tag[5] = 0;
> @@ -1142,7 +1142,7 @@ static int rtl838x_eth_tx(struct sk_buff *skb, struct net_device *dev)
> len = skb->len;
>
> /* Check for DSA tagging at the end of the buffer */
> - if (netdev_uses_dsa(dev) && skb->data[len-4] == 0x80 && skb->data[len-3] > 0
> + if (netdev_uses_dsa(dev) && skb->data[len-4] == 0x80 && skb->data[len-3] >= 0
> && skb->data[len-3] < priv->cpu_port && skb->data[len-2] == 0x10
> && skb->data[len-1] == 0x00) {
> /* Reuse tag space for CRC if possible */
More information about the openwrt-devel
mailing list