diff mbox

[ovs-dev,v2,3/4] tunneling: Calculate and update packet l4_offset in tunnel push.

Message ID 1499161601-3230-4-git-send-email-sugesh.chandran@intel.com
State Changes Requested
Delegated to: Joe Stringer
Headers show

Commit Message

Chandran, Sugesh July 4, 2017, 9:46 a.m. UTC
The following tunnel combine patch series avoids the packets recirculation
after the tunnel push. So it is necessary to populate all relevant packet meta
data fields for the following combined action-set.

Consider a chained tunnel test case shown below,

PKT-IN --> TUNNEL_PUSH --> MOD_PKT_HDR --> TUNNEL_POP

In this eg: the last tunnel_pop operation uses the l4_offset in the packet to
validate the packets. So it must be calculated and updated in the packet before
executing the action. Since there is no recirculation now on, this calculation
is doing as part of tunnel_push.

Signed-off-by: Sugesh Chandran <sugesh.chandran@intel.com>
Signed-off-by: Zoltán Balogh <zoltan.balogh@ericsson.com>
Co-authored-by: Zoltán Balogh <zoltan.balogh@ericsson.com>
---
 lib/netdev-native-tnl.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Joe Stringer July 14, 2017, 11:43 p.m. UTC | #1
On 4 July 2017 at 02:46, Sugesh Chandran <sugesh.chandran@intel.com> wrote:
> The following tunnel combine patch series avoids the packets recirculation
> after the tunnel push. So it is necessary to populate all relevant packet meta
> data fields for the following combined action-set.
>
> Consider a chained tunnel test case shown below,
>
> PKT-IN --> TUNNEL_PUSH --> MOD_PKT_HDR --> TUNNEL_POP
>
> In this eg: the last tunnel_pop operation uses the l4_offset in the packet to
> validate the packets. So it must be calculated and updated in the packet before
> executing the action. Since there is no recirculation now on, this calculation
> is doing as part of tunnel_push.
>
> Signed-off-by: Sugesh Chandran <sugesh.chandran@intel.com>
> Signed-off-by: Zoltán Balogh <zoltan.balogh@ericsson.com>
> Co-authored-by: Zoltán Balogh <zoltan.balogh@ericsson.com>
> ---

Could this be done inside netdev_tnl_push_ip_header() instead, for a
generic one-liner that applies to all IP tunnels?
Chandran, Sugesh July 17, 2017, 4:53 p.m. UTC | #2
Regards
_Sugesh


> -----Original Message-----

> From: Joe Stringer [mailto:joe@ovn.org]

> Sent: Saturday, July 15, 2017 12:43 AM

> To: Chandran, Sugesh <sugesh.chandran@intel.com>

> Cc: ovs dev <dev@openvswitch.org>; Andy Zhou <azhou@ovn.org>; Zoltán

> Balogh <zoltan.balogh@ericsson.com>

> Subject: Re: [PATCH v2 3/4] tunneling: Calculate and update packet l4_offset

> in tunnel push.

> 

> On 4 July 2017 at 02:46, Sugesh Chandran <sugesh.chandran@intel.com>

> wrote:

> > The following tunnel combine patch series avoids the packets

> > recirculation after the tunnel push. So it is necessary to populate

> > all relevant packet meta data fields for the following combined action-set.

> >

> > Consider a chained tunnel test case shown below,

> >

> > PKT-IN --> TUNNEL_PUSH --> MOD_PKT_HDR --> TUNNEL_POP

> >

> > In this eg: the last tunnel_pop operation uses the l4_offset in the

> > packet to validate the packets. So it must be calculated and updated

> > in the packet before executing the action. Since there is no

> > recirculation now on, this calculation is doing as part of tunnel_push.

> >

> > Signed-off-by: Sugesh Chandran <sugesh.chandran@intel.com>

> > Signed-off-by: Zoltán Balogh <zoltan.balogh@ericsson.com>

> > Co-authored-by: Zoltán Balogh <zoltan.balogh@ericsson.com>

> > ---

> 

> Could this be done inside netdev_tnl_push_ip_header() instead, for a

> generic one-liner that applies to all IP tunnels?

[Sugesh] Yes, agree with you,. Will move it to push_ip_header() function in the next version.
diff mbox

Patch

diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
index 7f3cf98..caa3a0a 100644
--- a/lib/netdev-native-tnl.c
+++ b/lib/netdev-native-tnl.c
@@ -224,6 +224,7 @@  netdev_tnl_push_udp_header(struct dp_packet *packet,
     udp->udp_src = netdev_tnl_get_src_port(packet);
     udp->udp_len = htons(ip_tot_size);
 
+    packet->l4_ofs = dp_packet_size(packet) - ip_tot_size;
     if (udp->udp_csum) {
         uint32_t csum;
         if (netdev_tnl_is_header_ipv6(dp_packet_data(packet))) {
@@ -440,6 +441,7 @@  netdev_gre_push_header(struct dp_packet *packet,
 
     greh = netdev_tnl_push_ip_header(packet, data->header, data->header_len, &ip_tot_size);
 
+    packet->l4_ofs = dp_packet_size(packet) - ip_tot_size;
     if (greh->flags & htons(GRE_CSUM)) {
         ovs_be16 *csum_opt = (ovs_be16 *) (greh + 1);
         *csum_opt = csum(greh, ip_tot_size);