Skip to content

Commit 2c38487

Browse files
committed
Revert "TUN-8158: Add logging to confirm when ICMP reply is returned to the edge"
This reverts commit e653741.
1 parent ae0b261 commit 2c38487

File tree

5 files changed

+31
-55
lines changed

5 files changed

+31
-55
lines changed

ingress/icmp_darwin.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,18 @@ func newICMPProxy(listenIP netip.Addr, zone string, logger *zerolog.Logger, idle
131131
}
132132

133133
func (ip *icmpProxy) Request(ctx context.Context, pk *packet.ICMP, responder *packetResponder) error {
134-
_, span := responder.requestSpan(ctx, pk)
134+
ctx, span := responder.requestSpan(ctx, pk)
135135
defer responder.exportSpan()
136136

137137
originalEcho, err := getICMPEcho(pk.Message)
138138
if err != nil {
139139
tracing.EndWithErrorStatus(span, err)
140140
return err
141141
}
142-
observeICMPRequest(ip.logger, span, pk.Src.String(), pk.Dst.String(), originalEcho.ID, originalEcho.Seq)
143-
142+
span.SetAttributes(
143+
attribute.Int("originalEchoID", originalEcho.ID),
144+
attribute.Int("seq", originalEcho.Seq),
145+
)
144146
echoIDTrackerKey := flow3Tuple{
145147
srcIP: pk.Src,
146148
dstIP: pk.Dst,
@@ -187,7 +189,6 @@ func (ip *icmpProxy) Request(ctx context.Context, pk *packet.ICMP, responder *pa
187189
tracing.EndWithErrorStatus(span, err)
188190
return err
189191
}
190-
191192
err = icmpFlow.sendToDst(pk.Dst, pk.Message)
192193
if err != nil {
193194
tracing.EndWithErrorStatus(span, err)
@@ -268,12 +269,15 @@ func (ip *icmpProxy) sendReply(ctx context.Context, reply *echoReply) error {
268269
_, span := icmpFlow.responder.replySpan(ctx, ip.logger)
269270
defer icmpFlow.responder.exportSpan()
270271

272+
span.SetAttributes(
273+
attribute.String("dst", reply.from.String()),
274+
attribute.Int("echoID", reply.echo.ID),
275+
attribute.Int("seq", reply.echo.Seq),
276+
attribute.Int("originalEchoID", icmpFlow.originalEchoID),
277+
)
271278
if err := icmpFlow.returnToSrc(reply); err != nil {
272279
tracing.EndWithErrorStatus(span, err)
273-
return err
274280
}
275-
observeICMPReply(ip.logger, span, reply.from.String(), reply.echo.ID, reply.echo.Seq)
276-
span.SetAttributes(attribute.Int("originalEchoID", icmpFlow.originalEchoID))
277281
tracing.End(span)
278282
return nil
279283
}

ingress/icmp_linux.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ func (ip *icmpProxy) Request(ctx context.Context, pk *packet.ICMP, responder *pa
107107
tracing.EndWithErrorStatus(span, err)
108108
return err
109109
}
110-
observeICMPRequest(ip.logger, span, pk.Src.String(), pk.Dst.String(), originalEcho.ID, originalEcho.Seq)
110+
span.SetAttributes(
111+
attribute.Int("originalEchoID", originalEcho.ID),
112+
attribute.Int("seq", originalEcho.Seq),
113+
)
111114

112115
shouldReplaceFunnelFunc := createShouldReplaceFunnelFunc(ip.logger, responder.datagramMuxer, pk, originalEcho.ID)
113116
newFunnelFunc := func() (packet.Funnel, error) {
@@ -196,10 +199,6 @@ func (ip *icmpProxy) handleResponse(ctx context.Context, flow *icmpEchoFlow, buf
196199

197200
n, from, err := flow.originConn.ReadFrom(buf)
198201
if err != nil {
199-
if flow.IsClosed() {
200-
tracing.EndWithErrorStatus(span, fmt.Errorf("flow was closed"))
201-
return false, nil
202-
}
203202
tracing.EndWithErrorStatus(span, err)
204203
return false, err
205204
}
@@ -215,14 +214,16 @@ func (ip *icmpProxy) handleResponse(ctx context.Context, flow *icmpEchoFlow, buf
215214
tracing.EndWithErrorStatus(span, err)
216215
return true, err
217216
}
218-
217+
span.SetAttributes(
218+
attribute.String("dst", reply.from.String()),
219+
attribute.Int("echoID", reply.echo.ID),
220+
attribute.Int("seq", reply.echo.Seq),
221+
)
219222
if err := flow.returnToSrc(reply); err != nil {
220-
ip.logger.Error().Err(err).Str("dst", from.String()).Msg("Failed to send ICMP reply")
223+
ip.logger.Debug().Err(err).Str("dst", from.String()).Msg("Failed to send ICMP reply")
221224
tracing.EndWithErrorStatus(span, err)
222225
return true, err
223226
}
224-
225-
observeICMPReply(ip.logger, span, from.String(), reply.echo.ID, reply.echo.Seq)
226227
tracing.End(span)
227228
return true, nil
228229
}

ingress/icmp_posix.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"fmt"
99
"net"
1010
"net/netip"
11-
"sync/atomic"
1211

1312
"github.com/google/gopacket/layers"
1413
"github.com/rs/zerolog"
@@ -47,7 +46,6 @@ type flow3Tuple struct {
4746
type icmpEchoFlow struct {
4847
*packet.ActivityTracker
4948
closeCallback func() error
50-
closed *atomic.Bool
5149
src netip.Addr
5250
originConn *icmp.PacketConn
5351
responder *packetResponder
@@ -61,7 +59,6 @@ func newICMPEchoFlow(src netip.Addr, closeCallback func() error, originConn *icm
6159
return &icmpEchoFlow{
6260
ActivityTracker: packet.NewActivityTracker(),
6361
closeCallback: closeCallback,
64-
closed: &atomic.Bool{},
6562
src: src,
6663
originConn: originConn,
6764
responder: responder,
@@ -89,14 +86,9 @@ func (ief *icmpEchoFlow) Equal(other packet.Funnel) bool {
8986
}
9087

9188
func (ief *icmpEchoFlow) Close() error {
92-
ief.closed.Store(true)
9389
return ief.closeCallback()
9490
}
9591

96-
func (ief *icmpEchoFlow) IsClosed() bool {
97-
return ief.closed.Load()
98-
}
99-
10092
// sendToDst rewrites the echo ID to the one assigned to this flow
10193
func (ief *icmpEchoFlow) sendToDst(dst netip.Addr, msg *icmp.Message) error {
10294
ief.UpdateLastActive()

ingress/icmp_windows.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,10 @@ func (ip *icmpProxy) Request(ctx context.Context, pk *packet.ICMP, responder *pa
281281
if err != nil {
282282
return err
283283
}
284-
observeICMPRequest(ip.logger, requestSpan, pk.Src.String(), pk.Dst.String(), echo.ID, echo.Seq)
284+
requestSpan.SetAttributes(
285+
attribute.Int("originalEchoID", echo.ID),
286+
attribute.Int("seq", echo.Seq),
287+
)
285288

286289
resp, err := ip.icmpEchoRoundtrip(pk.Dst, echo)
287290
if err != nil {
@@ -293,17 +296,17 @@ func (ip *icmpProxy) Request(ctx context.Context, pk *packet.ICMP, responder *pa
293296
responder.exportSpan()
294297

295298
_, replySpan := responder.replySpan(ctx, ip.logger)
299+
replySpan.SetAttributes(
300+
attribute.Int("originalEchoID", echo.ID),
301+
attribute.Int("seq", echo.Seq),
302+
attribute.Int64("rtt", int64(resp.rtt())),
303+
attribute.String("status", resp.status().String()),
304+
)
296305
err = ip.handleEchoReply(pk, echo, resp, responder)
297306
if err != nil {
298-
ip.logger.Err(err).Msg("Failed to send ICMP reply")
299307
tracing.EndWithErrorStatus(replySpan, err)
300308
return errors.Wrap(err, "failed to handle ICMP echo reply")
301309
}
302-
observeICMPReply(ip.logger, replySpan, pk.Dst.String(), echo.ID, echo.Seq)
303-
replySpan.SetAttributes(
304-
attribute.Int64("rtt", int64(resp.rtt())),
305-
attribute.String("status", resp.status().String()),
306-
)
307310
tracing.End(replySpan)
308311
return nil
309312
}

ingress/origin_icmp_proxy.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
"time"
88

99
"github.com/rs/zerolog"
10-
"go.opentelemetry.io/otel/attribute"
11-
"go.opentelemetry.io/otel/trace"
1210
"golang.org/x/net/icmp"
1311
"golang.org/x/net/ipv4"
1412
"golang.org/x/net/ipv6"
@@ -104,25 +102,3 @@ func getICMPEcho(msg *icmp.Message) (*icmp.Echo, error) {
104102
func isEchoReply(msg *icmp.Message) bool {
105103
return msg.Type == ipv4.ICMPTypeEchoReply || msg.Type == ipv6.ICMPTypeEchoReply
106104
}
107-
108-
func observeICMPRequest(logger *zerolog.Logger, span trace.Span, src string, dst string, echoID int, seq int) {
109-
logger.Debug().
110-
Str("src", src).
111-
Str("dst", dst).
112-
Int("originalEchoID", echoID).
113-
Int("originalEchoSeq", seq).
114-
Msg("Received ICMP request")
115-
span.SetAttributes(
116-
attribute.Int("originalEchoID", echoID),
117-
attribute.Int("seq", seq),
118-
)
119-
}
120-
121-
func observeICMPReply(logger *zerolog.Logger, span trace.Span, dst string, echoID int, seq int) {
122-
logger.Debug().Str("dst", dst).Int("echoID", echoID).Int("seq", seq).Msg("Sent ICMP reply to edge")
123-
span.SetAttributes(
124-
attribute.String("dst", dst),
125-
attribute.Int("echoID", echoID),
126-
attribute.Int("seq", seq),
127-
)
128-
}

0 commit comments

Comments
 (0)