Skip to content

Commit 4736eef

Browse files
committed
Change ip-netns to IPNETNS and add NETNS for inode
1 parent cc4eacd commit 4736eef

File tree

5 files changed

+8
-4
lines changed

5 files changed

+8
-4
lines changed

.goxc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"ConfigVersion": "0.1",
2+
"ConfigVersion": "0.2",
33
"PackageVersion": "unknown",
44
"PrereleaseInfo": "",
55
"BuildSettings": {

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Build and put it in your container host.
2222
koro NS_SPEC route { add | del } ROUTE
2323

2424
ROUTE := PREFIX NH
25-
NS_SPEC := { docker NAME | netns NAME | pid PID }
25+
NS_SPEC := { docker NAME | ipnetns NAME | netns NAME | pid PID }
2626
NH := [ via ADDRESS ] [ dev STRING ]
2727

2828
# Example

koro.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ func getNamepace (command *parser.Command) (namespace string, err error) {
2121
switch command.TargetType {
2222
case parser.DOCKER:
2323
namespace, err = koko_api.GetDockerContainerNS(command.Target)
24-
case parser.NETNS:
24+
case parser.IPNETNS:
2525
namespace = fmt.Sprintf("/var/run/netns/%s", command.Target)
26+
case parser.NETNS:
27+
namespace = command.Target
2628
case parser.PID:
2729
var pid int
2830
pid, err = strconv.Atoi(command.Target)

parser/command.peg

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ EOT <- !.
1515
netns <-
1616
'docker' spaces netnsid {p.TargetType = DOCKER} /
1717
'netns' spaces netnsid {p.TargetType = NETNS} /
18+
'ipnetns' spaces netnsid {p.TargetType = IPNETNS} /
1819
'pid' spaces netnsid {p.TargetType = PID} /
1920
<.+> {p.Err(begin, buffer, "Invalid namespace")} EOT
2021

parser/parser.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ const (
1717

1818
const (
1919
DOCKER = iota
20-
NETNS
20+
IPNETNS
2121
PID
22+
NETNS
2223
NSNONE
2324
)
2425

0 commit comments

Comments
 (0)