Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions plugins/policy/config_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,13 @@ func (pp *ConfigProcessor) Close() error {
return nil
}

func getHostIPNet(ip string) string {
if ip == "" {
return ip
}
return ip + "/32"
}

func getIngressRule(proto policy.Policy_Port_Protocol, dstPort int32, srcIPAddr string, ruleName string) *acl.AccessLists_Acl_Rule {

lowerDstPort := uint32(dstPort)
Expand All @@ -368,7 +375,7 @@ func getIngressRule(proto policy.Policy_Port_Protocol, dstPort int32, srcIPAddr
matches = &acl.AccessLists_Acl_Rule_Matches{
IpRule: &acl.AccessLists_Acl_Rule_Matches_IpRule{
Ip: &acl.AccessLists_Acl_Rule_Matches_IpRule_Ip{
SourceNetwork: srcIPAddr + "/32",
SourceNetwork: getHostIPNet(srcIPAddr),
},
Tcp: &acl.AccessLists_Acl_Rule_Matches_IpRule_Tcp{
DestinationPortRange: &acl.AccessLists_Acl_Rule_Matches_IpRule_Tcp_DestinationPortRange{
Expand All @@ -382,7 +389,7 @@ func getIngressRule(proto policy.Policy_Port_Protocol, dstPort int32, srcIPAddr
matches = &acl.AccessLists_Acl_Rule_Matches{
IpRule: &acl.AccessLists_Acl_Rule_Matches_IpRule{
Ip: &acl.AccessLists_Acl_Rule_Matches_IpRule_Ip{
SourceNetwork: srcIPAddr + "/32",
SourceNetwork: getHostIPNet(srcIPAddr),
},
Udp: &acl.AccessLists_Acl_Rule_Matches_IpRule_Udp{
DestinationPortRange: &acl.AccessLists_Acl_Rule_Matches_IpRule_Udp_DestinationPortRange{
Expand Down Expand Up @@ -449,14 +456,14 @@ func getFromRule(srcIPAddr string, ruleName string) *acl.AccessLists_Acl_Rule {
matches = &acl.AccessLists_Acl_Rule_Matches{
IpRule: &acl.AccessLists_Acl_Rule_Matches_IpRule{
Ip: &acl.AccessLists_Acl_Rule_Matches_IpRule_Ip{
SourceNetwork: srcIPAddr + "/32",
SourceNetwork: getHostIPNet(srcIPAddr),
},
},
}
matches = &acl.AccessLists_Acl_Rule_Matches{
IpRule: &acl.AccessLists_Acl_Rule_Matches_IpRule{
Ip: &acl.AccessLists_Acl_Rule_Matches_IpRule_Ip{
SourceNetwork: srcIPAddr + "/32",
SourceNetwork: getHostIPNet(srcIPAddr),
},
},
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.