blob: 6fb126f8d6ddd61414f1eaa55aea3855d1425d58 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
|
{% set conf_bgp = nbgp -%}
{% for asn in nbgp -%}
!
router bgp {{ asn }}
no bgp default ipv4-unicast
{#- set 'conf_bgp[asn].parameters' as bgp_params #}
{%- set bgp_params = conf_bgp[asn].parameters %}
{%- set bgp_afi = conf_bgp[asn].address_family %}
{#- START Global ASN address-family section; set protocol bgp xxx address-family #}
{%- if 'address_family' in conf_bgp[asn] %}
{%- for type in bgp_afi %}
{%- if type == "ipv4_unicast" %}
!
address-family ipv4 unicast
{%- if 'aggregate_address' in bgp_afi[type] %}
{%- for ip in bgp_afi[type].aggregate_address %}
{%- if ( ('as_set' in bgp_afi[type].aggregate_address[ip]) and ('summary_only' in bgp_afi[type].aggregate_address[ip] ) ) %}
aggregate-address {{ ip }} as-set summary-only
{%- elif 'as_set' in bgp_afi[type].aggregate_address[ip] %}
aggregate-address {{ ip }} as-set
{%- elif 'summary_only' in bgp_afi[type].aggregate_address[ip] %}
aggregate-address {{ ip }} summary-only
{%- else %}
aggregate-address {{ ip }}
{%- endif %}
{%- endfor %}
{%- endif %}
{#- END aggregate address ipv4 #}
{#- redistribute afi ipv4 #}
{%- if 'redistribute' in bgp_afi[type] %}
{%- for protocol in bgp_afi[type].redistribute %}
{%- if ( ('route_map' in bgp_afi[type].redistribute[protocol]) and ('metric' in bgp_afi[type].redistribute[protocol] ) ) %}
redistribute {{protocol}} metric {{bgp_afi[type].redistribute[protocol].metric}} route-map {{bgp_afi[type].redistribute[protocol].route_map}}
{%- elif 'metric' in bgp_afi[type].redistribute[protocol] %}
redistribute {{protocol}} metric {{bgp_afi[type].redistribute[protocol].metric}}
{%- elif 'route_map' in bgp_afi[type].redistribute[protocol] %}
redistribute {{protocol}} route-map {{bgp_afi[type].redistribute[protocol].route_map}}
{%- elif 'table' in bgp_afi[type].redistribute %}
redistribute table {{bgp_afi[type].redistribute.table}}
{%- else %}
redistribute {{protocol}}
{%- endif %}
{%- endfor %}
{%- endif %}
{#- END redistribute #}
{%- if 'network' in bgp_afi[type] %}
{%- for net in bgp_afi[type].network %}
network {{ net }}
{%- endfor %}
{%- endif %}
exit-address-family
!
{%- endif %}
{%- if type == "ipv6_unicast" %}
!
address-family ipv6 unicast
{%- if 'aggregate_address' in bgp_afi[type] %}
{%- for ip in bgp_afi[type].aggregate_address %}
{%- if ( ('as_set' in bgp_afi[type].aggregate_address[ip]) and ('summary_only' in bgp_afi[type].aggregate_address[ip] ) ) %}
aggregate-address {{ ip }} as-set summary-only
{%- elif 'as_set' in bgp_afi[type].aggregate_address[ip] %}
aggregate-address {{ ip }} as-set
{%- elif 'summary_only' in bgp_afi[type].aggregate_address[ip] %}
aggregate-address {{ ip }} summary-only
{%- else %}
aggregate-address {{ ip }}
{%- endif %}
{%- endfor %}
{%- endif %}
{#- END aggregate address ipv6 #}
{#- redistribute afi ipv6 #}
{%- if 'redistribute' in bgp_afi[type] %}
{%- for protocol in bgp_afi[type].redistribute %}
{%- if ( ('route_map' in bgp_afi[type].redistribute[protocol]) and ('metric' in bgp_afi[type].redistribute[protocol] ) ) %}
redistribute {{protocol}} metric {{bgp_afi[type].redistribute[protocol].metric}} route-map {{bgp_afi[type].redistribute[protocol].route_map}}
{%- elif 'metric' in bgp_afi[type].redistribute[protocol] %}
redistribute {{protocol}} metric {{bgp_afi[type].redistribute[protocol].metric}}
{%- elif 'route_map' in bgp_afi[type].redistribute[protocol] %}
redistribute {{protocol}} route-map {{bgp_afi[type].redistribute[protocol].route_map}}
{%- elif 'table' in bgp_afi[type].redistribute %}
redistribute table {{bgp_afi[type].redistribute.table}}
{%- else %}
redistribute {{protocol}}
{%- endif %}
{%- endfor %}
{%- endif %}
{#- END redistribute #}
{%- if 'network' in bgp_afi[type] %}
{%- for net in bgp_afi[type].network %}
network {{ net }}
{%- endfor %}
{%- endif %}
exit-address-family
!
{%- endif %}
{%- endfor %}
{%- endif %}
{#- END Global ASN address-family section; set protocols bgp 65001 address-family #}
{#- set protocols nbgp xxxx maximum-paths ibgp x, Generated by default for afi_4 #}
{#- We don't have this parameter in afi_6. But this is supported in the FRR #}
{%- if 'maximum_paths' in conf_bgp[asn] %}
{%- if 'ebgp' in conf_bgp[asn].maximum_paths %}
!
address-family ipv4 unicast
maximum-paths {{ conf_bgp[asn].maximum_paths.ebgp }}
exit-address-family
!
{%- endif %}
{%- if 'ibgp' in conf_bgp[asn].maximum_paths %}
!
address-family ipv4 unicast
maximum-paths ibgp {{ conf_bgp[asn].maximum_paths.ibgp }}
exit-address-family
!
{%- endif %}
{%- endif %}
{#- START peer-group; set protocol bgp xxx peer-group #}
{%- if 'peer_group' in conf_bgp[asn] %}
{%- for pr_group in conf_bgp[asn].peer_group %}
{%- set conf_peer_group = conf_bgp[asn].peer_group[pr_group] %}
neighbor {{pr_group}} peer-group
{#- First parameter for peer-group - remote-as #}
{%- if 'remote_as' in conf_peer_group %}
neighbor {{ pr_group }} remote-as {{ conf_peer_group.remote_as }}
{%- endif %}
{%- if 'bfd' in conf_peer_group %}
neighbor {{ pr_group }} bfd
{%- endif %}
{%- if 'capability' in conf_peer_group %}
{%- if 'dynamic' in conf_peer_group.capability %}
neighbor {{ pr_group }} capability dynamic
{%- endif %}
{%- if 'extended_nexthop' in conf_peer_group.capability %}
neighbor {{ pr_group }} capability extended-nexthop
{%- endif %}
{%- endif %}
{%- if 'description' in conf_peer_group %}
neighbor {{ pr_group }} description {{ conf_peer_group.description }}
{%- endif %}
{%- if 'disable_capability_negotiation' in conf_peer_group %}
neighbor {{ pr_group }} disable-capability-negotiation
{%- endif %}
{#- https://phabricator.vyos.net/T2844. 'disable-send-community' only for afi #}
{%- if 'disable_send_community' in conf_peer_group %}
!
{%- endif %}
{%- if 'ebgp_multihop' in conf_peer_group %}
neighbor {{ pr_group }} ebgp-multihop {{conf_peer_group.ebgp_multihop}}
{%- endif %}
{%- if 'local_as' in conf_peer_group %}
{%- for loc_asn in conf_peer_group.local_as %}
{%- if 'no_prepend' in conf_peer_group.local_as[loc_asn] %}
neighbor {{ pr_group }} local-as {{loc_asn}} no-prepend
{%- else %}
neighbor {{ pr_group }} local-as {{loc_asn}}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- if 'override_capability' in conf_peer_group %}
neighbor {{ pr_group }} override-capability
{%- endif %}
{%- if 'passive' in conf_peer_group %}
neighbor {{ pr_group }} passive
{%- endif %}
{%- if 'password' in conf_peer_group %}
neighbor {{ pr_group }} password {{ conf_peer_group.password }}
{%- endif %}
{%- if 'shutdown' in conf_peer_group %}
neighbor {{ pr_group }} shutdown
{%- endif %}
{%- if 'ttl_security' in conf_peer_group %}
{%- if 'hops' in conf_peer_group.ttl_security %}
neighbor {{ pr_group }} ttl-security hops {{conf_peer_group.ttl_security.hops}}
{%- endif %}
{%- endif %}
{%- if 'update_source' in conf_peer_group %}
neighbor {{ pr_group }} update-source {{ conf_peer_group.update_source }}
{%- endif %}
{#- START peer-group afi; set protocols bgp xxx peer-group FOO address-family #}
{%- if 'address_family' in conf_peer_group %}
{%- for afi in conf_peer_group.address_family %}
{%- if afi == "ipv4_unicast" %}
!
address-family ipv4 unicast
{%- if 'allowas_in' in conf_peer_group.address_family.ipv4_unicast %}
{%- if 'number' in conf_peer_group.address_family.ipv4_unicast.allowas_in %}
neighbor {{ pr_group }} allowas-in {{ conf_peer_group.address_family.ipv4_unicast.allowas_in.number }}
{%- else %}
neighbor {{ pr_group }} allowas-in
{%- endif %}
{%- endif %}
{#- START Single Params for peer-group; set protocols bgp xxx peer-group FOO address-family ipv4-unicast #}
{%- if 'remove_private_as' in conf_peer_group.address_family.ipv4_unicast %}
neighbor {{ pr_group }} remove-private-AS
{%- endif %}
{%- if 'route_reflector_client' in conf_peer_group.address_family.ipv4_unicast %}
neighbor {{ pr_group }} route-reflector-client
{%- endif %}
{%- if 'weight' in conf_peer_group.address_family.ipv4_unicast %}
neighbor {{ pr_group }} weight {{ conf_peer_group.address_family.ipv4_unicast.weight }}
{%- endif %}
{#- END single params for peer-group #}
{%- if 'attribute_unchanged' in conf_peer_group.address_family.ipv4_unicast %}
{%- if ( ('as_path' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged) and ('med' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged) ) %}
neighbor {{ pr_group }} attribute-unchanged as-path med
{%- elif ( ('as_path' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged) and ('next_hop' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged) ) %}
neighbor {{ pr_group }} attribute-unchanged as-path next-hop
{%- elif ( ('med' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged) and ('next_hop' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged) ) %}
neighbor {{ pr_group }} attribute-unchanged med next-hop
{%- elif 'as_path' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged %}
neighbor {{ pr_group }} attribute-unchanged as-path
{%- elif 'med' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged %}
neighbor {{ pr_group }} attribute-unchanged med
{%- elif 'next_hop' in conf_peer_group.address_family.ipv4_unicast.attribute_unchanged %}
neighbor {{ pr_group }} attribute-unchanged next-hop
{%- else %}
neighbor {{ pr_group }} attribute-unchanged as-path next-hop med
{%- endif %}
{%- endif %}
{#- END attribute-unchanged #}
{%- if 'capability' in conf_peer_group.address_family.ipv4_unicast %}
{%- if 'orf' in conf_peer_group.address_family.ipv4_unicast.capability %}
{%- if 'receive' in conf_peer_group.address_family.ipv4_unicast.capability.orf.prefix_list %}
neighbor {{ pr_group }} capability orf prefix-list receive
{%- endif %}
{%- if 'send' in conf_peer_group.address_family.ipv4_unicast.capability.orf.prefix_list %}
neighbor {{ pr_group }} capability orf prefix-list send
{%- endif %}
{%- endif %}
{%- endif %}
{%- if 'default_originate' in conf_peer_group.address_family.ipv4_unicast %}
{%- if 'route_map' in conf_peer_group.address_family.ipv4_unicast.default_originate %}
neighbor {{ pr_group }} default-originate route-map {{ conf_peer_group.address_family.ipv4_unicast.default_originate.route_map }}
{%- else %}
neighbor {{ pr_group }} default-originate
{%- endif %}
{%- endif %}
{%- if 'distribute_list' in conf_peer_group.address_family.ipv4_unicast %}
{%- if 'export' in conf_peer_group.address_family.ipv4_unicast.distribute_list %}
neighbor {{ pr_group }} distribute-list {{conf_peer_group.address_family.ipv4_unicast.distribute_list.export}} out
{%- endif %}
{%- if 'import' in conf_peer_group.address_family.ipv4_unicast.distribute_list %}
neighbor {{ pr_group }} distribute-list {{conf_peer_group.address_family.ipv4_unicast.distribute_list.import}} in
{%- endif %}
{%- endif %}
{%- if 'filter_list' in conf_peer_group.address_family.ipv4_unicast %}
{%- if 'export' in conf_peer_group.address_family.ipv4_unicast.filter_list %}
neighbor {{ pr_group }} filter-list {{conf_peer_group.address_family.ipv4_unicast.filter_list.export}} out
{%- endif %}
{%- if 'import' in conf_peer_group.address_family.ipv4_unicast.filter_list %}
neighbor {{ pr_group }} filter-list {{conf_peer_group.address_family.ipv4_unicast.filter_list.import}} in
{%- endif %}
{%- endif %}
{%- if 'maximum_prefix' in conf_peer_group.address_family.ipv4_unicast %}
neighbor {{ pr_group }} maximum-prefix {{ conf_peer_group.address_family.ipv4_unicast.maximum_prefix }}
{%- endif %}
{#- https://phabricator.vyos.net/T1817 #}
{%- if 'nexthop_self' in conf_peer_group.address_family.ipv4_unicast %}
{%- if 'force' in conf_peer_group.address_family.ipv4_unicast.nexthop_self %}
neighbor {{ pr_group }} next-hop-self force
neighbor {{ pr_group }} next-hop-self
{%- else %}
neighbor {{ pr_group }} next-hop-self
{%- endif %}
{%- endif %}
{%- if 'route_server_client' in conf_peer_group.address_family.ipv4_unicast %}
neighbor {{ pr_group }} route-server-client
{%- endif %}
{%- if 'route_map' in conf_peer_group.address_family.ipv4_unicast %}
{%- if 'export' in conf_peer_group.address_family.ipv4_unicast.route_map %}
neighbor {{ pr_group }} route-map {{conf_peer_group.address_family.ipv4_unicast.route_map.export}} out
{%- endif %}
{%- if 'import' in conf_peer_group.address_family.ipv4_unicast.route_map %}
neighbor {{ pr_group }} route-map {{conf_peer_group.address_family.ipv4_unicast.route_map.import}} in
{%- endif %}
{%- endif %}
{%- if 'prefix_list' in conf_peer_group.address_family.ipv4_unicast %}
{%- if 'export' in conf_peer_group.address_family.ipv4_unicast.prefix_list %}
neighbor {{ pr_group }} prefix-list {{conf_peer_group.address_family.ipv4_unicast.prefix_list.export}} out
{%- endif %}
{%- if 'import' in conf_peer_group.address_family.ipv4_unicast.prefix_list %}
neighbor {{ pr_group }} prefix-list {{conf_peer_group.address_family.ipv4_unicast.prefix_list.import}} in
{%- endif %}
{%- endif %}
{%- if 'soft_reconfiguration' in conf_peer_group.address_family.ipv4_unicast %}
{%- if 'inbound' is defined %}
neighbor {{ pr_group }} soft-reconfiguration inbound
{%- endif %}
{%- endif %}
{%- if 'unsuppress_map' in conf_peer_group.address_family.ipv4_unicast %}
neighbor {{ pr_group }} unsuppress-map {{conf_peer_group.address_family.ipv4_unicast.unsuppress_map}}
{%- endif %}
neighbor {{ pr_group }} activate
exit-address-family
!
{%- endif %}
{%- if afi == "ipv6_unicast" %}
!
address-family ipv6 unicast
{%- if 'allowas_in' in conf_peer_group.address_family.ipv6_unicast %}
{%- if 'number' in conf_peer_group.address_family.ipv6_unicast.allowas_in %}
neighbor {{ pr_group }} allowas-in {{ conf_peer_group.address_family.ipv6_unicast.allowas_in.number }}
{%- else %}
neighbor {{ pr_group }} allowas-in
{%- endif %}
{%- endif %}
{#- START Single Params for peer-group afi6; set protocols bgp xxx peer-group FOO address-family ipv6-unicast #}
{%- if 'remove_private_as' in conf_peer_group.address_family.ipv6_unicast %}
neighbor {{ pr_group }} remove-private-AS
{%- endif %}
{%- if 'route_reflector_client' in conf_peer_group.address_family.ipv6_unicast %}
neighbor {{ pr_group }} route-reflector-client
{%- endif %}
{%- if 'weight' in conf_peer_group.address_family.ipv6_unicast %}
neighbor {{ pr_group }} weight {{ conf_peer_group.address_family.ipv6_unicast.weight }}
{%- endif %}
{#- END single params for peer-group afi6 #}
{%- if 'attribute_unchanged' in conf_peer_group.address_family.ipv6_unicast %}
{%- if ( ('as_path' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged) and ('med' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged) ) %}
neighbor {{ pr_group }} attribute-unchanged as-path med
{%- elif ( ('as_path' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged) and ('next_hop' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged) ) %}
neighbor {{ pr_group }} attribute-unchanged as-path next-hop
{%- elif ( ('med' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged) and ('next_hop' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged) ) %}
neighbor {{ pr_group }} attribute-unchanged med next-hop
{%- elif 'as_path' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged %}
neighbor {{ pr_group }} attribute-unchanged as-path
{%- elif 'med' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged %}
neighbor {{ pr_group }} attribute-unchanged med
{%- elif 'next_hop' in conf_peer_group.address_family.ipv6_unicast.attribute_unchanged %}
neighbor {{ pr_group }} attribute-unchanged next-hop
{%- else %}
neighbor {{ pr_group }} attribute-unchanged as-path next-hop med
{%- endif %}
{%- endif %}
{#- END attribute-unchanged ipv6 #}
{%- if 'capability' in conf_peer_group.address_family.ipv6_unicast %}
{%- if 'orf' in conf_peer_group.address_family.ipv6_unicast.capability %}
{%- if 'receive' in conf_peer_group.address_family.ipv6_unicast.capability.orf.prefix_list %}
neighbor {{ pr_group }} capability orf prefix-list receive
{%- endif %}
{%- if 'send' in conf_peer_group.address_family.ipv6_unicast.capability.orf.prefix_list %}
neighbor {{ pr_group }} capability orf prefix-list send
{%- endif %}
{%- endif %}
{%- endif %}
{%- if 'default_originate' in conf_peer_group.address_family.ipv6_unicast %}
{%- if 'route_map' in conf_peer_group.address_family.ipv6_unicast.default_originate %}
neighbor {{ pr_group }} default-originate route-map {{ conf_peer_group.address_family.ipv6_unicast.default_originate.route_map }}
{%- else %}
neighbor {{ pr_group }} default-originate
{%- endif %}
{%- endif %}
{%- if 'distribute_list' in conf_peer_group.address_family.ipv6_unicast %}
{%- if 'export' in conf_peer_group.address_family.ipv6_unicast.distribute_list %}
neighbor {{ pr_group }} distribute-list {{conf_peer_group.address_family.ipv6_unicast.distribute_list.export}} out
{%- endif %}
{%- if 'import' in conf_peer_group.address_family.ipv6_unicast.distribute_list %}
neighbor {{ pr_group }} distribute-list {{conf_peer_group.address_family.ipv6_unicast.distribute_list.import}} in
{%- endif %}
{%- endif %}
{%- if 'filter_list' in conf_peer_group.address_family.ipv6_unicast %}
{%- if 'export' in conf_peer_group.address_family.ipv6_unicast.filter_list %}
neighbor {{ pr_group }} filter-list {{conf_peer_group.address_family.ipv6_unicast.filter_list.export}} out
{%- endif %}
{%- if 'import' in conf_peer_group.address_family.ipv6_unicast.filter_list %}
neighbor {{ pr_group }} filter-list {{conf_peer_group.address_family.ipv6_unicast.filter_list.import}} in
{%- endif %}
{%- endif %}
{%- if 'maximum_prefix' in conf_peer_group.address_family.ipv6_unicast %}
neighbor {{ pr_group }} maximum-prefix {{ conf_peer_group.address_family.ipv6_unicast.maximum_prefix }}
{%- endif %}
{#- https://phabricator.vyos.net/T1817 #}
{%- if 'nexthop_self' in conf_peer_group.address_family.ipv6_unicast %}
{%- if 'force' in conf_peer_group.address_family.ipv6_unicast.nexthop_self %}
neighbor {{ pr_group }} next-hop-self force
neighbor {{ pr_group }} next-hop-self
{%- else %}
neighbor {{ pr_group }} next-hop-self
{%- endif %}
{%- endif %}
{%- if 'route_server_client' in conf_peer_group.address_family.ipv6_unicast %}
neighbor {{ pr_group }} route-server-client
{%- endif %}
{%- if 'route_map' in conf_peer_group.address_family.ipv6_unicast %}
{%- if 'export' in conf_peer_group.address_family.ipv6_unicast.route_map %}
neighbor {{ pr_group }} route-map {{conf_peer_group.address_family.ipv6_unicast.route_map.export}} out
{%- endif %}
{%- if 'import' in conf_peer_group.address_family.ipv6_unicast.route_map %}
neighbor {{ pr_group }} route-map {{conf_peer_group.address_family.ipv6_unicast.route_map.import}} in
{%- endif %}
{%- endif %}
{%- if 'prefix_list' in conf_peer_group.address_family.ipv6_unicast %}
{%- if 'export' in conf_peer_group.address_family.ipv6_unicast.prefix_list %}
neighbor {{ pr_group }} prefix-list {{conf_peer_group.address_family.ipv6_unicast.prefix_list.export}} out
{%- endif %}
{%- if 'import' in conf_peer_group.address_family.ipv6_unicast.prefix_list %}
neighbor {{ pr_group }} prefix-list {{conf_peer_group.address_family.ipv6_unicast.prefix_list.import}} in
{%- endif %}
{%- endif %}
{%- if 'soft_reconfiguration' in conf_peer_group.address_family.ipv6_unicast %}
{%- if 'inbound' is defined %}
neighbor {{ pr_group }} soft-reconfiguration inbound
{%- endif %}
{%- endif %}
{%- if 'unsuppress_map' in conf_peer_group.address_family.ipv6_unicast %}
neighbor {{ pr_group }} unsuppress-map {{conf_peer_group.address_family.ipv6_unicast.unsuppress_map}}
{%- endif %}
neighbor {{ pr_group }} activate
exit-address-family
!
{%- endif %}
{%- endfor %}
{%- endif %}
{#- END peer-group afi; set protocols bgp xxx peer-group FOO address-family #}
{%- endfor %}
{%- endif %}
{#- END peer-group; set protocol bgp xxx peer-group #}
{#- START peer section; set protocol bgp xxx neighbor #}
{%- for peer in conf_bgp[asn].neighbor %}
{#- set peer-group as conf_peer #}
{%- set conf_peer = conf_bgp[asn].neighbor[peer] %}
{#- First parameter for peer-group - remote-as #}
{%- if 'remote_as' in conf_peer %}
neighbor {{ peer }} remote-as {{ conf_peer.remote_as }}
{%- endif %}
{%- if 'advertisement_interval' in conf_peer %}
neighbor {{ peer }} advertisement-interval {{ conf_peer.advertisement_interval }}
{%- endif %}
{%- if 'bfd' in conf_peer %}
{%- if 'check_control_plane_failure' in conf_peer.bfd %}
neighbor {{ peer }} bfd
neighbor {{ peer }} bfd check-control-plane-failure
{%- else %}
neighbor {{ peer }} bfd
{%- endif %}
{%- endif %}
{%- if 'capability' in conf_peer %}
{%- if 'dynamic' in conf_peer.capability %}
neighbor {{ peer }} capability dynamic
{%- endif %}
{%- if 'extended_nexthop' in conf_peer.capability %}
neighbor {{ peer }} capability extended-nexthop
{%- endif %}
{%- endif %}
{%- if 'description' in conf_peer %}
neighbor {{ peer }} description {{ conf_peer.description }}
{%- endif %}
{%- if 'disable_capability_negotiation' in conf_peer %}
neighbor {{ peer }} disable-capability-negotiation
{%- endif %}
{#- https://phabricator.vyos.net/T2844. 'disable-send-community' only for afi #}
{%- if 'disable_send_community' in conf_peer %}
!
{%- endif %}
{%- if 'ebgp_multihop' in conf_peer %}
neighbor {{ peer }} ebgp-multihop {{conf_peer.ebgp_multihop}}
{%- endif %}
{#- Need to check. 'Peer-group' needs to define before this section #}
{%- if 'interface' in conf_peer %}
{%- if 'peer_group' in conf_peer.interface %}
neighbor {{ peer }} interface peer-group {{conf_peer.interface.peer_group}}
{%- endif %}
{%- if 'remote_as' in conf_peer.interface %}
neighbor {{ peer }} interface remote-as {{conf_peer.interface.remote_as}}
{%- endif %}
{%- if 'v6only' in conf_peer.interface %}
{%- if 'peer_group' in conf_peer.interface.v6only %}
neighbor {{ peer }} peer-group {{conf_peer.interface.peer_group}}
{%- endif %}
{%- if 'remote_as' in conf_peer.interface.v6only %}
neighbor {{ peer }} interface v6only remote-as {{conf_peer.interface.v6only.remote_as}}
{%- endif %}
{%- endif %}
{%- endif %}
{%- if 'local_as' in conf_peer %}
{%- for loc_asn in conf_peer.local_as %}
{%- if 'no_prepend' in conf_peer.local_as[loc_asn] %}
neighbor {{ peer }} local-as {{loc_asn}} no-prepend
{%- else %}
neighbor {{ peer }} local-as {{loc_asn}}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- if 'override_capability' in conf_peer %}
neighbor {{ peer }} override-capability
{%- endif %}
{%- if 'passive' in conf_peer %}
neighbor {{ peer }} passive
{%- endif %}
{%- if 'password' in conf_peer %}
neighbor {{ peer }} password {{ conf_peer.password }}
{%- endif %}
{%- if 'peer_group' in conf_peer %}
neighbor {{ peer }} peer-group {{ conf_peer.peer_group }}
{%- endif %}
{%- if 'port' in conf_peer %}
neighbor {{ peer }} port {{ conf_peer.port }}
{%- endif %}
{%- if 'shutdown' in conf_peer %}
neighbor {{ peer }} shutdown
{%- endif %}
{%- if 'strict_capability_match' in conf_peer %}
neighbor {{ peer }} strict-capability-match
{%- endif %}
{#- set protocols bgp xxx neighbor x.x.x.x timers #}
{%- if 'timers' in conf_peer %}
{%- if ( ('connect' in conf_peer.timers) and ('holdtime' in conf_peer.timers) and ('keepalive' in conf_peer.timers ) ) %}
neighbor {{ peer }} timers {{conf_peer.timers.keepalive}} {{conf_peer.timers.holdtime}}
neighbor {{ peer }} timers connect {{conf_peer.timers.connect}}
{%- elif ( ('holdtime' in conf_peer.timers) and ('keepalive' in conf_peer.timers ) ) %}
neighbor {{ peer }} timers {{conf_peer.timers.keepalive}} {{conf_peer.timers.holdtime}}
{%- elif 'connect' in conf_peer.timers %}
neighbor {{ peer }} timers connect {{conf_peer.timers.connect}}
{%- endif %}
{%- endif %}
{%- if 'ttl_security' in conf_peer %}
{%- if 'hops' in conf_peer.ttl_security %}
neighbor {{ peer }} ttl-security hops {{conf_peer.ttl_security.hops}}
{%- endif %}
{%- endif %}
{%- if 'update_source' in conf_peer %}
neighbor {{ peer }} update-source {{ conf_peer.update_source }}
{%- endif %}
{#- START address family for peer; set protocols bgp xxx neighbor x.x.x.x address-family ipvX-unicast #}
{%- if 'address_family' in conf_peer %}
{%- for afi in conf_peer.address_family %}
{%- if afi == "ipv4_unicast" %}
!
address-family ipv4 unicast
{%- if 'allowas_in' in conf_peer.address_family.ipv4_unicast %}
{%- if 'number' in conf_peer.address_family.ipv4_unicast.allowas_in %}
neighbor {{ peer }} allowas-in {{ conf_peer.address_family.ipv4_unicast.allowas_in.number }}
{%- else %}
neighbor {{ peer }} allowas-in
{%- endif %}
{%- endif %}
{#- START Single Params for neighbor; #}
{%- if 'as_override' in conf_peer.address_family.ipv4_unicast %}
neighbor {{ peer }} as-override
{%- endif %}
{%- if 'remove_private_as' in conf_peer.address_family.ipv4_unicast %}
neighbor {{ peer }} remove-private-AS
{%- endif %}
{%- if 'route_reflector_client' in conf_peer.address_family.ipv4_unicast %}
neighbor {{ peer }} route-reflector-client
{%- endif %}
{%- if 'weight' in conf_peer.address_family.ipv4_unicast %}
neighbor {{ peer }} weight {{ conf_peer.address_family.ipv4_unicast.weight }}
{%- endif %}
{#- END single params for neighbor #}
{%- if 'attribute_unchanged' in conf_peer.address_family.ipv4_unicast %}
{%- if ( ('as_path' in conf_peer.address_family.ipv4_unicast.attribute_unchanged) and ('med' in conf_peer.address_family.ipv4_unicast.attribute_unchanged) ) %}
neighbor {{ peer }} attribute-unchanged as-path med
{%- elif ( ('as_path' in conf_peer.address_family.ipv4_unicast.attribute_unchanged) and ('next_hop' in conf_peer.address_family.ipv4_unicast.attribute_unchanged) ) %}
neighbor {{ peer }} attribute-unchanged as-path next-hop
{%- elif ( ('med' in conf_peer.address_family.ipv4_unicast.attribute_unchanged) and ('next_hop' in conf_peer.address_family.ipv4_unicast.attribute_unchanged) ) %}
neighbor {{ peer }} attribute-unchanged med next-hop
{%- elif 'as_path' in conf_peer.address_family.ipv4_unicast.attribute_unchanged %}
neighbor {{ peer }} attribute-unchanged as-path
{%- elif 'med' in conf_peer.address_family.ipv4_unicast.attribute_unchanged %}
neighbor {{ peer }} attribute-unchanged med
{%- elif 'next_hop' in conf_peer.address_family.ipv4_unicast.attribute_unchanged %}
neighbor {{ peer }} attribute-unchanged next-hop
{%- else %}
neighbor {{ peer }} attribute-unchanged as-path next-hop med
{%- endif %}
{%- endif %}
{#- END attribute-unchanged #}
{%- if 'capability' in conf_peer.address_family.ipv4_unicast %}
{%- if 'orf' in conf_peer.address_family.ipv4_unicast.capability %}
{%- if 'receive' in conf_peer.address_family.ipv4_unicast.capability.orf.prefix_list %}
neighbor {{ peer }} capability orf prefix-list receive
{%- endif %}
{%- if 'send' in conf_peer.address_family.ipv4_unicast.capability.orf.prefix_list %}
neighbor {{ peer }} capability orf prefix-list send
{%- endif %}
{%- endif %}
{%- endif %}
{%- if 'default_originate' in conf_peer.address_family.ipv4_unicast %}
{%- if 'route_map' in conf_peer.address_family.ipv4_unicast.default_originate %}
neighbor {{ peer }} default-originate route-map {{ conf_peer.address_family.ipv4_unicast.default_originate.route_map }}
{%- else %}
neighbor {{ peer }} default-originate
{%- endif %}
{%- endif %}
{%- if 'distribute_list' in conf_peer.address_family.ipv4_unicast %}
{%- if 'export' in conf_peer.address_family.ipv4_unicast.distribute_list %}
neighbor {{ peer }} distribute-list {{conf_peer.address_family.ipv4_unicast.distribute_list.export}} out
{%- endif %}
{%- if 'import' in conf_peer.address_family.ipv4_unicast.distribute_list %}
neighbor {{ peer }} distribute-list {{conf_peer.address_family.ipv4_unicast.distribute_list.import}} in
{%- endif %}
{%- endif %}
{%- if 'filter_list' in conf_peer.address_family.ipv4_unicast %}
{%- if 'export' in conf_peer.address_family.ipv4_unicast.filter_list %}
neighbor {{ peer }} filter-list {{conf_peer.address_family.ipv4_unicast.filter_list.export}} out
{%- endif %}
{%- if 'import' in conf_peer.address_family.ipv4_unicast.filter_list %}
neighbor {{ peer }} filter-list {{conf_peer.address_family.ipv4_unicast.filter_list.import}} in
{%- endif %}
{%- endif %}
{%- if 'maximum_prefix' in conf_peer.address_family.ipv4_unicast %}
neighbor {{ peer }} maximum-prefix {{ conf_peer.address_family.ipv4_unicast.maximum_prefix }}
{%- endif %}
{#- https://phabricator.vyos.net/T1817 #}
{%- if 'nexthop_self' in conf_peer.address_family.ipv4_unicast %}
{%- if 'force' in conf_peer.address_family.ipv4_unicast.nexthop_self %}
neighbor {{ peer }} next-hop-self force
neighbor {{ peer }} next-hop-self
{%- else %}
neighbor {{ peer }} next-hop-self
{%- endif %}
{%- endif %}
{%- if 'route_server_client' in conf_peer.address_family.ipv4_unicast %}
neighbor {{ peer }} route-server-client
{%- endif %}
{%- if 'route_map' in conf_peer.address_family.ipv4_unicast %}
{%- if 'export' in conf_peer.address_family.ipv4_unicast.route_map %}
neighbor {{ peer }} route-map {{conf_peer.address_family.ipv4_unicast.route_map.export}} out
{%- endif %}
{%- if 'import' in conf_peer.address_family.ipv4_unicast.route_map %}
neighbor {{ peer }} route-map {{conf_peer.address_family.ipv4_unicast.route_map.import}} in
{%- endif %}
{%- endif %}
{%- if 'prefix_list' in conf_peer.address_family.ipv4_unicast %}
{%- if 'export' in conf_peer.address_family.ipv4_unicast.prefix_list %}
neighbor {{ peer }} prefix-list {{conf_peer.address_family.ipv4_unicast.prefix_list.export}} out
{%- endif %}
{%- if 'import' in conf_peer.address_family.ipv4_unicast.prefix_list %}
neighbor {{ peer }} prefix-list {{conf_peer.address_family.ipv4_unicast.prefix_list.import}} in
{%- endif %}
{%- endif %}
{%- if 'soft_reconfiguration' in conf_peer.address_family.ipv4_unicast %}
{%- if 'inbound' is defined %}
neighbor {{ peer }} soft-reconfiguration inbound
{%- endif %}
{%- endif %}
{%- if 'unsuppress_map' in conf_peer.address_family.ipv4_unicast %}
neighbor {{ peer }} unsuppress-map {{conf_peer.address_family.ipv4_unicast.unsuppress_map}}
{%- endif %}
neighbor {{ peer }} activate
exit-address-family
!
{%- endif %}
{%- if afi == "ipv6_unicast" %}
!
address-family ipv6 unicast
{%- if 'allowas_in' in conf_peer.address_family.ipv6_unicast %}
{%- if 'number' in conf_peer.address_family.ipv6_unicast.allowas_in %}
neighbor {{ peer }} allowas-in {{ conf_peer.address_family.ipv6_unicast.allowas_in.number }}
{%- else %}
neighbor {{ peer }} allowas-in
{%- endif %}
{%- endif %}
{#- START Single Params for neighbor #}
{%- if 'as_override' in conf_peer.address_family.ipv6_unicast %}
neighbor {{ peer }} as-override
{%- endif %}
{%- if 'remove_private_as' in conf_peer.address_family.ipv6_unicast %}
neighbor {{ peer }} remove-private-AS
{%- endif %}
{%- if 'route_reflector_client' in conf_peer.address_family.ipv6_unicast %}
neighbor {{ peer }} route-reflector-client
{%- endif %}
{%- if 'weight' in conf_peer.address_family.ipv6_unicast %}
neighbor {{ peer }} weight {{ conf_peer.address_family.ipv6_unicast.weight }}
{%- endif %}
{#- END single params for neighbor #}
{%- if 'attribute_unchanged' in conf_peer.address_family.ipv6_unicast %}
{%- if ( ('as_path' in conf_peer.address_family.ipv6_unicast.attribute_unchanged) and ('med' in conf_peer.address_family.ipv6_unicast.attribute_unchanged) ) %}
neighbor {{ peer }} attribute-unchanged as-path med
{%- elif ( ('as_path' in conf_peer.address_family.ipv6_unicast.attribute_unchanged) and ('next_hop' in conf_peer.address_family.ipv6_unicast.attribute_unchanged) ) %}
neighbor {{ peer }} attribute-unchanged as-path next-hop
{%- elif ( ('med' in conf_peer.address_family.ipv6_unicast.attribute_unchanged) and ('next_hop' in conf_peer.address_family.ipv6_unicast.attribute_unchanged) ) %}
neighbor {{ peer }} attribute-unchanged med next-hop
{%- elif 'as_path' in conf_peer.address_family.ipv6_unicast.attribute_unchanged %}
neighbor {{ peer }} attribute-unchanged as-path
{%- elif 'med' in conf_peer.address_family.ipv6_unicast.attribute_unchanged %}
neighbor {{ peer }} attribute-unchanged med
{%- elif 'next_hop' in conf_peer.address_family.ipv6_unicast.attribute_unchanged %}
neighbor {{ peer }} attribute-unchanged next-hop
{%- else %}
neighbor {{ peer }} attribute-unchanged as-path next-hop med
{%- endif %}
{%- endif %}
{#- END attribute-unchanged #}
{%- if 'capability' in conf_peer.address_family.ipv6_unicast %}
{%- if 'orf' in conf_peer.address_family.ipv6_unicast.capability %}
{%- if 'receive' in conf_peer.address_family.ipv6_unicast.capability.orf.prefix_list %}
neighbor {{ peer }} capability orf prefix-list receive
{%- endif %}
{%- if 'send' in conf_peer.address_family.ipv6_unicast.capability.orf.prefix_list %}
neighbor {{ peer }} capability orf prefix-list send
{%- endif %}
{%- endif %}
{%- endif %}
{%- if 'default_originate' in conf_peer.address_family.ipv6_unicast %}
{%- if 'route_map' in conf_peer.address_family.ipv6_unicast.default_originate %}
neighbor {{ peer }} default-originate route-map {{ conf_peer.address_family.ipv6_unicast.default_originate.route_map }}
{%- else %}
neighbor {{ peer }} default-originate
{%- endif %}
{%- endif %}
{%- if 'distribute_list' in conf_peer.address_family.ipv6_unicast %}
{%- if 'export' in conf_peer.address_family.ipv6_unicast.distribute_list %}
neighbor {{ peer }} distribute-list {{conf_peer.address_family.ipv6_unicast.distribute_list.export}} out
{%- endif %}
{%- if 'import' in conf_peer.address_family.ipv6_unicast.distribute_list %}
neighbor {{ peer }} distribute-list {{conf_peer.address_family.ipv6_unicast.distribute_list.import}} in
{%- endif %}
{%- endif %}
{%- if 'filter_list' in conf_peer.address_family.ipv6_unicast %}
{%- if 'export' in conf_peer.address_family.ipv6_unicast.filter_list %}
neighbor {{ peer }} filter-list {{conf_peer.address_family.ipv6_unicast.filter_list.export}} out
{%- endif %}
{%- if 'import' in conf_peer.address_family.ipv6_unicast.filter_list %}
neighbor {{ peer }} filter-list {{conf_peer.address_family.ipv6_unicast.filter_list.import}} in
{%- endif %}
{%- endif %}
{%- if 'maximum_prefix' in conf_peer.address_family.ipv6_unicast %}
neighbor {{ peer }} maximum-prefix {{ conf_peer.address_family.ipv6_unicast.maximum_prefix }}
{%- endif %}
{#- https://phabricator.vyos.net/T1817 #}
{%- if 'nexthop_self' in conf_peer.address_family.ipv6_unicast %}
{%- if 'force' in conf_peer.address_family.ipv6_unicast.nexthop_self %}
neighbor {{ peer }} next-hop-self force
neighbor {{ peer }} next-hop-self
{%- else %}
neighbor {{ peer }} next-hop-self
{%- endif %}
{%- endif %}
{%- if 'route_server_client' in conf_peer.address_family.ipv6_unicast %}
neighbor {{ peer }} route-server-client
{%- endif %}
{%- if 'route_map' in conf_peer.address_family.ipv6_unicast %}
{%- if 'export' in conf_peer.address_family.ipv6_unicast.route_map %}
neighbor {{ peer }} route-map {{conf_peer.address_family.ipv6_unicast.route_map.export}} out
{%- endif %}
{%- if 'import' in conf_peer.address_family.ipv6_unicast.route_map %}
neighbor {{ peer }} route-map {{conf_peer.address_family.ipv6_unicast.route_map.import}} in
{%- endif %}
{%- endif %}
{%- if 'prefix_list' in conf_peer.address_family.ipv6_unicast %}
{%- if 'export' in conf_peer.address_family.ipv6_unicast.prefix_list %}
neighbor {{ peer }} prefix-list {{conf_peer.address_family.ipv6_unicast.prefix_list.export}} out
{%- endif %}
{%- if 'import' in conf_peer.address_family.ipv6_unicast.prefix_list %}
neighbor {{ peer }} prefix-list {{conf_peer.address_family.ipv6_unicast.prefix_list.import}} in
{%- endif %}
{%- endif %}
{%- if 'soft_reconfiguration' in conf_peer.address_family.ipv6_unicast %}
{%- if 'inbound' is defined %}
neighbor {{ peer }} soft-reconfiguration inbound
{%- endif %}
{%- endif %}
{%- if 'unsuppress_map' in conf_peer.address_family.ipv6_unicast %}
neighbor {{ peer }} unsuppress-map {{conf_peer.address_family.ipv6_unicast.unsuppress_map}}
{%- endif %}
neighbor {{ peer }} activate
exit-address-family
!
{%- endif %}
{%- endfor %}
{%- endif %}
{#- END address family for peer #}
{%- endfor %}
{#- END peer section; set protocols bgp xxx neighbor #}
{#- START parameters section; set protocol bgp xxx parameters #}
{%- if 'always_compare_med' in bgp_params %}
bgp always-compare-med
{%- endif %}
{%- if 'bestpath' in bgp_params %}
{%- if 'compare_routerid' in bgp_params.bestpath %}
bgp bestpath compare-routerid
{%- endif %}
{%- if 'as_path' in bgp_params.bestpath %}
{%- if 'confed' in bgp_params.bestpath.as_path %}
bgp bestpath as-path confed
{%- endif %}
{%- if 'ignore' in bgp_params.bestpath.as_path %}
bgp bestpath as-path ignore
{%- endif %}
{%- if 'multipath_relax' in bgp_params.bestpath.as_path %}
bgp bestpath as-path multipath-relax
{%- endif %}
{%- endif %}
{%- if 'med' in bgp_params.bestpath %}
{%- if ( ('confed' in bgp_params.bestpath.med) and ('missing_as_worst' in bgp_params.bestpath.med ) ) %}
bgp bestpath med confed missing-as-worst
{%- elif 'confed' in bgp_params.bestpath.med %}
bgp bestpath med confed
{%- elif 'missing_as_worst' in bgp_params.bestpath.med %}
bgp bestpath med missing-as-worst
{%- endif%}
{%- endif %}
{%- endif %}
{%- if 'cluster_id' in bgp_params %}
bgp cluster-id {{ bgp_params.cluster_id }}
{%- endif %}
{%- if 'confederation' in bgp_params %}
{%- if 'identifier' in bgp_params.confederation %}
bgp confederation identifier {{ bgp_params.confederation.identifier }}
{%- endif %}
{%- if 'peers' in bgp_params.confederation %}
bgp confederation peers {{ bgp_params.confederation.peers }}
{%- endif %}
{%- endif %}
{#- Doesn't work in current FRR configuration; vtysh (bgp dampening 16 751 2001 61) #}
{%- if 'dampening' in bgp_params %}
{%- if ( ('half_life' in bgp_params.dampening) and ('max_suppress_time' in bgp_params.dampening) and ('re_use' in bgp_params.dampening) and ('start_suppress_time' in bgp_params.dampening ) ) %}
bgp dampening {{ bgp_params.dampening.half_life }} {{ bgp_params.dampening.re_use }} {{ bgp_params.dampening.start_suppress_time }} {{ bgp_params.dampening.max_suppress_time }}
{%- endif %}
{%- endif %}
{%- if 'default' in bgp_params %}
{%- if 'local_pref' in bgp_params.default %}
bgp default local-preference {{ bgp_params.default.local_pref }}
{%- endif %}
{#- We use this is parameter as default in template (5-th string) #}
{%- if 'no_ipv4_unicast' in bgp_params.default %}
no bgp default ipv4-unicast
{%- endif %}
{%- endif %}
{%- if 'deterministic_med' in bgp_params %}
bgp deterministic-med
{%- endif %}
{%- if 'distance' in bgp_params %}
{%- if 'global' in bgp_params.distance %}
{%- if ( ('external' in bgp_params.distance.global) and ('internal' in bgp_params.distance.global) and ('local' in bgp_params.distance.global ) ) %}
!
address-family ipv4 unicast
distance bgp {{ bgp_params.distance.global.external }} {{ bgp_params.distance.global.internal }} {{ bgp_params.distance.global.local }}
exit-address-family
!
{%- endif %}
{%- endif %}
{%- if 'prefix' in bgp_params.distance %}
!
address-family ipv4 unicast
{%- for prfx in bgp_params.distance.prefix %}
distance {{ bgp_params.distance.prefix[prfx].distance }} {{ prfx }}
{%- endfor %}
exit-address-family
!
{%- endif %}
{%- endif %}
{%- if 'graceful_restart' in bgp_params %}
{%- if 'stalepath_time' in bgp_params.graceful_restart %}
bgp graceful-restart stalepath-time {{ bgp_params.graceful_restart.stalepath_time }}
{%- endif %}
{%- endif %}
{%- if 'log_neighbor_changes' in bgp_params %}
bgp log-neighbor-changes
{%- endif %}
{%- if 'network_import_check' in bgp_params %}
bgp network import-check
{%- endif %}
{%- if 'no_client_to_client_reflection' in bgp_params %}
no bgp client-to-client reflection
{%- endif %}
{%- if 'no_fast_external_failover' in bgp_params %}
no bgp fast-external-failover
{%- endif %}
{#- END parameters; set protocols bgp xxx parameters #}
{%- if 'timers' in conf_bgp[asn] %}
{%- if ( ('holdtime' in conf_bgp[asn].timers) and ('keepalive' in conf_bgp[asn].timers ) ) %}
timers bgp {{conf_bgp[asn].timers.keepalive}} {{conf_bgp[asn].timers.holdtime}}
{%- endif %}
{%- endif %}
{%- if 'route_map' in conf_bgp[asn] %}
!
ip protocol bgp route-map {{conf_bgp[asn].route_map}}
{%- endif %}
!
{%- endfor -%}
{#- END asn; router bgp xxx #}
|