Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow invalid VLAN/VNI value during network creation #1069

Merged
merged 2 commits into from
Nov 17, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions netctl/netctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"os"
"regexp"
"sort"
"strconv"
"strings"
"text/tabwriter"

Expand Down Expand Up @@ -517,6 +518,8 @@ func createNetwork(ctx *cli.Context) {
subnetv6 := ctx.String("subnetv6")
gatewayv6 := ctx.String("gatewayv6")

pktTagInString := ctx.String("pkt-tag")

if subnet == "" {
errExit(ctx, exitHelp, "Subnet is required", true)
}
Expand All @@ -527,14 +530,22 @@ func createNetwork(ctx *cli.Context) {
}
if gatewayv6 != "" {
if ok := net.ParseIP(gatewayv6); ok == nil {
errExit(ctx, exitHelp, "Invalid IPv6 gateway ", true)
errExit(ctx, exitHelp, "Invalid IPv6 gateway", true)
}
}

var pktTag int
var err error
if len(pktTagInString) > 0 {
pktTag, err = strconv.Atoi(pktTagInString)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, drop the declaration of err on 538 and use
pktTag, err := strconv.Atoi(pktTagInString)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't as pktTag need to be used in line 560.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just the err, pktTag still decalred on 537, not a blocker

if err != nil {
errExit(ctx, exitHelp, "Invalid VLAN ID or VNI, expected an integer", true)
}
}

tenant := ctx.String("tenant")
network := ctx.Args()[0]
encap := ctx.String("encap")
pktTag := ctx.Int("pkt-tag")
nwType := ctx.String("nw-type")
nwTag := ctx.String("nw-tag")

Expand Down