Skip to content

[VRF]: FRR config templates support VRF#3047

Closed
tylerlinp wants to merge 19 commits intosonic-net:masterfrom
tylerlinp:frr-config
Closed

[VRF]: FRR config templates support VRF#3047
tylerlinp wants to merge 19 commits intosonic-net:masterfrom
tylerlinp:frr-config

Conversation

@tylerlinp
Copy link
Copy Markdown
Contributor

- What I did

  1. BGP support VRF
  2. Add static route save configuration

Add VRF support for FRR config templates:
frr.conf.j2
bgpd.conf.j2
zebra.conf.j2

- How I did it

Based the following config schema and j2 templates, sonic-cfggen generate .conf file

  1. BGP_NEIGHBOR key extend to vrf_name|ip_address
    "BGP_NEIGHBOR": {
    "10.0.0.61": {
    "rrclient": "0",
    "local_addr": "10.0.0.60",
    "asn": "64015",
    "name": "ARISTA15T0",
    "nhopself": "0"
    },
    "Vrf-blue|10.0.0.49": {
    "rrclient": "0",
    "local_addr": "10.0.0.48",
    "asn": "64009",
    "name": "ARISTA09T0",
    "nhopself": "0"
    }
    }
  2. BGP_PEER_RANGE add an attribute vrf_name
    "BGP_PEER_RANGE": {
    "PeerGroup": {
    "name": "PeerGroup",
    "ip_range": [
    "192.168.0.0/27"
    ]
    },
    "PeerGroup1": {
    "vrf_name": "Vrf-blue",
    "name": "PeerGroup1",
    "ip_range": [
    "192.168.8.0/27"
    ]
    }
    }
  3. Add table STATIC_ROUTE:
    a. key is prefix or vrf_name|prefix
    b. fields are nexthop, distance, nexthop-vrf
    c. nexthop is mandatory, its value can be ip_address or if_alias
    "STATIC_ROUTE": {
    "11.11.11.0/24": {
    "distance": "10",
    "nexthop": "1.1.1.1"
    },
    "Vrf-blue|22.11.11.0/24": {
    "distance": "10",
    "nexthop-vrf": "Vrf-red",
    "nexthop": "2.1.1.1"
    },
    "Vrf-red|11.11.11.0/24": {
    "nexthop": "1.1.1.1"
    }
    }

- How to verify it
Pass ansible test cases and various diffrent configurations generate tests

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

tylerlinp and others added 3 commits June 12, 2019 19:50
Merge Azure/sonic-buildimage
1. BGP_NEIGHBOR key extend to vrf_name|ip_address
2. BGP_PEER_RANGE add an attribute vrf_name
3. Add table STATIC_ROUTE:
   a. key is prefix or vrf_name|prefix
   b. fields are nexthop, distance, nexthop-vrf
   c. nexthop is mandatory, its value can be ip_address or if_alias
@lguohan
Copy link
Copy Markdown
Collaborator

lguohan commented Jun 22, 2019

what is the context of this pr? have we reviewed the design?

Tyler Li added 3 commits July 22, 2019 18:47
1. Compatible with old interface table, which has no name keys, to deal with config in .xml file
2. Sort all config and then output .conf file
3. Rollback advertise 64 prefix for lo ipv6 addresses
4. Add seperator between default route and static route
@shine4chen
Copy link
Copy Markdown
Contributor

shine4chen commented Aug 30, 2019

@lguohan there is the description about frr template change In vrf-hld-1.2 which has been approved.

@prsunny
Copy link
Copy Markdown
Contributor

prsunny commented Oct 9, 2019

@tylerlinp , can you resolve the conflict for this?

@prsunny
Copy link
Copy Markdown
Contributor

prsunny commented Oct 9, 2019

retest vs please

@lguohan lguohan requested a review from pavel-shirshov October 9, 2019 21:53
prsunny
prsunny previously approved these changes Oct 10, 2019
@prsunny
Copy link
Copy Markdown
Contributor

prsunny commented Oct 25, 2019

@tylerlinp , can you please resolve the conflicts

Copy link
Copy Markdown
Contributor

@pavel-shirshov pavel-shirshov left a comment

Choose a reason for hiding this comment

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

As comments

def load_peers(self):
peers = set()
command = ["vtysh", "-c", "show bgp neighbors json"]
vrfs = set()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

vrfs could be a list here

