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

2019-02-25 Thread Matthias May via dev
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 
> 
> 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 
> 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 
> Signed-off-by: Ben Pfaff 
> ---
>  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(, ntohs(eth->eth_type) + ETH_HEADER_LEN);
>  }
>  
> -if (dp_packet_try_pull(, 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(, len)) {
>  rstp_port_received_bpdu(xport->rstp_port, dp_packet_data(),
>  dp_packet_size());
>  }
> 

OK.
Thank you.

BR
Matthias
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


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

2019-02-22 Thread Ben Pfaff
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 

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 
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 
Signed-off-by: Ben Pfaff 
---
 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(, ntohs(eth->eth_type) + ETH_HEADER_LEN);
 }
 
-if (dp_packet_try_pull(, 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(, len)) {
 rstp_port_received_bpdu(xport->rstp_port, dp_packet_data(),
 dp_packet_size());
 }
-- 
2.20.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


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

2019-02-14 Thread Matthias May via dev
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 
---
 ofproto/ofproto-dpif-xlate.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

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();
 
@@ -1787,7 +1790,9 @@ rstp_process_packet(const struct xport *xport, const 
struct dp_packet *packet)
 dp_packet_set_size(, ntohs(eth->eth_type) + ETH_HEADER_LEN);
 }
 
-if (dp_packet_try_pull(, 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(, len)) {
 rstp_port_received_bpdu(xport->rstp_port, dp_packet_data(),
 dp_packet_size());
 }
-- 
2.20.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev