diff --git a/runsc/sandbox/BUILD b/runsc/sandbox/BUILD index a43c8418d..5cea466e7 100644 --- a/runsc/sandbox/BUILD +++ b/runsc/sandbox/BUILD @@ -11,6 +11,7 @@ go_library( "memory.go", "network.go", "network_unsafe.go", + "no_xdp.go", "sandbox.go", "sandbox_impl.go", "xdp.go", diff --git a/runsc/sandbox/no_xdp.go b/runsc/sandbox/no_xdp.go new file mode 100644 index 000000000..04f3cf952 --- /dev/null +++ b/runsc/sandbox/no_xdp.go @@ -0,0 +1,45 @@ +// Copyright 2024 The gVisor Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !xdp +// +build !xdp + +package sandbox + +import ( + "errors" + "net" + "os" + + "gvisor.dev/gvisor/pkg/urpc" + "gvisor.dev/gvisor/runsc/config" +) + +// This file holds placeholders for XDP support, which is not compiled in by default. +// +// To enable XDP support, build gVisor with `--define=gotags=xdp`. + +const noXDPMsg = "XDP support was not built into this release -- rebuild with --define=gotags=xdp" + +func createRedirectInterfacesAndRoutes(conn *urpc.Client, conf *config.Config) error { + return errors.New(noXDPMsg) +} + +func createSocketXDP(iface net.Interface) ([]*os.File, error) { + return nil, errors.New(noXDPMsg) +} + +func createXDPTunnel(conn *urpc.Client, nsPath string, conf *config.Config) error { + return errors.New(noXDPMsg) +} diff --git a/runsc/sandbox/xdp.go b/runsc/sandbox/xdp.go index b66ee46aa..c6c09410a 100644 --- a/runsc/sandbox/xdp.go +++ b/runsc/sandbox/xdp.go @@ -12,6 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. +//go:build xdp +// +build xdp + package sandbox import ( @@ -34,6 +37,10 @@ import ( xdpcmd "gvisor.dev/gvisor/tools/xdp/cmd" ) +// This file supports XDP in gVisor. It is not compiled in by default. +// +// To enable XDP support, build gVisor with `--define=gotags=xdp`. + // createRedirectInterfacesAndRoutes initializes the network using an AF_XDP // socket on a *host* device, not a device in the container netns. It: //