MCPcopy Index your code
hub / github.com/coder/coder / createVethPair

Function createVethPair

tailnet/test/integration/network.go:687–704  ·  view source on GitHub ↗

createVethPair creates a veth pair with the given names.

(parentVethName, peerVethName string, options ...linkOption)

Source from the content-addressed store, hash-verified

685
686// createVethPair creates a veth pair with the given names.
687func createVethPair(parentVethName, peerVethName string, options ...linkOption) error {
688 linkAttrs := netlink.NewLinkAttrs()
689 linkAttrs.Name = parentVethName
690 for _, option := range options {
691 linkAttrs = option(linkAttrs)
692 }
693 veth := &netlink.Veth{
694 LinkAttrs: linkAttrs,
695 PeerName: peerVethName,
696 }
697
698 err := netlink.LinkAdd(veth)
699 if err != nil {
700 return xerrors.Errorf("LinkAdd(type: veth, name: %q, peerName: %q): %w", parentVethName, peerVethName, err)
701 }
702
703 return nil
704}
705
706// setVethNetNS moves the veth interface to the specified network namespace.
707func setVethNetNS(vethName string, netNSFd int) error {

Callers 3

createFakeInternetFunction · 0.85
SetupNetworkingMethod · 0.85
joinBridgeFunction · 0.85

Calls 1

ErrorfMethod · 0.45

Tested by

no test coverage detected