Skip to content

Commit 3245fa2

Browse files
committed
rename vrfID to vpnID
Signed-off-by: YujiOshima <[email protected]>
1 parent 2d80224 commit 3245fa2

File tree

6 files changed

+44
-44
lines changed

6 files changed

+44
-44
lines changed

drivers/ipvlan/ipvlan.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const (
2121
parentOpt = "parent" // parent interface -o parent
2222
modeOpt = "_mode" // ipvlan mode ux opt suffix
2323
bgpNeighborOpt = "bgp-neighbor" // BGP neighbor address
24-
vrfOpt = "vrf" // BGP vrf ID
24+
vpnOpt = "vpn" // BGP vpn ID
2525
asOpt = "asnum" // BGP AS number default 65000
2626
remoteAsOpt = "rasnum" // BGP remote AS number dafault 65000
2727
subnetAdvertise = "subnet-advertise" // Advertise IP Subnet with BGP

drivers/ipvlan/ipvlan_joinleave.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (d *driver) Join(nid, eid string, sboxKey string, jinfo driverapi.JoinInfo,
6363
if n.config.SubnetAdvertise == "" {
6464
//Advertise container route as /32 route
6565
advIP := &net.IPNet{IP: ep.addr.IP, Mask: net.IPv4Mask(255, 255, 255, 255)}
66-
err = routemanager.AdvertiseNewRoute(advIP.String(), n.config.VrfID)
66+
err = routemanager.AdvertiseNewRoute(advIP.String(), n.config.VpnID)
6767
if err != nil {
6868
return err
6969
}
@@ -145,7 +145,7 @@ func (d *driver) Leave(nid, eid string) error {
145145
if network.config.IpvlanMode == modeL3 && network.config.SubnetAdvertise == "" {
146146
//Withdraw container route as /32 route
147147
witdIP := &net.IPNet{IP: endpoint.addr.IP, Mask: net.IPv4Mask(255, 255, 255, 255)}
148-
err = routemanager.WithdrawRoute(witdIP.String(), network.config.VrfID)
148+
err = routemanager.WithdrawRoute(witdIP.String(), network.config.VpnID)
149149
}
150150
if endpoint == nil {
151151
return fmt.Errorf("could not find endpoint with id %s", eid)

drivers/ipvlan/ipvlan_network.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (d *driver) createNetwork(config *configuration) error {
117117
if routemanager == nil {
118118
InitRouteMonitering(config.ASnum, config.RemoteASnum)
119119
}
120-
err := routemanager.CreateVrfNetwork(config.Parent, config.VrfID)
120+
err := routemanager.CreateVrfNetwork(config.Parent, config.VpnID)
121121
if err != nil {
122122
return err
123123
}
@@ -127,13 +127,13 @@ func (d *driver) createNetwork(config *configuration) error {
127127
if config.SubnetAdvertise != "" {
128128
if config.Ipv4Subnets != nil {
129129
for _, subnet := range config.Ipv4Subnets {
130-
err := routemanager.AdvertiseNewRoute(subnet.SubnetIP, config.VrfID)
130+
err := routemanager.AdvertiseNewRoute(subnet.SubnetIP, config.VpnID)
131131
if err != nil {
132132
return err
133133
}
134134
}
135135
for _, subnet := range config.Ipv6Subnets {
136-
err := routemanager.AdvertiseNewRoute(subnet.SubnetIP, config.VrfID)
136+
err := routemanager.AdvertiseNewRoute(subnet.SubnetIP, config.VpnID)
137137
if err != nil {
138138
return err
139139
}
@@ -179,13 +179,13 @@ func (d *driver) DeleteNetwork(nid string) error {
179179
//Advertise container network subnet
180180
if n.config.Ipv4Subnets != nil {
181181
for _, subnet := range n.config.Ipv4Subnets {
182-
err := routemanager.WithdrawRoute(subnet.SubnetIP, n.config.VrfID)
182+
err := routemanager.WithdrawRoute(subnet.SubnetIP, n.config.VpnID)
183183
if err != nil {
184184
return err
185185
}
186186
}
187187
for _, subnet := range n.config.Ipv6Subnets {
188-
err := routemanager.WithdrawRoute(subnet.SubnetIP, n.config.VrfID)
188+
err := routemanager.WithdrawRoute(subnet.SubnetIP, n.config.VpnID)
189189
if err != nil {
190190
return err
191191
}
@@ -259,14 +259,14 @@ func (config *configuration) fromOptions(labels map[string]string) error {
259259
case bgpNeighborOpt:
260260
// parse driver option '-o bgp-neighbor'
261261
config.BgpNeighbor = value
262-
case vrfOpt:
263-
// parse driver option '-o vrf'
262+
case vpnOpt:
263+
// parse driver option '-o vpn'
264264
_, err := strconv.Atoi(value)
265265
if err != nil {
266-
logrus.Errorf("vrf ID must be numeral")
266+
logrus.Errorf("vpn ID must be numeral")
267267
return err
268268
}
269-
config.VrfID = value
269+
config.VpnID = value
270270
case asOpt:
271271
// parse driver options '-o asnum'
272272
config.ASnum = value

drivers/ipvlan/ipvlan_store.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type configuration struct {
3131
Ipv4Subnets []*ipv4Subnet
3232
Ipv6Subnets []*ipv6Subnet
3333
BgpNeighbor string
34-
VrfID string
34+
VpnID string
3535
ASnum string
3636
RemoteASnum string
3737
SubnetAdvertise string

drivers/ipvlan/l3_route_interface.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ type host struct {
88
}
99

1010
type routingInterface interface {
11-
CreateVrfNetwork(ParentIface string, vrfID string) error
12-
AdvertiseNewRoute(localPrefix string, vrfID string) error
13-
WithdrawRoute(localPrefix string, vrfID string) error
11+
CreateVrfNetwork(ParentIface string, vpnID string) error
12+
AdvertiseNewRoute(localPrefix string, vpnID string) error
13+
WithdrawRoute(localPrefix string, vpnID string) error
1414
DiscoverNew(isself bool, Address string) error
1515
DiscoverDelete(isself bool, Address string) error
1616
}

drivers/ipvlan/l3_route_manager.go

+28-28
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const (
1818

1919
type rib struct {
2020
path *bgpapi.Path
21-
vrfID string
21+
vpnID string
2222
}
2323

2424
// BgpRouteManager advertize and withdraw routes by BGP
@@ -56,8 +56,8 @@ func NewBgpRouteManager(as string, ras string) *BgpRouteManager {
5656
return b
5757
}
5858

59-
//CreateVrfNetwork create vrf in BGP server and start monitoring vrf rib if vrfID="", network use global rib
60-
func (b *BgpRouteManager) CreateVrfNetwork(parentIface string, vrfID string) error {
59+
//CreateVrfNetwork create vrf in BGP server and start monitoring vrf rib if vpnID="", network use global rib
60+
func (b *BgpRouteManager) CreateVrfNetwork(parentIface string, vpnID string) error {
6161
log.Debugf("BGP Global config : %v", b.bgpGlobalcfg)
6262
if b.bgpGlobalcfg == nil {
6363
log.Debugf("BGP Global config is emply set config")
@@ -78,35 +78,35 @@ func (b *BgpRouteManager) CreateVrfNetwork(parentIface string, vrfID string) err
7878
break
7979
}
8080
}
81-
if vrfID == "" {
81+
if vpnID == "" {
8282
log.Debugf("vrf ID is empty. network paths are in global rib")
8383
return nil
8484
}
85-
b.parentIfaces[vrfID] = parentIface
85+
b.parentIfaces[vpnID] = parentIface
8686
err := cleanExistingRoutes(parentIface)
8787
if err != nil {
8888
log.Debugf("Error cleaning old routes: %s", err)
8989
return err
9090
}
91-
rdrtstr := strconv.Itoa(b.asnum) + ":" + vrfID
91+
rdrtstr := strconv.Itoa(b.asnum) + ":" + vpnID
9292
rd, err := bgp.ParseRouteDistinguisher(rdrtstr)
9393
if err != nil {
94-
log.Errorf("Fail to parse RD from vrfID %s : %s", vrfID, err)
94+
log.Errorf("Fail to parse RD from vpnID %s : %s", vpnID, err)
9595
return err
9696
}
9797
rdSerialized, _ := rd.Serialize()
9898

9999
rt, err := bgp.ParseRouteTarget(rdrtstr)
100100
if err != nil {
101-
log.Errorf("Fail to parse RT from vrfID %s : %s", vrfID, err)
101+
log.Errorf("Fail to parse RT from vpnID %s : %s", vpnID, err)
102102
return err
103103
}
104104
rtSerialized, _ := rt.Serialize()
105105
var rts [][]byte
106106
rts = append(rts, rtSerialized)
107107

108108
arg := &bgpapi.Vrf{
109-
Name: bgpVrfprefix + vrfID,
109+
Name: bgpVrfprefix + vpnID,
110110
Rd: rdSerialized,
111111
ImportRt: rts,
112112
ExportRt: rts,
@@ -116,8 +116,8 @@ func (b *BgpRouteManager) CreateVrfNetwork(parentIface string, vrfID string) err
116116
return err
117117
}
118118
go func() {
119-
err := b.monitorBestPath(vrfID)
120-
log.Errorf("faital monitoring VrfID %s rib : %v", vrfID, err)
119+
err := b.monitorBestPath(vpnID)
120+
log.Errorf("faital monitoring VpnID %s rib : %v", vpnID, err)
121121
}()
122122
return nil
123123
}
@@ -143,7 +143,7 @@ func (b *BgpRouteManager) handleRibUpdate(p *rib) error {
143143
bgpCache := &ribCache{
144144
BgpTable: make(map[string]*ribLocal),
145145
}
146-
monitorUpdate, err := bgpCache.handleBgpRibMonitor(p.path, p.vrfID)
146+
monitorUpdate, err := bgpCache.handleBgpRibMonitor(p.path, p.vpnID)
147147
if err != nil {
148148
log.Errorf("error processing bgp update [ %s ]", err)
149149
return err
@@ -155,7 +155,7 @@ func (b *BgpRouteManager) handleRibUpdate(p *rib) error {
155155
monitorUpdate.IsWithdraw = true
156156
log.Debugf("BGP update has withdrawn the routes: %v ", monitorUpdate)
157157
if route, ok := b.learnedRoutes[monitorUpdate.BgpPrefix.String()]; ok {
158-
err = delNetlinkRoute(route.BgpPrefix, route.NextHop, b.parentIfaces[p.vrfID])
158+
err = delNetlinkRoute(route.BgpPrefix, route.NextHop, b.parentIfaces[p.vpnID])
159159
// If the bgp update contained a withdraw, remove the local netlink route for the remote endpoint
160160
if err != nil {
161161
log.Errorf("Error removing learned bgp route [ %s ]", err)
@@ -171,7 +171,7 @@ func (b *BgpRouteManager) handleRibUpdate(p *rib) error {
171171
b.learnedRoutes[monitorUpdate.BgpPrefix.String()] = monitorUpdate
172172
log.Debugf("Learned routes: %v ", monitorUpdate)
173173

174-
err = addNetlinkRoute(monitorUpdate.BgpPrefix, monitorUpdate.NextHop, b.parentIfaces[p.vrfID])
174+
err = addNetlinkRoute(monitorUpdate.BgpPrefix, monitorUpdate.NextHop, b.parentIfaces[p.vpnID])
175175
if err != nil {
176176
log.Debugf("Error Adding route results [ %s ]", err)
177177
return err
@@ -186,11 +186,11 @@ func (b *BgpRouteManager) handleRibUpdate(p *rib) error {
186186
return nil
187187
}
188188

189-
func (b *BgpRouteManager) monitorBestPath(VrfID string) error {
189+
func (b *BgpRouteManager) monitorBestPath(VpnID string) error {
190190
var routeFamily uint32
191-
if VrfID == "" {
191+
if VpnID == "" {
192192
routeFamily = uint32(bgp.RF_IPv4_UC)
193-
VrfID = "global"
193+
VpnID = "global"
194194
} else {
195195
routeFamily = uint32(bgp.RF_IPv4_VPN)
196196
}
@@ -202,7 +202,7 @@ func (b *BgpRouteManager) monitorBestPath(VrfID string) error {
202202
for _, d := range currib.Destinations {
203203
for _, p := range d.Paths {
204204
if p.Best {
205-
b.handleRibUpdate(&rib{path: p, vrfID: VrfID})
205+
b.handleRibUpdate(&rib{path: p, vpnID: VpnID})
206206
break
207207
}
208208
}
@@ -223,7 +223,7 @@ func (b *BgpRouteManager) monitorBestPath(VrfID string) error {
223223
EndCh <- struct{}{}
224224
return err
225225
}
226-
err := b.handleRibUpdate(&rib{path: r.Data.(*bgpapi.Destination).Paths[0], vrfID: VrfID})
226+
err := b.handleRibUpdate(&rib{path: r.Data.(*bgpapi.Destination).Paths[0], vpnID: VpnID})
227227
if err != nil {
228228
log.Errorf(err.Error())
229229
continue
@@ -233,15 +233,15 @@ func (b *BgpRouteManager) monitorBestPath(VrfID string) error {
233233
}
234234

235235
// AdvertiseNewRoute advetise the local namespace IP prefixes to the bgp neighbors
236-
func (b *BgpRouteManager) AdvertiseNewRoute(localPrefix string, VrfID string) error {
236+
func (b *BgpRouteManager) AdvertiseNewRoute(localPrefix string, VpnID string) error {
237237
_, localPrefixCIDR, _ := net.ParseCIDR(localPrefix)
238238
log.Debugf("Adding this hosts container network [ %s ] into the BGP domain", localPrefix)
239239
path := &bgpapi.Path{
240240
Pattrs: make([][]byte, 0),
241241
IsWithdraw: false,
242242
}
243243
var target bgpapi.Resource
244-
if VrfID == "" {
244+
if VpnID == "" {
245245
target = bgpapi.Resource_GLOBAL
246246
} else {
247247
target = bgpapi.Resource_VRF
@@ -254,7 +254,7 @@ func (b *BgpRouteManager) AdvertiseNewRoute(localPrefix string, VrfID string) er
254254
path.Pattrs = append(path.Pattrs, origin)
255255
arg := &bgpapi.AddPathRequest{
256256
Resource: target,
257-
VrfId: bgpVrfprefix + VrfID,
257+
VrfId: bgpVrfprefix + VpnID,
258258
Path: path,
259259
}
260260
_, err := b.bgpServer.AddPath(arg)
@@ -265,15 +265,15 @@ func (b *BgpRouteManager) AdvertiseNewRoute(localPrefix string, VrfID string) er
265265
}
266266

267267
//WithdrawRoute withdraw the local namespace IP prefixes to the bgp neighbors
268-
func (b *BgpRouteManager) WithdrawRoute(localPrefix string, VrfID string) error {
268+
func (b *BgpRouteManager) WithdrawRoute(localPrefix string, VpnID string) error {
269269
_, localPrefixCIDR, _ := net.ParseCIDR(localPrefix)
270270
log.Debugf("Withdraw this hosts container network [ %s ] from the BGP domain", localPrefix)
271271
path := &bgpapi.Path{
272272
Pattrs: make([][]byte, 0),
273273
IsWithdraw: true,
274274
}
275275
var target bgpapi.Resource
276-
if VrfID == "" {
276+
if VpnID == "" {
277277
target = bgpapi.Resource_GLOBAL
278278
} else {
279279
target = bgpapi.Resource_VRF
@@ -286,7 +286,7 @@ func (b *BgpRouteManager) WithdrawRoute(localPrefix string, VrfID string) error
286286
path.Pattrs = append(path.Pattrs, origin)
287287
arg := &bgpapi.DeletePathRequest{
288288
Resource: target,
289-
VrfId: bgpVrfprefix + VrfID,
289+
VrfId: bgpVrfprefix + VpnID,
290290
Path: path,
291291
}
292292
err := b.bgpServer.DeletePath(arg)
@@ -359,12 +359,12 @@ func (b *BgpRouteManager) DiscoverDelete(isself bool, Address string) error {
359359

360360
return nil
361361
}
362-
func (cache *ribCache) handleBgpRibMonitor(routeMonitor *bgpapi.Path, VrfID string) (*ribLocal, error) {
362+
func (cache *ribCache) handleBgpRibMonitor(routeMonitor *bgpapi.Path, VpnID string) (*ribLocal, error) {
363363
ribLocal := &ribLocal{}
364364
var nlri bgp.AddrPrefixInterface
365365

366366
if len(routeMonitor.Nlri) > 0 {
367-
if VrfID == "global" {
367+
if VpnID == "global" {
368368
nlri = &bgp.IPAddrPrefix{}
369369
err := nlri.DecodeFromBytes(routeMonitor.Nlri)
370370
if err != nil {
@@ -386,7 +386,7 @@ func (cache *ribCache) handleBgpRibMonitor(routeMonitor *bgpapi.Path, VrfID stri
386386
return nil, err
387387
}
388388
nlriSplit := strings.Split(nlri.String(), ":")
389-
if VrfID != nlriSplit[1] {
389+
if VpnID != nlriSplit[1] {
390390
return nil, nil
391391
}
392392
bgpPrefix, err := parseIPNet(nlriSplit[len(nlriSplit)-1])

0 commit comments

Comments
 (0)