packet/bgp: Reduce struct size of "IPAddrPrefix" struct#1612
Open
iwaseyusuke wants to merge 3 commits intoosrg:masterfrom
Open
packet/bgp: Reduce struct size of "IPAddrPrefix" struct#1612iwaseyusuke wants to merge 3 commits intoosrg:masterfrom
iwaseyusuke wants to merge 3 commits intoosrg:masterfrom
Conversation
This patch refactors the inheritance (embedding) relationship of IPAddrPrefix and its derivatives and removes "addrlen" field. "addrlen" is used only to determine whether the given prefix is IPv4 or IPv6. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
cstockton
reviewed
May 27, 2019
| case bgp.RF_IPv4_UC, bgp.RF_IPv4_VPN: | ||
| if path.GetRouteFamily() == bgp.RF_IPv4_UC { | ||
| prefix = path.GetNlri().(*bgp.IPAddrPrefix).IPAddrPrefixDefault.Prefix.To4() | ||
| prefix = path.GetNlri().(*bgp.IPAddrPrefix).Prefix.To4() |
There was a problem hiding this comment.
This should be refactored to future proof the code from panics, even if currently this is highly unlikely, i.e.:
switch T := path.GetNlri().(type) {
case *bgp.IPAddrPrefix:
prefix = T.Prefix.To4()
case *bgp.LabeledVPNIPAddrPrefix):
...
default:
... what is sane in this case? Right now that is a panic about concrete types, can we do better?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch refactors the inheritance (embedding) relationship of IPAddrPrefix and its derivatives and removes "addrlen" field. "addrlen" is used only to determine whether the given prefix is IPv4 or IPv6.