Skip to content

Commit

Permalink
Merge pull request #2436 from lebauce/update-protobuf
Browse files Browse the repository at this point in the history
Update protobuf to not use gogo faster
  • Loading branch information
lebauce committed Apr 1, 2024
2 parents 78cfcb0 + eb47ef8 commit 14cf82b
Show file tree
Hide file tree
Showing 24 changed files with 3,849 additions and 13,143 deletions.
2 changes: 1 addition & 1 deletion flow/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (f *WSTableClient) lookupFlows(flowset chan *FlowSet, host string, flowSear
}
for _, b := range reply.FlowSetBytes {
var f FlowSet
if err := f.Unmarshal(b); err != nil {
if err := proto.Unmarshal(b, &f); err != nil {
logging.GetLogger().Errorf("Error returned while reading TableReply from: %s", host)
flowset <- NewFlowSet()
}
Expand Down
3 changes: 2 additions & 1 deletion flow/client/flow_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"time"

"github.com/safchain/insanelock"
"google.golang.org/protobuf/proto"

"github.com/skydive-project/skydive/config"
"github.com/skydive-project/skydive/flow"
Expand Down Expand Up @@ -142,7 +143,7 @@ func (c *FlowClient) close() {

// SendMessage sends a flow to the server
func (c *FlowClient) SendMessage(m *flow.Message) error {
data, err := m.Marshal()
data, err := proto.Marshal(m)
if err != nil {
return err
}
Expand Down
31 changes: 16 additions & 15 deletions flow/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/google/gopacket/layers"
"github.com/pierrec/xxHash/xxHash64"
"github.com/spf13/cast"
"google.golang.org/protobuf/types/known/timestamppb"

"github.com/skydive-project/skydive/config"
fl "github.com/skydive-project/skydive/flow/layers"
Expand Down Expand Up @@ -1037,24 +1038,24 @@ func (f *Flow) updateDNSLayer(layer gopacket.Layer, timestamp time.Time) error {
d := layer.(*layers.DNS)
dnsToAppend := &fl.DNS{
AA: d.AA,
ID: d.ID,
ID: uint32(d.ID),
QR: d.QR,
RA: d.RA,
RD: d.RD,
TC: d.TC,
ANCount: d.ANCount,
ARCount: d.ARCount,
NSCount: d.NSCount,
QDCount: d.QDCount,
ANCount: uint32(d.ANCount),
ARCount: uint32(d.ARCount),
NSCount: uint32(d.NSCount),
QDCount: uint32(d.QDCount),
ResponseCode: d.ResponseCode.String(),
OpCode: d.OpCode.String(),
Z: d.Z,
Z: uint32(d.Z),
}
dnsToAppend.Questions = fl.GetDNSQuestions(d.Questions)
dnsToAppend.Answers = fl.GetDNSRecords(d.Answers)
dnsToAppend.Authorities = fl.GetDNSRecords(d.Authorities)
dnsToAppend.Additionals = fl.GetDNSRecords(d.Additionals)
dnsToAppend.Timestamp = timestamp
dnsToAppend.Timestamp = timestamppb.New(timestamp)
f.DNS = dnsToAppend
return nil
}
Expand All @@ -1065,11 +1066,11 @@ func (f *Flow) newApplicationLayer(packet *Packet, opts *Opts) error {
d := layer.(*layers.DHCPv4)
f.DHCPv4 = &fl.DHCPv4{
File: d.File,
Flags: d.Flags,
HardwareLen: d.HardwareLen,
HardwareOpts: d.HardwareOpts,
Flags: uint32(d.Flags),
HardwareLen: uint32(d.HardwareLen),
HardwareOpts: uint32(d.HardwareOpts),
ServerName: d.ServerName,
Secs: d.Secs,
Secs: uint32(d.Secs),
}
return nil
}
Expand All @@ -1086,10 +1087,10 @@ func (f *Flow) newApplicationLayer(packet *Packet, opts *Opts) error {
if layer := packet.Layer(layers.LayerTypeVRRP); layer != nil {
d := layer.(*layers.VRRPv2)
f.VRRPv2 = &fl.VRRPv2{
AdverInt: d.AdverInt,
Priority: d.Priority,
Version: d.Version,
VirtualRtrID: d.VirtualRtrID,
AdverInt: uint32(d.AdverInt),
Priority: uint32(d.Priority),
Version: uint32(d.Version),
VirtualRtrID: uint32(d.VirtualRtrID),
}
return nil
}
Expand Down

0 comments on commit 14cf82b

Please sign in to comment.