When changing values in a custom header I don't receive the packet back on the other host. E.g., I broadcast a packet from node1, with the following code running on node0:
#include "common-boilerplate-pre.p4"
const bit<16> TYPE_IPV4 = 0x800;
struct metadata {
/* In our case it is empty */
}
header test_t {
bit<64> offset;
bit<8> a;
bit<8> b;
bit<8> c;
bit<8> d;
}
struct headers {
ethernet_t ethernet;
ipv4_t ipv4;
test_t four_bytes;
}
PARSER {
state start {
packet.extract(hdr.ethernet);
transition select(hdr.ethernet.etherType) {
TYPE_IPV4: parse_ipv4;
default: accept;
}
}
state parse_ipv4 {
packet.extract(hdr.ipv4);
transition parse_four_bytes;
}
state parse_four_bytes {
packet.extract(hdr.four_bytes);
transition accept;
}
}
CTL_MAIN {
apply {
if (hdr.ipv4.isValid()) {
# Since we don't go through the kernel this is actually not needed.
hdr.ethernet.srcAddr = 0x001122334455;
hdr.four_bytes.a = 0x12;
SET_EGRESS_PORT(GET_INGRESS_PORT());
}
}
}
CTL_EMIT {
apply {
packet.emit(hdr.ethernet);
packet.emit(hdr.ipv4);
packet.emit(hdr.four_bytes);
}
}
#include "common-boilerplate-post.p4"
I don't receive the changed packet back on node1.
Output on node0 which shows the packet it correctly parsed and line hdr.four_bytes.a = 0x12; is applied to the packet:
And I receive the packet back on node1: (with correctly mirrored payload 0x01020304)
Frame 193: 64 bytes on wire (512 bits), 64 bytes captured (512 bits) on interface enp65s0f0np0, id 0
Ethernet II, Src: CIMSYS_33:44:55 (00:11:22:33:44:55), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Internet Protocol Version 4, Src: 0.0.0.0, Dst: 0.0.0.0
User Datagram Protocol, Src Port: 1336, Dst Port: 1337
Data (4 bytes)
I don't see any errors and the log even claims the packet is emitted back, I am unsure why I don't receive the packet back on node1. Especially since when I only modify the mac address I still get the packet back.
Ok nvm. I figured it out. Since I modified the UDP data which is included in the UDP checksum without fixing the checksum it was discarded somewhere on the path.
When changing values in a custom header I don't receive the packet back on the other host. E.g., I broadcast a packet from node1, with the following code running on node0:
I don't receive the changed packet back on node1.
Output on node0 which shows the packet it correctly parsed and line
hdr.four_bytes.a = 0x12;
is applied to the packet:If I uncomment the line
hdr.four_bytes.a = 0x12;
I get the following output on node0:And I receive the packet back on node1: (with correctly mirrored payload 0x01020304)
I don't see any errors and the log even claims the packet is emitted back, I am unsure why I don't receive the packet back on node1. Especially since when I only modify the mac address I still get the packet back.