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

[frrcfgd][bgpcfgd] Add portchannel support #8911

Merged
merged 8 commits into from
Oct 13, 2021

Conversation

d-dashkov
Copy link
Contributor

Why I did it

To add portchannel support in frrcfgd and bgpcfgd.
fix #8907

How I did it

Added handling of the portchannel name as an IP address by adding check in is_zero_ip() to prevent parsing portchannel name with socket.inet_pton().

How to verify it

config portchannel add PortChannel0001
config portchannel add PortChannel0002
sudo config route add prefix 20.0.0.1/32 nexthop PortChannel0001
sudo config route add prefix 20.0.0.1/32 nexthop PortChannel0002
admin@sonic:~$ show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup

S>* 0.0.0.0/0 [200/0] via 192.168.111.3, eth0, weight 1, 00:00:45
C>* 10.1.0.1/32 is directly connected, Loopback0, 00:00:46
S   20.0.0.1/32 [1/0] is directly connected, PortChannel0001 inactive, weight 1, 00:00:09
                      is directly connected, PortChannel0002 inactive, weight 1, 00:00:09
C>* 30.0.0.0/24 is directly connected, Ethernet0, 00:00:46
C>* 192.168.111.0/24 is directly connected, eth0, 00:00:46

Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
@@ -183,7 +183,10 @@ def __ne__(self, other):
def __hash__(self):
return hash((self.af, self.blackhole, self.ip, self.interface, self.distance, self.nh_vrf))
def is_zero_ip(self):
return sum([x for x in socket.inet_pton(self.af, self.ip)]) == 0
if self.ip.startswith('PortChannel'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't overload this function. You can write a new function as "is_portchannel" and update the caller to treat this valid.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote a new function and wrapped it in zero_ip() in try-exception because the string is being processed in inet_pton() which throws an exception

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, please add unittests

Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
@prsunny prsunny requested a review from shi-su October 7, 2021 18:23
Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
@d-dashkov d-dashkov requested a review from prsunny October 7, 2021 20:42
@lgtm-com
Copy link

lgtm-com bot commented Oct 7, 2021

This pull request introduces 2 alerts when merging cdcb9fc into 3426739 - view on LGTM.com

new alerts:

  • 2 for Except block handles 'BaseException'

Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
@lgtm-com
Copy link

lgtm-com bot commented Oct 8, 2021

This pull request introduces 2 alerts when merging 4dd4c17 into 3855ce2 - view on LGTM.com

new alerts:

  • 2 for Except block handles 'BaseException'

Copy link
Contributor

@shi-su shi-su left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the LGTM warning. Other parts look good to me.

Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
@d-dashkov d-dashkov requested a review from shi-su October 12, 2021 18:57
@prsunny prsunny merged commit e8adee2 into sonic-net:master Oct 13, 2021
judyjoseph pushed a commit that referenced this pull request Oct 21, 2021
* To add portchannel support in frrcfgd and bgpcfgd
* Update is_zero_ip() to handle portchannel name
Signed-off-by: d-dashkov <Dmytro_Dashkov@Jabil.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't add route with a nexthop of a PortChannel
5 participants