Ok, thanks for the clarification.

On Mon, 5 Mar 2018, 03:23 Yang, Yi, <yi.y.y...@intel.com> wrote:

> On Mon, Mar 05, 2018 at 04:19:58AM +0800, Joe Stringer wrote:
> > ?On 2 March 2018 at 04:32, Yi Yang <yi.y.y...@intel.com> wrote:
> > > From: Feng Yang <feng.y...@intel.com>
> > >
> > > +
> > > +        csum = csum_continue(csum, udp, ip_tot_size);
> > > +        udp->udp_csum = csum_finish(csum);
> > > +
> > > +        if (!udp->udp_csum) {
> > > +            udp->udp_csum = htons(0xffff);
> >
> > What's the motivation behind this?
>
> More comments, this is from the existing ovs code, Feng checked why.
>
> [Feng] According to the standard RFC768,
> https://tools.ietf.org/html/rfc768, I quote, "if the computed  checksum
> is zero,  it is transmitted  as all ones (the equivalent  in one's
> complement  arithmetic)". Actually, netdev_tnl_udp_push_header( ) did
> the same.
>
> >
> > > +        }
> > > +    }
> > > +
> > > +    packet->packet_type = htonl(PT_ETH);
> > > +}
> > > +
> > > +
> > > +int
> > > +netdev_gtpu_build_header(const struct netdev *netdev,
> > > +                          struct ovs_action_push_tnl *data,
> > > +                          const struct netdev_tnl_build_header_params
> *params)
> > > +{
> > > +    struct netdev_vport *dev = netdev_vport_cast(netdev);
> > > +    struct netdev_tunnel_config *tnl_cfg;
> > > +    struct gtpuhdr *gtph;
> > > +    struct udp_header *udp;
> > > +
> > > +    /* XXX: RCUfy tnl_cfg. */
> > > +    ovs_mutex_lock(&dev->mutex);
> > > +
> > > +    tnl_cfg = &dev->tnl_cfg;
> > > +    udp = netdev_tnl_ip_build_header(data, params, IPPROTO_UDP);
> > > +    udp->udp_dst = tnl_cfg->dst_port;
> > > +    udp->udp_src = htons(GTPU_DST_PORT);
> > > +
> > > +    if (params->is_ipv6 || params->flow->tunnel.flags &
> FLOW_TNL_F_CSUM) {
> > > +        /* Write a value in now to mark that we should compute the
> checksum
> > > +         * later. 0xffff is handy because it is transparent to the
> > > +         * calculation. */
> > > +        udp->udp_csum = htons(0xffff);
> >
> > Maybe I missed it, but I didn't see where in this patch that it is
> > computed later due to this value.
> >
>
> This is also from the existing code. udp_build_header is doing same
> thing.
>
> [Feng]  udp_csum is calculated in netdev_gtpu_push_header( ). In
> principle, udp_csum can be arbitrarily set to any two octets except all
> zero, which means transmitter generated no checksum, according to the
> standard, https://tools.ietf.org/html/rfc768.
> We followed what udp_build_header( ) did, by setting udp_csum to 0xffff.
>
>
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to