Skip to content

Commit

Permalink
config: add validation for IPv4NativeRoutingCIDR
Browse files Browse the repository at this point in the history
Make sure the provided range is actually a v4 CIDR.

Signed-off-by: Gilberto Bertin <gilberto@isovalent.com>
  • Loading branch information
jibi committed Jun 28, 2021
1 parent a66b2f2 commit dd69fd6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pkg/option/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2523,8 +2523,16 @@ func (c *DaemonConfig) Populate() {

if nativeRoutingCIDR != "" {
c.ipv4NativeRoutingCIDR = cidr.MustParseCIDR(nativeRoutingCIDR)

if len(c.ipv4NativeRoutingCIDR.IP) != net.IPv4len {
log.Fatalf("%s must be an IPv4 CIDR", NativeRoutingCIDR)
}
} else if ipv4NativeRoutingCIDR != "" {
c.ipv4NativeRoutingCIDR = cidr.MustParseCIDR(ipv4NativeRoutingCIDR)

if len(c.ipv4NativeRoutingCIDR.IP) != net.IPv4len {
log.Fatalf("%s must be an IPv4 CIDR", IPv4NativeRoutingCIDR)
}
}

if err := c.calculateBPFMapSizes(); err != nil {
Expand Down

0 comments on commit dd69fd6

Please sign in to comment.