Skip to content

Commit

Permalink
add: compatible with switch
Browse files Browse the repository at this point in the history
  • Loading branch information
ak1ra24 committed Dec 13, 2019
1 parent 4ff9f37 commit 4baa6b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,13 @@ func S2nLink(nodeName string, inf Interface) []string {

nodeinf := inf.Name
peerBr := inf.Args
peerBr = fmt.Sprintf("%s-%s", peerBr, nodeName)
s2nLinkCmd := fmt.Sprintf("ip link add %s netns %s type veth peer name %s", nodeinf, nodeName, peerBr)
peerBrInf := fmt.Sprintf("%s-%s", peerBr, nodeName)
s2nLinkCmd := fmt.Sprintf("ip link add %s netns %s type veth peer name %s", nodeinf, nodeName, peerBrInf)
s2nLinkCmds = append(s2nLinkCmds, s2nLinkCmd)
s2nLinkCmds = append(s2nLinkCmds, NetnsLinkUp(nodeName, nodeinf))
s2nLinkCmds = append(s2nLinkCmds, HostLinkUp(peerBr))
s2nLinkCmds = append(s2nLinkCmds, HostLinkUp(peerBrInf))
setBrLinkCmd := fmt.Sprintf("ip link set dev %s master %s", peerBrInf, peerBr)
s2nLinkCmds = append(s2nLinkCmds, setBrLinkCmd)

return s2nLinkCmds
}
Expand Down
2 changes: 1 addition & 1 deletion shell/shell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ func TestS2nLink(t *testing.T) {
Args: "SW",
},
},
want: []string{"ip link add net0 netns R1 type veth peer name SW-R1", "ip netns exec R1 ip link set net0 up", "ip link set SW-R1 up"},
want: []string{"ip link add net0 netns R1 type veth peer name SW-R1", "ip netns exec R1 ip link set net0 up", "ip link set SW-R1 up", "ip link set dev SW-R1 master SW"},
},
}
for _, tt := range tests {
Expand Down

0 comments on commit 4baa6b6

Please sign in to comment.