diff --git a/internal/probe/probe.go b/internal/probe/probe.go index ce82d37..9eab5df 100755 --- a/internal/probe/probe.go +++ b/internal/probe/probe.go @@ -8,6 +8,7 @@ import ( "github.com/pouriyajamshidi/flat/clsact" "github.com/pouriyajamshidi/flat/internal/flowtable" "github.com/pouriyajamshidi/flat/internal/packet" + "github.com/pouriyajamshidi/flat/internal/types" "github.com/vishvananda/netlink" "golang.org/x/sys/unix" ) @@ -180,7 +181,7 @@ func (p *probe) Close() error { // Run attaches the probe, reads from the eBPF map // as well as calculating and displaying the flow latencies -func Run(ctx context.Context, iface netlink.Link) error { +func Run(ctx context.Context, userInput types.UserInput) error { log.Println("Starting up the probe") if err := setRlimit(); err != nil { @@ -196,7 +197,7 @@ func Run(ctx context.Context, iface netlink.Link) error { } }() - probe, err := newProbe(iface) + probe, err := newProbe(userInput.Interface) if err != nil { return err @@ -235,7 +236,16 @@ func Run(ctx context.Context, iface netlink.Link) error { log.Printf("Could not unmarshall packet: %+v", pkt) continue } - packet.CalcLatency(packetAttrs, flowtable) + if !userInput.IP.IsValid() && userInput.Port == 0 { + packet.CalcLatency(packetAttrs, flowtable) + // FIXME: + // } else if (userInput.Port == packetAttrs.DstPort || userInput.Port == packetAttrs.SrcPort) && (userInput.IP == packetAttrs.DstIP.Unmap() || userInput.IP == packetAttrs.SrcIP.Unmap()) { + // packet.CalcLatency(packetAttrs, flowtable) + } else if userInput.IP == packetAttrs.DstIP.Unmap() || userInput.IP == packetAttrs.SrcIP.Unmap() { + packet.CalcLatency(packetAttrs, flowtable) + } else if userInput.Port == packetAttrs.DstPort || userInput.Port == packetAttrs.SrcPort { + packet.CalcLatency(packetAttrs, flowtable) + } } } } diff --git a/internal/probe/probe_bpfeb.o b/internal/probe/probe_bpfeb.o index f6d34e4..03f8ccc 100644 Binary files a/internal/probe/probe_bpfeb.o and b/internal/probe/probe_bpfeb.o differ diff --git a/internal/probe/probe_bpfel.o b/internal/probe/probe_bpfel.o index 909e6c6..b1915a0 100644 Binary files a/internal/probe/probe_bpfel.o and b/internal/probe/probe_bpfel.o differ