Skip to content

Commit b86aea9

Browse files
authored
Merge pull request #3497 from gravitl/v0.99_fixes
v0.99: egress policy fix
2 parents 8a2c1d6 + b167226 commit b86aea9

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

logic/egress.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,15 @@ func DoesNodeHaveAccessToEgress(node *models.Node, e *schema.Egress, acls []mode
4646
}
4747
srcVal := ConvAclTagToValueMap(acl.Src)
4848
for _, dstI := range acl.Dst {
49-
50-
if dstI.ID == models.NodeTagID && dstI.Value == "*" {
51-
return true
52-
}
53-
if dstI.ID == models.EgressID && dstI.Value == e.ID {
54-
e := schema.Egress{ID: dstI.Value}
55-
err := e.Get(db.WithContext(context.TODO()))
56-
if err != nil {
57-
continue
49+
if (dstI.ID == models.EgressID && dstI.Value == e.ID) || (dstI.ID == models.NodeTagID && dstI.Value == "*") {
50+
if dstI.ID == models.EgressID {
51+
e := schema.Egress{ID: dstI.Value}
52+
err := e.Get(db.WithContext(context.TODO()))
53+
if err != nil {
54+
continue
55+
}
5856
}
57+
5958
if node.IsStatic {
6059
if _, ok := srcVal[node.StaticNode.ClientID]; ok {
6160
return true
@@ -71,8 +70,8 @@ func DoesNodeHaveAccessToEgress(node *models.Node, e *schema.Egress, acls []mode
7170
return true
7271
}
7372
}
74-
7573
}
74+
7675
}
7776
}
7877
return false

logic/peers.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
207207
defaultUserPolicy, _ := GetDefaultPolicy(models.NetworkID(node.Network), models.UserPolicy)
208208
defaultDevicePolicy, _ := GetDefaultPolicy(models.NetworkID(node.Network), models.DevicePolicy)
209209
if (defaultDevicePolicy.Enabled && defaultUserPolicy.Enabled) ||
210-
(!CheckIfAnyPolicyisUniDirectional(node, acls) && !CheckIfAnyActiveEgressPolicy(node, acls)) {
210+
(!CheckIfAnyPolicyisUniDirectional(node, acls) &&
211+
!(node.EgressDetails.IsEgressGateway && len(node.EgressDetails.EgressGatewayRanges) > 0)) {
211212
aclRule := models.AclRule{
212213
ID: fmt.Sprintf("%s-allowed-network-rules", node.ID.String()),
213214
AllowedProtocol: models.ALL,

0 commit comments

Comments
 (0)