@@ -34,17 +34,17 @@ var (
34
34
globalInterfaceNameFlag string
35
35
// chainNameForDBAclFlag is a cli-flag that specifies the nftables chain name for DB access control list.
36
36
chainNameForDBAclFlag string
37
- // bgpMyAsNumberFlag is a cli-flag that specifies the my as number
38
- bgpMyAsNumberFlag int
37
+ // bgpLocalAsnFlag is a cli-flag that specifies the my as number
38
+ bgpLocalAsnFlag int
39
39
// bgpServingPortFlag is a cli-flag that specifies the port of bgp
40
40
bgpServingPortFlag int
41
41
// bgpKeepaliveIntervalSecFlag is a cli-flag that specifies the interval seconds of bgp keepalive
42
42
bgpKeepaliveIntervalSecFlag int
43
43
// bgpPeerXAddrFlag and bgpPeerXAsn is a cli-flag that specifies neighbor address and asn of bgp peer.
44
44
bgpPeer1AddrFlag string
45
- bgpPeer1AsnFlag string
45
+ bgpPeer1AsnFlag int
46
46
bgpPeer2AddrFlag string
47
- bgpPeer2AsnFlag string
47
+ bgpPeer2AsnFlag int
48
48
// gobgpGrpcPortFlag is a cli-flag that specifies port of gobgp gRPC
49
49
gobgpGrpcPortFlag int
50
50
@@ -74,16 +74,16 @@ func parseAllFlags(args []string) error {
74
74
fs .StringVar (& chainNameForDBAclFlag , "chain-name-for-db-acl" , "mariadb" , "the chain name for DB access control" )
75
75
fs .StringVar (& dbReplicaUserNameFlag , "db-replica-user-name" , "repl" , "the username for replication" )
76
76
fs .StringVar (& bgpPeer1AddrFlag , "bgp-peer1-addr" , "" , "the address of bgp peer#1" )
77
- fs .StringVar (& bgpPeer1AsnFlag , "bgp-peer1-asn" , "" , "the asn of bgp peer#1" )
78
77
fs .StringVar (& bgpPeer2AddrFlag , "bgp-peer2-addr" , "" , "the address of bgp peer#2" )
79
- fs .StringVar (& bgpPeer2AsnFlag , "bgp-peer2-asn" , "" , "the asn of bgp peer#2" )
80
78
81
79
fs .IntVar (& mainPollingSpanSecondFlag , "main-polling-span-second" , 4 , "the span seconds of the loop in main.go" )
82
80
fs .IntVar (& httpAPIServerPortFlag , "http-api-server-port" , 54545 , "the port the http api server listens" )
83
81
fs .IntVar (& prometheusExporterPortFlag , "prometheus-exporter-port" , 50505 , "the port the prometheus exporter listens" )
84
82
fs .IntVar (& dbReplicaSourcePortFlag , "db-replica-source-port" , 13306 , "the port of primary as replication source" )
85
83
fs .IntVar (& dbServingPortFlag , "db-serving-port" , 3306 , "the port of database service" )
86
- fs .IntVar (& bgpMyAsNumberFlag , "bgp-my-as-number" , 65001 , "the my as number" )
84
+ fs .IntVar (& bgpLocalAsnFlag , "bgp-local-asn" , 0 , "the as number of local" )
85
+ fs .IntVar (& bgpPeer1AsnFlag , "bgp-peer1-asn" , 0 , "the asn of bgp peer#1" )
86
+ fs .IntVar (& bgpPeer2AsnFlag , "bgp-peer2-asn" , 0 , "the asn of bgp peer#2" )
87
87
fs .IntVar (& bgpServingPortFlag , "bgp-serving-port" , 179 , "the port of bgp" )
88
88
fs .IntVar (& bgpKeepaliveIntervalSecFlag , "bgp-keepalive-interval-sec" , 3 , "the interval seconds of bgp keepalive" )
89
89
fs .IntVar (& gobgpGrpcPortFlag , "gobgp-grpc-port" , 50051 , "the listen port of gobgp gRPC" )
@@ -104,8 +104,12 @@ func validateAllFlags() error {
104
104
return fmt .Errorf ("--prometheus-exporter-port must be the range of uint16(tcp port)" )
105
105
}
106
106
107
- if bgpPeer1AddrFlag == "" || bgpPeer1AsnFlag == "" || bgpPeer2AddrFlag == "" || bgpPeer2AsnFlag == "" {
108
- return fmt .Errorf ("insufficient bgp peer addresses" )
107
+ if bgpLocalAsnFlag == 0 {
108
+ return fmt .Errorf ("--bgp-local-asan must be specified" )
109
+ }
110
+
111
+ if bgpPeer1AddrFlag == "" || bgpPeer1AsnFlag == 0 || bgpPeer2AddrFlag == "" || bgpPeer2AsnFlag == 0 {
112
+ return fmt .Errorf ("insufficient bgp peer" )
109
113
}
110
114
111
115
return nil
0 commit comments