diff mbox series

[ovs-dev,v2] rstp: add ability to receive VLAN-tagged BPDUs

Message ID 20190214231614.24662-1-matthias.may@neratec.com
State Accepted
Commit f2f78d5c8c8cb5294dbb2c90c7e5e3b15620f46a
Headers show
Series [ovs-dev,v2] rstp: add ability to receive VLAN-tagged BPDUs | expand

Commit Message

姜立东 via dev Feb. 14, 2019, 11:16 p.m. UTC
There are switches which allow to transmit their BPDUs VLAN-tagged.
With this change OVS is able to receive VLAN-tagged BPDUs, but still
transmits its own BPDUs untagged.
This was tested against Westermo RFI-207-F4G-T3G.

v2: Send patch to different address of mailing list according to suggestion
    of Flavio Leitner.

Signed-off-by: Matthias May <matthias.may@neratec.com>
---
 ofproto/ofproto-dpif-xlate.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

0-day Robot Feb. 14, 2019, 11:59 p.m. UTC | #1
Bleep bloop.  Greetings Matthias May via dev, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
ERROR: Author should not be mailing list.
Lines checked: 50, Warnings: 0, Errors: 1


Please check this out.  If you feel there has been an error, please email aconole@bytheb.org

Thanks,
0-day Robot
Ben Pfaff Feb. 22, 2019, 11:12 p.m. UTC | #2
On Fri, Feb 15, 2019 at 12:16:14AM +0100, Matthias May via dev wrote:
> There are switches which allow to transmit their BPDUs VLAN-tagged.
> With this change OVS is able to receive VLAN-tagged BPDUs, but still
> transmits its own BPDUs untagged.
> This was tested against Westermo RFI-207-F4G-T3G.
> 
> v2: Send patch to different address of mailing list according to suggestion
>     of Flavio Leitner.
> 
> Signed-off-by: Matthias May <matthias.may@neratec.com>

I applied this to master.  Thanks!

I fussed with it a bit to make it closer to the preferred style.  Here
is what I committed:

--8<--------------------------cut here-------------------------->8--

From: Matthias May <matthias.may@neratec.com>
Date: Fri, 15 Feb 2019 00:16:14 +0100
Subject: [PATCH] rstp: add ability to receive VLAN-tagged BPDUs

There are switches which allow to transmit their BPDUs VLAN-tagged.
With this change OVS is able to receive VLAN-tagged BPDUs, but still
transmits its own BPDUs untagged.
This was tested against Westermo RFI-207-F4G-T3G.

Signed-off-by: Matthias May <matthias.may@neratec.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 ofproto/ofproto-dpif-xlate.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index acd4817c2549..81b72be37eb5 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -1787,7 +1787,11 @@ rstp_process_packet(const struct xport *xport, const struct dp_packet *packet)
         dp_packet_set_size(&payload, ntohs(eth->eth_type) + ETH_HEADER_LEN);
     }
 
-    if (dp_packet_try_pull(&payload, ETH_HEADER_LEN + LLC_HEADER_LEN)) {
+    int len = ETH_HEADER_LEN + LLC_HEADER_LEN;
+    if (eth->eth_type == htons(ETH_TYPE_VLAN)) {
+        len += VLAN_HEADER_LEN;
+    }
+    if (dp_packet_try_pull(&payload, len)) {
         rstp_port_received_bpdu(xport->rstp_port, dp_packet_data(&payload),
                                 dp_packet_size(&payload));
     }
姜立东 via dev Feb. 25, 2019, 8:33 a.m. UTC | #3
On 23/02/2019 00:12, Ben Pfaff wrote:
> On Fri, Feb 15, 2019 at 12:16:14AM +0100, Matthias May via dev wrote:
>> There are switches which allow to transmit their BPDUs VLAN-tagged.
>> With this change OVS is able to receive VLAN-tagged BPDUs, but still
>> transmits its own BPDUs untagged.
>> This was tested against Westermo RFI-207-F4G-T3G.
>>
>> v2: Send patch to different address of mailing list according to suggestion
>>     of Flavio Leitner.
>>
>> Signed-off-by: Matthias May <matthias.may@neratec.com>
> 
> I applied this to master.  Thanks!
> 
> I fussed with it a bit to make it closer to the preferred style.  Here
> is what I committed:
> 
> --8<--------------------------cut here-------------------------->8--
> 
> From: Matthias May <matthias.may@neratec.com>
> Date: Fri, 15 Feb 2019 00:16:14 +0100
> Subject: [PATCH] rstp: add ability to receive VLAN-tagged BPDUs
> 
> There are switches which allow to transmit their BPDUs VLAN-tagged.
> With this change OVS is able to receive VLAN-tagged BPDUs, but still
> transmits its own BPDUs untagged.
> This was tested against Westermo RFI-207-F4G-T3G.
> 
> Signed-off-by: Matthias May <matthias.may@neratec.com>
> Signed-off-by: Ben Pfaff <blp@ovn.org>
> ---
>  ofproto/ofproto-dpif-xlate.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
> index acd4817c2549..81b72be37eb5 100644
> --- a/ofproto/ofproto-dpif-xlate.c
> +++ b/ofproto/ofproto-dpif-xlate.c
> @@ -1787,7 +1787,11 @@ rstp_process_packet(const struct xport *xport, const struct dp_packet *packet)
>          dp_packet_set_size(&payload, ntohs(eth->eth_type) + ETH_HEADER_LEN);
>      }
>  
> -    if (dp_packet_try_pull(&payload, ETH_HEADER_LEN + LLC_HEADER_LEN)) {
> +    int len = ETH_HEADER_LEN + LLC_HEADER_LEN;
> +    if (eth->eth_type == htons(ETH_TYPE_VLAN)) {
> +        len += VLAN_HEADER_LEN;
> +    }
> +    if (dp_packet_try_pull(&payload, len)) {
>          rstp_port_received_bpdu(xport->rstp_port, dp_packet_data(&payload),
>                                  dp_packet_size(&payload));
>      }
> 

OK.
Thank you.

BR
Matthias
diff mbox series

Patch

diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index acd4817c2..7830fee2e 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -1771,9 +1771,12 @@  xport_rstp_should_manage_bpdu(const struct xport *xport)
     return rstp_should_manage_bpdu(xport_get_rstp_port_state(xport));
 }
 
+#define LEN_WITHOUT_VLAN (ETH_HEADER_LEN + LLC_HEADER_LEN)
+#define LEN_WITH_VLAN (VLAN_HEADER_LEN + LEN_WITHOUT_VLAN)
 static void
 rstp_process_packet(const struct xport *xport, const struct dp_packet *packet)
 {
+    int len;
     struct dp_packet payload = *packet;
     struct eth_header *eth = dp_packet_data(&payload);
 
@@ -1787,7 +1790,9 @@  rstp_process_packet(const struct xport *xport, const struct dp_packet *packet)
         dp_packet_set_size(&payload, ntohs(eth->eth_type) + ETH_HEADER_LEN);
     }
 
-    if (dp_packet_try_pull(&payload, ETH_HEADER_LEN + LLC_HEADER_LEN)) {
+    /* Pull a bit less payload when the BPDU is enveloped in a VLAN header */
+    len = (ntohs(eth->eth_type) == 0x8100) ? LEN_WITH_VLAN : LEN_WITHOUT_VLAN;
+    if (dp_packet_try_pull(&payload, len)) {
         rstp_port_received_bpdu(xport->rstp_port, dp_packet_data(&payload),
                                 dp_packet_size(&payload));
     }