Skip to content

Commit

Permalink
Add NetworkPolicy rule name in traceflow observation
Browse files Browse the repository at this point in the history
Signed-off-by: Kumar Atish <atish.iaf@gmail.com>
  • Loading branch information
Atish-iaf committed Nov 3, 2023
1 parent c9bbcb1 commit 4621040
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build/charts/antrea/crds/traceflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ spec:
type: string
networkPolicy:
type: string
networkPolicyRule:
type: string
ttl:
type: integer
minimum: 0
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5048,6 +5048,8 @@ spec:
type: string
networkPolicy:
type: string
networkPolicyRule:
type: string
ttl:
type: integer
minimum: 0
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-crds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5021,6 +5021,8 @@ spec:
type: string
networkPolicy:
type: string
networkPolicyRule:
type: string
ttl:
type: integer
minimum: 0
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5048,6 +5048,8 @@ spec:
type: string
networkPolicy:
type: string
networkPolicyRule:
type: string
ttl:
type: integer
minimum: 0
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5048,6 +5048,8 @@ spec:
type: string
networkPolicy:
type: string
networkPolicyRule:
type: string
ttl:
type: integer
minimum: 0
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5048,6 +5048,8 @@ spec:
type: string
networkPolicy:
type: string
networkPolicyRule:
type: string
ttl:
type: integer
minimum: 0
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5048,6 +5048,8 @@ spec:
type: string
networkPolicy:
type: string
networkPolicyRule:
type: string
ttl:
type: integer
minimum: 0
Expand Down
9 changes: 9 additions & 0 deletions pkg/agent/controller/traceflow/packetin.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ func (c *Controller) parsePacketIn(pktIn *ofctrl.PacketIn) (*crdv1beta1.Traceflo
npRef := c.networkPolicyQuerier.GetNetworkPolicyByRuleFlowID(egressInfo)
if npRef != nil {
ob.NetworkPolicy = npRef.ToString()
ruleRef := c.networkPolicyQuerier.GetRuleByFlowID(egressInfo)
if ruleRef != nil {
ob.NetworkPolicyRule = ruleRef.Name
}
}
obs = append(obs, *ob)
}
Expand All @@ -222,6 +226,10 @@ func (c *Controller) parsePacketIn(pktIn *ofctrl.PacketIn) (*crdv1beta1.Traceflo
npRef := c.networkPolicyQuerier.GetNetworkPolicyByRuleFlowID(ingressInfo)
if npRef != nil {
ob.NetworkPolicy = npRef.ToString()
ruleRef := c.networkPolicyQuerier.GetRuleByFlowID(ingressInfo)
if ruleRef != nil {
ob.NetworkPolicyRule = ruleRef.Name
}
}
obs = append(obs, *ob)
}
Expand All @@ -237,6 +245,7 @@ func (c *Controller) parsePacketIn(pktIn *ofctrl.PacketIn) (*crdv1beta1.Traceflo
if ruleRef := c.networkPolicyQuerier.GetRuleByFlowID(notAllowConjInfo); ruleRef != nil {
if npRef := ruleRef.PolicyRef; npRef != nil {
ob.NetworkPolicy = npRef.ToString()
ob.NetworkPolicyRule = ruleRef.Name
}
if ruleRef.Action != nil && *ruleRef.Action == crdv1beta1.RuleActionReject {
ob.Action = crdv1beta1.ActionRejected
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/crd/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,8 @@ type Observation struct {
DstMAC string `json:"dstMAC,omitempty" yaml:"dstMAC,omitempty"`
// NetworkPolicy is the combination of Namespace and NetworkPolicyName.
NetworkPolicy string `json:"networkPolicy,omitempty" yaml:"networkPolicy,omitempty"`
// NetworkPolicyRule is the name of an ingress or an egress rule in NetworkPolicy.
NetworkPolicyRule string `json:"networkPolicyRule,omitempty" yaml:"networkPolicyRule,omitempty"`
// Egress is the name of the Egress.
Egress string `json:"egress,omitempty" yaml:"egress,omitempty"`
// TTL is the observation TTL.
Expand Down

0 comments on commit 4621040

Please sign in to comment.