Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix packet parsing #452

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion dataplane/forwarding/protocol/ip/ip4.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ func (ip *IP4) SetPayload(id fwdpb.PacketHeaderId, length int64) {
if !ok {
proto = protoReserved
}
ip.header.Field(ip4ProtoPos, ip4ProtoBytes).SetValue(uint(proto))
if id != fwdpb.PacketHeaderId_PACKET_HEADER_ID_OPAQUE { // If the packet header is an unknown type, don't change it.
ip.header.Field(ip4ProtoPos, ip4ProtoBytes).SetValue(uint(proto))
}

ip.header.Field(ip4LengthPos, ip4LengthBytes).SetValue(uint(length) + uint(len(ip.header)))
ip.payload = length

Expand Down
5 changes: 4 additions & 1 deletion dataplane/forwarding/protocol/ip/ip6.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ func (ip *IP6) SetPayload(id fwdpb.PacketHeaderId, length int64) {
if !ok {
proto = protoReserved
}
ip.header.Field(ip6ProtoPos, ip6ProtoBytes).SetValue(uint(proto))
if id != fwdpb.PacketHeaderId_PACKET_HEADER_ID_OPAQUE { // If the packet header is an unknown type, don't change it.
ip.header.Field(ip6ProtoPos, ip6ProtoBytes).SetValue(uint(proto))
}

ip.header.Field(ip6LengthPos, ip6LengthBytes).SetValue(uint(length))
ip.payload = length
}
Expand Down
2 changes: 2 additions & 0 deletions dataplane/saiserver/hostif.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,8 @@ func (hostif *hostif) CPUPacketStream(srv pktiopb.PacketIO_CPUPacketStreamServer
case <-ctx.Done():
return nil
case pkt := <-packetCh:
log.V(3).Infof("received packet %x", pkt.GetPacket().GetFrame())

acts := []*fwdpb.ActionDesc{fwdconfig.Action(fwdconfig.UpdateAction(fwdpb.UpdateType_UPDATE_TYPE_SET, fwdpb.PacketFieldNum_PACKET_FIELD_NUM_HOST_PORT_ID).
WithUint64Value(pkt.GetPacket().GetHostPort())).Build()}
err = hostif.dataplane.InjectPacket(&fwdpb.ContextId{Id: hostif.dataplane.ID()}, &fwdpb.PortId{ObjectId: &fwdpb.ObjectId{Id: cpuPortID}}, fwdpb.PacketHeaderId_PACKET_HEADER_ID_ETHERNET,
Expand Down
2 changes: 1 addition & 1 deletion dataplane/saiserver/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ func getPreIngressPipeline() []*fwdpb.ActionDesc {

func getL3Pipeline() []*fwdpb.ActionDesc {
return []*fwdpb.ActionDesc{
fwdconfig.Action(fwdconfig.DecapAction(fwdpb.PacketHeaderId_PACKET_HEADER_ID_ETHERNET)).Build(), // Decap L2 header.
fwdconfig.Action(fwdconfig.LookupAction(IngressActionTable)).Build(), // Run ingress action.
fwdconfig.Action(fwdconfig.DecapAction(fwdpb.PacketHeaderId_PACKET_HEADER_ID_ETHERNET)).Build(), // Decap L2 header.
fwdconfig.Action(fwdconfig.UpdateAction(fwdpb.UpdateType_UPDATE_TYPE_DEC, fwdpb.PacketFieldNum_PACKET_FIELD_NUM_IP_HOP).WithValue([]byte{0x1})).Build(), // Decrement TTL.
fwdconfig.Action(fwdconfig.LookupAction(FIBSelectorTable)).Build(), // Lookup in FIB.
fwdconfig.Action(fwdconfig.EncapAction(fwdpb.PacketHeaderId_PACKET_HEADER_ID_ETHERNET)).Build(), // Encap L2 header.
Expand Down
Loading