Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

an error in the code #2089

Closed
shengslin opened this issue Jun 1, 2019 · 1 comment
Closed

an error in the code #2089

shengslin opened this issue Jun 1, 2019 · 1 comment

Comments

@shengslin
Copy link

hi, when I read the function pkg/server/zclient.go:newIPRouteBody, I found some mistakes.
In this function, "isWithdraw" is used as a criterion which is an uninitialized return value .
As follows, line 33


1. func newIPRouteBody(dst []*table.Path, vrfId uint32, z *zebraClient) (body *zebra.IPRouteBody, isWithdraw bool) {
2. 	version := z.client.Version
3. 	paths := filterOutExternalPath(dst)
4. 	if len(paths) == 0 {
5. 		return nil, false
6. 	}
7. 	path := paths[0]
8. 	l := strings.SplitN(path.GetNlri().String(), "/", 2)
9. 	var prefix net.IP
10. 	var nexthop zebra.Nexthop
11. 	nexthops := make([]zebra.Nexthop, 0, len(paths))
12. 	msgFlags := zebra.MESSAGE_NEXTHOP
13. 	switch path.GetRouteFamily() {
14. 	case bgp.RF_IPv4_UC, bgp.RF_IPv4_VPN:
15. 		if path.GetRouteFamily() == bgp.RF_IPv4_UC {
16. 			prefix = path.GetNlri().(*bgp.IPAddrPrefix).IPAddrPrefixDefault.Prefix.To4()
17. 		} else {
18. 			prefix = path.GetNlri().(*bgp.LabeledVPNIPAddrPrefix).IPAddrPrefixDefault.Prefix.To4()
19. 		}
20. 	case bgp.RF_IPv6_UC, bgp.RF_IPv6_VPN:
21. 		if path.GetRouteFamily() == bgp.RF_IPv6_UC {
22. 			prefix = path.GetNlri().(*bgp.IPv6AddrPrefix).IPAddrPrefixDefault.Prefix.To16()
23. 		} else {
24. 			prefix = path.GetNlri().(*bgp.LabeledVPNIPv6AddrPrefix).IPAddrPrefixDefault.Prefix.To16()
25. 		}
26. 	default:
27. 		return nil, false
28. 	}
29. 	var nhVrfId uint32
30. 	if nhvrfid, ok := z.pathVrfMap[path]; ok {
31. 		// if the path is withdraw, delete path from pathVrfMap after refer the path
32. 		nhVrfId = nhvrfid
33. 		if isWithdraw {   //  an uninitialized return value
34. 			delete(z.pathVrfMap, path)
35. 		}
36. 	} else {
37. 		nhVrfId = zebra.VRF_DEFAULT
38. 	}
39. 
40. .........
41. }

irino added a commit to irino/gobgp that referenced this issue Jun 2, 2019
@irino
Copy link
Contributor

irino commented Jun 3, 2019

I sent PR #2090 and it is merged. I assume this issue can be closed.

@fujita fujita closed this as completed Jun 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants