Skip to content

Commit 874dfad

Browse files
author
Saied Kazemi
authored
Ignore empty IP addresses and traceroute data (#140)
1 parent 7750262 commit 874dfad

File tree

9 files changed

+31
-15
lines changed

9 files changed

+31
-15
lines changed

hopannotation/hopannotation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func (hc *HopCache) Annotate(ctx context.Context, hops []string, traceStartTime
163163
// Validate all hop IP addresses.
164164
allErrs := []error{}
165165
for _, hop := range hops {
166-
if net.ParseIP(hop).String() == "<nil>" {
166+
if net.ParseIP(hop) == nil {
167167
allErrs = append(allErrs, fmt.Errorf("%w: %v", ErrParseHopIP, hop))
168168
}
169169
}

internal/triggertrace/triggertrace.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (h *Handler) Open(ctx context.Context, timestamp time.Time, uuid string, so
100100
defer h.DestinationsLock.Unlock()
101101
destination, err := h.findDestination(sockID)
102102
if err != nil {
103-
log.Printf("failed to find destination from SockID %+v\n", *sockID)
103+
log.Printf("context %p: failed to find destination from SockID %+v\n", ctx, *sockID)
104104
return
105105
}
106106
if uuid == "" {
@@ -117,7 +117,7 @@ func (h *Handler) Close(ctx context.Context, timestamp time.Time, uuid string) {
117117
destination, ok := h.Destinations[uuid]
118118
if !ok {
119119
h.DestinationsLock.Unlock()
120-
log.Printf("failed to find destination for UUID %q", uuid)
120+
log.Printf("context %p: failed to find destination for UUID %q", ctx, uuid)
121121
return
122122
}
123123
delete(h.Destinations, uuid)
@@ -137,29 +137,29 @@ func (h *Handler) traceAnnotateAndArchive(ctx context.Context, dest Destination)
137137
}()
138138
rawData, err := h.IPCache.FetchTrace(dest.RemoteIP, dest.Cookie)
139139
if err != nil {
140-
log.Printf("failed to run a traceroute to %q (error: %v)\n", dest, err)
140+
log.Printf("context %p: failed to run a traceroute to %q (error: %v)\n", ctx, dest, err)
141141
return
142142
}
143143
parsedData, err := h.Parser.ParseRawData(rawData)
144144
if err != nil {
145-
log.Printf("failed to parse traceroute output (error: %v)\n", err)
145+
log.Printf("context %p: failed to parse traceroute output (error: %v)\n", ctx, err)
146146
return
147147
}
148148
hops := parsedData.ExtractHops()
149149
if len(hops) == 0 {
150-
log.Printf("failed to extract hops from traceroute %+v\n", string(rawData))
150+
log.Printf("context %p: failed to extract hops from traceroute %+v\n", ctx, string(rawData))
151151
return
152152
}
153153

154154
traceStartTime := parsedData.StartTime()
155155
annotations, allErrs := h.HopAnnotator.Annotate(ctx, hops, traceStartTime)
156156
if allErrs != nil {
157-
log.Printf("failed to annotate some or all hops (errors: %+v)\n", allErrs)
157+
log.Printf("context %p: failed to annotate some or all hops (errors: %+v)\n", ctx, allErrs)
158158
}
159159
if len(annotations) > 0 {
160160
allErrs := h.HopAnnotator.WriteAnnotations(annotations, traceStartTime)
161161
if allErrs != nil {
162-
log.Printf("failed to write some or all annotations due to the following error(s):\n")
162+
log.Printf("context %p: failed to write some or all annotations due to the following error(s):\n", ctx)
163163
for _, err := range allErrs {
164164
log.Printf("error: %v\n", err)
165165
}

parser/scamper1.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ func (s1 Scamper1) ExtractHops() []string {
158158
hops := make(map[string]struct{}, 100)
159159
for i := range tracelb.Nodes {
160160
node := &tracelb.Nodes[i]
161-
hops[node.Addr] = struct{}{}
161+
if net.ParseIP(node.Addr) != nil {
162+
hops[node.Addr] = struct{}{}
163+
}
162164
for j := range node.Links {
163165
links := node.Links[j]
164166
for k := range links {
165167
link := &links[k]
166-
// Parse the IP string, to avoid formatting variations.
167-
ip := net.ParseIP(link.Addr)
168-
if ip.String() != "<nil>" {
169-
hops[ip.String()] = struct{}{}
168+
if net.ParseIP(link.Addr) != nil {
169+
hops[link.Addr] = struct{}{}
170170
}
171171
}
172172
}

parser/scamper1_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func TestScamper1Parser(t *testing.T) {
3434
"2600:803::79",
3535
"2600:803:150f::4a"},
3636
},
37+
{"valid-star", nil, []string{}}, // all "addr" values are either "*" or ""
3738
}
3839
for i, test := range tests {
3940
// Read in the test traceroute output file.

parser/scamper2.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7+
"net"
78
"time"
89

910
"github.com/m-lab/traceroute-caller/tracer"
@@ -126,7 +127,9 @@ func (s2 Scamper2) ExtractHops() []string {
126127
hops := make(map[string]struct{}, 100)
127128
for i := range trace.Hops {
128129
hop := &trace.Hops[i]
129-
hops[hop.Addr] = struct{}{}
130+
if net.ParseIP(hop.Addr) != nil {
131+
hops[hop.Addr] = struct{}{}
132+
}
130133
}
131134
hopStrings := make([]string, 0, len(hops))
132135
for h := range hops {

parser/scamper2_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func TestScamper2Parser(t *testing.T) {
3939
"4.69.140.198",
4040
"212.187.137.18",
4141
"91.189.88.142"}},
42+
{"valid-star", nil, []string{}}, // all "addr" values are either "*" or ""
4243
}
4344
for i, test := range tests {
4445
// Read in the test traceroute output file.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{"UUID":"ndt-zmm9m_1572302065_000000000002A773","TracerouteCallerVersion":"bc092be","CachedResult":true,"CachedUUID":"ndt-zmm9m_1572302065_000000000002A76F"}
2+
{"type":"cycle-start", "list_name":"/tmp/scamperctrl:3939", "id":1, "hostname":"ndt-zmm9m", "start_time":1575164139}
3+
{"type":"tracelb", "version":"0.1", "userid":0, "method":"icmp-echo", "src":"2800:870:1000:10::139", "dst":"2804:14d:1883:8632:f169:d644:5aec:79f1", "start":{"sec":1575164139, "usec":693300, "ftime":"2019-12-01 01:35:39"}, "probe_size":60, "firsthop":1, "attempts":3, "confidence":95, "tos":0, "gaplimit":3, "wait_timeout":5, "wait_probe":250, "probec":127, "probec_max":3000, "nodec":7, "linkc":7, "nodes":[{"addr":"*", "q_ttl":1, "linkc":1, "links":[[{"addr":"", "probes":[{"tx":{"sec":1575164139, "usec":944016}, "replyc":1, "ttl":2, "attempt":0, "flowid":1, "replies":[{"rx":{"sec":1575164140, "usec":52182}, "ttl":63, "rtt":108.166, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164140, "usec":194494}, "replyc":1, "ttl":2, "attempt":0, "flowid":2, "replies":[{"rx":{"sec":1575164140, "usec":302708}, "ttl":63, "rtt":108.214, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164140, "usec":445045}, "replyc":1, "ttl":2, "attempt":0, "flowid":3, "replies":[{"rx":{"sec":1575164140, "usec":553226}, "ttl":63, "rtt":108.181, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164140, "usec":695568}, "replyc":1, "ttl":2, "attempt":0, "flowid":4, "replies":[{"rx":{"sec":1575164140, "usec":808715}, "ttl":63, "rtt":113.147, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164140, "usec":946106}, "replyc":1, "ttl":2, "attempt":0, "flowid":5, "replies":[{"rx":{"sec":1575164141, "usec":54911}, "ttl":63, "rtt":108.805, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164141, "usec":196148}, "replyc":1, "ttl":2, "attempt":0, "flowid":6, "replies":[{"rx":{"sec":1575164141, "usec":306202}, "ttl":63, "rtt":110.054, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]}]}]]},{"addr":"*", "name":"mia15-loop0-v6.mia.seabone.net", "q_ttl":1, "linkc":1, "links":[[{"addr":"", "probes":[{"tx":{"sec":1575164141, "usec":446287}, "replyc":1, "ttl":3, "attempt":0, "flowid":1, "replies":[{"rx":{"sec":1575164141, "usec":560479}, "ttl":62, "rtt":114.192, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164141, "usec":696851}, "replyc":1, "ttl":3, "attempt":0, "flowid":2, "replies":[{"rx":{"sec":1575164141, "usec":808462}, "ttl":62, "rtt":111.611, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164141, "usec":947817}, "replyc":1, "ttl":3, "attempt":0, "flowid":3, "replies":[{"rx":{"sec":1575164142, "usec":58248}, "ttl":62, "rtt":110.431, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164142, "usec":198606}, "replyc":1, "ttl":3, "attempt":0, "flowid":4, "replies":[{"rx":{"sec":1575164142, "usec":312272}, "ttl":62, "rtt":113.666, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164142, "usec":449586}, "replyc":1, "ttl":3, "attempt":0, "flowid":5, "replies":[{"rx":{"sec":1575164142, "usec":560230}, "ttl":62, "rtt":110.644, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164142, "usec":700507}, "replyc":1, "ttl":3, "attempt":0, "flowid":6, "replies":[{"rx":{"sec":1575164142, "usec":816227}, "ttl":62, "rtt":115.720, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]}]}]]},{"addr":"*", "q_ttl":1, "linkc":1, "links":[[{"addr":"", "probes":[{"tx":{"sec":1575164142, "usec":950589}, "replyc":1, "ttl":4, "attempt":0, "flowid":1, "replies":[{"rx":{"sec":1575164143, "usec":189802}, "ttl":57, "rtt":239.213, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164143, "usec":201075}, "replyc":1, "ttl":4, "attempt":0, "flowid":2, "replies":[{"rx":{"sec":1575164143, "usec":445745}, "ttl":57, "rtt":244.670, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164143, "usec":452043}, "replyc":1, "ttl":4, "attempt":0, "flowid":3, "replies":[{"rx":{"sec":1575164143, "usec":693688}, "ttl":57, "rtt":241.645, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164143, "usec":702902}, "replyc":1, "ttl":4, "attempt":0, "flowid":4, "replies":[{"rx":{"sec":1575164143, "usec":949616}, "ttl":57, "rtt":246.714, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164143, "usec":953807}, "replyc":1, "ttl":4, "attempt":0, "flowid":5, "replies":[{"rx":{"sec":1575164144, "usec":197621}, "ttl":57, "rtt":243.814, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164144, "usec":204821}, "replyc":1, "ttl":4, "attempt":0, "flowid":6, "replies":[{"rx":{"sec":1575164144, "usec":445510}, "ttl":57, "rtt":240.689, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]}]}]]},{"addr":"*", "q_ttl":1, "linkc":1, "links":[[{"addr":"*"}],[{"addr":"*"}],[{"addr":"", "probes":[{"tx":{"sec":1575164324, "usec":590253}, "replyc":1, "ttl":7, "attempt":0, "flowid":1, "replies":[{"rx":{"sec":1575164324, "usec":824749}, "ttl":58, "rtt":234.496, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":4}]},{"tx":{"sec":1575164324, "usec":841081}, "replyc":1, "ttl":7, "attempt":0, "flowid":2, "replies":[{"rx":{"sec":1575164325, "usec":76639}, "ttl":58, "rtt":235.558, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":4}]},{"tx":{"sec":1575164325, "usec":91914}, "replyc":1, "ttl":7, "attempt":0, "flowid":3, "replies":[{"rx":{"sec":1575164325, "usec":327057}, "ttl":58, "rtt":235.143, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":4}]},{"tx":{"sec":1575164325, "usec":342302}, "replyc":1, "ttl":7, "attempt":0, "flowid":4, "replies":[{"rx":{"sec":1575164325, "usec":577104}, "ttl":58, "rtt":234.802, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":4}]},{"tx":{"sec":1575164325, "usec":593376}, "replyc":1, "ttl":7, "attempt":0, "flowid":5, "replies":[{"rx":{"sec":1575164325, "usec":827783}, "ttl":58, "rtt":234.407, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":4}]},{"tx":{"sec":1575164325, "usec":844042}, "replyc":1, "ttl":7, "attempt":0, "flowid":6, "replies":[{"rx":{"sec":1575164326, "usec":78377}, "ttl":58, "rtt":234.335, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":4}]}]}]]},{"addr":"*", "q_ttl":4, "linkc":1, "links":[[{"addr":"", "probes":[{"tx":{"sec":1575164326, "usec":94321}, "replyc":1, "ttl":8, "attempt":0, "flowid":1, "replies":[{"rx":{"sec":1575164326, "usec":335873}, "ttl":59, "rtt":241.552, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164326, "usec":345134}, "replyc":1, "ttl":8, "attempt":0, "flowid":2, "replies":[{"rx":{"sec":1575164326, "usec":579447}, "ttl":59, "rtt":234.313, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164326, "usec":595723}, "replyc":1, "ttl":8, "attempt":0, "flowid":3, "replies":[{"rx":{"sec":1575164326, "usec":829901}, "ttl":59, "rtt":234.178, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164326, "usec":846169}, "replyc":1, "ttl":8, "attempt":0, "flowid":4, "replies":[{"rx":{"sec":1575164327, "usec":80350}, "ttl":59, "rtt":234.181, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164327, "usec":96636}, "replyc":1, "ttl":8, "attempt":0, "flowid":5, "replies":[{"rx":{"sec":1575164327, "usec":331346}, "ttl":59, "rtt":234.710, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]},{"tx":{"sec":1575164327, "usec":347537}, "replyc":1, "ttl":8, "attempt":0, "flowid":6, "replies":[{"rx":{"sec":1575164327, "usec":581954}, "ttl":59, "rtt":234.417, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":1}]}]}]]},{"addr":"*", "q_ttl":1, "linkc":1, "links":[[{"addr":"", "probes":[{"tx":{"sec":1575164327, "usec":598270}, "replyc":1, "ttl":9, "attempt":0, "flowid":1, "replies":[{"rx":{"sec":1575164327, "usec":831999}, "ttl":58, "rtt":233.729, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":0}]},{"tx":{"sec":1575164327, "usec":849211}, "replyc":1, "ttl":9, "attempt":0, "flowid":2, "replies":[{"rx":{"sec":1575164328, "usec":82908}, "ttl":58, "rtt":233.697, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":0}]},{"tx":{"sec":1575164328, "usec":100215}, "replyc":1, "ttl":9, "attempt":0, "flowid":3, "replies":[{"rx":{"sec":1575164328, "usec":333772}, "ttl":58, "rtt":233.557, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":0}]},{"tx":{"sec":1575164328, "usec":351061}, "replyc":1, "ttl":9, "attempt":0, "flowid":4, "replies":[{"rx":{"sec":1575164328, "usec":584821}, "ttl":58, "rtt":233.760, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":0}]},{"tx":{"sec":1575164328, "usec":602097}, "replyc":1, "ttl":9, "attempt":0, "flowid":5, "replies":[{"rx":{"sec":1575164328, "usec":835675}, "ttl":58, "rtt":233.578, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":0}]},{"tx":{"sec":1575164328, "usec":852955}, "replyc":1, "ttl":9, "attempt":0, "flowid":6, "replies":[{"rx":{"sec":1575164329, "usec":86491}, "ttl":58, "rtt":233.536, "icmp_type":3, "icmp_code":0, "icmp_q_tos":0, "icmp_q_ttl":0}]}]}]]},{"addr":"*", "q_ttl":0, "linkc":1, "links":[[{"addr":"*"}],[{"addr":"*"}],[{"addr":"*"}]]}]}
4+
{"type":"cycle-stop", "list_name":"/tmp/scamperctrl:3939", "id":1, "hostname":"ndt-zmm9m", "stop_time":1575164599}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{"UUID":"0280ea26207e_1637004208_unsafe_0000000000438AA2","TracerouteCallerVersion":"18200bf","CachedResult":false,"CachedUUID":""}
2+
{"type":"cycle-start", "list_name":"default", "id":0, "hostname":"0280ea26207e", "start_time":1638999963}
3+
{"type":"trace","version":"0.1", "userid":0, "method":"icmp-echo-paris", "src":"192.168.144.2", "dst":"91.189.88.142", "icmp_sum":33009, "stop_reason":"COMPLETED", "stop_data":0, "start":{"sec":1638999963, "usec":787829, "ftime":"2021-12-08 21:46:03"}, "hop_count":14, "attempts":2, "hoplimit":0, "firsthop":1, "wait":5, "wait_probe":0, "tos":0, "probe_size":44, "probe_count":16, "hops":[{"addr":"*", "probe_ttl":1, "probe_id":1, "probe_size":44, "tx":{"sec":1638999963, "usec":788025}, "rtt":0.070, "reply_ttl":64, "reply_tos":192, "reply_ipid":11379, "reply_size":72, "icmp_type":11, "icmp_code":0, "icmp_q_ttl":1, "icmp_q_ipl":44, "icmp_q_tos":0},{"addr":"", "probe_ttl":2, "probe_id":1, "probe_size":44, "tx":{"sec":1638999963, "usec":838384}, "rtt":3.662, "reply_ttl":254, "reply_tos":128, "reply_ipid":0, "reply_size":56, "icmp_type":11, "icmp_code":0, "icmp_q_ttl":1, "icmp_q_ipl":44, "icmp_q_tos":0},{"addr":"", "probe_ttl":3, "probe_id":1, "probe_size":44, "tx":{"sec":1638999963, "usec":888335}, "rtt":7.819, "reply_ttl":253, "reply_tos":128, "reply_ipid":0, "reply_size":56, "icmp_type":11, "icmp_code":0, "icmp_q_ttl":1, "icmp_q_ipl":44, "icmp_q_tos":128},{"addr":"", "probe_ttl":4, "probe_id":1, "probe_size":44, "tx":{"sec":1638999963, "usec":938392}, "rtt":0.648, "reply_ttl":251, "reply_tos":128, "reply_ipid":6664, "reply_size":56, "icmp_type":11, "icmp_code":0, "icmp_q_ttl":1, "icmp_q_ipl":44, "icmp_q_tos":128},{"addr":"*", "probe_ttl":5, "probe_id":1, "probe_size":44, "tx":{"sec":1638999963, "usec":988314}, "rtt":0.986, "reply_ttl":251, "reply_tos":128, "reply_ipid":0, "reply_size":56, "icmp_type":11, "icmp_code":0, "icmp_q_ttl":1, "icmp_q_ipl":44, "icmp_q_tos":128},{"addr":"", "probe_ttl":6, "probe_id":1, "probe_size":44, "tx":{"sec":1638999964, "usec":38569}, "rtt":1.447, "reply_ttl":250, "reply_tos":128, "reply_ipid":0, "reply_size":56, "icmp_type":11, "icmp_code":0, "icmp_q_ttl":1, "icmp_q_ipl":44, "icmp_q_tos":128},{"addr":"", "probe_ttl":7, "probe_id":1, "probe_size":44, "tx":{"sec":1638999964, "usec":88418}, "rtt":2.244, "reply_ttl":249, "reply_tos":128, "reply_ipid":31440, "reply_size":96, "icmp_type":11, "icmp_code":0, "icmp_q_ttl":1, "icmp_q_ipl":44, "icmp_q_tos":128},{"addr":"*", "probe_ttl":10, "probe_id":1, "probe_size":44, "tx":{"sec":1638999984, "usec":151628}, "rtt":3.719, "reply_ttl":249, "reply_tos":128, "reply_ipid":0, "reply_size":56, "icmp_type":11, "icmp_code":0, "icmp_q_ttl":1, "icmp_q_ipl":44, "icmp_q_tos":128},{"addr":"*", "probe_ttl":11, "probe_id":1, "probe_size":44, "tx":{"sec":1638999984, "usec":202751}, "rtt":2.871, "reply_ttl":248, "reply_tos":128, "reply_ipid":0, "reply_size":56, "icmp_type":11, "icmp_code":0, "icmp_q_ttl":1, "icmp_q_ipl":44, "icmp_q_tos":0},{"addr":"", "probe_ttl":12, "probe_id":1, "probe_size":44, "tx":{"sec":1638999984, "usec":251999}, "rtt":135.640, "reply_ttl":238, "reply_tos":128, "reply_ipid":0, "reply_size":56, "icmp_type":11, "icmp_code":0, "icmp_q_ttl":1, "icmp_q_ipl":44, "icmp_q_tos":0},{"addr":"*", "probe_ttl":13, "probe_id":1, "probe_size":44, "tx":{"sec":1638999984, "usec":387776}, "rtt":135.565, "reply_ttl":46, "reply_tos":128, "reply_ipid":19426, "reply_size":72, "icmp_type":11, "icmp_code":0, "icmp_q_ttl":1, "icmp_q_ipl":44, "icmp_q_tos":0},{"addr":"*", "probe_ttl":14, "probe_id":1, "probe_size":44, "tx":{"sec":1638999984, "usec":523505}, "rtt":135.610, "reply_ttl":46, "reply_tos":128, "reply_ipid":26001, "reply_size":44, "icmp_type":0, "icmp_code":0}]}
4+
{"type":"cycle-stop", "list_name":"default", "id":0, "hostname":"0280ea26207e", "stop_time":1638999984}

tracer/scamper.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func NewScamper(cfg ScamperConfig) (*Scamper, error) {
8181

8282
// Trace starts a new scamper process to run a traceroute based on the
8383
// traceroute type and saves it in a file.
84-
func (s *Scamper) Trace(remoteIP, cookie, uuid string, t time.Time) (out []byte, err error) {
84+
func (s *Scamper) Trace(remoteIP, cookie, uuid string, t time.Time) ([]byte, error) {
8585
tracesInProgress.WithLabelValues("scamper").Inc()
8686
defer tracesInProgress.WithLabelValues("scamper").Dec()
8787
return s.trace(remoteIP, cookie, uuid, t)
@@ -141,6 +141,9 @@ func traceAndWrite(ctx context.Context, label string, filename string, cmd []str
141141
if err != nil {
142142
return nil, err
143143
}
144+
if len(data) == 0 {
145+
return nil, fmt.Errorf("context %p: failed to obtain a traceroute (command: %v)", ctx, cmd)
146+
}
144147

145148
buff := bytes.Buffer{}
146149
// It's OK to ignore the return values because err is always nil. If

0 commit comments

Comments
 (0)