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

Function createBridge

tailnet/test/integration/network.go:649–664  ·  view source on GitHub ↗

createBridge creates a bridge in the given network namespace. The bridge is automatically brought up.

(netNS *os.File, name string)

Source from the content-addressed store, hash-verified

647// createBridge creates a bridge in the given network namespace. The bridge is
648// automatically brought up.
649func createBridge(netNS *os.File, name string) error {
650 // While it might be possible to create a bridge directly in a NetNS or move
651 // an existing bridge to a NetNS, I couldn't figure out a way to do it.
652 // Creating it directly within the NetNS is the simplest way.
653 _, err := commandInNetNS(netNS, "ip", []string{"link", "add", name, "type", "bridge"}).Output()
654 if err != nil {
655 return xerrors.Errorf("create bridge %q in netns: %w", name, wrapExitErr(err))
656 }
657
658 _, err = commandInNetNS(netNS, "ip", []string{"link", "set", name, "up"}).Output()
659 if err != nil {
660 return xerrors.Errorf("set bridge %q up in netns: %w", name, wrapExitErr(err))
661 }
662
663 return nil
664}
665
666// setInterfaceBridge sets the master of the given interface to the specified
667// bridge.

Callers 1

createFakeInternetFunction · 0.85

Calls 4

commandInNetNSFunction · 0.85
wrapExitErrFunction · 0.85
OutputMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected