Skip to content

Commit f4273a9

Browse files
committed
fix: require cluster-as and neighbor-as parameters in configuration
1 parent 876516b commit f4273a9

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

pkg/speaker/config.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ import (
2828

2929
const (
3030
DefaultBGPGrpcPort = 50051
31-
DefaultBGPClusterAs = 65000
32-
DefaultBGPNeighborAs = 65001
3331
DefaultBGPHoldtime = 90 * time.Second
3432
DefaultPprofPort = 10667
3533
DefaultGracefulRestartDeferralTime = 360 * time.Second
@@ -77,12 +75,12 @@ func ParseFlags() (*Configuration, error) {
7775
argAnnounceClusterIP = pflag.BoolP("announce-cluster-ip", "", false, "The Cluster IP of the service to announce to the BGP peers.")
7876
argGrpcHost = pflag.IP("grpc-host", net.IP{127, 0, 0, 1}, "The host address for grpc to listen, default: 127.0.0.1")
7977
argGrpcPort = pflag.Int32("grpc-port", DefaultBGPGrpcPort, "The port for grpc to listen, default:50051")
80-
argClusterAs = pflag.Uint32("cluster-as", DefaultBGPClusterAs, "The AS number of container network, default 65000")
78+
argClusterAs = pflag.Uint32("cluster-as", 0, "The AS number of the local BGP speaker (required)")
8179
argRouterID = pflag.IP("router-id", nil, "The address for the speaker to use as router id, default the node ip")
8280
argNodeIPs = pflag.IPSlice("node-ips", nil, "The comma-separated list of node IP addresses to use instead of the pod IP address for the next hop router IP address.")
8381
argNeighborAddress = pflag.IPSlice("neighbor-address", nil, "Comma separated IPv4 router addresses the speaker connects to.")
8482
argNeighborIPv6Address = pflag.IPSlice("neighbor-ipv6-address", nil, "Comma separated IPv6 router addresses the speaker connects to.")
85-
argNeighborAs = pflag.Uint32("neighbor-as", DefaultBGPNeighborAs, "The router as number, default 65001")
83+
argNeighborAs = pflag.Uint32("neighbor-as", 0, "The AS number of the BGP neighbor/peer (required)")
8684
argAuthPassword = pflag.String("auth-password", "", "bgp peer auth password")
8785
argHoldTime = pflag.Duration("holdtime", DefaultBGPHoldtime, "ovn-speaker goes down abnormally, the local saving time of BGP route will be affected.Holdtime must be in the range 3s to 65536s. (default 90s)")
8886
argPprofPort = pflag.Int32("pprof-port", DefaultPprofPort, "The port to get profiling data, default: 10667")
@@ -172,6 +170,12 @@ func ParseFlags() (*Configuration, error) {
172170
if len(config.NeighborAddresses) == 0 && len(config.NeighborIPv6Addresses) == 0 {
173171
return nil, errors.New("at least one of --neighbor-address or --neighbor-ipv6-address must be specified")
174172
}
173+
if config.ClusterAs == 0 {
174+
return nil, errors.New("--cluster-as must be specified")
175+
}
176+
if config.NeighborAs == 0 {
177+
return nil, errors.New("--neighbor-as must be specified")
178+
}
175179

176180
for _, addr := range config.NeighborAddresses {
177181
if addr.To4() == nil {

0 commit comments

Comments
 (0)