From 2f1b4c1ce18d8d752b3b1f0c565417b61771f510 Mon Sep 17 00:00:00 2001 From: Josh Deprez Date: Sun, 16 Jun 2024 10:21:56 +1000 Subject: [PATCH] Workaround for trailing data on AARP packets --- router/aarp.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/router/aarp.go b/router/aarp.go index 8158034..62261ef 100644 --- a/router/aarp.go +++ b/router/aarp.go @@ -37,6 +37,8 @@ const ( maxAMTEntryAge = 30 * time.Second aarpRequestRetransmit = 1 * time.Second aarpRequestTimeout = 10 * time.Second + + aarpBodyLength = 28 // bytes ) const aarpStatusTemplate = ` @@ -181,8 +183,17 @@ func (a *AARPMachine) Run(ctx context.Context) error { a.incomingCh = nil } + // sfiera/multitalk will return an "excess data" error if the + // payload is too big. Most traffic I've seen locally does not have + // this problem, but I've seen one report with some junk trailing + // data on AARP packets. + payload := ethFrame.Payload + if len(payload) > aarpBodyLength { + payload = payload[:aarpBodyLength] + } + var aapkt aarp.Packet - if err := aarp.Unmarshal(ethFrame.Payload, &aapkt); err != nil { + if err := aarp.Unmarshal(payload, &aapkt); err != nil { log.Printf("Couldn't unmarshal AARP packet: %v", err) continue }