-
Notifications
You must be signed in to change notification settings - Fork 51
/
datapath_icmp.go
47 lines (32 loc) · 1.37 KB
/
datapath_icmp.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// +build linux
package nfqdatapath
import (
"go.aporeto.io/enforcerd/trireme-lib/collector"
"go.aporeto.io/enforcerd/trireme-lib/controller/pkg/packet"
"go.aporeto.io/enforcerd/trireme-lib/controller/pkg/pucontext"
)
type icmpActionType int
const (
icmpAccept icmpActionType = iota
icmpDrop
)
func (d *Datapath) processNetworkICMPPacket(context *pucontext.PUContext, packet *packet.Packet, icmpType int8, icmpCode int8) icmpActionType {
srcAddr := packet.SourceAddress()
dstAddr := packet.DestinationAddress()
report, pkt, err := context.NetworkICMPACLPolicy(srcAddr, icmpType, icmpCode)
d.reportExternalServiceFlowCommon(context, report, pkt, false, packet, &collector.EndPoint{IP: srcAddr.String()}, &collector.EndPoint{IP: dstAddr.String()})
if err != nil || pkt.Action.Rejected() {
return icmpDrop
}
return icmpAccept
}
func (d *Datapath) processApplicationICMPPacket(context *pucontext.PUContext, packet *packet.Packet, icmpType int8, icmpCode int8) icmpActionType {
srcAddr := packet.SourceAddress()
dstAddr := packet.DestinationAddress()
report, pkt, err := context.ApplicationICMPACLPolicy(dstAddr, icmpType, icmpCode)
d.reportExternalServiceFlowCommon(context, report, pkt, true, packet, &collector.EndPoint{IP: srcAddr.String()}, &collector.EndPoint{IP: dstAddr.String()})
if err != nil || pkt.Action.Rejected() {
return icmpDrop
}
return icmpAccept
}