github-vet / github-vet/rangeloop-pointer-findings
laincloud/networkd: virtualip.go; 34 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [laincloud/networkd](https://www.github.com/laincloud/networkd) at [virtualip.go](https://github.com/laincloud/networkd/blob/4f34e1f7c9a2c0d179421000a8ddef775f22ab0d/virtualip.go#L294-L327)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.
> function call which takes a reference to config at line 301 may start a goroutine
[Click here to see the code in its original context.](https://github.com/laincloud/networkd/blob/4f34e1f7c9a2c0d179421000a8ddef775f22ab0d/virtualip.go#L294-L327)
Click here to show the 34 line(s) of Go which triggered the analyzer.
```go
for port, config := range item.ports {
if cont != nil && cont.ip != "" {
if config.containerIp == "" {
config.containerIp = cont.ip
item.ports[port] = config
} else if config.containerIp != cont.ip {
// remove old ip rules
item.DeleteIpRule(&config)
config.containerIp = cont.ip
item.ports[port] = config
}
}
if config.containerIp == "" {
continue
}
switch state {
case LockerStateCreated:
item.CreateIpRule(&config)
// calico
self.AddCalicoRule("ingress", item.appName, "allow", config.proto, config.containerPort)
case LockerStateLocked:
vi, _ := self.vDb.GetVirtualIp(item)
item.CreateIpRule(&config)
if vi.state == VirtualIpStateCreated || vi.state == VirtualIpStateUnused {
// calico
self.AddCalicoRule("ingress", item.appName, "allow", config.proto, config.containerPort)
self.CreateAppKey(item)
}
case LockerStateUnlocked:
item.DeleteIpRule(&config)
}
}
```
Click here to show extra information the analyzer produced.
```
The following paths through the callgraph could lead to a goroutine:
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesAcl, 1) -> (Fatal, 1) -> (Run, 0)
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesCheckAcl, 1) -> (Fatal, 1) -> (Run, 0) -> (Infof, 1) -> (Shutdown, 0) -> (JoinHostPort, 2)
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesAcl, 1) -> (Fatal, 1) -> (Run, 0) -> (Infof, 1) -> (Shutdown, 0) -> (JoinHostPort, 2)
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesCheckAcl, 1) -> (Fatal, 1) -> (Run, 0) -> (Infof, 1) -> (Shutdown, 0) -> (JoinHostPort, 2) -> (WatchSwarmIps, 1) -> (WatchLeaderIps, 2)
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesCheckAcl, 1) -> (Fatal, 1) -> (Run, 0) -> (Infof, 1)
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesCheckAcl, 1) -> (Fatal, 1) -> (Run, 0) -> (Infof, 1) -> (Shutdown, 0) -> (JoinHostPort, 2) -> (WatchTinydnsIps, 1) -> (WatchProcIps, 3)
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesAcl, 1) -> (Fatal, 1) -> (Run, 0) -> (Infof, 1) -> (Shutdown, 0) -> (JoinHostPort, 2) -> (WatchDeploydIps, 1) -> (WatchLeaderIps, 2)
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesAcl, 1) -> (Fatal, 1) -> (Run, 0) -> (Infof, 1) -> (Shutdown, 0) -> (JoinHostPort, 2) -> (WatchTinydnsIps, 1) -> (WatchProcIps, 3)
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesCheckAcl, 1) -> (Fatal, 1) -> (Run, 0)
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesAcl, 1) -> (Fatal, 1) -> (Run, 0) -> (Infof, 1)
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesAcl, 1) -> (Fatal, 1) -> (Run, 0) -> (Infof, 1) -> (Shutdown, 0) -> (JoinHostPort, 2) -> (BroadcastIp, 1)
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesCheckAcl, 1) -> (Fatal, 1) -> (Run, 0) -> (Infof, 1) -> (Shutdown, 0) -> (JoinHostPort, 2) -> (WatchDeploydIps, 1) -> (WatchLeaderIps, 2)
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesCheckAcl, 1) -> (Fatal, 1) -> (Run, 0) -> (Infof, 1) -> (Shutdown, 0) -> (JoinHostPort, 2) -> (WatchWebrouterIps, 1) -> (WatchProcIps, 3)
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesAcl, 1) -> (Fatal, 1) -> (Run, 0) -> (Infof, 1) -> (Shutdown, 0) -> (JoinHostPort, 2) -> (WatchWebrouterIps, 1) -> (WatchProcIps, 3)
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesAcl, 1) -> (Fatal, 1) -> (Run, 0) -> (Infof, 1) -> (Shutdown, 0) -> (JoinHostPort, 2) -> (WatchSwarmIps, 1) -> (WatchLeaderIps, 2)
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesCheckAcl, 1) -> (Fatal, 1) -> (Run, 0) -> (Infof, 1) -> (Shutdown, 0) -> (JoinHostPort, 2) -> (WatchStreamRouter, 2)
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesCheckAcl, 1) -> (Fatal, 1) -> (Run, 0) -> (Infof, 1) -> (Shutdown, 0) -> (JoinHostPort, 2) -> (BroadcastIp, 1)
(DeleteIpRule, 1) -> (doIptablesDeleteAcl, 1) -> (doIptablesAcl, 1) -> (Fatal, 1) -> (Run, 0) -> (Infof, 1) -> (Shutdown, 0) -> (JoinHostPort, 2) -> (WatchStreamRouter, 2)
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: 4f34e1f7c9a2c0d179421000a8ddef775f22ab0d
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.