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
+ // bgpLocalAsnFlag is a cli-flag that specifies the my as number
38
+ bgpLocalAsnFlag int
39
+ // bgpServingPortFlag is a cli-flag that specifies the port of bgp
40
+ bgpServingPortFlag int
41
+ // bgpKeepaliveIntervalSecFlag is a cli-flag that specifies the interval seconds of bgp keepalive
42
+ bgpKeepaliveIntervalSecFlag int
43
+ // bgpPeerXAddrFlag and bgpPeerXAsn is a cli-flag that specifies neighbor address and asn of bgp peer.
44
+ bgpPeer1AddrFlag string
45
+ bgpPeer1AsnFlag int
46
+ bgpPeer2AddrFlag string
47
+ bgpPeer2AsnFlag int
48
+ // gobgpGrpcPortFlag is a cli-flag that specifies port of gobgp gRPC
49
+ gobgpGrpcPortFlag int
37
50
38
51
// mainPollingSpanSecondFlag is a cli-flag that specifies the span seconds of the loop in main.go.
39
52
mainPollingSpanSecondFlag int
@@ -60,12 +73,20 @@ func parseAllFlags(args []string) error {
60
73
fs .StringVar (& globalInterfaceNameFlag , "global-interface-name" , "eth0" , "the interface name of global" )
61
74
fs .StringVar (& chainNameForDBAclFlag , "chain-name-for-db-acl" , "mariadb" , "the chain name for DB access control" )
62
75
fs .StringVar (& dbReplicaUserNameFlag , "db-replica-user-name" , "repl" , "the username for replication" )
76
+ fs .StringVar (& bgpPeer1AddrFlag , "bgp-peer1-addr" , "" , "the address of bgp peer#1" )
77
+ fs .StringVar (& bgpPeer2AddrFlag , "bgp-peer2-addr" , "" , "the address of bgp peer#2" )
63
78
64
79
fs .IntVar (& mainPollingSpanSecondFlag , "main-polling-span-second" , 4 , "the span seconds of the loop in main.go" )
65
80
fs .IntVar (& httpAPIServerPortFlag , "http-api-server-port" , 54545 , "the port the http api server listens" )
66
81
fs .IntVar (& prometheusExporterPortFlag , "prometheus-exporter-port" , 50505 , "the port the prometheus exporter listens" )
67
82
fs .IntVar (& dbReplicaSourcePortFlag , "db-replica-source-port" , 13306 , "the port of primary as replication source" )
68
83
fs .IntVar (& dbServingPortFlag , "db-serving-port" , 3306 , "the port of database service" )
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
+ fs .IntVar (& bgpServingPortFlag , "bgp-serving-port" , 179 , "the port of bgp" )
88
+ fs .IntVar (& bgpKeepaliveIntervalSecFlag , "bgp-keepalive-interval-sec" , 3 , "the interval seconds of bgp keepalive" )
89
+ fs .IntVar (& gobgpGrpcPortFlag , "gobgp-grpc-port" , 50051 , "the listen port of gobgp gRPC" )
69
90
70
91
fs .BoolVar (& enablePrometheusExporterFlag , "prometheus-exporter" , true , "enables the prometheus exporter" )
71
92
fs .BoolVar (& enableHTTPAPIFlag , "http-api" , true , "enables the http api server" )
@@ -83,6 +104,14 @@ func validateAllFlags() error {
83
104
return fmt .Errorf ("--prometheus-exporter-port must be the range of uint16(tcp port)" )
84
105
}
85
106
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" )
113
+ }
114
+
86
115
return nil
87
116
}
88
117
0 commit comments