ruderich.org/simon
/
linux-network-namespace-labs
/
linux-network-namespace-labs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7142a60
)
Disallow node names which are numbers
author
Simon Ruderich
<simon@ruderich.org>
Tue, 5 Nov 2024 06:46:17 +0000
(07:46 +0100)
committer
Simon Ruderich
<simon@ruderich.org>
Tue, 5 Nov 2024 06:46:17 +0000
(07:46 +0100)
config.go
patch
|
blob
|
history
diff --git
a/config.go
b/config.go
index d3239b434a21c99b3cbac7ba3dfab36aead27c88..66cefc07e6c5738c5dbdc13196e14988a18fc8a9 100644
(file)
--- a/
config.go
+++ b/
config.go
@@
-10,6
+10,7
@@
import (
"fmt"
"net/netip"
"os"
+ "strconv"
"strings"
)
@@
-155,6
+156,13
@@
func parseConfigNode(cfg *Config, args []string) error {
res := Node{
Name: args[0],
}
+ _, err := strconv.Atoi(res.Name)
+ if err == nil {
+ // `ip` "netns" option uses the PID's namespace when given a number
+ // but we need the namespace name.
+ return fmt.Errorf("invalid name %q (must not be a number)",
+ res.Name)
+ }
if cfg.Nodes[res.Name] != nil {
return fmt.Errorf("%q already exists", res.Name)
}