Skip to content

Commit 87e2c00

Browse files
committed
Added vrrp interfaces for gateway redundancy without vxlan
1 parent 3ad3881 commit 87e2c00

File tree

6 files changed

+54
-1
lines changed

6 files changed

+54
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
bin
2+
*~

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,10 @@ vlans:
588588
untagged_ports:
589589
- PortChannel11
590590
vrf: Vrf45
591+
vrrp:
592+
group: 1
593+
priority: 66
594+
ip: 10.255.1.1/24
591595
```
592596

593597
Result:
@@ -614,6 +618,12 @@ Result:
614618
"Vlan4000|PortChannel11": {
615619
"tagging_mode": "untagged"
616620
}
621+
},
622+
"VRRP_INTERFACE": {
623+
"Vrrp1-v4": {
624+
"parent_interface": "Vlan4000"
625+
},
626+
"Vrrp1-v4|10.255.1.1/24": {}
617627
}
618628
}
619629
```

configdb/configdb.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type ConfigDB struct {
3737
VLANs map[string]VLAN `json:"VLAN,omitempty"`
3838
VLANInterfaces map[string]VLANInterface `json:"VLAN_INTERFACE,omitempty"`
3939
VLANMembers map[string]VLANMember `json:"VLAN_MEMBER,omitempty"`
40+
VRRPInterfaces map[string]VRRPInterface `json:"VRRP_INTERFACE,omitempty"`
4041
VLANSubinterfaces map[string]VLANSubinterface `json:"VLAN_SUB_INTERFACE,omitempty"`
4142
VRFs map[string]VRF `json:"VRF,omitempty"`
4243
VXLANEVPN *VXLANEVPN `json:"VXLAN_EVPN_NVO,omitempty"`
@@ -76,6 +77,11 @@ func GenerateConfigDB(input *values.Values, platform *p.Platform, environment *p
7677
return nil, err
7778
}
7879

80+
vrrpInterfaces, err := getVRRPInterfaces(input.VLANs, version)
81+
if err != nil {
82+
return nil, err
83+
}
84+
7985
configdb := ConfigDB{
8086
ACLRules: rules,
8187
ACLTables: tables,
@@ -112,6 +118,7 @@ func GenerateConfigDB(input *values.Values, platform *p.Platform, environment *p
112118
VLANs: getVLANs(input.VLANs),
113119
VLANInterfaces: vlanInterfaces,
114120
VLANMembers: getVLANMembers(input.VLANs),
121+
VRRPInterfaces: vrrpInterfaces,
115122
VLANSubinterfaces: getVLANSubinterfaces(input.VLANSubinterfaces),
116123
VRFs: getVRFs(input.Interconnects, input.Ports, input.VLANs),
117124
VXLANEVPN: vxlanevpn,
@@ -576,6 +583,31 @@ func getVLANMembers(vlans []values.VLAN) map[string]VLANMember {
576583
return vlanMembers
577584
}
578585

586+
func getVRRPInterfaces(vlans []values.VLAN, version *v.Version) (map[string]VRRPInterface, error) {
587+
vrrpInterfaces := make(map[string]VRRPInterface)
588+
for _, vlan := range vlans {
589+
if vlan.VRRP.Group == "" {
590+
continue
591+
}
592+
593+
if version.Branch != string(v.Branch202111) {
594+
return nil, fmt.Errorf("vrrp configuration only works with sonic versions from the ec202111 branch")
595+
}
596+
597+
vrrpInterfaces["Vrrp"+vlan.VRRP.Group+"-v4"] = VRRPInterface{
598+
ParentInterface: "Vlan" + vlan.ID,
599+
}
600+
601+
if vlan.VRRP.IP == "" {
602+
continue
603+
}
604+
605+
vrrpInterfaces["Vrrp"+vlan.VRRP.Group+"-v4|"+vlan.VRRP.IP] = VRRPInterface{}
606+
}
607+
608+
return vrrpInterfaces, nil
609+
}
610+
579611
func getVLANSubinterfaces(subinterfaces []values.VLANSubinterface) map[string]VLANSubinterface {
580612
vlanSubinterfaces := make(map[string]VLANSubinterface)
581613

configdb/fields.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,10 @@ type VLANMember struct {
220220
TaggingMode TaggingMode `json:"tagging_mode,omitempty"`
221221
}
222222

223+
type VRRPInterface struct {
224+
ParentInterface string `json:"parent_interface,omitempty"`
225+
}
226+
223227
type VLANSubinterface struct {
224228
AdminStatus AdminStatus `json:"admin_status,omitempty"`
225229
VRFName string `json:"vrf_name,omitempty"`

tests/test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
for i in 1 2 3 4
3+
for i in 1 2 3 4 5
44
do
55
test_dir=$(pwd)/tests/$i
66
docker run --rm --mac-address aa:aa:aa:aa:aa:aa -v $test_dir:/etc/sonic -v $(pwd)/tests/device:/usr/share/sonic/device:ro -v $test_dir:/sonic sonic-configdb-utils:local generate -i /sonic/sonic-config.yaml -o /sonic/config_db.json

values/values.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ type VLAN struct {
128128
TaggedPorts []string `yaml:"tagged_ports"`
129129
UntaggedPorts []string `yaml:"untagged_ports"`
130130
VRF string `yaml:"vrf"`
131+
VRRP VRRP `yaml:"vrrp"`
132+
}
133+
134+
type VRRP struct {
135+
Group string `yaml:"group"`
136+
IP string `yaml:"ip"`
131137
}
132138

133139
type VTEP struct {

0 commit comments

Comments
 (0)