update P4D2 and SIGCOMM2017 examples for new checksum API (#56)

This commit is contained in:
Han Wang 2017-10-07 11:25:24 -07:00 committed by GitHub
parent ef64a2cfd8
commit 28a8414c58
24 changed files with 53 additions and 61 deletions

View File

@ -152,7 +152,7 @@ parser MyParser(
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum( control MyVerifyChecksum(
in my_headers_t hdr, inout my_headers_t hdr,
inout my_metadata_t meta) inout my_metadata_t meta)
{ {
apply { } apply { }

View File

@ -150,7 +150,7 @@ parser MyParser(
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum( control MyVerifyChecksum(
in my_headers_t hdr, inout my_headers_t hdr,
inout my_metadata_t meta) inout my_metadata_t meta)
{ {
apply { } apply { }

View File

@ -69,7 +69,7 @@ parser MyParser(
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum( control MyVerifyChecksum(
in my_headers_t hdr, inout my_headers_t hdr,
inout my_metadata_t meta) inout my_metadata_t meta)
{ {
apply { apply {

View File

@ -134,7 +134,7 @@ parser MyParser(
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum( control MyVerifyChecksum(
in my_headers_t hdr, inout my_headers_t hdr,
inout my_metadata_t meta) inout my_metadata_t meta)
{ {
apply { apply {

View File

@ -72,7 +72,7 @@ parser ParserImpl(packet_in packet,
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control verifyChecksum(in headers hdr, inout metadata meta) { control verifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }

View File

@ -75,7 +75,7 @@ parser ParserImpl(packet_in packet,
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control verifyChecksum(in headers hdr, inout metadata meta) { control verifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }
@ -132,25 +132,21 @@ control computeChecksum(
inout headers hdr, inout headers hdr,
inout metadata meta) inout metadata meta)
{ {
Checksum16() ipv4_checksum;
apply { apply {
if (hdr.ipv4.isValid()) { update_checksum(true,
hdr.ipv4.hdrChecksum = ipv4_checksum.get( { hdr.ipv4.version,
{ hdr.ipv4.ihl,
hdr.ipv4.version, hdr.ipv4.diffserv,
hdr.ipv4.ihl, hdr.ipv4.totalLen,
hdr.ipv4.diffserv, hdr.ipv4.identification,
hdr.ipv4.totalLen, hdr.ipv4.flags,
hdr.ipv4.identification, hdr.ipv4.fragOffset,
hdr.ipv4.flags, hdr.ipv4.ttl,
hdr.ipv4.fragOffset, hdr.ipv4.protocol,
hdr.ipv4.ttl, hdr.ipv4.srcAddr,
hdr.ipv4.protocol, hdr.ipv4.dstAddr
hdr.ipv4.srcAddr, },
hdr.ipv4.dstAddr hdr.ipv4.hdrChecksum, HashAlgorithm.csum16);
});
}
} }
} }

View File

@ -150,7 +150,7 @@ inout standard_metadata_t standard_metadata) {
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control verifyChecksum(in headers hdr, inout metadata meta) { control verifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }

View File

@ -138,7 +138,7 @@ inout standard_metadata_t standard_metadata) {
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control verifyChecksum(in headers hdr, inout metadata meta) { control verifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }
@ -228,13 +228,9 @@ control computeChecksum(
inout headers hdr, inout headers hdr,
inout metadata meta) inout metadata meta)
{ {
Checksum16() ipv4_checksum;
apply { apply {
if (hdr.ipv4.isValid()) { update_checksum(true,
hdr.ipv4.hdrChecksum = ipv4_checksum.get( { hdr.ipv4.version,
{
hdr.ipv4.version,
hdr.ipv4.ihl, hdr.ipv4.ihl,
hdr.ipv4.diffserv, hdr.ipv4.diffserv,
hdr.ipv4.totalLen, hdr.ipv4.totalLen,
@ -245,8 +241,8 @@ inout metadata meta)
hdr.ipv4.protocol, hdr.ipv4.protocol,
hdr.ipv4.srcAddr, hdr.ipv4.srcAddr,
hdr.ipv4.dstAddr hdr.ipv4.dstAddr
}); },
} hdr.ipv4.hdrChecksum, HashAlgorithm.csum16);
} }
} }

View File

@ -62,7 +62,7 @@ parser MyParser(packet_in packet,
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum(in headers hdr, inout metadata meta) { control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }
@ -157,4 +157,4 @@ MyIngress(),
MyEgress(), MyEgress(),
MyComputeChecksum(), MyComputeChecksum(),
MyDeparser() MyDeparser()
) main; ) main;

View File

@ -74,7 +74,7 @@ parser MyParser(packet_in packet,
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum(in headers hdr, inout metadata meta) { control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }
@ -173,4 +173,4 @@ MyIngress(),
MyEgress(), MyEgress(),
MyComputeChecksum(), MyComputeChecksum(),
MyDeparser() MyDeparser()
) main; ) main;

View File

@ -132,7 +132,7 @@ parser MyParser(packet_in packet,
/************************************************************************* /*************************************************************************
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum(in headers hdr, control MyVerifyChecksum(inout headers hdr,
inout metadata meta) { inout metadata meta) {
apply { } apply { }
} }

View File

@ -132,7 +132,7 @@ parser MyParser(packet_in packet,
/************************************************************************* /*************************************************************************
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum(in headers hdr, control MyVerifyChecksum(inout headers hdr,
inout metadata meta) { inout metadata meta) {
apply { } apply { }
} }

View File

@ -78,7 +78,7 @@ parser MyParser(packet_in packet,
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum(in headers hdr, inout metadata meta) { control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }
@ -185,4 +185,4 @@ MyIngress(),
MyEgress(), MyEgress(),
MyComputeChecksum(), MyComputeChecksum(),
MyDeparser() MyDeparser()
) main; ) main;

View File

@ -76,7 +76,7 @@ parser MyParser(packet_in packet,
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum(in headers hdr, inout metadata meta) { control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }
@ -185,4 +185,4 @@ MyIngress(),
MyEgress(), MyEgress(),
MyComputeChecksum(), MyComputeChecksum(),
MyDeparser() MyDeparser()
) main; ) main;

View File

@ -130,7 +130,7 @@ parser MyParser(packet_in packet,
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum(in headers hdr, inout metadata meta) { control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }
@ -430,4 +430,4 @@ MyIngress(),
MyEgress(), MyEgress(),
MyComputeChecksum(), MyComputeChecksum(),
MyDeparser() MyDeparser()
) main; ) main;

View File

@ -130,7 +130,7 @@ parser MyParser(packet_in packet,
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum(in headers hdr, inout metadata meta) { control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }

View File

@ -86,7 +86,7 @@ parser MyParser(packet_in packet,
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum(in headers hdr, inout metadata meta) { control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }

View File

@ -87,7 +87,7 @@ parser MyParser(packet_in packet,
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum(in headers hdr, inout metadata meta) { control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }

View File

@ -148,7 +148,7 @@ parser MyParser(packet_in packet,
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum(in headers hdr, inout metadata meta) { control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }
@ -277,4 +277,4 @@ MyIngress(),
MyEgress(), MyEgress(),
MyComputeChecksum(), MyComputeChecksum(),
MyDeparser() MyDeparser()
) main; ) main;

View File

@ -140,7 +140,7 @@ parser MyParser(packet_in packet,
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum(in headers hdr, inout metadata meta) { control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }
@ -264,4 +264,4 @@ MyIngress(),
MyEgress(), MyEgress(),
MyComputeChecksum(), MyComputeChecksum(),
MyDeparser() MyDeparser()
) main; ) main;

View File

@ -74,7 +74,7 @@ parser MyParser(packet_in packet,
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum(in headers hdr, inout metadata meta) { control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }
@ -177,4 +177,4 @@ MyIngress(),
MyEgress(), MyEgress(),
MyComputeChecksum(), MyComputeChecksum(),
MyDeparser() MyDeparser()
) main; ) main;

View File

@ -74,7 +74,7 @@ parser MyParser(packet_in packet,
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum(in headers hdr, inout metadata meta) { control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }
@ -188,4 +188,4 @@ MyIngress(),
MyEgress(), MyEgress(),
MyComputeChecksum(), MyComputeChecksum(),
MyDeparser() MyDeparser()
) main; ) main;

View File

@ -92,7 +92,7 @@ parser MyParser(packet_in packet,
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum(in headers hdr, inout metadata meta) { control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }
@ -178,4 +178,4 @@ MyIngress(),
MyEgress(), MyEgress(),
MyComputeChecksum(), MyComputeChecksum(),
MyDeparser() MyDeparser()
) main; ) main;

View File

@ -96,7 +96,7 @@ parser MyParser(packet_in packet,
************ C H E C K S U M V E R I F I C A T I O N ************* ************ C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/ *************************************************************************/
control MyVerifyChecksum(in headers hdr, inout metadata meta) { control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
apply { } apply { }
} }
@ -188,4 +188,4 @@ MyIngress(),
MyEgress(), MyEgress(),
MyComputeChecksum(), MyComputeChecksum(),
MyDeparser() MyDeparser()
) main; ) main;