Skip to content

Commit 2ec517c

Browse files
authored
avoid using nil in NameForAnalyzerOut method where possible (#931)
1 parent 757cfa1 commit 2ec517c

14 files changed

+59
-59
lines changed

pkg/ibmvpc/examples/out/explain_out/tgwAnotherEnableDefaultDifFile_all_vpcs_explain.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Interpreted destination(s): test-vpc2-ky/vsi21a-ky[10.240.64.4]
66
Connections from test-vpc1-ky/vsi11-ky[10.240.11.4] to test-vpc2-ky/vsi21a-ky[10.240.64.4]: All Connections
77

88
Path:
9-
vsi11-ky[10.240.11.4] -> security group sg11-ky -> network ACL acl11-ky -> subnet subnet11-ky ->
9+
test-vpc1-ky/vsi11-ky[10.240.11.4] -> security group sg11-ky -> network ACL acl11-ky -> subnet subnet11-ky ->
1010
test-vpc1-ky -> TGW local-tg-ky -> test-vpc2-ky ->
11-
subnet subnet21-ky -> network ACL acl21-ky -> security group sg21-ky -> vsi21a-ky[10.240.64.4]
11+
subnet subnet21-ky -> network ACL acl21-ky -> security group sg21-ky -> test-vpc2-ky/vsi21a-ky[10.240.64.4]
1212

1313
------------------------------------------------------------------------------------------------------------------------
1414

pkg/ibmvpc/examples/out/explain_out/tgwAnotherExampleEnabledConn_all_vpcs_explain.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Interpreted destination(s): test-vpc1-ky/ky-vsi0-subnet11[10.240.80.4]
66
Connections from test-vpc0-ky/ky-vsi0-subnet5[10.240.9.4] to test-vpc1-ky/ky-vsi0-subnet11[10.240.80.4]: All Connections
77

88
Path:
9-
ky-vsi0-subnet5[10.240.9.4] -> security group sg1-ky -> network ACL acl3-ky -> subnet subnet5 ->
9+
test-vpc0-ky/ky-vsi0-subnet5[10.240.9.4] -> security group sg1-ky -> network ACL acl3-ky -> subnet subnet5 ->
1010
test-vpc0-ky -> TGW local-tg-ky -> test-vpc1-ky ->
11-
subnet subnet11 -> network ACL acl11-ky -> security group sg11-ky -> ky-vsi0-subnet11[10.240.80.4]
11+
subnet subnet11 -> network ACL acl11-ky -> security group sg11-ky -> test-vpc1-ky/ky-vsi0-subnet11[10.240.80.4]
1212

1313
------------------------------------------------------------------------------------------------------------------------
1414

pkg/ibmvpc/examples/out/explain_out/tgwDisabledDenyPrefix_all_vpcs_explain.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cross-vpc-connection: transit-connection tg_connection0 of transit-gateway local
1111
Ingress: network ACL acl1-ky allows connection; security group sg1-ky allows connection
1212

1313
Path:
14-
ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
14+
test-vpc2-ky/ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
1515
test-vpc2-ky -> | TGW local-tg-ky |
1616

1717
------------------------------------------------------------------------------------------------------------------------

pkg/ibmvpc/examples/out/explain_out/tgwDisabledDenyPrefix_all_vpcs_explain_detail.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cross-vpc-connection: transit-connection tg_connection0 of transit-gateway local
1111
Ingress: network ACL acl1-ky allows connection; security group sg1-ky allows connection
1212

1313
Path:
14-
ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
14+
test-vpc2-ky/ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
1515
test-vpc2-ky -> | TGW local-tg-ky |
1616

1717

pkg/ibmvpc/examples/out/explain_out/tgwDisablesTCPRespond_all_vpcs_explain_detail.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ Connections from test-vpc0-ky/ky-vsi0-subnet0[10.240.0.5] to test-vpc1-ky/ky-vsi
77
TCP response is blocked
88

99
Path:
10-
ky-vsi0-subnet0[10.240.0.5] -> security group sg1-ky -> network ACL acl1-ky -> subnet subnet0 ->
10+
test-vpc0-ky/ky-vsi0-subnet0[10.240.0.5] -> security group sg1-ky -> network ACL acl1-ky -> subnet subnet0 ->
1111
test-vpc0-ky -> TGW local-tg-ky -> test-vpc1-ky ->
12-
subnet subnet10 -> network ACL acl11-ky -> security group sg11-ky -> ky-vsi0-subnet10[10.240.64.4]
12+
subnet subnet10 -> network ACL acl11-ky -> security group sg11-ky -> test-vpc1-ky/ky-vsi0-subnet10[10.240.64.4]
1313

1414

1515
Details:

pkg/ibmvpc/examples/out/explain_out/tgwEnableDefaultFilter_all_vpcs_explain_detail.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Interpreted destination(s): test-vpc1-ky/ky-vsi0-subnet11[10.240.80.4]
66
Connections from test-vpc0-ky/ky-vsi0-subnet5[10.240.9.4] to test-vpc1-ky/ky-vsi0-subnet11[10.240.80.4]: All Connections
77

88
Path:
9-
ky-vsi0-subnet5[10.240.9.4] -> security group sg1-ky -> network ACL acl3-ky -> subnet subnet5 ->
9+
test-vpc0-ky/ky-vsi0-subnet5[10.240.9.4] -> security group sg1-ky -> network ACL acl3-ky -> subnet subnet5 ->
1010
test-vpc0-ky -> TGW local-tg-ky -> test-vpc1-ky ->
11-
subnet subnet11 -> network ACL acl11-ky -> security group sg11-ky -> ky-vsi0-subnet11[10.240.80.4]
11+
subnet subnet11 -> network ACL acl11-ky -> security group sg11-ky -> test-vpc1-ky/ky-vsi0-subnet11[10.240.80.4]
1212

1313

1414
Details:

pkg/ibmvpc/examples/out/explain_out/tgwEnabledSpecificFilter_all_vpcs_explain_detail.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Interpreted destination(s): test-vpc0-ky/ky-vsi0-subnet2[10.240.4.4]
66
Connections from test-vpc2-ky/ky-vsi1-subnet20[10.240.128.5] to test-vpc0-ky/ky-vsi0-subnet2[10.240.4.4]: All Connections
77

88
Path:
9-
ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
9+
test-vpc2-ky/ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
1010
test-vpc2-ky -> TGW local-tg-ky -> test-vpc0-ky ->
11-
subnet subnet2 -> network ACL acl2-ky -> security group sg1-ky -> ky-vsi0-subnet2[10.240.4.4]
11+
subnet subnet2 -> network ACL acl2-ky -> security group sg1-ky -> test-vpc0-ky/ky-vsi0-subnet2[10.240.4.4]
1212

1313

1414
Details:

pkg/ibmvpc/examples/out/explain_out/tgwExampleCidr_all_vpcs_explain_detail.txt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Interpreted destination(s): test-vpc0-ky/ky-vsi1-subnet2[10.240.4.5], test-vpc0-
66
Connections from test-vpc2-ky/ky-vsi1-subnet20[10.240.128.5] to test-vpc0-ky/ky-vsi0-subnet2[10.240.4.4]: All Connections
77

88
Path:
9-
ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
9+
test-vpc2-ky/ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
1010
test-vpc2-ky -> TGW local-tg-ky -> test-vpc0-ky ->
11-
subnet subnet2 -> network ACL acl2-ky -> security group sg1-ky -> ky-vsi0-subnet2[10.240.4.4]
11+
subnet subnet2 -> network ACL acl2-ky -> security group sg1-ky -> test-vpc0-ky/ky-vsi0-subnet2[10.240.4.4]
1212

1313

1414
Details:
@@ -46,9 +46,9 @@ TCP response is enabled; The relevant rules are:
4646
Connections from test-vpc2-ky/ky-vsi1-subnet20[10.240.128.5] to test-vpc0-ky/ky-vsi0-subnet3[10.240.5.5]: All Connections
4747

4848
Path:
49-
ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
49+
test-vpc2-ky/ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
5050
test-vpc2-ky -> TGW local-tg-ky -> test-vpc0-ky ->
51-
subnet subnet3 -> network ACL acl2-ky -> security group sg1-ky -> ky-vsi0-subnet3[10.240.5.5]
51+
subnet subnet3 -> network ACL acl2-ky -> security group sg1-ky -> test-vpc0-ky/ky-vsi0-subnet3[10.240.5.5]
5252

5353

5454
Details:
@@ -86,9 +86,9 @@ TCP response is enabled; The relevant rules are:
8686
Connections from test-vpc2-ky/ky-vsi1-subnet20[10.240.128.5] to test-vpc0-ky/ky-vsi1-subnet2[10.240.4.5]: All Connections
8787

8888
Path:
89-
ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
89+
test-vpc2-ky/ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
9090
test-vpc2-ky -> TGW local-tg-ky -> test-vpc0-ky ->
91-
subnet subnet2 -> network ACL acl2-ky -> security group sg1-ky -> ky-vsi1-subnet2[10.240.4.5]
91+
subnet subnet2 -> network ACL acl2-ky -> security group sg1-ky -> test-vpc0-ky/ky-vsi1-subnet2[10.240.4.5]
9292

9393

9494
Details:
@@ -126,9 +126,9 @@ TCP response is enabled; The relevant rules are:
126126
Connections from test-vpc2-ky/ky-vsi1-subnet20[10.240.128.5] to test-vpc0-ky/ky-vsi1-subnet3[10.240.5.4]: All Connections
127127

128128
Path:
129-
ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
129+
test-vpc2-ky/ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
130130
test-vpc2-ky -> TGW local-tg-ky -> test-vpc0-ky ->
131-
subnet subnet3 -> network ACL acl2-ky -> security group sg1-ky -> ky-vsi1-subnet3[10.240.5.4]
131+
subnet subnet3 -> network ACL acl2-ky -> security group sg1-ky -> test-vpc0-ky/ky-vsi1-subnet3[10.240.5.4]
132132

133133

134134
Details:
@@ -171,7 +171,7 @@ cross-vpc-connection: transit-connection tg_connection0 of transit-gateway local
171171
Ingress: network ACL acl1-ky allows connection; security group sg1-ky allows connection
172172

173173
Path:
174-
ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
174+
test-vpc2-ky/ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
175175
test-vpc2-ky -> | TGW local-tg-ky |
176176

177177

@@ -203,7 +203,7 @@ cross-vpc-connection: transit-connection tg_connection0 of transit-gateway local
203203
Ingress: network ACL acl1-ky allows connection; security group sg1-ky allows connection
204204

205205
Path:
206-
ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
206+
test-vpc2-ky/ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
207207
test-vpc2-ky -> | TGW local-tg-ky |
208208

209209

@@ -235,7 +235,7 @@ cross-vpc-connection: transit-connection tg_connection0 of transit-gateway local
235235
Ingress: network ACL acl1-ky allows connection; security group sg1-ky allows connection
236236

237237
Path:
238-
ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
238+
test-vpc2-ky/ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
239239
test-vpc2-ky -> | TGW local-tg-ky |
240240

241241

@@ -267,7 +267,7 @@ cross-vpc-connection: transit-connection tg_connection0 of transit-gateway local
267267
Ingress: network ACL acl1-ky allows connection; security group sg1-ky allows connection
268268

269269
Path:
270-
ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
270+
test-vpc2-ky/ky-vsi1-subnet20[10.240.128.5] -> security group sg21-ky -> network ACL acl21-ky -> subnet subnet20 ->
271271
test-vpc2-ky -> | TGW local-tg-ky |
272272

273273

pkg/ibmvpc/examples/out/explain_out/tgwSubnetToSubnet_all_vpcs_explain.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cross-vpc-connection: transit-connection tg_connection3 of transit-gateway local
1111
Ingress: network ACL acl31-ky allows connection; security group sg31-ky allows connection
1212

1313
Path:
14-
vsi11-ky[10.240.11.4] -> security group sg11-ky -> | network ACL acl11-ky |
14+
test-vpc1-ky/vsi11-ky[10.240.11.4] -> security group sg11-ky -> | network ACL acl11-ky |
1515

1616
------------------------------------------------------------------------------------------------------------------------
1717

pkg/vpcmodel/explainabilityPrint.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ func (g *groupedConnLine) explainabilityLineStr(c *VPCConfig, connQuery *netset.
181181

182182
// path in "3" above
183183
missingExternalRouter := isExternal && externalRouter == nil
184-
path := "Path:\n" + pathStr(allRulesDetails, filtersRelevant, src, dst, ingressBlocking, egressBlocking,
184+
path := "Path:\n" + pathStr(c, allRulesDetails, filtersRelevant, src, dst, ingressBlocking, egressBlocking,
185185
loadBalancerBlocking, missingExternalRouter, externalRouter, crossVpcRouter,
186186
crossVpcConnection, rules, privateSubnetRule) + newLine
187187
// details is "4" above
@@ -440,12 +440,12 @@ func stringFilterEffect(allRulesDetails *rulesDetails, filterLayerName string, t
440440
// if the connection does not exist. In the latter case the path is until the first block with the first block between ||
441441
// e.g.: "vsi1-ky[10.240.10.4] -> SG sg1-ky -> subnet ... -> ACL acl1-ky -> PublicGateway: public-gw-ky -> Public Internet 161.26.0.0/16"
442442
// e.g.: "vsi1-ky[10.240.10.4] -> security group sg1-ky -> subnet1-ky -> | network ACL acl1-ky |"
443-
func pathStr(allRulesDetails *rulesDetails, filtersRelevant map[string]bool, src, dst EndpointElem,
443+
func pathStr(c *VPCConfig, allRulesDetails *rulesDetails, filtersRelevant map[string]bool, src, dst EndpointElem,
444444
ingressBlocking, egressBlocking, loadBalancerBlocking, missingExternalRouter bool,
445445
externalRouter, crossVpcRouter RoutingResource, crossVpcConnection *netset.TransportSet,
446446
rules *rulesConnection, privateSubnetRule PrivateSubnetRule) string {
447447
var pathSlice []string
448-
pathSlice = append(pathSlice, "\t"+src.NameForAnalyzerOut(nil))
448+
pathSlice = append(pathSlice, "\t"+src.NameForAnalyzerOut(c))
449449
if loadBalancerBlocking {
450450
// todo: add loadBalancer as part of the path and also as blocking??? separate PR?
451451
// connection is stopped at the src itself:
@@ -463,15 +463,15 @@ func pathStr(allRulesDetails *rulesDetails, filtersRelevant map[string]bool, src
463463
return blockedPathStr(pathSlice)
464464
}
465465
if isExternal {
466-
externalRouterStr := newLineTab + externalRouter.Kind() + space + externalRouter.NameForAnalyzerOut(nil)
466+
externalRouterStr := newLineTab + externalRouter.Kind() + space + externalRouter.NameForAnalyzerOut(c)
467467
// externalRouter is fip - add its cidr
468468
if externalRouter.Kind() == fipRouter {
469469
externalRouterStr += space + externalRouter.ExternalIP()
470470
}
471471
pathSlice = append(pathSlice, externalRouterStr)
472472
} else if crossVpcRouterInPath { // src and dst are internal and there is a cross vpc Router
473473
pathSlice = append(pathSlice, newLineTab+src.(InternalNodeIntf).Subnet().VPC().Name(),
474-
crossVpcRouter.Kind()+space+crossVpcRouter.NameForAnalyzerOut(nil))
474+
crossVpcRouter.Kind()+space+crossVpcRouter.NameForAnalyzerOut(c))
475475
if crossVpcConnection.IsEmpty() { // cross vpc (tgw) denys connection
476476
pathSlice[len(pathSlice)-1] = blockedLeft + pathSlice[len(pathSlice)-1] // blocking cross-vpc router
477477
return blockedPathStr(pathSlice)
@@ -485,9 +485,9 @@ func pathStr(allRulesDetails *rulesDetails, filtersRelevant map[string]bool, src
485485
}
486486
// got here: full path
487487
if len(ingressPath) == 0 {
488-
pathSlice = append(pathSlice, newLineTab+dst.NameForAnalyzerOut(nil))
488+
pathSlice = append(pathSlice, newLineTab+dst.NameForAnalyzerOut(c))
489489
} else {
490-
pathSlice = append(pathSlice, dst.NameForAnalyzerOut(nil))
490+
pathSlice = append(pathSlice, dst.NameForAnalyzerOut(c))
491491
}
492492
return strings.Join(pathSlice, arrow)
493493
}

0 commit comments

Comments
 (0)