js_bgp = json.loads(out)
peers = set(js_bgp.keys())
js_vrf = json.loads(out)
vrfs = set(js_vrf['vrfs'].keys())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you don't need to change it to set

vrfs = set(js_vrf['vrfs'].keys())

peers = set()
for vrf in vrfs:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this require list not set

if '|' in key:
vrf, nbr = key.split('|', 1)
cmds.append('router bgp {} vrf {}'.format(self.bgp_asn, vrf))
syslog.syslog(syslog.LOG_INFO, 'Enter router bgp {} vrf {}'.format(self.bgp_asn, vrf))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this is debug output

vrf = 'default'
nbr = key
cmds.append('router bgp {}'.format(self.bgp_asn))
syslog.syslog(syslog.LOG_INFO, 'Enter router bgp {}'.format(self.bgp_asn))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

debug output

{% endfor %}
{% set vrf_routers = [] %}
{% set vrf_bgp_nbr = {} %}
{% for nbr_key in BGP_NEIGHBOR %}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suggest to put this into bgpd.peer template.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This can not move out because peer-group PEER_V4/PEER_V6 need config in these vrfs.

@tylerlinp
Copy link
Copy Markdown
Contributor Author

retest vs please

@tylerlinp
Copy link
Copy Markdown
Contributor Author

retest mellanox please

@tylerlinp
Copy link
Copy Markdown
Contributor Author

retest vsimage please

@tylerlinp
Copy link
Copy Markdown
Contributor Author

retest vsimage please

1 similar comment
@tylerlinp
Copy link
Copy Markdown
Contributor Author

retest vsimage please

Copy link
Copy Markdown
Contributor

@pavel-shirshov pavel-shirshov left a comment

Choose a reason for hiding this comment

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

as the comment

{% endif %}
{% if vrf_bgp_pr[pr_vrf].update({pr_key:BGP_PEER_RANGE[pr_key]}) %}
{% endif %}
{% endfor %}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it possible to put all the code inside of bgpcfgd?
Currently this change put a huge amount of logic inside of the jinja2.
Can we put all the logic into bgpcfgd?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not just peer_range, there are configs even peer. If to aware vrf in conf, we have to loop all vrfs. Now vrfs get from BGP_NEIGHBOR and BGP_PEER_RANGE. Theoretically speaking, all can be put into bgpcfgd, then no j2 template left. But that would be a huge work.

@tylerlinp
Copy link
Copy Markdown
Contributor Author

retest vsimage please

1 similar comment
@prsunny
Copy link
Copy Markdown
Contributor

prsunny commented Jan 17, 2020

retest vsimage please

@tylerlinp
Copy link
Copy Markdown
Contributor Author

@prsunny @pavel-shirshov Could you please merge this PR, as vrf pytest need it to load config.

@liat-grozovik
Copy link
Copy Markdown
Collaborator

@prsunny and @lguohan
This one is important for 201911 if we want VRF test to pass on it as well (test_vrf and test_vrf_attr).
Can we mark this one as required for 201911 as well?

@tylerlinp
Copy link
Copy Markdown
Contributor Author

retest vsimage please

1 similar comment
@tylerlinp
Copy link
Copy Markdown
Contributor Author

retest vsimage please

@prsunny
Copy link
Copy Markdown
Contributor

prsunny commented Apr 13, 2020

@pavel-shirshov , can you please review this and sign-off?

@tylerlinp
Copy link
Copy Markdown
Contributor Author

This will be obsoleted.

@pavel-shirshov
Copy link
Copy Markdown
Contributor

@prsunny It is obsoleted. Also as I commented before I don't think that having all the logic in j2 makes our templates easy to maintain.

@tylerlinp tylerlinp closed this May 29, 2020
@rlhui
Copy link
Copy Markdown
Contributor

rlhui commented Jun 4, 2020

@pavel-shirshov - wondering what's the PR for the FRR config for vrf, would you please point it?

@pavel-shirshov
Copy link
Copy Markdown
Contributor

@Rihui we don't have such pr.
Do you have any information about vrf feature? What does that mean?

@rlhui
Copy link
Copy Markdown
Contributor

rlhui commented Jun 4, 2020

@pavel-shirshov , I was referring to the 201911 feature as described in https://github.com/Azure/SONiC/blob/master/doc/vrf/sonic-vrf-hld.md; this PR was associated with that originally.

MuLinForest pushed a commit to MuLinForest/sonic-buildimage that referenced this pull request Aug 6, 2024
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.

7 participants