mirror of
https://github.com/tailscale/tailscale.git
synced 2025-03-28 03:52:35 +00:00
wgengine/filter: add check for unknown proto
Updates #14280 Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
f39ee8e520
commit
f0b63d0eec
@ -41,6 +41,9 @@ const (
|
||||
// ReasonFragment means that the packet was dropped because it was an IP fragment.
|
||||
ReasonFragment DropReason = "fragment"
|
||||
|
||||
// ReasonUnknownProtocol means that the packet was dropped because it was an unknown protocol.
|
||||
ReasonUnknownProtocol DropReason = "unknown_protocol"
|
||||
|
||||
// ReasonError means that the packet was dropped because of an error.
|
||||
ReasonError DropReason = "error"
|
||||
)
|
||||
|
@ -621,6 +621,11 @@ func (f *Filter) pre(q *packet.Parsed, rf RunFlags, dir direction) (Response, us
|
||||
return Drop, usermetric.ReasonTooShort
|
||||
}
|
||||
|
||||
if q.IPProto == ipproto.Unknown {
|
||||
f.logRateLimit(rf, q, dir, Drop, "unknown proto")
|
||||
return Drop, usermetric.ReasonUnknownProtocol
|
||||
}
|
||||
|
||||
if q.Dst.Addr().IsMulticast() {
|
||||
f.logRateLimit(rf, q, dir, Drop, "multicast")
|
||||
return Drop, usermetric.ReasonMulticast
|
||||
|
@ -390,7 +390,8 @@ func TestPreFilter(t *testing.T) {
|
||||
}{
|
||||
{"empty", Accept, "", []byte{}},
|
||||
{"short", Drop, usermetric.ReasonTooShort, []byte("short")},
|
||||
{"junk", Drop, "", raw4default(ipproto.Unknown, 10)},
|
||||
{"short-junk", Drop, usermetric.ReasonTooShort, raw4default(ipproto.Unknown, 10)},
|
||||
{"long-junk", Drop, usermetric.ReasonUnknownProtocol, raw4default(ipproto.Unknown, 21)},
|
||||
{"fragment", Accept, "", raw4default(ipproto.Fragment, 40)},
|
||||
{"tcp", noVerdict, "", raw4default(ipproto.TCP, 0)},
|
||||
{"udp", noVerdict, "", raw4default(ipproto.UDP, 0)},
|
||||
|
Loading…
x
Reference in New Issue
Block a user