gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/tools/xdp/main.go (about) 1 // Copyright 2022 The gVisor Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 //go:build amd64 || arm64 16 // +build amd64 arm64 17 18 // The xdp_loader tool is used to load compiled XDP object files into the XDP 19 // hook of a net device. It is intended primarily for testing. 20 package main 21 22 import ( 23 "context" 24 _ "embed" 25 "os" 26 27 "github.com/google/subcommands" 28 "gvisor.dev/gvisor/runsc/flag" 29 "gvisor.dev/gvisor/tools/xdp/cmd" 30 ) 31 32 func main() { 33 subcommands.Register(new(cmd.DropCommand), "") 34 subcommands.Register(new(cmd.PassCommand), "") 35 subcommands.Register(new(cmd.RedirectHostCommand), "") 36 subcommands.Register(new(cmd.TcpdumpCommand), "") 37 subcommands.Register(new(cmd.TunnelCommand), "") 38 39 flag.Parse() 40 ctx := context.Background() 41 os.Exit(int(subcommands.Execute(ctx))) 42 }