[P4-design] [P4-dev] udp checksum

Mihai Budiu mbudiu at vmware.com
Tue Oct 24 11:38:54 EDT 2017


This is cross-posted to p4-design as well.

I was wrong, in fact v1model does not offer any support for incremental checksums. The future standard architecture PSA will.

So it looks like v1model should be extended to support payloads in computing checksums. This is necessary to support legacy P4-14 programs anyway.

I have upgraded this issue https://github.com/p4lang/p4c/issues/490 to a bug to track this problem.

To solve this problem I would like to propose to add two methods to v1model.p4:

extern void verify_checksum_with_payload<T, O>(in bool condition, in T data, inout O checksum, HashAlgorithm algo);
extern void update_checksum_with_payload<T, O>(in bool condition, in T data, inout O checksum, HashAlgorithm algo);

The signature of these two methods is exactly the same as verify_checksum and update_checksum. The only difference is that these methods would also use the payload in their calculation.

If no one objects or proposes an alternative, I will implement support for these two methods in the P4-14 front-end and in the bmv2 back-end.

Thank you,
Mihai

From: Mihai Budiu
Sent: Monday, October 23, 2017 6:51 PM
To: 'Dingyuan Hu' <h-dy at outlook.com>; p4-dev <p4-dev at lists.p4.org>
Subject: RE: [P4-dev] udp checksum

If you are talking about the v1model architecture, indeed, it does not offer support for calculating TCP/UDP checksums. It should offer support for incrementally updating a UDP/TCP checksum after changing a packet header. I am not sure whether this feature has been thoroughly tested.

Mihai

From: P4-dev [mailto:p4-dev-bounces at lists.p4.org] On Behalf Of Dingyuan Hu
Sent: Monday, October 23, 2017 6:25 PM
To: p4-dev <p4-dev at lists.p4.org<mailto:p4-dev at lists.p4.org>>
Subject: Re: [P4-dev] udp checksum

Hi all,
I have the same question.
And I use P4_16, so there is no `payload` keyword.
How can I calculate UDP checksum for IPv6? It can’t be ignored.

Thanks,
Dingyuan Hu

From: P4-dev [mailto:p4-dev-bounces at lists.p4.org] On Behalf Of Kentaro Ebisawa
Sent: Monday, 2 October 2017 4:24 PM
To: p4-dev <p4-dev at lists.p4.org<mailto:p4-dev at lists.p4.org>>
Subject: [P4-dev] udp checksum

Hi,

Is there any example code to calculate udp checksum?
I went through examples under https://github.com/p4lang/tutorials<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_p4lang_tutorials&d=DwMGaQ&c=uilaK90D4TOVoH58JNXRgQ&r=tGW6TKXajnoXSyy1S1P4DHGPe8sj54GGvw-b21n7aWg&m=jkKEXuSI2IKVbhwaraXNhz8GdDL-XS_IMdsgwO8Sgpg&s=w0tAdxZy_G0R13Fcsq9jM4R7yGo7G-iCSSz1mqs8Jck&e=> but could not find one.

BTW, I wrote with below P4-14 code but checksum wasn't calculated correctly.
Also, p4c shown warning for 8'0. Could it be related? (Assuming not but ...)

* Warning:
p4can.p4:84:6: warning: missing terminating ' character
     8'0;
      ^

* UDP Checksum code I tried with.
field_list udp_checksum_list {
    // IPv4 Pseudo Header Format. Must modify for IPv6 support.
    ipv4.srcAddr;
    ipv4.dstAddr;
    8'0;
    ipv4.protocol;
    udp.length_;
    udp.srcPort;
    udp.dstPort;
    udp.length_;
    // udp.checksum;
    payload;
}
field_list_calculation udp_checksum {
    input {
        udp_checksum_list;
    }
    algorithm : csum16;
    output_width : 16;
}
calculated_field udp.checksum {
    verify udp_checksum;
    update udp_checksum;
}


--
Kentaro Ebisawa <ebiken.g at gmail.com><mailto:ebiken.g at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-design_lists.p4.org/attachments/20171024/8df6eaae/attachment-0002.html>


More information about the P4-design mailing list