[P4-dev] udp checksum

Mihai Budiu mbudiu at vmware.com
Mon Oct 23 21:50:53 EDT 2017


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>
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-dev_lists.p4.org/attachments/20171024/c9975a7a/attachment-0002.html>


More information about the P4-dev mailing list