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.
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
Fixbug: EVPN issue in FRR template #4260
Fixbug: EVPN issue in FRR template #4260
Changes from 7 commits
b2d35e0
08c2945
ba84889
4c8a4c6
e99a2cf
244faf0
94ff75d
6cac8ec
1b04b91
6ba0066
7e9ef26
e14028a
4b6a51a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know why you talk about route here. data['local_addr'] is the bgp session's local IP. Here you just check if bgp session's local IP is in one of local interface subnet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
route is not clear to me. here is a bgp session, not route.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be bgp session.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i finally understood what you are trying to do in this block (spend about 30 minutes)! it is so difficult to understand because people do not understand what local_addresses and interfaces mean. In fact, what you really should do here is to create two functions.
one function is
find_local_interface(ip). The input is a ip address, and return value is interface name. return None if you cannot find a interface.
second function is
check_interface_type(interface_name). You can return vnet interface it is vnet interface, or default if the interface is in default vrf.
since you do not have such abstract, it is difficult for others to understand the code and maintain.
Please put code readability into priority.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what should be the log message here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this is an intermediate state. Maybe it should add some log with INFO level to display this state. Same problem at here https://github.com/Azure/sonic-buildimage/blob/master/dockers/docker-fpm-frr/bgpcfgd#L295
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is really a bad interface design! the function name is generic. in fact the fuction does very specific thing, it assume the value is ip prefix and convert the string into ipnetwork, and then get an attribute, and finally convert it into a string.
to evaulate whether a function provide a good abstraction or not. People should be able to understand the what the function's job by just looking at the function name at the caller without looking into the implementation of the function.
I think you need to either get rid of this function, or have a function get_ip_from_ipprefix function to do the specific job you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree with your comment. And I think this is a very common tool function maybe we should extract it to a common python package.
Because we did also use it at : https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-config-engine/sonic-cfggen#L81
Should I do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are right, that was my miss. it is not a good code.
In reply to: 400696041 [](ancestors = 400696041)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would also want to consider VLAN_INTERFACE as well - CFG_VLAN_INTF_TABLE_NAME
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your suggestion. Have added VlanInterfaceMgr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this true that vnet interface will only have interface name without ip addresses? @prsunny ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, vnet interface will also have ip address as any other regular entry. I don't think we need to mention about 'vnet' in this function as this is a generic handler. The comment can just state, "Interface table can have two keys, one with ip prefix and one without ip prefix".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pterosaur , can you modify the comment accordingly, current description is not accurate.