├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── bpf-map.go ├── kv.go ├── vendor.conf └── vendor ├── github.com ├── Sirupsen │ └── logrus │ │ ├── LICENSE │ │ ├── README.md │ │ ├── doc.go │ │ ├── entry.go │ │ ├── exported.go │ │ ├── formatter.go │ │ ├── hooks.go │ │ ├── json_formatter.go │ │ ├── logger.go │ │ ├── logrus.go │ │ ├── terminal_bsd.go │ │ ├── terminal_linux.go │ │ ├── terminal_notwindows.go │ │ ├── terminal_solaris.go │ │ ├── terminal_windows.go │ │ ├── text_formatter.go │ │ └── writer.go ├── cilium │ └── cilium │ │ ├── LICENSE │ │ ├── README.md │ │ ├── bpf │ │ ├── COPYING │ │ ├── bpf_features.h │ │ ├── bpf_lb.c │ │ ├── bpf_lxc.c │ │ ├── bpf_netdev.c │ │ ├── bpf_overlay.c │ │ ├── include │ │ │ ├── bpf │ │ │ │ └── api.h │ │ │ ├── iproute2 │ │ │ │ └── bpf_elf.h │ │ │ └── linux │ │ │ │ ├── bpf.h │ │ │ │ ├── bpf_common.h │ │ │ │ ├── byteorder.h │ │ │ │ ├── byteorder │ │ │ │ ├── big_endian.h │ │ │ │ └── little_endian.h │ │ │ │ ├── icmp.h │ │ │ │ ├── icmpv6.h │ │ │ │ ├── if_arp.h │ │ │ │ ├── if_ether.h │ │ │ │ ├── in.h │ │ │ │ ├── in6.h │ │ │ │ ├── ioctl.h │ │ │ │ ├── ip.h │ │ │ │ ├── ipv6.h │ │ │ │ ├── perf_event.h │ │ │ │ ├── swab.h │ │ │ │ ├── tcp.h │ │ │ │ ├── type_mapper.h │ │ │ │ └── udp.h │ │ ├── lib │ │ │ ├── arp.h │ │ │ ├── common.h │ │ │ ├── conntrack.h │ │ │ ├── csum.h │ │ │ ├── dbg.h │ │ │ ├── drop.h │ │ │ ├── encap.h │ │ │ ├── eth.h │ │ │ ├── events.h │ │ │ ├── geneve.h │ │ │ ├── icmp6.h │ │ │ ├── ipv4.h │ │ │ ├── ipv6.h │ │ │ ├── l3.h │ │ │ ├── l4.h │ │ │ ├── lb.h │ │ │ ├── lxc.h │ │ │ ├── maps.h │ │ │ ├── nat46.h │ │ │ ├── policy.h │ │ │ └── utils.h │ │ ├── lxc_config.h │ │ ├── netdev_config.h │ │ ├── node_config.h │ │ └── probes │ │ │ ├── raw_insn.h │ │ │ └── raw_main.c │ │ ├── common │ │ └── tests │ │ │ ├── bpf-event-test.c │ │ │ ├── event.h │ │ │ └── perf-event-test.go │ │ ├── pkg │ │ └── bpf │ │ │ ├── bpf.go │ │ │ ├── bpffs.go │ │ │ ├── map.go │ │ │ ├── perf.go │ │ │ └── prog.go │ │ └── vendor.conf └── urfave │ └── cli │ ├── LICENSE │ ├── README.md │ ├── app.go │ ├── category.go │ ├── cli.go │ ├── command.go │ ├── context.go │ ├── errors.go │ ├── flag.go │ ├── flag_generated.go │ ├── funcs.go │ └── help.go └── golang.org └── x └── sys ├── LICENSE ├── PATENTS ├── README └── unix ├── README.md ├── asm_darwin_386.s ├── asm_darwin_amd64.s ├── asm_darwin_arm.s ├── asm_darwin_arm64.s ├── asm_dragonfly_amd64.s ├── asm_freebsd_386.s ├── asm_freebsd_amd64.s ├── asm_freebsd_arm.s ├── asm_linux_386.s ├── asm_linux_amd64.s ├── asm_linux_arm.s ├── asm_linux_arm64.s ├── asm_linux_mips64x.s ├── asm_linux_mipsx.s ├── asm_linux_ppc64x.s ├── asm_linux_s390x.s ├── asm_netbsd_386.s ├── asm_netbsd_amd64.s ├── asm_netbsd_arm.s ├── asm_openbsd_386.s ├── asm_openbsd_amd64.s ├── asm_solaris_amd64.s ├── bluetooth_linux.go ├── cap_freebsd.go ├── constants.go ├── dev_linux.go ├── dirent.go ├── endian_big.go ├── endian_little.go ├── env_unix.go ├── env_unset.go ├── errors_freebsd_386.go ├── errors_freebsd_amd64.go ├── file_unix.go ├── flock.go ├── flock_linux_32bit.go ├── gccgo.go ├── gccgo_c.c ├── gccgo_linux_amd64.go ├── gccgo_linux_sparc64.go ├── openbsd_pledge.go ├── race.go ├── race0.go ├── sockcmsg_linux.go ├── sockcmsg_unix.go ├── str.go ├── syscall.go ├── syscall_bsd.go ├── syscall_darwin.go ├── syscall_darwin_386.go ├── syscall_darwin_amd64.go ├── syscall_darwin_arm.go ├── syscall_darwin_arm64.go ├── syscall_dragonfly.go ├── syscall_dragonfly_amd64.go ├── syscall_freebsd.go ├── syscall_freebsd_386.go ├── syscall_freebsd_amd64.go ├── syscall_freebsd_arm.go ├── syscall_linux.go ├── syscall_linux_386.go ├── syscall_linux_amd64.go ├── syscall_linux_amd64_gc.go ├── syscall_linux_arm.go ├── syscall_linux_arm64.go ├── syscall_linux_mips64x.go ├── syscall_linux_mipsx.go ├── syscall_linux_ppc64x.go ├── syscall_linux_s390x.go ├── syscall_linux_sparc64.go ├── syscall_netbsd.go ├── syscall_netbsd_386.go ├── syscall_netbsd_amd64.go ├── syscall_netbsd_arm.go ├── syscall_no_getwd.go ├── syscall_openbsd.go ├── syscall_openbsd_386.go ├── syscall_openbsd_amd64.go ├── syscall_solaris.go ├── syscall_solaris_amd64.go ├── syscall_unix.go ├── syscall_unix_gc.go ├── zerrors_darwin_386.go ├── zerrors_darwin_amd64.go ├── zerrors_darwin_arm.go ├── zerrors_darwin_arm64.go ├── zerrors_dragonfly_amd64.go ├── zerrors_freebsd_386.go ├── zerrors_freebsd_amd64.go ├── zerrors_freebsd_arm.go ├── zerrors_linux_386.go ├── zerrors_linux_amd64.go ├── zerrors_linux_arm.go ├── zerrors_linux_arm64.go ├── zerrors_linux_mips.go ├── zerrors_linux_mips64.go ├── zerrors_linux_mips64le.go ├── zerrors_linux_mipsle.go ├── zerrors_linux_ppc64.go ├── zerrors_linux_ppc64le.go ├── zerrors_linux_s390x.go ├── zerrors_linux_sparc64.go ├── zerrors_netbsd_386.go ├── zerrors_netbsd_amd64.go ├── zerrors_netbsd_arm.go ├── zerrors_openbsd_386.go ├── zerrors_openbsd_amd64.go ├── zerrors_solaris_amd64.go ├── zsyscall_darwin_386.go ├── zsyscall_darwin_amd64.go ├── zsyscall_darwin_arm.go ├── zsyscall_darwin_arm64.go ├── zsyscall_dragonfly_amd64.go ├── zsyscall_freebsd_386.go ├── zsyscall_freebsd_amd64.go ├── zsyscall_freebsd_arm.go ├── zsyscall_linux_386.go ├── zsyscall_linux_amd64.go ├── zsyscall_linux_arm.go ├── zsyscall_linux_arm64.go ├── zsyscall_linux_mips.go ├── zsyscall_linux_mips64.go ├── zsyscall_linux_mips64le.go ├── zsyscall_linux_mipsle.go ├── zsyscall_linux_ppc64.go ├── zsyscall_linux_ppc64le.go ├── zsyscall_linux_s390x.go ├── zsyscall_linux_sparc64.go ├── zsyscall_netbsd_386.go ├── zsyscall_netbsd_amd64.go ├── zsyscall_netbsd_arm.go ├── zsyscall_openbsd_386.go ├── zsyscall_openbsd_amd64.go ├── zsyscall_solaris_amd64.go ├── zsysctl_openbsd.go ├── zsysnum_darwin_386.go ├── zsysnum_darwin_amd64.go ├── zsysnum_darwin_arm.go ├── zsysnum_darwin_arm64.go ├── zsysnum_dragonfly_amd64.go ├── zsysnum_freebsd_386.go ├── zsysnum_freebsd_amd64.go ├── zsysnum_freebsd_arm.go ├── zsysnum_linux_386.go ├── zsysnum_linux_amd64.go ├── zsysnum_linux_arm.go ├── zsysnum_linux_arm64.go ├── zsysnum_linux_mips.go ├── zsysnum_linux_mips64.go ├── zsysnum_linux_mips64le.go ├── zsysnum_linux_mipsle.go ├── zsysnum_linux_ppc64.go ├── zsysnum_linux_ppc64le.go ├── zsysnum_linux_s390x.go ├── zsysnum_linux_sparc64.go ├── zsysnum_netbsd_386.go ├── zsysnum_netbsd_amd64.go ├── zsysnum_netbsd_arm.go ├── zsysnum_openbsd_386.go ├── zsysnum_openbsd_amd64.go ├── zsysnum_solaris_amd64.go ├── ztypes_darwin_386.go ├── ztypes_darwin_amd64.go ├── ztypes_darwin_arm.go ├── ztypes_darwin_arm64.go ├── ztypes_dragonfly_amd64.go ├── ztypes_freebsd_386.go ├── ztypes_freebsd_amd64.go ├── ztypes_freebsd_arm.go ├── ztypes_linux_386.go ├── ztypes_linux_amd64.go ├── ztypes_linux_arm.go ├── ztypes_linux_arm64.go ├── ztypes_linux_mips.go ├── ztypes_linux_mips64.go ├── ztypes_linux_mips64le.go ├── ztypes_linux_mipsle.go ├── ztypes_linux_ppc64.go ├── ztypes_linux_ppc64le.go ├── ztypes_linux_s390x.go ├── ztypes_linux_sparc64.go ├── ztypes_netbsd_386.go ├── ztypes_netbsd_amd64.go ├── ztypes_netbsd_arm.go ├── ztypes_openbsd_386.go ├── ztypes_openbsd_amd64.go └── ztypes_solaris_amd64.go /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | 26 | bpf-map 27 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: bpf-map 2 | 3 | SOURCES := $(shell find . -name '*.go') 4 | 5 | bpf-map: bpf-map.go 6 | go build 7 | 8 | clean: 9 | go clean 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bpf-map 2 | 3 | **Archived:** This tool has been superseded by bpftool. 4 | 5 | A small tool to generically introspect BPF maps without requiring to be aware 6 | of the specific data structures stored inside. Can print the metadata of the 7 | map or its contents in hexadecimal form. 8 | 9 | ## Install 10 | 11 | Install from source via `go get`: 12 | 13 | ``` 14 | go get github.com/cilium/bpf-map 15 | ``` 16 | 17 | Download the binary release: 18 | 19 | ``` 20 | curl -SsL https://github.com/cilium/bpf-map/releases/download/v1.0/bpf-map -o bpf-map 21 | chmod +x bpf-map 22 | ``` 23 | 24 | ## Usage 25 | 26 | ``` 27 | $ bpf-map dump /sys/fs/bpf/tc/globals/path/map 28 | ``` 29 | 30 | ## Example 31 | 32 | ``` 33 | $ sudo bpf-map info /sys/fs/bpf/tc/globals/cilium_lxc 34 | Type: Hash 35 | Key size: 4 36 | Value size: 104 37 | Max entries: 1024 38 | Flags: 0x0 39 | 40 | $ sudo bpf-map dump /sys/fs/bpf/tc/globals/cilium_lxc 41 | Key: 42 | 00000000 e8 f7 01 00 |....| 43 | Value: 44 | 00000000 11 00 00 00 01 02 ca 74 0e c4 d8 25 33 18 00 00 |.......t...%3...| 45 | 00000010 1a 19 4b e1 ed 4b 00 00 f0 0d 00 00 00 00 00 00 |..K..K..........| 46 | 00000020 c0 a8 21 0b 00 00 74 ca 00 00 00 00 00 00 00 00 |..!...t.........| 47 | 00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 48 | 00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 49 | 00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 50 | 00000060 00 00 00 00 00 00 00 00 |........| 51 | 52 | Key: 53 | 00000000 ee 1c 01 00 |....| 54 | Value: 55 | 00000000 0f 00 00 00 01 01 d6 8a 4e 9b 9d a5 57 d5 00 00 |........N...W...| 56 | 00000010 ba 58 00 80 b9 c1 00 00 f0 0d 00 00 00 00 00 00 |.X..............| 57 | 00000020 c0 a8 21 0b 00 00 8a d6 00 00 00 00 00 00 00 00 |..!.............| 58 | 00000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 59 | 00000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 60 | 00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 61 | 00000060 00 00 00 00 00 00 00 00 |........| 62 | [...] 63 | ``` 64 | -------------------------------------------------------------------------------- /bpf-map.go: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016 Authors of Cilium 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package main 17 | 18 | import ( 19 | "encoding/hex" 20 | "fmt" 21 | "os" 22 | 23 | "github.com/cilium/cilium/pkg/bpf" 24 | "github.com/urfave/cli" 25 | ) 26 | 27 | func main() { 28 | app := cli.NewApp() 29 | app.Name = "bpf-map" 30 | app.Usage = "Generic tool to introspect BPF maps" 31 | app.UsageText = "bpf-map { dump | info | update | remove } " 32 | app.Version = "1.0" 33 | app.Commands = []cli.Command{ 34 | { 35 | Name: "dump", 36 | Aliases: []string{"d"}, 37 | Usage: "Dump contents of map", 38 | ArgsUsage: "", 39 | Action: dumpMap, 40 | }, 41 | { 42 | Name: "info", 43 | Aliases: []string{"i"}, 44 | Usage: "Print metadata information of map", 45 | ArgsUsage: "", 46 | Action: infoMap, 47 | }, 48 | { 49 | Name: "update", 50 | Aliases: []string{"u"}, 51 | Usage: "Update a map entry with keys and values in hex", 52 | ArgsUsage: " ", 53 | Action: updateMap, 54 | }, 55 | { 56 | Name: "remove", 57 | Aliases: []string{"r"}, 58 | Usage: "Remove a map entry (key in hex)", 59 | ArgsUsage: " ", 60 | Action: deleteKey, 61 | }, 62 | } 63 | 64 | app.Run(os.Args) 65 | } 66 | 67 | func dumpMap(ctx *cli.Context) { 68 | if len(ctx.Args()) < 1 { 69 | cli.ShowCommandHelp(ctx, "dump") 70 | os.Exit(1) 71 | } 72 | 73 | path := ctx.Args().Get(0) 74 | m, err := bpf.OpenMap(path) 75 | if err != nil { 76 | fmt.Fprintf(os.Stderr, "Unable to open map %s: %s\n", path, err) 77 | os.Exit(1) 78 | } 79 | 80 | dumpit := func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) { 81 | fmt.Printf("Key:\n%sValue:\n%s\n", hex.Dump(key), hex.Dump(value)) 82 | return nil, nil, nil 83 | } 84 | 85 | err = m.Dump(dumpit, nil) 86 | if err != nil { 87 | fmt.Fprintf(os.Stderr, "Unable to dump map %s: %s\n", path, err) 88 | os.Exit(1) 89 | } 90 | } 91 | 92 | func infoMap(ctx *cli.Context) { 93 | if len(ctx.Args()) < 1 { 94 | cli.ShowCommandHelp(ctx, "info") 95 | os.Exit(1) 96 | } 97 | 98 | path := ctx.Args().Get(0) 99 | m, err := bpf.OpenMap(path) 100 | if err != nil { 101 | fmt.Fprintf(os.Stderr, "Unable to open map %s: %s\n", path, err) 102 | os.Exit(1) 103 | } 104 | 105 | fmt.Printf("Type:\t\t%s\nKey size:\t%d\nValue size:\t%d\nMax entries:\t%d\nFlags:\t\t%#x\n", 106 | m.MapType.String(), m.KeySize, m.ValueSize, m.MaxEntries, m.Flags) 107 | 108 | fmt.Printf("Owner prog type:\t%s\n", m.OwnerProgType.String()) 109 | } 110 | 111 | func updateMap(ctx *cli.Context) { 112 | if len(ctx.Args()) < 3 { 113 | cli.ShowCommandHelp(ctx, "update") 114 | os.Exit(1) 115 | } 116 | 117 | path := ctx.Args().Get(0) 118 | m, err := bpf.OpenMap(path) 119 | if err != nil { 120 | fmt.Fprintf(os.Stderr, "Unable to open map %s: %s\n", path, err) 121 | os.Exit(1) 122 | } 123 | 124 | key, err := newByteValue(ctx.Args().Get(1), m.KeySize, m.ValueSize) 125 | if err != nil { 126 | fmt.Fprintf(os.Stderr, "Invalid key: %s\n", err) 127 | os.Exit(1) 128 | } 129 | 130 | value, err := newByteValue(ctx.Args().Get(2), m.ValueSize, m.ValueSize) 131 | if err != nil { 132 | fmt.Fprintf(os.Stderr, "Invalid value: %s\n", err) 133 | os.Exit(1) 134 | } 135 | 136 | if err := m.Update(key, value); err != nil { 137 | fmt.Fprintf(os.Stderr, "Unable to set key: %s\n", err) 138 | os.Exit(1) 139 | } else { 140 | fmt.Println("Updated") 141 | } 142 | } 143 | 144 | func deleteKey(ctx *cli.Context) { 145 | if len(ctx.Args()) < 2 { 146 | cli.ShowCommandHelp(ctx, "remove") 147 | os.Exit(1) 148 | } 149 | 150 | path := ctx.Args().Get(0) 151 | m, err := bpf.OpenMap(path) 152 | if err != nil { 153 | fmt.Fprintf(os.Stderr, "Unable to open map %s: %s\n", path, err) 154 | os.Exit(1) 155 | } 156 | 157 | key, err := newByteValue(ctx.Args().Get(1), m.KeySize, m.ValueSize) 158 | if err != nil { 159 | fmt.Fprintf(os.Stderr, "Invalid key: %s\n", err) 160 | os.Exit(1) 161 | } 162 | 163 | if err := m.Delete(key); err != nil { 164 | fmt.Fprintf(os.Stderr, "Unable to remove key: %s\n", err) 165 | os.Exit(1) 166 | } else { 167 | fmt.Println("Removed") 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /kv.go: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2016 Authors of Cilium 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | // 16 | package main 17 | 18 | import ( 19 | "encoding/hex" 20 | "fmt" 21 | "unsafe" 22 | 23 | "github.com/cilium/cilium/pkg/bpf" 24 | ) 25 | 26 | // Helper that parses and stores map keys/values 27 | type byteValue struct { 28 | data []byte 29 | 30 | // Size of related values (so not necessarily the size of the data) 31 | size uint32 32 | } 33 | 34 | func newByteValue(s string, expected, sz uint32) (byteValue, error) { 35 | b, err := hex.DecodeString(s) 36 | if err == nil && uint32(len(b)) != expected { 37 | err = fmt.Errorf("Expected length %v, not %v", expected, len(b)) 38 | } 39 | return byteValue{b, sz}, err 40 | } 41 | 42 | func (b byteValue) NewValue() bpf.MapValue { 43 | return byteValue{make([]byte, b.size), b.size} 44 | } 45 | 46 | func (b byteValue) GetKeyPtr() unsafe.Pointer { 47 | return b.GetValuePtr() 48 | } 49 | 50 | func (b byteValue) GetValuePtr() unsafe.Pointer { 51 | return unsafe.Pointer(&b.data[0]) 52 | } 53 | -------------------------------------------------------------------------------- /vendor.conf: -------------------------------------------------------------------------------- 1 | github.com/Sirupsen/logrus v0.9.0 2 | github.com/cilium/cilium a79f2eaf285fbdfa05f686aaa694a772b6d9319b 3 | github.com/urfave/cli 0bdeddeeb0f650497d603c4ad7b20cfe685682f6 4 | golang.org/x/sys d8f5ea21b9295e315e612b4bcf4bedea93454d4 5 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Simon Eskildsen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package logrus is a structured logger for Go, completely API compatible with the standard library logger. 3 | 4 | 5 | The simplest way to use Logrus is simply the package-level exported logger: 6 | 7 | package main 8 | 9 | import ( 10 | log "github.com/Sirupsen/logrus" 11 | ) 12 | 13 | func main() { 14 | log.WithFields(log.Fields{ 15 | "animal": "walrus", 16 | "number": 1, 17 | "size": 10, 18 | }).Info("A walrus appears") 19 | } 20 | 21 | Output: 22 | time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10 23 | 24 | For a full guide visit https://github.com/Sirupsen/logrus 25 | */ 26 | package logrus 27 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/exported.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "io" 5 | ) 6 | 7 | var ( 8 | // std is the name of the standard logger in stdlib `log` 9 | std = New() 10 | ) 11 | 12 | func StandardLogger() *Logger { 13 | return std 14 | } 15 | 16 | // SetOutput sets the standard logger output. 17 | func SetOutput(out io.Writer) { 18 | std.mu.Lock() 19 | defer std.mu.Unlock() 20 | std.Out = out 21 | } 22 | 23 | // SetFormatter sets the standard logger formatter. 24 | func SetFormatter(formatter Formatter) { 25 | std.mu.Lock() 26 | defer std.mu.Unlock() 27 | std.Formatter = formatter 28 | } 29 | 30 | // SetLevel sets the standard logger level. 31 | func SetLevel(level Level) { 32 | std.mu.Lock() 33 | defer std.mu.Unlock() 34 | std.Level = level 35 | } 36 | 37 | // GetLevel returns the standard logger level. 38 | func GetLevel() Level { 39 | std.mu.Lock() 40 | defer std.mu.Unlock() 41 | return std.Level 42 | } 43 | 44 | // AddHook adds a hook to the standard logger hooks. 45 | func AddHook(hook Hook) { 46 | std.mu.Lock() 47 | defer std.mu.Unlock() 48 | std.Hooks.Add(hook) 49 | } 50 | 51 | // WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key. 52 | func WithError(err error) *Entry { 53 | return std.WithField(ErrorKey, err) 54 | } 55 | 56 | // WithField creates an entry from the standard logger and adds a field to 57 | // it. If you want multiple fields, use `WithFields`. 58 | // 59 | // Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal 60 | // or Panic on the Entry it returns. 61 | func WithField(key string, value interface{}) *Entry { 62 | return std.WithField(key, value) 63 | } 64 | 65 | // WithFields creates an entry from the standard logger and adds multiple 66 | // fields to it. This is simply a helper for `WithField`, invoking it 67 | // once for each field. 68 | // 69 | // Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal 70 | // or Panic on the Entry it returns. 71 | func WithFields(fields Fields) *Entry { 72 | return std.WithFields(fields) 73 | } 74 | 75 | // Debug logs a message at level Debug on the standard logger. 76 | func Debug(args ...interface{}) { 77 | std.Debug(args...) 78 | } 79 | 80 | // Print logs a message at level Info on the standard logger. 81 | func Print(args ...interface{}) { 82 | std.Print(args...) 83 | } 84 | 85 | // Info logs a message at level Info on the standard logger. 86 | func Info(args ...interface{}) { 87 | std.Info(args...) 88 | } 89 | 90 | // Warn logs a message at level Warn on the standard logger. 91 | func Warn(args ...interface{}) { 92 | std.Warn(args...) 93 | } 94 | 95 | // Warning logs a message at level Warn on the standard logger. 96 | func Warning(args ...interface{}) { 97 | std.Warning(args...) 98 | } 99 | 100 | // Error logs a message at level Error on the standard logger. 101 | func Error(args ...interface{}) { 102 | std.Error(args...) 103 | } 104 | 105 | // Panic logs a message at level Panic on the standard logger. 106 | func Panic(args ...interface{}) { 107 | std.Panic(args...) 108 | } 109 | 110 | // Fatal logs a message at level Fatal on the standard logger. 111 | func Fatal(args ...interface{}) { 112 | std.Fatal(args...) 113 | } 114 | 115 | // Debugf logs a message at level Debug on the standard logger. 116 | func Debugf(format string, args ...interface{}) { 117 | std.Debugf(format, args...) 118 | } 119 | 120 | // Printf logs a message at level Info on the standard logger. 121 | func Printf(format string, args ...interface{}) { 122 | std.Printf(format, args...) 123 | } 124 | 125 | // Infof logs a message at level Info on the standard logger. 126 | func Infof(format string, args ...interface{}) { 127 | std.Infof(format, args...) 128 | } 129 | 130 | // Warnf logs a message at level Warn on the standard logger. 131 | func Warnf(format string, args ...interface{}) { 132 | std.Warnf(format, args...) 133 | } 134 | 135 | // Warningf logs a message at level Warn on the standard logger. 136 | func Warningf(format string, args ...interface{}) { 137 | std.Warningf(format, args...) 138 | } 139 | 140 | // Errorf logs a message at level Error on the standard logger. 141 | func Errorf(format string, args ...interface{}) { 142 | std.Errorf(format, args...) 143 | } 144 | 145 | // Panicf logs a message at level Panic on the standard logger. 146 | func Panicf(format string, args ...interface{}) { 147 | std.Panicf(format, args...) 148 | } 149 | 150 | // Fatalf logs a message at level Fatal on the standard logger. 151 | func Fatalf(format string, args ...interface{}) { 152 | std.Fatalf(format, args...) 153 | } 154 | 155 | // Debugln logs a message at level Debug on the standard logger. 156 | func Debugln(args ...interface{}) { 157 | std.Debugln(args...) 158 | } 159 | 160 | // Println logs a message at level Info on the standard logger. 161 | func Println(args ...interface{}) { 162 | std.Println(args...) 163 | } 164 | 165 | // Infoln logs a message at level Info on the standard logger. 166 | func Infoln(args ...interface{}) { 167 | std.Infoln(args...) 168 | } 169 | 170 | // Warnln logs a message at level Warn on the standard logger. 171 | func Warnln(args ...interface{}) { 172 | std.Warnln(args...) 173 | } 174 | 175 | // Warningln logs a message at level Warn on the standard logger. 176 | func Warningln(args ...interface{}) { 177 | std.Warningln(args...) 178 | } 179 | 180 | // Errorln logs a message at level Error on the standard logger. 181 | func Errorln(args ...interface{}) { 182 | std.Errorln(args...) 183 | } 184 | 185 | // Panicln logs a message at level Panic on the standard logger. 186 | func Panicln(args ...interface{}) { 187 | std.Panicln(args...) 188 | } 189 | 190 | // Fatalln logs a message at level Fatal on the standard logger. 191 | func Fatalln(args ...interface{}) { 192 | std.Fatalln(args...) 193 | } 194 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import "time" 4 | 5 | const DefaultTimestampFormat = time.RFC3339 6 | 7 | // The Formatter interface is used to implement a custom Formatter. It takes an 8 | // `Entry`. It exposes all the fields, including the default ones: 9 | // 10 | // * `entry.Data["msg"]`. The message passed from Info, Warn, Error .. 11 | // * `entry.Data["time"]`. The timestamp. 12 | // * `entry.Data["level"]. The level the entry was logged at. 13 | // 14 | // Any additional fields added with `WithField` or `WithFields` are also in 15 | // `entry.Data`. Format is expected to return an array of bytes which are then 16 | // logged to `logger.Out`. 17 | type Formatter interface { 18 | Format(*Entry) ([]byte, error) 19 | } 20 | 21 | // This is to not silently overwrite `time`, `msg` and `level` fields when 22 | // dumping it. If this code wasn't there doing: 23 | // 24 | // logrus.WithField("level", 1).Info("hello") 25 | // 26 | // Would just silently drop the user provided level. Instead with this code 27 | // it'll logged as: 28 | // 29 | // {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."} 30 | // 31 | // It's not exported because it's still using Data in an opinionated way. It's to 32 | // avoid code duplication between the two default formatters. 33 | func prefixFieldClashes(data Fields) { 34 | _, ok := data["time"] 35 | if ok { 36 | data["fields.time"] = data["time"] 37 | } 38 | 39 | _, ok = data["msg"] 40 | if ok { 41 | data["fields.msg"] = data["msg"] 42 | } 43 | 44 | _, ok = data["level"] 45 | if ok { 46 | data["fields.level"] = data["level"] 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | // A hook to be fired when logging on the logging levels returned from 4 | // `Levels()` on your implementation of the interface. Note that this is not 5 | // fired in a goroutine or a channel with workers, you should handle such 6 | // functionality yourself if your call is non-blocking and you don't wish for 7 | // the logging calls for levels returned from `Levels()` to block. 8 | type Hook interface { 9 | Levels() []Level 10 | Fire(*Entry) error 11 | } 12 | 13 | // Internal type for storing the hooks on a logger instance. 14 | type LevelHooks map[Level][]Hook 15 | 16 | // Add a hook to an instance of logger. This is called with 17 | // `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface. 18 | func (hooks LevelHooks) Add(hook Hook) { 19 | for _, level := range hook.Levels() { 20 | hooks[level] = append(hooks[level], hook) 21 | } 22 | } 23 | 24 | // Fire all the hooks for the passed level. Used by `entry.log` to fire 25 | // appropriate hooks for a log entry. 26 | func (hooks LevelHooks) Fire(level Level, entry *Entry) error { 27 | for _, hook := range hooks[level] { 28 | if err := hook.Fire(entry); err != nil { 29 | return err 30 | } 31 | } 32 | 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/json_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | ) 7 | 8 | type JSONFormatter struct { 9 | // TimestampFormat sets the format used for marshaling timestamps. 10 | TimestampFormat string 11 | } 12 | 13 | func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { 14 | data := make(Fields, len(entry.Data)+3) 15 | for k, v := range entry.Data { 16 | switch v := v.(type) { 17 | case error: 18 | // Otherwise errors are ignored by `encoding/json` 19 | // https://github.com/Sirupsen/logrus/issues/137 20 | data[k] = v.Error() 21 | default: 22 | data[k] = v 23 | } 24 | } 25 | prefixFieldClashes(data) 26 | 27 | timestampFormat := f.TimestampFormat 28 | if timestampFormat == "" { 29 | timestampFormat = DefaultTimestampFormat 30 | } 31 | 32 | data["time"] = entry.Time.Format(timestampFormat) 33 | data["msg"] = entry.Message 34 | data["level"] = entry.Level.String() 35 | 36 | serialized, err := json.Marshal(data) 37 | if err != nil { 38 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) 39 | } 40 | return append(serialized, '\n'), nil 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/logrus.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | ) 7 | 8 | // Fields type, used to pass to `WithFields`. 9 | type Fields map[string]interface{} 10 | 11 | // Level type 12 | type Level uint8 13 | 14 | // Convert the Level to a string. E.g. PanicLevel becomes "panic". 15 | func (level Level) String() string { 16 | switch level { 17 | case DebugLevel: 18 | return "debug" 19 | case InfoLevel: 20 | return "info" 21 | case WarnLevel: 22 | return "warning" 23 | case ErrorLevel: 24 | return "error" 25 | case FatalLevel: 26 | return "fatal" 27 | case PanicLevel: 28 | return "panic" 29 | } 30 | 31 | return "unknown" 32 | } 33 | 34 | // ParseLevel takes a string level and returns the Logrus log level constant. 35 | func ParseLevel(lvl string) (Level, error) { 36 | switch lvl { 37 | case "panic": 38 | return PanicLevel, nil 39 | case "fatal": 40 | return FatalLevel, nil 41 | case "error": 42 | return ErrorLevel, nil 43 | case "warn", "warning": 44 | return WarnLevel, nil 45 | case "info": 46 | return InfoLevel, nil 47 | case "debug": 48 | return DebugLevel, nil 49 | } 50 | 51 | var l Level 52 | return l, fmt.Errorf("not a valid logrus Level: %q", lvl) 53 | } 54 | 55 | // These are the different logging levels. You can set the logging level to log 56 | // on your instance of logger, obtained with `logrus.New()`. 57 | const ( 58 | // PanicLevel level, highest level of severity. Logs and then calls panic with the 59 | // message passed to Debug, Info, ... 60 | PanicLevel Level = iota 61 | // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the 62 | // logging level is set to Panic. 63 | FatalLevel 64 | // ErrorLevel level. Logs. Used for errors that should definitely be noted. 65 | // Commonly used for hooks to send errors to an error tracking service. 66 | ErrorLevel 67 | // WarnLevel level. Non-critical entries that deserve eyes. 68 | WarnLevel 69 | // InfoLevel level. General operational entries about what's going on inside the 70 | // application. 71 | InfoLevel 72 | // DebugLevel level. Usually only enabled when debugging. Very verbose logging. 73 | DebugLevel 74 | ) 75 | 76 | // Won't compile if StdLogger can't be realized by a log.Logger 77 | var ( 78 | _ StdLogger = &log.Logger{} 79 | _ StdLogger = &Entry{} 80 | _ StdLogger = &Logger{} 81 | ) 82 | 83 | // StdLogger is what your logrus-enabled library should take, that way 84 | // it'll accept a stdlib logger and a logrus logger. There's no standard 85 | // interface, this is the closest we get, unfortunately. 86 | type StdLogger interface { 87 | Print(...interface{}) 88 | Printf(string, ...interface{}) 89 | Println(...interface{}) 90 | 91 | Fatal(...interface{}) 92 | Fatalf(string, ...interface{}) 93 | Fatalln(...interface{}) 94 | 95 | Panic(...interface{}) 96 | Panicf(string, ...interface{}) 97 | Panicln(...interface{}) 98 | } 99 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | 3 | package logrus 4 | 5 | import "syscall" 6 | 7 | const ioctlReadTermios = syscall.TIOCGETA 8 | 9 | type Termios syscall.Termios 10 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_linux.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2013 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package logrus 7 | 8 | import "syscall" 9 | 10 | const ioctlReadTermios = syscall.TCGETS 11 | 12 | type Termios syscall.Termios 13 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_notwindows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build linux darwin freebsd openbsd netbsd dragonfly 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | // IsTerminal returns true if stderr's file descriptor is a terminal. 16 | func IsTerminal() bool { 17 | fd := syscall.Stderr 18 | var termios Termios 19 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 20 | return err == 0 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | 3 | package logrus 4 | 5 | import ( 6 | "os" 7 | 8 | "golang.org/x/sys/unix" 9 | ) 10 | 11 | // IsTerminal returns true if the given file descriptor is a terminal. 12 | func IsTerminal() bool { 13 | _, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA) 14 | return err == nil 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_windows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build windows 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 16 | 17 | var ( 18 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 19 | ) 20 | 21 | // IsTerminal returns true if stderr's file descriptor is a terminal. 22 | func IsTerminal() bool { 23 | fd := syscall.Stderr 24 | var st uint32 25 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 26 | return r != 0 && e == 0 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/text_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "runtime" 7 | "sort" 8 | "strings" 9 | "time" 10 | ) 11 | 12 | const ( 13 | nocolor = 0 14 | red = 31 15 | green = 32 16 | yellow = 33 17 | blue = 34 18 | gray = 37 19 | ) 20 | 21 | var ( 22 | baseTimestamp time.Time 23 | isTerminal bool 24 | ) 25 | 26 | func init() { 27 | baseTimestamp = time.Now() 28 | isTerminal = IsTerminal() 29 | } 30 | 31 | func miniTS() int { 32 | return int(time.Since(baseTimestamp) / time.Second) 33 | } 34 | 35 | type TextFormatter struct { 36 | // Set to true to bypass checking for a TTY before outputting colors. 37 | ForceColors bool 38 | 39 | // Force disabling colors. 40 | DisableColors bool 41 | 42 | // Disable timestamp logging. useful when output is redirected to logging 43 | // system that already adds timestamps. 44 | DisableTimestamp bool 45 | 46 | // Enable logging the full timestamp when a TTY is attached instead of just 47 | // the time passed since beginning of execution. 48 | FullTimestamp bool 49 | 50 | // TimestampFormat to use for display when a full timestamp is printed 51 | TimestampFormat string 52 | 53 | // The fields are sorted by default for a consistent output. For applications 54 | // that log extremely frequently and don't use the JSON formatter this may not 55 | // be desired. 56 | DisableSorting bool 57 | } 58 | 59 | func (f *TextFormatter) Format(entry *Entry) ([]byte, error) { 60 | var keys []string = make([]string, 0, len(entry.Data)) 61 | for k := range entry.Data { 62 | keys = append(keys, k) 63 | } 64 | 65 | if !f.DisableSorting { 66 | sort.Strings(keys) 67 | } 68 | 69 | b := &bytes.Buffer{} 70 | 71 | prefixFieldClashes(entry.Data) 72 | 73 | isColorTerminal := isTerminal && (runtime.GOOS != "windows") 74 | isColored := (f.ForceColors || isColorTerminal) && !f.DisableColors 75 | 76 | timestampFormat := f.TimestampFormat 77 | if timestampFormat == "" { 78 | timestampFormat = DefaultTimestampFormat 79 | } 80 | if isColored { 81 | f.printColored(b, entry, keys, timestampFormat) 82 | } else { 83 | if !f.DisableTimestamp { 84 | f.appendKeyValue(b, "time", entry.Time.Format(timestampFormat)) 85 | } 86 | f.appendKeyValue(b, "level", entry.Level.String()) 87 | if entry.Message != "" { 88 | f.appendKeyValue(b, "msg", entry.Message) 89 | } 90 | for _, key := range keys { 91 | f.appendKeyValue(b, key, entry.Data[key]) 92 | } 93 | } 94 | 95 | b.WriteByte('\n') 96 | return b.Bytes(), nil 97 | } 98 | 99 | func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []string, timestampFormat string) { 100 | var levelColor int 101 | switch entry.Level { 102 | case DebugLevel: 103 | levelColor = gray 104 | case WarnLevel: 105 | levelColor = yellow 106 | case ErrorLevel, FatalLevel, PanicLevel: 107 | levelColor = red 108 | default: 109 | levelColor = blue 110 | } 111 | 112 | levelText := strings.ToUpper(entry.Level.String())[0:4] 113 | 114 | if !f.FullTimestamp { 115 | fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, miniTS(), entry.Message) 116 | } else { 117 | fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %-44s ", levelColor, levelText, entry.Time.Format(timestampFormat), entry.Message) 118 | } 119 | for _, k := range keys { 120 | v := entry.Data[k] 121 | fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=%+v", levelColor, k, v) 122 | } 123 | } 124 | 125 | func needsQuoting(text string) bool { 126 | for _, ch := range text { 127 | if !((ch >= 'a' && ch <= 'z') || 128 | (ch >= 'A' && ch <= 'Z') || 129 | (ch >= '0' && ch <= '9') || 130 | ch == '-' || ch == '.') { 131 | return false 132 | } 133 | } 134 | return true 135 | } 136 | 137 | func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) { 138 | 139 | b.WriteString(key) 140 | b.WriteByte('=') 141 | 142 | switch value := value.(type) { 143 | case string: 144 | if needsQuoting(value) { 145 | b.WriteString(value) 146 | } else { 147 | fmt.Fprintf(b, "%q", value) 148 | } 149 | case error: 150 | errmsg := value.Error() 151 | if needsQuoting(errmsg) { 152 | b.WriteString(errmsg) 153 | } else { 154 | fmt.Fprintf(b, "%q", value) 155 | } 156 | default: 157 | fmt.Fprint(b, value) 158 | } 159 | 160 | b.WriteByte(' ') 161 | } 162 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/writer.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "runtime" 7 | ) 8 | 9 | func (logger *Logger) Writer() *io.PipeWriter { 10 | reader, writer := io.Pipe() 11 | 12 | go logger.writerScanner(reader) 13 | runtime.SetFinalizer(writer, writerFinalizer) 14 | 15 | return writer 16 | } 17 | 18 | func (logger *Logger) writerScanner(reader *io.PipeReader) { 19 | scanner := bufio.NewScanner(reader) 20 | for scanner.Scan() { 21 | logger.Print(scanner.Text()) 22 | } 23 | if err := scanner.Err(); err != nil { 24 | logger.Errorf("Error while reading from Writer: %s", err) 25 | } 26 | reader.Close() 27 | } 28 | 29 | func writerFinalizer(writer *io.PipeWriter) { 30 | writer.Close() 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/bpf_features.h: -------------------------------------------------------------------------------- 1 | #ifndef BPF_FEATURES_H_ 2 | #define BPF_FEATURES_H_ 3 | 4 | #define HAVE_SKB_CHANGE_TAIL 5 | 6 | #define HAVE_LRU_MAP_TYPE 7 | 8 | #define HAVE_MAP_VAL_ADJ 9 | 10 | #define HAVE_MARK_MAP_VALS 11 | 12 | #endif /* BPF_FEATURES_H_ */ 13 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/include/iproute2/bpf_elf.h: -------------------------------------------------------------------------------- 1 | #ifndef __BPF_ELF__ 2 | #define __BPF_ELF__ 3 | 4 | #include 5 | 6 | /* Note: 7 | * 8 | * Below ELF section names and bpf_elf_map structure definition 9 | * are not (!) kernel ABI. It's rather a "contract" between the 10 | * application and the BPF loader in tc. For compatibility, the 11 | * section names should stay as-is. Introduction of aliases, if 12 | * needed, are a possibility, though. 13 | */ 14 | 15 | /* ELF section names, etc */ 16 | #define ELF_SECTION_LICENSE "license" 17 | #define ELF_SECTION_MAPS "maps" 18 | #define ELF_SECTION_CLASSIFIER "classifier" 19 | #define ELF_SECTION_ACTION "action" 20 | 21 | #define ELF_MAX_MAPS 64 22 | #define ELF_MAX_LICENSE_LEN 128 23 | 24 | /* Object pinning settings */ 25 | #define PIN_NONE 0 26 | #define PIN_OBJECT_NS 1 27 | #define PIN_GLOBAL_NS 2 28 | 29 | /* ELF map definition */ 30 | struct bpf_elf_map { 31 | __u32 type; 32 | __u32 size_key; 33 | __u32 size_value; 34 | __u32 max_elem; 35 | __u32 flags; 36 | __u32 id; 37 | __u32 pinning; 38 | }; 39 | 40 | #endif /* __BPF_ELF__ */ 41 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/include/linux/bpf_common.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_BPF_COMMON_H__ 2 | #define __LINUX_BPF_COMMON_H__ 3 | 4 | /* Instruction classes */ 5 | #define BPF_CLASS(code) ((code) & 0x07) 6 | #define BPF_LD 0x00 7 | #define BPF_LDX 0x01 8 | #define BPF_ST 0x02 9 | #define BPF_STX 0x03 10 | #define BPF_ALU 0x04 11 | #define BPF_JMP 0x05 12 | #define BPF_RET 0x06 13 | #define BPF_MISC 0x07 14 | 15 | /* ld/ldx fields */ 16 | #define BPF_SIZE(code) ((code) & 0x18) 17 | #define BPF_W 0x00 18 | #define BPF_H 0x08 19 | #define BPF_B 0x10 20 | #define BPF_MODE(code) ((code) & 0xe0) 21 | #define BPF_IMM 0x00 22 | #define BPF_ABS 0x20 23 | #define BPF_IND 0x40 24 | #define BPF_MEM 0x60 25 | #define BPF_LEN 0x80 26 | #define BPF_MSH 0xa0 27 | 28 | /* alu/jmp fields */ 29 | #define BPF_OP(code) ((code) & 0xf0) 30 | #define BPF_ADD 0x00 31 | #define BPF_SUB 0x10 32 | #define BPF_MUL 0x20 33 | #define BPF_DIV 0x30 34 | #define BPF_OR 0x40 35 | #define BPF_AND 0x50 36 | #define BPF_LSH 0x60 37 | #define BPF_RSH 0x70 38 | #define BPF_NEG 0x80 39 | #define BPF_MOD 0x90 40 | #define BPF_XOR 0xa0 41 | 42 | #define BPF_JA 0x00 43 | #define BPF_JEQ 0x10 44 | #define BPF_JGT 0x20 45 | #define BPF_JGE 0x30 46 | #define BPF_JSET 0x40 47 | #define BPF_SRC(code) ((code) & 0x08) 48 | #define BPF_K 0x00 49 | #define BPF_X 0x08 50 | 51 | #ifndef BPF_MAXINSNS 52 | #define BPF_MAXINSNS 4096 53 | #endif 54 | 55 | #endif /* __LINUX_BPF_COMMON_H__ */ 56 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/include/linux/byteorder.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASM_X86_BYTEORDER_H 2 | #define _ASM_X86_BYTEORDER_H 3 | 4 | #include 5 | 6 | #if __BYTE_ORDER == __LITTLE_ENDIAN 7 | #include 8 | #else 9 | #include 10 | #endif 11 | 12 | #endif /* _ASM_X86_BYTEORDER_H */ 13 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/include/linux/byteorder/big_endian.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_BYTEORDER_BIG_ENDIAN_H 2 | #define _LINUX_BYTEORDER_BIG_ENDIAN_H 3 | 4 | #ifndef __BIG_ENDIAN 5 | #define __BIG_ENDIAN 4321 6 | #endif 7 | #ifndef __BIG_ENDIAN_BITFIELD 8 | #define __BIG_ENDIAN_BITFIELD 9 | #endif 10 | 11 | #include 12 | #include 13 | 14 | #define __constant_htonl(x) ((__be32)(__u32)(x)) 15 | #define __constant_ntohl(x) ((__u32)(__be32)(x)) 16 | #define __constant_htons(x) ((__be16)(__u16)(x)) 17 | #define __constant_ntohs(x) ((__u16)(__be16)(x)) 18 | #define __constant_cpu_to_le64(x) ((__le64)___constant_swab64((x))) 19 | #define __constant_le64_to_cpu(x) ___constant_swab64((__u64)(__le64)(x)) 20 | #define __constant_cpu_to_le32(x) ((__le32)___constant_swab32((x))) 21 | #define __constant_le32_to_cpu(x) ___constant_swab32((__u32)(__le32)(x)) 22 | #define __constant_cpu_to_le16(x) ((__le16)___constant_swab16((x))) 23 | #define __constant_le16_to_cpu(x) ___constant_swab16((__u16)(__le16)(x)) 24 | #define __constant_cpu_to_be64(x) ((__be64)(__u64)(x)) 25 | #define __constant_be64_to_cpu(x) ((__u64)(__be64)(x)) 26 | #define __constant_cpu_to_be32(x) ((__be32)(__u32)(x)) 27 | #define __constant_be32_to_cpu(x) ((__u32)(__be32)(x)) 28 | #define __constant_cpu_to_be16(x) ((__be16)(__u16)(x)) 29 | #define __constant_be16_to_cpu(x) ((__u16)(__be16)(x)) 30 | #define __cpu_to_le64(x) ((__le64)__swab64((x))) 31 | #define __le64_to_cpu(x) __swab64((__u64)(__le64)(x)) 32 | #define __cpu_to_le32(x) ((__le32)__swab32((x))) 33 | #define __le32_to_cpu(x) __swab32((__u32)(__le32)(x)) 34 | #define __cpu_to_le16(x) ((__le16)__swab16((x))) 35 | #define __le16_to_cpu(x) __swab16((__u16)(__le16)(x)) 36 | #define __cpu_to_be64(x) ((__be64)(__u64)(x)) 37 | #define __be64_to_cpu(x) ((__u64)(__be64)(x)) 38 | #define __cpu_to_be32(x) ((__be32)(__u32)(x)) 39 | #define __be32_to_cpu(x) ((__u32)(__be32)(x)) 40 | #define __cpu_to_be16(x) ((__be16)(__u16)(x)) 41 | #define __be16_to_cpu(x) ((__u16)(__be16)(x)) 42 | 43 | static __inline__ __le64 __cpu_to_le64p(const __u64 *p) 44 | { 45 | return (__le64)__swab64p(p); 46 | } 47 | static __inline__ __u64 __le64_to_cpup(const __le64 *p) 48 | { 49 | return __swab64p((__u64 *)p); 50 | } 51 | static __inline__ __le32 __cpu_to_le32p(const __u32 *p) 52 | { 53 | return (__le32)__swab32p(p); 54 | } 55 | static __inline__ __u32 __le32_to_cpup(const __le32 *p) 56 | { 57 | return __swab32p((__u32 *)p); 58 | } 59 | static __inline__ __le16 __cpu_to_le16p(const __u16 *p) 60 | { 61 | return (__le16)__swab16p(p); 62 | } 63 | static __inline__ __u16 __le16_to_cpup(const __le16 *p) 64 | { 65 | return __swab16p((__u16 *)p); 66 | } 67 | static __inline__ __be64 __cpu_to_be64p(const __u64 *p) 68 | { 69 | return (__be64)*p; 70 | } 71 | static __inline__ __u64 __be64_to_cpup(const __be64 *p) 72 | { 73 | return (__u64)*p; 74 | } 75 | static __inline__ __be32 __cpu_to_be32p(const __u32 *p) 76 | { 77 | return (__be32)*p; 78 | } 79 | static __inline__ __u32 __be32_to_cpup(const __be32 *p) 80 | { 81 | return (__u32)*p; 82 | } 83 | static __inline__ __be16 __cpu_to_be16p(const __u16 *p) 84 | { 85 | return (__be16)*p; 86 | } 87 | static __inline__ __u16 __be16_to_cpup(const __be16 *p) 88 | { 89 | return (__u16)*p; 90 | } 91 | #define __cpu_to_le64s(x) __swab64s((x)) 92 | #define __le64_to_cpus(x) __swab64s((x)) 93 | #define __cpu_to_le32s(x) __swab32s((x)) 94 | #define __le32_to_cpus(x) __swab32s((x)) 95 | #define __cpu_to_le16s(x) __swab16s((x)) 96 | #define __le16_to_cpus(x) __swab16s((x)) 97 | #define __cpu_to_be64s(x) do { (void)(x); } while (0) 98 | #define __be64_to_cpus(x) do { (void)(x); } while (0) 99 | #define __cpu_to_be32s(x) do { (void)(x); } while (0) 100 | #define __be32_to_cpus(x) do { (void)(x); } while (0) 101 | #define __cpu_to_be16s(x) do { (void)(x); } while (0) 102 | #define __be16_to_cpus(x) do { (void)(x); } while (0) 103 | 104 | 105 | #endif /* _LINUX_BYTEORDER_BIG_ENDIAN_H */ 106 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/include/linux/byteorder/little_endian.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_BYTEORDER_LITTLE_ENDIAN_H 2 | #define _LINUX_BYTEORDER_LITTLE_ENDIAN_H 3 | 4 | #ifndef __LITTLE_ENDIAN 5 | #define __LITTLE_ENDIAN 1234 6 | #endif 7 | #ifndef __LITTLE_ENDIAN_BITFIELD 8 | #define __LITTLE_ENDIAN_BITFIELD 9 | #endif 10 | 11 | #include 12 | #include 13 | 14 | #define __constant_htonl(x) ((__be32)___constant_swab32((x))) 15 | #define __constant_ntohl(x) ___constant_swab32((__be32)(x)) 16 | #define __constant_htons(x) ((__be16)___constant_swab16((x))) 17 | #define __constant_ntohs(x) ___constant_swab16((__be16)(x)) 18 | #define __constant_cpu_to_le64(x) ((__le64)(__u64)(x)) 19 | #define __constant_le64_to_cpu(x) ((__u64)(__le64)(x)) 20 | #define __constant_cpu_to_le32(x) ((__le32)(__u32)(x)) 21 | #define __constant_le32_to_cpu(x) ((__u32)(__le32)(x)) 22 | #define __constant_cpu_to_le16(x) ((__le16)(__u16)(x)) 23 | #define __constant_le16_to_cpu(x) ((__u16)(__le16)(x)) 24 | #define __constant_cpu_to_be64(x) ((__be64)___constant_swab64((x))) 25 | #define __constant_be64_to_cpu(x) ___constant_swab64((__u64)(__be64)(x)) 26 | #define __constant_cpu_to_be32(x) ((__be32)___constant_swab32((x))) 27 | #define __constant_be32_to_cpu(x) ___constant_swab32((__u32)(__be32)(x)) 28 | #define __constant_cpu_to_be16(x) ((__be16)___constant_swab16((x))) 29 | #define __constant_be16_to_cpu(x) ___constant_swab16((__u16)(__be16)(x)) 30 | #define __cpu_to_le64(x) ((__le64)(__u64)(x)) 31 | #define __le64_to_cpu(x) ((__u64)(__le64)(x)) 32 | #define __cpu_to_le32(x) ((__le32)(__u32)(x)) 33 | #define __le32_to_cpu(x) ((__u32)(__le32)(x)) 34 | #define __cpu_to_le16(x) ((__le16)(__u16)(x)) 35 | #define __le16_to_cpu(x) ((__u16)(__le16)(x)) 36 | #define __cpu_to_be64(x) ((__be64)__swab64((x))) 37 | #define __be64_to_cpu(x) __swab64((__u64)(__be64)(x)) 38 | #define __cpu_to_be32(x) ((__be32)__swab32((x))) 39 | #define __be32_to_cpu(x) __swab32((__u32)(__be32)(x)) 40 | #define __cpu_to_be16(x) ((__be16)__swab16((x))) 41 | #define __be16_to_cpu(x) __swab16((__u16)(__be16)(x)) 42 | 43 | static __inline__ __le64 __cpu_to_le64p(const __u64 *p) 44 | { 45 | return (__le64)*p; 46 | } 47 | static __inline__ __u64 __le64_to_cpup(const __le64 *p) 48 | { 49 | return (__u64)*p; 50 | } 51 | static __inline__ __le32 __cpu_to_le32p(const __u32 *p) 52 | { 53 | return (__le32)*p; 54 | } 55 | static __inline__ __u32 __le32_to_cpup(const __le32 *p) 56 | { 57 | return (__u32)*p; 58 | } 59 | static __inline__ __le16 __cpu_to_le16p(const __u16 *p) 60 | { 61 | return (__le16)*p; 62 | } 63 | static __inline__ __u16 __le16_to_cpup(const __le16 *p) 64 | { 65 | return (__u16)*p; 66 | } 67 | static __inline__ __be64 __cpu_to_be64p(const __u64 *p) 68 | { 69 | return (__be64)__swab64p(p); 70 | } 71 | static __inline__ __u64 __be64_to_cpup(const __be64 *p) 72 | { 73 | return __swab64p((__u64 *)p); 74 | } 75 | static __inline__ __be32 __cpu_to_be32p(const __u32 *p) 76 | { 77 | return (__be32)__swab32p(p); 78 | } 79 | static __inline__ __u32 __be32_to_cpup(const __be32 *p) 80 | { 81 | return __swab32p((__u32 *)p); 82 | } 83 | static __inline__ __be16 __cpu_to_be16p(const __u16 *p) 84 | { 85 | return (__be16)__swab16p(p); 86 | } 87 | static __inline__ __u16 __be16_to_cpup(const __be16 *p) 88 | { 89 | return __swab16p((__u16 *)p); 90 | } 91 | #define __cpu_to_le64s(x) do { (void)(x); } while (0) 92 | #define __le64_to_cpus(x) do { (void)(x); } while (0) 93 | #define __cpu_to_le32s(x) do { (void)(x); } while (0) 94 | #define __le32_to_cpus(x) do { (void)(x); } while (0) 95 | #define __cpu_to_le16s(x) do { (void)(x); } while (0) 96 | #define __le16_to_cpus(x) do { (void)(x); } while (0) 97 | #define __cpu_to_be64s(x) __swab64s((x)) 98 | #define __be64_to_cpus(x) __swab64s((x)) 99 | #define __cpu_to_be32s(x) __swab32s((x)) 100 | #define __be32_to_cpus(x) __swab32s((x)) 101 | #define __cpu_to_be16s(x) __swab16s((x)) 102 | #define __be16_to_cpus(x) __swab16s((x)) 103 | 104 | 105 | #endif /* _LINUX_BYTEORDER_LITTLE_ENDIAN_H */ 106 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/include/linux/icmp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * INET An implementation of the TCP/IP protocol suite for the LINUX 3 | * operating system. INET is implemented using the BSD Socket 4 | * interface as the means of communication with the user level. 5 | * 6 | * Definitions for the ICMP protocol. 7 | * 8 | * Version: @(#)icmp.h 1.0.3 04/28/93 9 | * 10 | * Author: Fred N. van Kempen, 11 | * 12 | * This program is free software; you can redistribute it and/or 13 | * modify it under the terms of the GNU General Public License 14 | * as published by the Free Software Foundation; either version 15 | * 2 of the License, or (at your option) any later version. 16 | */ 17 | #ifndef _LINUX_ICMP_H 18 | #define _LINUX_ICMP_H 19 | 20 | #include 21 | 22 | #define ICMP_ECHOREPLY 0 /* Echo Reply */ 23 | #define ICMP_DEST_UNREACH 3 /* Destination Unreachable */ 24 | #define ICMP_SOURCE_QUENCH 4 /* Source Quench */ 25 | #define ICMP_REDIRECT 5 /* Redirect (change route) */ 26 | #define ICMP_ECHO 8 /* Echo Request */ 27 | #define ICMP_TIME_EXCEEDED 11 /* Time Exceeded */ 28 | #define ICMP_PARAMETERPROB 12 /* Parameter Problem */ 29 | #define ICMP_TIMESTAMP 13 /* Timestamp Request */ 30 | #define ICMP_TIMESTAMPREPLY 14 /* Timestamp Reply */ 31 | #define ICMP_INFO_REQUEST 15 /* Information Request */ 32 | #define ICMP_INFO_REPLY 16 /* Information Reply */ 33 | #define ICMP_ADDRESS 17 /* Address Mask Request */ 34 | #define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */ 35 | #define NR_ICMP_TYPES 18 36 | 37 | 38 | /* Codes for UNREACH. */ 39 | #define ICMP_NET_UNREACH 0 /* Network Unreachable */ 40 | #define ICMP_HOST_UNREACH 1 /* Host Unreachable */ 41 | #define ICMP_PROT_UNREACH 2 /* Protocol Unreachable */ 42 | #define ICMP_PORT_UNREACH 3 /* Port Unreachable */ 43 | #define ICMP_FRAG_NEEDED 4 /* Fragmentation Needed/DF set */ 44 | #define ICMP_SR_FAILED 5 /* Source Route failed */ 45 | #define ICMP_NET_UNKNOWN 6 46 | #define ICMP_HOST_UNKNOWN 7 47 | #define ICMP_HOST_ISOLATED 8 48 | #define ICMP_NET_ANO 9 49 | #define ICMP_HOST_ANO 10 50 | #define ICMP_NET_UNR_TOS 11 51 | #define ICMP_HOST_UNR_TOS 12 52 | #define ICMP_PKT_FILTERED 13 /* Packet filtered */ 53 | #define ICMP_PREC_VIOLATION 14 /* Precedence violation */ 54 | #define ICMP_PREC_CUTOFF 15 /* Precedence cut off */ 55 | #define NR_ICMP_UNREACH 15 /* instead of hardcoding immediate value */ 56 | 57 | /* Codes for REDIRECT. */ 58 | #define ICMP_REDIR_NET 0 /* Redirect Net */ 59 | #define ICMP_REDIR_HOST 1 /* Redirect Host */ 60 | #define ICMP_REDIR_NETTOS 2 /* Redirect Net for TOS */ 61 | #define ICMP_REDIR_HOSTTOS 3 /* Redirect Host for TOS */ 62 | 63 | /* Codes for TIME_EXCEEDED. */ 64 | #define ICMP_EXC_TTL 0 /* TTL count exceeded */ 65 | #define ICMP_EXC_FRAGTIME 1 /* Fragment Reass time exceeded */ 66 | 67 | 68 | struct icmphdr { 69 | __u8 type; 70 | __u8 code; 71 | __sum16 checksum; 72 | union { 73 | struct { 74 | __be16 id; 75 | __be16 sequence; 76 | } echo; 77 | __be32 gateway; 78 | struct { 79 | __be16 __unused; 80 | __be16 mtu; 81 | } frag; 82 | } un; 83 | }; 84 | 85 | 86 | /* 87 | * constants for (set|get)sockopt 88 | */ 89 | 90 | #define ICMP_FILTER 1 91 | 92 | struct icmp_filter { 93 | __u32 data; 94 | }; 95 | 96 | 97 | #endif /* _LINUX_ICMP_H */ 98 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/include/linux/icmpv6.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_ICMPV6_H 2 | #define _LINUX_ICMPV6_H 3 | 4 | #include 5 | #include 6 | 7 | struct icmp6hdr { 8 | 9 | __u8 icmp6_type; 10 | __u8 icmp6_code; 11 | __sum16 icmp6_cksum; 12 | 13 | 14 | union { 15 | __be32 un_data32[1]; 16 | __be16 un_data16[2]; 17 | __u8 un_data8[4]; 18 | 19 | struct icmpv6_echo { 20 | __be16 identifier; 21 | __be16 sequence; 22 | } u_echo; 23 | 24 | struct icmpv6_nd_advt { 25 | #if defined(__LITTLE_ENDIAN_BITFIELD) 26 | __u32 reserved:5, 27 | override:1, 28 | solicited:1, 29 | router:1, 30 | reserved2:24; 31 | #elif defined(__BIG_ENDIAN_BITFIELD) 32 | __u32 router:1, 33 | solicited:1, 34 | override:1, 35 | reserved:29; 36 | #else 37 | #error "Please fix " 38 | #endif 39 | } u_nd_advt; 40 | 41 | struct icmpv6_nd_ra { 42 | __u8 hop_limit; 43 | #if defined(__LITTLE_ENDIAN_BITFIELD) 44 | __u8 reserved:3, 45 | router_pref:2, 46 | home_agent:1, 47 | other:1, 48 | managed:1; 49 | 50 | #elif defined(__BIG_ENDIAN_BITFIELD) 51 | __u8 managed:1, 52 | other:1, 53 | home_agent:1, 54 | router_pref:2, 55 | reserved:3; 56 | #else 57 | #error "Please fix " 58 | #endif 59 | __be16 rt_lifetime; 60 | } u_nd_ra; 61 | 62 | } icmp6_dataun; 63 | 64 | #define icmp6_identifier icmp6_dataun.u_echo.identifier 65 | #define icmp6_sequence icmp6_dataun.u_echo.sequence 66 | #define icmp6_pointer icmp6_dataun.un_data32[0] 67 | #define icmp6_mtu icmp6_dataun.un_data32[0] 68 | #define icmp6_unused icmp6_dataun.un_data32[0] 69 | #define icmp6_maxdelay icmp6_dataun.un_data16[0] 70 | #define icmp6_router icmp6_dataun.u_nd_advt.router 71 | #define icmp6_solicited icmp6_dataun.u_nd_advt.solicited 72 | #define icmp6_override icmp6_dataun.u_nd_advt.override 73 | #define icmp6_ndiscreserved icmp6_dataun.u_nd_advt.reserved 74 | #define icmp6_hop_limit icmp6_dataun.u_nd_ra.hop_limit 75 | #define icmp6_addrconf_managed icmp6_dataun.u_nd_ra.managed 76 | #define icmp6_addrconf_other icmp6_dataun.u_nd_ra.other 77 | #define icmp6_rt_lifetime icmp6_dataun.u_nd_ra.rt_lifetime 78 | #define icmp6_router_pref icmp6_dataun.u_nd_ra.router_pref 79 | }; 80 | 81 | 82 | #define ICMPV6_ROUTER_PREF_LOW 0x3 83 | #define ICMPV6_ROUTER_PREF_MEDIUM 0x0 84 | #define ICMPV6_ROUTER_PREF_HIGH 0x1 85 | #define ICMPV6_ROUTER_PREF_INVALID 0x2 86 | 87 | #define ICMPV6_DEST_UNREACH 1 88 | #define ICMPV6_PKT_TOOBIG 2 89 | #define ICMPV6_TIME_EXCEED 3 90 | #define ICMPV6_PARAMPROB 4 91 | 92 | #define ICMPV6_INFOMSG_MASK 0x80 93 | 94 | #define ICMPV6_ECHO_REQUEST 128 95 | #define ICMPV6_ECHO_REPLY 129 96 | #define ICMPV6_MGM_QUERY 130 97 | #define ICMPV6_MGM_REPORT 131 98 | #define ICMPV6_MGM_REDUCTION 132 99 | 100 | #define ICMPV6_NI_QUERY 139 101 | #define ICMPV6_NI_REPLY 140 102 | 103 | #define ICMPV6_MLD2_REPORT 143 104 | 105 | #define ICMPV6_DHAAD_REQUEST 144 106 | #define ICMPV6_DHAAD_REPLY 145 107 | #define ICMPV6_MOBILE_PREFIX_SOL 146 108 | #define ICMPV6_MOBILE_PREFIX_ADV 147 109 | 110 | /* 111 | * Codes for Destination Unreachable 112 | */ 113 | #define ICMPV6_NOROUTE 0 114 | #define ICMPV6_ADM_PROHIBITED 1 115 | #define ICMPV6_NOT_NEIGHBOUR 2 116 | #define ICMPV6_ADDR_UNREACH 3 117 | #define ICMPV6_PORT_UNREACH 4 118 | #define ICMPV6_POLICY_FAIL 5 119 | #define ICMPV6_REJECT_ROUTE 6 120 | 121 | /* 122 | * Codes for Time Exceeded 123 | */ 124 | #define ICMPV6_EXC_HOPLIMIT 0 125 | #define ICMPV6_EXC_FRAGTIME 1 126 | 127 | /* 128 | * Codes for Parameter Problem 129 | */ 130 | #define ICMPV6_HDR_FIELD 0 131 | #define ICMPV6_UNK_NEXTHDR 1 132 | #define ICMPV6_UNK_OPTION 2 133 | 134 | /* 135 | * constants for (set|get)sockopt 136 | */ 137 | 138 | #define ICMPV6_FILTER 1 139 | 140 | /* 141 | * ICMPV6 filter 142 | */ 143 | 144 | #define ICMPV6_FILTER_BLOCK 1 145 | #define ICMPV6_FILTER_PASS 2 146 | #define ICMPV6_FILTER_BLOCKOTHERS 3 147 | #define ICMPV6_FILTER_PASSONLY 4 148 | 149 | struct icmp6_filter { 150 | __u32 data[8]; 151 | }; 152 | 153 | /* 154 | * Definitions for MLDv2 155 | */ 156 | #define MLD2_MODE_IS_INCLUDE 1 157 | #define MLD2_MODE_IS_EXCLUDE 2 158 | #define MLD2_CHANGE_TO_INCLUDE 3 159 | #define MLD2_CHANGE_TO_EXCLUDE 4 160 | #define MLD2_ALLOW_NEW_SOURCES 5 161 | #define MLD2_BLOCK_OLD_SOURCES 6 162 | 163 | #define MLD2_ALL_MCR_INIT { { { 0xff,0x02,0,0,0,0,0,0,0,0,0,0,0,0,0,0x16 } } } 164 | 165 | 166 | #endif /* _LINUX_ICMPV6_H */ 167 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/include/linux/in6.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Types and definitions for AF_INET6 3 | * Linux INET6 implementation 4 | * 5 | * Authors: 6 | * Pedro Roque 7 | * 8 | * Sources: 9 | * IPv6 Program Interfaces for BSD Systems 10 | * 11 | * 12 | * Advanced Sockets API for IPv6 13 | * 14 | * 15 | * This program is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU General Public License 17 | * as published by the Free Software Foundation; either version 18 | * 2 of the License, or (at your option) any later version. 19 | */ 20 | 21 | #ifndef _LINUX_IN6_H 22 | #define _LINUX_IN6_H 23 | 24 | #include 25 | 26 | /* 27 | * IPv6 address structure 28 | */ 29 | 30 | struct in6_addr { 31 | union { 32 | __u8 u6_addr8[16]; 33 | __be16 u6_addr16[8]; 34 | __be32 u6_addr32[4]; 35 | } in6_u; 36 | #define s6_addr in6_u.u6_addr8 37 | #define s6_addr16 in6_u.u6_addr16 38 | #define s6_addr32 in6_u.u6_addr32 39 | }; 40 | 41 | /* 42 | * Bitmask constant declarations to help applications select out the 43 | * flow label and priority fields. 44 | * 45 | * Note that this are in host byte order while the flowinfo field of 46 | * sockaddr_in6 is in network byte order. 47 | */ 48 | 49 | #define IPV6_FLOWINFO_FLOWLABEL 0x000fffff 50 | #define IPV6_FLOWINFO_PRIORITY 0x0ff00000 51 | 52 | /* These definitions are obsolete */ 53 | #define IPV6_PRIORITY_UNCHARACTERIZED 0x0000 54 | #define IPV6_PRIORITY_FILLER 0x0100 55 | #define IPV6_PRIORITY_UNATTENDED 0x0200 56 | #define IPV6_PRIORITY_RESERVED1 0x0300 57 | #define IPV6_PRIORITY_BULK 0x0400 58 | #define IPV6_PRIORITY_RESERVED2 0x0500 59 | #define IPV6_PRIORITY_INTERACTIVE 0x0600 60 | #define IPV6_PRIORITY_CONTROL 0x0700 61 | #define IPV6_PRIORITY_8 0x0800 62 | #define IPV6_PRIORITY_9 0x0900 63 | #define IPV6_PRIORITY_10 0x0a00 64 | #define IPV6_PRIORITY_11 0x0b00 65 | #define IPV6_PRIORITY_12 0x0c00 66 | #define IPV6_PRIORITY_13 0x0d00 67 | #define IPV6_PRIORITY_14 0x0e00 68 | #define IPV6_PRIORITY_15 0x0f00 69 | 70 | /* 71 | * IPV6 extension headers 72 | */ 73 | #define IPPROTO_HOPOPTS 0 /* IPv6 hop-by-hop options */ 74 | #define IPPROTO_ROUTING 43 /* IPv6 routing header */ 75 | #define IPPROTO_FRAGMENT 44 /* IPv6 fragmentation header */ 76 | #define IPPROTO_ICMPV6 58 /* ICMPv6 */ 77 | #define IPPROTO_NONE 59 /* IPv6 no next header */ 78 | #define IPPROTO_DSTOPTS 60 /* IPv6 destination options */ 79 | #define IPPROTO_MH 135 /* IPv6 mobility header */ 80 | 81 | /* 82 | * IPv6 TLV options. 83 | */ 84 | #define IPV6_TLV_PAD1 0 85 | #define IPV6_TLV_PADN 1 86 | #define IPV6_TLV_ROUTERALERT 5 87 | #define IPV6_TLV_JUMBO 194 88 | #define IPV6_TLV_HAO 201 /* home address option */ 89 | 90 | /* 91 | * IPV6 socket options 92 | */ 93 | #define IPV6_ADDRFORM 1 94 | #define IPV6_2292PKTINFO 2 95 | #define IPV6_2292HOPOPTS 3 96 | #define IPV6_2292DSTOPTS 4 97 | #define IPV6_2292RTHDR 5 98 | #define IPV6_2292PKTOPTIONS 6 99 | #define IPV6_CHECKSUM 7 100 | #define IPV6_2292HOPLIMIT 8 101 | #define IPV6_NEXTHOP 9 102 | #define IPV6_AUTHHDR 10 /* obsolete */ 103 | #define IPV6_FLOWINFO 11 104 | 105 | #define IPV6_UNICAST_HOPS 16 106 | #define IPV6_MULTICAST_IF 17 107 | #define IPV6_MULTICAST_HOPS 18 108 | #define IPV6_MULTICAST_LOOP 19 109 | #define IPV6_ADD_MEMBERSHIP 20 110 | #define IPV6_DROP_MEMBERSHIP 21 111 | #define IPV6_ROUTER_ALERT 22 112 | #define IPV6_MTU_DISCOVER 23 113 | #define IPV6_MTU 24 114 | #define IPV6_RECVERR 25 115 | #define IPV6_V6ONLY 26 116 | #define IPV6_JOIN_ANYCAST 27 117 | #define IPV6_LEAVE_ANYCAST 28 118 | 119 | /* IPV6_MTU_DISCOVER values */ 120 | #define IPV6_PMTUDISC_DONT 0 121 | #define IPV6_PMTUDISC_WANT 1 122 | #define IPV6_PMTUDISC_DO 2 123 | #define IPV6_PMTUDISC_PROBE 3 124 | /* same as IPV6_PMTUDISC_PROBE, provided for symetry with IPv4 125 | * also see comments on IP_PMTUDISC_INTERFACE 126 | */ 127 | #define IPV6_PMTUDISC_INTERFACE 4 128 | /* weaker version of IPV6_PMTUDISC_INTERFACE, which allows packets to 129 | * get fragmented if they exceed the interface mtu 130 | */ 131 | #define IPV6_PMTUDISC_OMIT 5 132 | 133 | /* Flowlabel */ 134 | #define IPV6_FLOWLABEL_MGR 32 135 | #define IPV6_FLOWINFO_SEND 33 136 | 137 | #define IPV6_IPSEC_POLICY 34 138 | #define IPV6_XFRM_POLICY 35 139 | #define IPV6_HDRINCL 36 140 | 141 | /* 142 | * Multicast Routing: 143 | * see include/uapi/linux/mroute6.h. 144 | * 145 | * MRT6_BASE 200 146 | * ... 147 | * MRT6_MAX 148 | */ 149 | #endif /* _LINUX_IN6_H */ 150 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/include/linux/ioctl.h: -------------------------------------------------------------------------------- 1 | #ifndef _ASM_GENERIC_IOCTL_H 2 | #define _ASM_GENERIC_IOCTL_H 3 | 4 | /* ioctl command encoding: 32 bits total, command in lower 16 bits, 5 | * size of the parameter structure in the lower 14 bits of the 6 | * upper 16 bits. 7 | * Encoding the size of the parameter structure in the ioctl request 8 | * is useful for catching programs compiled with old versions 9 | * and to avoid overwriting user space outside the user buffer area. 10 | * The highest 2 bits are reserved for indicating the ``access mode''. 11 | * NOTE: This limits the max parameter size to 16kB -1 ! 12 | */ 13 | 14 | /* 15 | * The following is for compatibility across the various Linux 16 | * platforms. The generic ioctl numbering scheme doesn't really enforce 17 | * a type field. De facto, however, the top 8 bits of the lower 16 18 | * bits are indeed used as a type field, so we might just as well make 19 | * this explicit here. Please be sure to use the decoding macros 20 | * below from now on. 21 | */ 22 | #define _IOC_NRBITS 8 23 | #define _IOC_TYPEBITS 8 24 | 25 | /* 26 | * Let any architecture override either of the following before 27 | * including this file. 28 | */ 29 | 30 | #ifndef _IOC_SIZEBITS 31 | # define _IOC_SIZEBITS 14 32 | #endif 33 | 34 | #ifndef _IOC_DIRBITS 35 | # define _IOC_DIRBITS 2 36 | #endif 37 | 38 | #define _IOC_NRMASK ((1 << _IOC_NRBITS)-1) 39 | #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS)-1) 40 | #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS)-1) 41 | #define _IOC_DIRMASK ((1 << _IOC_DIRBITS)-1) 42 | 43 | #define _IOC_NRSHIFT 0 44 | #define _IOC_TYPESHIFT (_IOC_NRSHIFT+_IOC_NRBITS) 45 | #define _IOC_SIZESHIFT (_IOC_TYPESHIFT+_IOC_TYPEBITS) 46 | #define _IOC_DIRSHIFT (_IOC_SIZESHIFT+_IOC_SIZEBITS) 47 | 48 | /* 49 | * Direction bits, which any architecture can choose to override 50 | * before including this file. 51 | */ 52 | 53 | #ifndef _IOC_NONE 54 | # define _IOC_NONE 0U 55 | #endif 56 | 57 | #ifndef _IOC_WRITE 58 | # define _IOC_WRITE 1U 59 | #endif 60 | 61 | #ifndef _IOC_READ 62 | # define _IOC_READ 2U 63 | #endif 64 | 65 | #define _IOC(dir,type,nr,size) \ 66 | (((dir) << _IOC_DIRSHIFT) | \ 67 | ((type) << _IOC_TYPESHIFT) | \ 68 | ((nr) << _IOC_NRSHIFT) | \ 69 | ((size) << _IOC_SIZESHIFT)) 70 | 71 | #define _IOC_TYPECHECK(t) (sizeof(t)) 72 | 73 | /* used to create numbers */ 74 | #define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0) 75 | #define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size))) 76 | #define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) 77 | #define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size))) 78 | #define _IOR_BAD(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size)) 79 | #define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size)) 80 | #define _IOWR_BAD(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size)) 81 | 82 | /* used to decode ioctl numbers.. */ 83 | #define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK) 84 | #define _IOC_TYPE(nr) (((nr) >> _IOC_TYPESHIFT) & _IOC_TYPEMASK) 85 | #define _IOC_NR(nr) (((nr) >> _IOC_NRSHIFT) & _IOC_NRMASK) 86 | #define _IOC_SIZE(nr) (((nr) >> _IOC_SIZESHIFT) & _IOC_SIZEMASK) 87 | 88 | /* ...and for the drivers/sound files... */ 89 | 90 | #define IOC_IN (_IOC_WRITE << _IOC_DIRSHIFT) 91 | #define IOC_OUT (_IOC_READ << _IOC_DIRSHIFT) 92 | #define IOC_INOUT ((_IOC_WRITE|_IOC_READ) << _IOC_DIRSHIFT) 93 | #define IOCSIZE_MASK (_IOC_SIZEMASK << _IOC_SIZESHIFT) 94 | #define IOCSIZE_SHIFT (_IOC_SIZESHIFT) 95 | 96 | #endif /* _ASM_GENERIC_IOCTL_H */ 97 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/include/linux/ip.h: -------------------------------------------------------------------------------- 1 | /* 2 | * INET An implementation of the TCP/IP protocol suite for the LINUX 3 | * operating system. INET is implemented using the BSD Socket 4 | * interface as the means of communication with the user level. 5 | * 6 | * Definitions for the IP protocol. 7 | * 8 | * Version: @(#)ip.h 1.0.2 04/28/93 9 | * 10 | * Authors: Fred N. van Kempen, 11 | * 12 | * This program is free software; you can redistribute it and/or 13 | * modify it under the terms of the GNU General Public License 14 | * as published by the Free Software Foundation; either version 15 | * 2 of the License, or (at your option) any later version. 16 | */ 17 | #ifndef _LINUX_IP_H 18 | #define _LINUX_IP_H 19 | 20 | #include 21 | #include 22 | 23 | #define IPTOS_TOS_MASK 0x1E 24 | #define IPTOS_TOS(tos) ((tos)&IPTOS_TOS_MASK) 25 | #define IPTOS_LOWDELAY 0x10 26 | #define IPTOS_THROUGHPUT 0x08 27 | #define IPTOS_RELIABILITY 0x04 28 | #define IPTOS_MINCOST 0x02 29 | 30 | #define IPTOS_PREC_MASK 0xE0 31 | #define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK) 32 | #define IPTOS_PREC_NETCONTROL 0xe0 33 | #define IPTOS_PREC_INTERNETCONTROL 0xc0 34 | #define IPTOS_PREC_CRITIC_ECP 0xa0 35 | #define IPTOS_PREC_FLASHOVERRIDE 0x80 36 | #define IPTOS_PREC_FLASH 0x60 37 | #define IPTOS_PREC_IMMEDIATE 0x40 38 | #define IPTOS_PREC_PRIORITY 0x20 39 | #define IPTOS_PREC_ROUTINE 0x00 40 | 41 | 42 | /* IP options */ 43 | #define IPOPT_COPY 0x80 44 | #define IPOPT_CLASS_MASK 0x60 45 | #define IPOPT_NUMBER_MASK 0x1f 46 | 47 | #define IPOPT_COPIED(o) ((o)&IPOPT_COPY) 48 | #define IPOPT_CLASS(o) ((o)&IPOPT_CLASS_MASK) 49 | #define IPOPT_NUMBER(o) ((o)&IPOPT_NUMBER_MASK) 50 | 51 | #define IPOPT_CONTROL 0x00 52 | #define IPOPT_RESERVED1 0x20 53 | #define IPOPT_MEASUREMENT 0x40 54 | #define IPOPT_RESERVED2 0x60 55 | 56 | #define IPOPT_END (0 |IPOPT_CONTROL) 57 | #define IPOPT_NOOP (1 |IPOPT_CONTROL) 58 | #define IPOPT_SEC (2 |IPOPT_CONTROL|IPOPT_COPY) 59 | #define IPOPT_LSRR (3 |IPOPT_CONTROL|IPOPT_COPY) 60 | #define IPOPT_TIMESTAMP (4 |IPOPT_MEASUREMENT) 61 | #define IPOPT_CIPSO (6 |IPOPT_CONTROL|IPOPT_COPY) 62 | #define IPOPT_RR (7 |IPOPT_CONTROL) 63 | #define IPOPT_SID (8 |IPOPT_CONTROL|IPOPT_COPY) 64 | #define IPOPT_SSRR (9 |IPOPT_CONTROL|IPOPT_COPY) 65 | #define IPOPT_RA (20|IPOPT_CONTROL|IPOPT_COPY) 66 | 67 | #define IPVERSION 4 68 | #define MAXTTL 255 69 | #define IPDEFTTL 64 70 | 71 | #define IPOPT_OPTVAL 0 72 | #define IPOPT_OLEN 1 73 | #define IPOPT_OFFSET 2 74 | #define IPOPT_MINOFF 4 75 | #define MAX_IPOPTLEN 40 76 | #define IPOPT_NOP IPOPT_NOOP 77 | #define IPOPT_EOL IPOPT_END 78 | #define IPOPT_TS IPOPT_TIMESTAMP 79 | 80 | #define IPOPT_TS_TSONLY 0 /* timestamps only */ 81 | #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ 82 | #define IPOPT_TS_PRESPEC 3 /* specified modules only */ 83 | 84 | #define IPV4_BEET_PHMAXLEN 8 85 | 86 | struct iphdr { 87 | #if defined(__LITTLE_ENDIAN_BITFIELD) 88 | __u8 ihl:4, 89 | version:4; 90 | #elif defined (__BIG_ENDIAN_BITFIELD) 91 | __u8 version:4, 92 | ihl:4; 93 | #else 94 | #error "Please fix " 95 | #endif 96 | __u8 tos; 97 | __be16 tot_len; 98 | __be16 id; 99 | __be16 frag_off; 100 | __u8 ttl; 101 | __u8 protocol; 102 | __sum16 check; 103 | __be32 saddr; 104 | __be32 daddr; 105 | /*The options start here. */ 106 | }; 107 | 108 | 109 | struct ip_auth_hdr { 110 | __u8 nexthdr; 111 | __u8 hdrlen; /* This one is measured in 32 bit units! */ 112 | __be16 reserved; 113 | __be32 spi; 114 | __be32 seq_no; /* Sequence number */ 115 | __u8 auth_data[0]; /* Variable len but >=4. Mind the 64 bit alignment! */ 116 | }; 117 | 118 | struct ip_esp_hdr { 119 | __be32 spi; 120 | __be32 seq_no; /* Sequence number */ 121 | __u8 enc_data[0]; /* Variable len but >=8. Mind the 64 bit alignment! */ 122 | }; 123 | 124 | struct ip_comp_hdr { 125 | __u8 nexthdr; 126 | __u8 flags; 127 | __be16 cpi; 128 | }; 129 | 130 | struct ip_beet_phdr { 131 | __u8 nexthdr; 132 | __u8 hdrlen; 133 | __u8 padlen; 134 | __u8 reserved; 135 | }; 136 | 137 | #endif /* _LINUX_IP_H */ 138 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/include/linux/ipv6.h: -------------------------------------------------------------------------------- 1 | #ifndef _IPV6_H 2 | #define _IPV6_H 3 | 4 | #include 5 | #include 6 | 7 | /* The latest drafts declared increase in minimal mtu up to 1280. */ 8 | 9 | #define IPV6_MIN_MTU 1280 10 | 11 | /* 12 | * Advanced API 13 | * source interface/address selection, source routing, etc... 14 | * *under construction* 15 | */ 16 | 17 | #define IPV6_SRCRT_STRICT 0x01 /* Deprecated; will be removed */ 18 | #define IPV6_SRCRT_TYPE_0 0 /* Deprecated; will be removed */ 19 | #define IPV6_SRCRT_TYPE_2 2 /* IPv6 type 2 Routing Header */ 20 | 21 | /* 22 | * routing header 23 | */ 24 | struct ipv6_rt_hdr { 25 | __u8 nexthdr; 26 | __u8 hdrlen; 27 | __u8 type; 28 | __u8 segments_left; 29 | 30 | /* 31 | * type specific data 32 | * variable length field 33 | */ 34 | }; 35 | 36 | 37 | struct ipv6_opt_hdr { 38 | __u8 nexthdr; 39 | __u8 hdrlen; 40 | /* 41 | * TLV encoded option data follows. 42 | */ 43 | } __attribute__((packed)); /* required for some archs */ 44 | 45 | #define ipv6_destopt_hdr ipv6_opt_hdr 46 | #define ipv6_hopopt_hdr ipv6_opt_hdr 47 | 48 | /* Router Alert option values (RFC2711) */ 49 | #define IPV6_OPT_ROUTERALERT_MLD 0x0000 /* MLD(RFC2710) */ 50 | 51 | /* 52 | * routing header type 0 (used in cmsghdr struct) 53 | */ 54 | 55 | struct rt0_hdr { 56 | struct ipv6_rt_hdr rt_hdr; 57 | __u32 reserved; 58 | struct in6_addr addr[0]; 59 | 60 | #define rt0_type rt_hdr.type 61 | }; 62 | 63 | /* 64 | * routing header type 2 65 | */ 66 | 67 | struct rt2_hdr { 68 | struct ipv6_rt_hdr rt_hdr; 69 | __u32 reserved; 70 | struct in6_addr addr; 71 | 72 | #define rt2_type rt_hdr.type 73 | }; 74 | 75 | /* 76 | * home address option in destination options header 77 | */ 78 | 79 | struct ipv6_destopt_hao { 80 | __u8 type; 81 | __u8 length; 82 | struct in6_addr addr; 83 | } __attribute__((packed)); 84 | 85 | /* 86 | * IPv6 fixed header 87 | * 88 | * BEWARE, it is incorrect. The first 4 bits of flow_lbl 89 | * are glued to priority now, forming "class". 90 | */ 91 | 92 | struct ipv6hdr { 93 | #if defined(__LITTLE_ENDIAN_BITFIELD) 94 | __u8 priority:4, 95 | version:4; 96 | #elif defined(__BIG_ENDIAN_BITFIELD) 97 | __u8 version:4, 98 | priority:4; 99 | #else 100 | #error "Please fix " 101 | #endif 102 | __u8 flow_lbl[3]; 103 | 104 | __be16 payload_len; 105 | __u8 nexthdr; 106 | __u8 hop_limit; 107 | 108 | struct in6_addr saddr; 109 | struct in6_addr daddr; 110 | }; 111 | 112 | 113 | /* index values for the variables in ipv6_devconf */ 114 | enum { 115 | DEVCONF_FORWARDING = 0, 116 | DEVCONF_HOPLIMIT, 117 | DEVCONF_MTU6, 118 | DEVCONF_ACCEPT_RA, 119 | DEVCONF_ACCEPT_REDIRECTS, 120 | DEVCONF_AUTOCONF, 121 | DEVCONF_DAD_TRANSMITS, 122 | DEVCONF_RTR_SOLICITS, 123 | DEVCONF_RTR_SOLICIT_INTERVAL, 124 | DEVCONF_RTR_SOLICIT_DELAY, 125 | DEVCONF_USE_TEMPADDR, 126 | DEVCONF_TEMP_VALID_LFT, 127 | DEVCONF_TEMP_PREFERED_LFT, 128 | DEVCONF_REGEN_MAX_RETRY, 129 | DEVCONF_MAX_DESYNC_FACTOR, 130 | DEVCONF_MAX_ADDRESSES, 131 | DEVCONF_FORCE_MLD_VERSION, 132 | DEVCONF_ACCEPT_RA_DEFRTR, 133 | DEVCONF_ACCEPT_RA_PINFO, 134 | DEVCONF_ACCEPT_RA_RTR_PREF, 135 | DEVCONF_RTR_PROBE_INTERVAL, 136 | DEVCONF_ACCEPT_RA_RT_INFO_MAX_PLEN, 137 | DEVCONF_PROXY_NDP, 138 | DEVCONF_OPTIMISTIC_DAD, 139 | DEVCONF_ACCEPT_SOURCE_ROUTE, 140 | DEVCONF_MC_FORWARDING, 141 | DEVCONF_DISABLE_IPV6, 142 | DEVCONF_ACCEPT_DAD, 143 | DEVCONF_FORCE_TLLAO, 144 | DEVCONF_NDISC_NOTIFY, 145 | DEVCONF_MLDV1_UNSOLICITED_REPORT_INTERVAL, 146 | DEVCONF_MLDV2_UNSOLICITED_REPORT_INTERVAL, 147 | DEVCONF_SUPPRESS_FRAG_NDISC, 148 | DEVCONF_ACCEPT_RA_FROM_LOCAL, 149 | DEVCONF_USE_OPTIMISTIC, 150 | DEVCONF_ACCEPT_RA_MTU, 151 | DEVCONF_STABLE_SECRET, 152 | DEVCONF_USE_OIF_ADDRS_ONLY, 153 | DEVCONF_ACCEPT_RA_MIN_HOP_LIMIT, 154 | DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN, 155 | DEVCONF_MAX 156 | }; 157 | 158 | 159 | #endif /* _IPV6_H */ 160 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/include/linux/tcp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * INET An implementation of the TCP/IP protocol suite for the LINUX 3 | * operating system. INET is implemented using the BSD Socket 4 | * interface as the means of communication with the user level. 5 | * 6 | * Definitions for the TCP protocol. 7 | * 8 | * Version: @(#)tcp.h 1.0.2 04/28/93 9 | * 10 | * Author: Fred N. van Kempen, 11 | * 12 | * This program is free software; you can redistribute it and/or 13 | * modify it under the terms of the GNU General Public License 14 | * as published by the Free Software Foundation; either version 15 | * 2 of the License, or (at your option) any later version. 16 | */ 17 | #ifndef _LINUX_TCP_H 18 | #define _LINUX_TCP_H 19 | 20 | #include 21 | 22 | struct tcphdr { 23 | __be16 source; 24 | __be16 dest; 25 | __be32 seq; 26 | __be32 ack_seq; 27 | #if defined(__LITTLE_ENDIAN_BITFIELD) 28 | __u16 res1:4, 29 | doff:4, 30 | fin:1, 31 | syn:1, 32 | rst:1, 33 | psh:1, 34 | ack:1, 35 | urg:1, 36 | ece:1, 37 | cwr:1; 38 | #elif defined(__BIG_ENDIAN_BITFIELD) 39 | __u16 doff:4, 40 | res1:4, 41 | cwr:1, 42 | ece:1, 43 | urg:1, 44 | ack:1, 45 | psh:1, 46 | rst:1, 47 | syn:1, 48 | fin:1; 49 | #else 50 | #error "Adjust your defines" 51 | #endif 52 | __be16 window; 53 | __sum16 check; 54 | __be16 urg_ptr; 55 | }; 56 | 57 | /* 58 | * The union cast uses a gcc extension to avoid aliasing problems 59 | * (union is compatible to any of its members) 60 | * This means this part of the code is -fstrict-aliasing safe now. 61 | */ 62 | union tcp_word_hdr { 63 | struct tcphdr hdr; 64 | __be32 words[5]; 65 | }; 66 | 67 | #define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3]) 68 | 69 | enum { 70 | TCP_FLAG_CWR = __constant_cpu_to_be32(0x00800000), 71 | TCP_FLAG_ECE = __constant_cpu_to_be32(0x00400000), 72 | TCP_FLAG_URG = __constant_cpu_to_be32(0x00200000), 73 | TCP_FLAG_ACK = __constant_cpu_to_be32(0x00100000), 74 | TCP_FLAG_PSH = __constant_cpu_to_be32(0x00080000), 75 | TCP_FLAG_RST = __constant_cpu_to_be32(0x00040000), 76 | TCP_FLAG_SYN = __constant_cpu_to_be32(0x00020000), 77 | TCP_FLAG_FIN = __constant_cpu_to_be32(0x00010000), 78 | TCP_RESERVED_BITS = __constant_cpu_to_be32(0x0F000000), 79 | TCP_DATA_OFFSET = __constant_cpu_to_be32(0xF0000000) 80 | }; 81 | 82 | /* 83 | * TCP general constants 84 | */ 85 | #define TCP_MSS_DEFAULT 536U /* IPv4 (RFC1122, RFC2581) */ 86 | #define TCP_MSS_DESIRED 1220U /* IPv6 (tunneled), EDNS0 (RFC3226) */ 87 | 88 | 89 | #endif /* _LINUX_TCP_H */ 90 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/include/linux/type_mapper.h: -------------------------------------------------------------------------------- 1 | #ifndef __LINUX_TYPE_MAPPER_H__ 2 | #define __LINUX_TYPE_MAPPER_H__ 3 | 4 | #include 5 | 6 | #define __u64 uint64_t 7 | #define __u32 uint32_t 8 | #define __u16 uint16_t 9 | #define __u8 uint8_t 10 | 11 | #define __s64 int64_t 12 | #define __s32 int32_t 13 | #define __s16 int16_t 14 | #define __s8 int8_t 15 | 16 | #define __aligned_u64 uint64_t 17 | 18 | #define __be64 uint64_t 19 | #define __be32 uint32_t 20 | #define __be16 uint16_t 21 | 22 | #define __le64 uint64_t 23 | #define __le32 uint32_t 24 | #define __le16 uint16_t 25 | 26 | #define __sum16 uint16_t 27 | 28 | #endif 29 | 30 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/include/linux/udp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * INET An implementation of the TCP/IP protocol suite for the LINUX 3 | * operating system. INET is implemented using the BSD Socket 4 | * interface as the means of communication with the user level. 5 | * 6 | * Definitions for the UDP protocol. 7 | * 8 | * Version: @(#)udp.h 1.0.2 04/28/93 9 | * 10 | * Author: Fred N. van Kempen, 11 | * 12 | * This program is free software; you can redistribute it and/or 13 | * modify it under the terms of the GNU General Public License 14 | * as published by the Free Software Foundation; either version 15 | * 2 of the License, or (at your option) any later version. 16 | */ 17 | #ifndef _LINUX_UDP_H 18 | #define _LINUX_UDP_H 19 | 20 | #include 21 | 22 | struct udphdr { 23 | __be16 source; 24 | __be16 dest; 25 | __be16 len; 26 | __sum16 check; 27 | }; 28 | 29 | /* UDP socket options */ 30 | #define UDP_CORK 1 /* Never send partially complete segments */ 31 | #define UDP_ENCAP 100 /* Set the socket to accept encapsulated packets */ 32 | #define UDP_NO_CHECK6_TX 101 /* Disable sending checksum for UDP6X */ 33 | #define UDP_NO_CHECK6_RX 102 /* Disable accpeting checksum for UDP6 */ 34 | 35 | /* UDP encapsulation types */ 36 | #define UDP_ENCAP_ESPINUDP_NON_IKE 1 /* draft-ietf-ipsec-nat-t-ike-00/01 */ 37 | #define UDP_ENCAP_ESPINUDP 2 /* draft-ietf-ipsec-udp-encaps-06 */ 38 | #define UDP_ENCAP_L2TPINUDP 3 /* rfc2661 */ 39 | 40 | 41 | #endif /* _LINUX_UDP_H */ 42 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/lib/arp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2017 Authors of Cilium 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | #ifndef __LIB_ARP__ 19 | #define __LIB_ARP__ 20 | 21 | #include 22 | #include 23 | #include "eth.h" 24 | #include "dbg.h" 25 | #include "drop.h" 26 | 27 | struct arp_eth { 28 | unsigned char ar_sha[ETH_ALEN]; 29 | __be32 ar_sip; 30 | unsigned char ar_tha[ETH_ALEN]; 31 | __be32 ar_tip; 32 | } __attribute__((packed)); 33 | 34 | /* Check if packet is ARP request for IP */ 35 | static inline int arp_check(struct ethhdr *eth, struct arphdr *arp, 36 | struct arp_eth *arp_eth, __be32 ip, 37 | union macaddr *mac) 38 | { 39 | union macaddr *dmac = (union macaddr *) ð->h_dest; 40 | 41 | return arp->ar_op == bpf_htons(ARPOP_REQUEST) && 42 | arp->ar_hrd == bpf_htons(ARPHRD_ETHER) && 43 | (eth_is_bcast(dmac) || !eth_addrcmp(dmac, mac)) && 44 | arp_eth->ar_tip == ip; 45 | } 46 | 47 | static inline int arp_prepare_response(struct __sk_buff *skb, struct ethhdr *eth, 48 | struct arp_eth *arp_eth, __be32 ip, 49 | union macaddr *mac) 50 | { 51 | union macaddr smac = *(union macaddr *) ð->h_source; 52 | __be32 sip = arp_eth->ar_sip; 53 | __be16 arpop = bpf_htons(ARPOP_REPLY); 54 | 55 | if (eth_store_saddr(skb, mac->addr, 0) < 0 || 56 | eth_store_daddr(skb, smac.addr, 0) < 0 || 57 | skb_store_bytes(skb, 20, &arpop, sizeof(arpop), 0) < 0 || 58 | skb_store_bytes(skb, 22, mac, 6, 0) < 0 || 59 | skb_store_bytes(skb, 28, &ip, 4, 0) < 0 || 60 | skb_store_bytes(skb, 32, &smac, sizeof(smac), 0) < 0 || 61 | skb_store_bytes(skb, 38, &sip, sizeof(sip), 0) < 0) 62 | return DROP_WRITE_ERROR; 63 | 64 | return 0; 65 | } 66 | 67 | static inline int arp_respond(struct __sk_buff *skb, union macaddr *mac, __be32 ip) 68 | { 69 | void *data_end = (void *) (long) skb->data_end; 70 | void *data = (void *) (long) skb->data; 71 | struct arphdr *arp = data + ETH_HLEN; 72 | struct ethhdr *eth = data; 73 | struct arp_eth *arp_eth; 74 | int ret; 75 | 76 | if (data + ETH_HLEN + sizeof(*arp) + sizeof(*arp_eth) > data_end) 77 | return TC_ACT_OK; 78 | 79 | arp_eth = data + ETH_HLEN + sizeof(*arp); 80 | 81 | if (arp_check(eth, arp, arp_eth, ip, mac)) { 82 | ret = arp_prepare_response(skb, eth, arp_eth, ip, mac); 83 | if (unlikely(ret != 0)) 84 | goto error; 85 | 86 | cilium_trace_capture(skb, DBG_CAPTURE_DELIVERY, skb->ifindex); 87 | return redirect(skb->ifindex, 0); 88 | } 89 | 90 | /* Pass any unknown ARP requests to the Linux stack */ 91 | return TC_ACT_OK; 92 | 93 | error: 94 | return send_drop_notify_error(skb, ret, TC_ACT_SHOT); 95 | } 96 | 97 | #endif /* __LIB_ARP__ */ 98 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/lib/csum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2017 Authors of Cilium 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #ifndef __LIB_CSUM_H_ 20 | #define __LIB_CSUM_H_ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #define TCP_CSUM_OFF (offsetof(struct tcphdr, check)) 27 | #define UDP_CSUM_OFF (offsetof(struct udphdr, check)) 28 | 29 | struct csum_offset 30 | { 31 | __u16 offset; 32 | __u16 flags; 33 | }; 34 | 35 | /** 36 | * Determins the L4 checksum field offset and required flags 37 | * @arg nexthdr L3 nextheader field 38 | * @arg off Pointer to uninitialied struct csum_offset struct 39 | * 40 | * Sets off.offset to offset from start of L4 header to L4 checksum field 41 | * and off.flags to the required flags, namely BPF_F_MARK_MANGLED_0 for UDP. 42 | * For unknown L4 protocols or L4 protocols which do not have a checksum 43 | * field, off is initialied to 0. 44 | */ 45 | static inline void csum_l4_offset_and_flags(__u8 nexthdr, struct csum_offset *off) 46 | { 47 | switch (nexthdr) { 48 | case IPPROTO_TCP: 49 | off->offset = TCP_CSUM_OFF; 50 | break; 51 | 52 | case IPPROTO_UDP: 53 | off->offset = UDP_CSUM_OFF; 54 | off->flags = BPF_F_MARK_MANGLED_0; 55 | break; 56 | 57 | case IPPROTO_ICMPV6: 58 | off->offset = offsetof(struct icmp6hdr, icmp6_cksum); 59 | break; 60 | 61 | case IPPROTO_ICMP: 62 | break; 63 | } 64 | } 65 | 66 | /** 67 | * Helper to change L4 checksum 68 | * @arg skb Packet 69 | * @arg l4_off Offset to L4 header 70 | * @arg csum Pointer to csum_offset as extracted by csum_l4_offset_and_flags() 71 | * @arg from From value or 0 if to contains csum diff 72 | * @arg to To value or a csum diff 73 | * @arg flags Additional flags to be passed to l4_csum_replace() 74 | */ 75 | static inline int csum_l4_replace(struct __sk_buff *skb, int l4_off, struct csum_offset *csum, 76 | int from, int to, int flags) 77 | { 78 | return l4_csum_replace(skb, l4_off + csum->offset, from, to, flags | csum->flags); 79 | } 80 | 81 | #endif /* __LB_H_ */ 82 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/lib/dbg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2017 Authors of Cilium 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | #ifndef __LIB_DBG__ 19 | #define __LIB_DBG__ 20 | 21 | /* Trace types */ 22 | enum { 23 | DBG_UNSPEC, 24 | DBG_GENERIC, /* Generic, no message, useful to dump random integers */ 25 | DBG_LOCAL_DELIVERY, 26 | DBG_ENCAP, 27 | DBG_LXC_FOUND, 28 | DBG_POLICY_DENIED, 29 | DBG_CT_LOOKUP, 30 | DBG_CT_LOOKUP_REV, 31 | DBG_CT_MATCH, 32 | DBG_CT_CREATED, 33 | DBG_CT_CREATED2, 34 | DBG_ICMP6_HANDLE, 35 | DBG_ICMP6_REQUEST, 36 | DBG_ICMP6_NS, 37 | DBG_ICMP6_TIME_EXCEEDED, 38 | DBG_CT_VERDICT, 39 | DBG_DECAP, 40 | DBG_PORT_MAP, 41 | DBG_ERROR_RET, 42 | DBG_TO_HOST, 43 | DBG_TO_STACK, 44 | DBG_PKT_HASH, 45 | DBG_LB6_LOOKUP_MASTER, 46 | DBG_LB6_LOOKUP_MASTER_FAIL, 47 | DBG_LB6_LOOKUP_SLAVE, 48 | DBG_LB6_LOOKUP_SLAVE_SUCCESS, 49 | DBG_LB6_REVERSE_NAT_LOOKUP, 50 | DBG_LB6_REVERSE_NAT, 51 | DBG_LB4_LOOKUP_MASTER, 52 | DBG_LB4_LOOKUP_MASTER_FAIL, 53 | DBG_LB4_LOOKUP_SLAVE, 54 | DBG_LB4_LOOKUP_SLAVE_SUCCESS, 55 | DBG_LB4_REVERSE_NAT_LOOKUP, 56 | DBG_LB4_REVERSE_NAT, 57 | DBG_LB4_LOOPBACK_SNAT, 58 | DBG_LB4_LOOPBACK_SNAT_REV, 59 | DBG_CT_LOOKUP4, 60 | DBG_RR_SLAVE_SEL, 61 | DBG_REV_PROXY_LOOKUP, 62 | DBG_REV_PROXY_FOUND, 63 | DBG_REV_PROXY_UPDATE, 64 | DBG_L4_POLICY, 65 | DBG_NETDEV_IN_CLUSTER, /* arg1: security-context, arg2: unused */ 66 | DBG_NETDEV_ENCAP4, /* arg1 encap lookup key, arg2: identity */ 67 | }; 68 | 69 | /* Capture types */ 70 | enum { 71 | DBG_CAPTURE_UNSPEC, 72 | DBG_CAPTURE_FROM_LXC, 73 | DBG_CAPTURE_FROM_NETDEV, 74 | DBG_CAPTURE_FROM_OVERLAY, 75 | DBG_CAPTURE_DELIVERY, 76 | DBG_CAPTURE_FROM_LB, 77 | DBG_CAPTURE_AFTER_V46, 78 | DBG_CAPTURE_AFTER_V64, 79 | DBG_CAPTURE_PROXY_PRE, 80 | DBG_CAPTURE_PROXY_POST, 81 | }; 82 | 83 | #ifndef EVENT_SOURCE 84 | #define EVENT_SOURCE 0 85 | #endif 86 | 87 | #if defined DEBUG || defined ENABLE_TRACE 88 | #include "events.h" 89 | #endif 90 | 91 | #ifdef DEBUG 92 | #include "utils.h" 93 | 94 | # define printk(fmt, ...) \ 95 | ({ \ 96 | char ____fmt[] = fmt; \ 97 | trace_printk(____fmt, sizeof(____fmt), \ 98 | ##__VA_ARGS__); \ 99 | }) 100 | 101 | struct debug_msg { 102 | NOTIFY_COMMON_HDR 103 | __u32 arg1; 104 | __u32 arg2; 105 | __u32 arg3; 106 | }; 107 | 108 | static inline void cilium_trace(struct __sk_buff *skb, __u8 type, __u32 arg1, __u32 arg2) 109 | { 110 | uint32_t hash = get_hash_recalc(skb); 111 | struct debug_msg msg = { 112 | .type = CILIUM_NOTIFY_DBG_MSG, 113 | .subtype = type, 114 | .source = EVENT_SOURCE, 115 | .hash = hash, 116 | .arg1 = arg1, 117 | .arg2 = arg2, 118 | }; 119 | 120 | skb_event_output(skb, &cilium_events, BPF_F_CURRENT_CPU, &msg, sizeof(msg)); 121 | } 122 | 123 | static inline void cilium_trace3(struct __sk_buff *skb, __u8 type, __u32 arg1, 124 | __u32 arg2, __u32 arg3) 125 | { 126 | uint32_t hash = get_hash_recalc(skb); 127 | struct debug_msg msg = { 128 | .type = CILIUM_NOTIFY_DBG_MSG, 129 | .subtype = type, 130 | .source = EVENT_SOURCE, 131 | .hash = hash, 132 | .arg1 = arg1, 133 | .arg2 = arg2, 134 | .arg3 = arg3, 135 | }; 136 | 137 | skb_event_output(skb, &cilium_events, BPF_F_CURRENT_CPU, &msg, sizeof(msg)); 138 | } 139 | 140 | #else 141 | # define printk(fmt, ...) \ 142 | do { } while (0) 143 | 144 | static inline void cilium_trace(struct __sk_buff *skb, __u8 type, __u32 arg1, __u32 arg2) 145 | { 146 | } 147 | 148 | static inline void cilium_trace3(struct __sk_buff *skb, __u8 type, __u32 arg1, 149 | __u32 arg2, __u32 arg3) 150 | { 151 | } 152 | 153 | #endif 154 | 155 | #ifdef ENABLE_TRACE 156 | 157 | #ifndef TRACE_PAYLOAD_LEN 158 | #define TRACE_PAYLOAD_LEN 128ULL 159 | #endif 160 | 161 | struct debug_capture_msg { 162 | NOTIFY_COMMON_HDR 163 | __u32 len_orig; 164 | __u32 len_cap; 165 | __u32 arg1; 166 | __u32 arg2; 167 | }; 168 | 169 | static inline void cilium_trace_capture2(struct __sk_buff *skb, __u8 type, __u32 arg1, __u32 arg2) 170 | { 171 | uint64_t skb_len = skb->len, cap_len = min(TRACE_PAYLOAD_LEN, skb_len); 172 | uint32_t hash = get_hash_recalc(skb); 173 | struct debug_capture_msg msg = { 174 | .type = CILIUM_NOTIFY_DBG_CAPTURE, 175 | .subtype = type, 176 | .source = EVENT_SOURCE, 177 | .hash = hash, 178 | .len_orig = skb_len, 179 | .len_cap = cap_len, 180 | .arg1 = arg1, 181 | .arg2 = arg2, 182 | }; 183 | 184 | skb_event_output(skb, &cilium_events, 185 | (cap_len << 32) | BPF_F_CURRENT_CPU, 186 | &msg, sizeof(msg)); 187 | } 188 | 189 | static inline void cilium_trace_capture(struct __sk_buff *skb, __u8 type, __u32 arg1) 190 | { 191 | return cilium_trace_capture2(skb, type, arg1, 0); 192 | } 193 | 194 | #else /* ENABLE_TRACE */ 195 | 196 | static inline void cilium_trace_capture(struct __sk_buff *skb, __u8 type, __u32 arg1) 197 | { 198 | } 199 | 200 | static inline void cilium_trace_capture2(struct __sk_buff *skb, __u8 type, __u32 arg1, __u32 arg2) 201 | { 202 | } 203 | 204 | #endif /* ENABLE_TRACE */ 205 | 206 | 207 | #endif /* __LIB_DBG__ */ 208 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/lib/drop.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2017 Authors of Cilium 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | /* 19 | * Drop & error notification via perf event ring buffer 20 | * 21 | * API: 22 | * int send_drop_notify(skb, src, dst, dst_id, ifindex, exitcode) 23 | * int send_drop_notify_error(skb, error, exitcode) 24 | * 25 | * Both functions are implemented as terminal calls and will cause the BPF 26 | * program to terminate after execution. 27 | * 28 | * If DROP_NOTIFY is not defined, the API will be compiled in as a NOP. 29 | */ 30 | 31 | #ifndef __LIB_DROP__ 32 | #define __LIB_DROP__ 33 | 34 | #include "dbg.h" 35 | #include "events.h" 36 | #include "common.h" 37 | #include "utils.h" 38 | 39 | #ifdef DROP_NOTIFY 40 | __section_tail(CILIUM_MAP_CALLS, CILIUM_CALL_ERROR_NOTIFY) int __send_error_notify(struct __sk_buff *skb) 41 | { 42 | uint64_t skb_len = skb->len, cap_len = min(128ULL, skb_len); 43 | uint32_t hash = get_hash_recalc(skb); 44 | struct drop_notify msg = { 45 | .type = CILIUM_NOTIFY_DROP, 46 | .source = EVENT_SOURCE, 47 | .hash = hash, 48 | .len_orig = skb_len, 49 | .len_cap = cap_len, 50 | .ifindex = skb->ingress_ifindex, 51 | }; 52 | int error = skb->cb[1]; 53 | 54 | if (error < 0) 55 | error = -error; 56 | 57 | msg.subtype = error; 58 | 59 | skb_event_output(skb, &cilium_events, 60 | (cap_len << 32) | BPF_F_CURRENT_CPU, 61 | &msg, sizeof(msg)); 62 | 63 | return skb->cb[0]; 64 | } 65 | 66 | /** 67 | * send_drop_notify_error 68 | * @skb: socket buffer 69 | * @error: error code to be returned 70 | * @exitcode: error code to return to the kernel 71 | * 72 | * Generate a notification to indicate a packet was dropped due to an error 73 | * condition while parsing and processing the packet. Use send_drop_notify() 74 | * instead for any policy related drops. 75 | * 76 | * NOTE: This is terminal function and will cause the BPF program to exit 77 | */ 78 | static inline int send_drop_notify_error(struct __sk_buff *skb, int error, int exitcode) 79 | { 80 | if (IS_ERR(error)) { 81 | skb->cb[0] = exitcode; 82 | skb->cb[1] = error; 83 | 84 | ep_tail_call(skb, CILIUM_CALL_ERROR_NOTIFY); 85 | 86 | return exitcode; 87 | } 88 | 89 | /* No error condition, return original return code */ 90 | return error; 91 | } 92 | 93 | __section_tail(CILIUM_MAP_CALLS, CILIUM_CALL_DROP_NOTIFY) int __send_drop_notify(struct __sk_buff *skb) 94 | { 95 | uint64_t skb_len = skb->len, cap_len = min(64ULL, skb_len); 96 | uint32_t hash = get_hash_recalc(skb); 97 | struct drop_notify msg = { 98 | .type = CILIUM_NOTIFY_DROP, 99 | .subtype = -(DROP_POLICY), 100 | .source = EVENT_SOURCE, 101 | .hash = hash, 102 | .len_orig = skb_len, 103 | .len_cap = cap_len, 104 | .src_label = skb->cb[1], 105 | .dst_label = skb->cb[2], 106 | .dst_id = skb->cb[3], 107 | .ifindex = skb->cb[4], 108 | }; 109 | 110 | skb_event_output(skb, &cilium_events, 111 | (cap_len << 32) | BPF_F_CURRENT_CPU, 112 | &msg, sizeof(msg)); 113 | 114 | return skb->cb[0]; 115 | } 116 | 117 | /** 118 | * send_drop_notify 119 | * @skb: socket buffer 120 | * @src: source context ID 121 | * @dst: destination context ID 122 | * @dst_id: designated destination container ID 123 | * @ifindex: designated destination ifindex 124 | * @exitcode: error code to return to the kernel 125 | * 126 | * Generate a notification to indicate a packet was dropped due to a policy 127 | * violation. Use send_drop_notify_error() for any generic error related 128 | * packet drops instead. 129 | * 130 | * NOTE: This is terminal function and will cause the BPF program to exit 131 | */ 132 | static inline int send_drop_notify(struct __sk_buff *skb, __u32 src, __u32 dst, 133 | __u32 dst_id, __u32 ifindex, int exitcode) 134 | { 135 | skb->cb[0] = exitcode; 136 | skb->cb[1] = src; 137 | skb->cb[2] = dst; 138 | skb->cb[3] = dst_id; 139 | skb->cb[4] = ifindex, 140 | 141 | ep_tail_call(skb, CILIUM_CALL_DROP_NOTIFY); 142 | 143 | return exitcode; 144 | } 145 | #else 146 | static inline int send_drop_notify_error(struct __sk_buff *skb, int error, int exitcode) 147 | { 148 | return exitcode; 149 | } 150 | 151 | static inline int send_drop_notify(struct __sk_buff *skb, __u32 src, __u32 dst, 152 | __u32 dst_id, __u32 ifindex, int exitcode) 153 | { 154 | return exitcode; 155 | } 156 | #endif 157 | 158 | #endif /* __LIB_DROP__ */ 159 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/lib/encap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2017 Authors of Cilium 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | #ifndef __LIB_ENCAP_H_ 19 | #define __LIB_ENCAP_H_ 20 | 21 | #include "common.h" 22 | #include "dbg.h" 23 | #include "geneve.h" 24 | 25 | /* validating options on tx is optional */ 26 | #undef VALIDATE_GENEVE_TX 27 | 28 | #ifdef ENCAP_IFINDEX 29 | 30 | static inline int __encap_and_redirect(struct __sk_buff *skb, struct endpoint_key *k, 31 | __u32 seclabel, uint8_t *buf, int sz) 32 | { 33 | struct endpoint_key *tunnel; 34 | struct bpf_tunnel_key key = {}; 35 | __u32 node_id; 36 | int ret; 37 | 38 | if ((tunnel = map_lookup_elem(&tunnel_endpoint_map, k)) == NULL) { 39 | return DROP_NO_TUNNEL_ENDPOINT; 40 | } 41 | 42 | node_id = bpf_htonl(tunnel->ip4); 43 | key.tunnel_id = seclabel; 44 | key.remote_ipv4 = node_id; 45 | 46 | cilium_trace(skb, DBG_ENCAP, node_id, seclabel); 47 | 48 | ret = skb_set_tunnel_key(skb, &key, sizeof(key), 0); 49 | if (unlikely(ret < 0)) 50 | return DROP_WRITE_ERROR; 51 | 52 | #ifdef GENEVE_OPTS 53 | ret = skb_set_tunnel_opt(skb, buf, sz); 54 | if (unlikely(ret < 0)) 55 | return DROP_WRITE_ERROR; 56 | #ifdef VALIDATE_GENEVE_TX 57 | if (1) { 58 | struct geneveopt_val geneveopt_val = {}; 59 | 60 | ret = parse_geneve_options(&geneveopt_val, buf); 61 | if (IS_ERR(ret)) 62 | return ret; 63 | } 64 | #endif /* VALIDATE_GENEVE_TX */ 65 | #endif /* GENEVE_OPTS */ 66 | 67 | return redirect(ENCAP_IFINDEX, 0); 68 | } 69 | 70 | static inline int __inline__ encap_and_redirect(struct __sk_buff *skb, struct endpoint_key *key, 71 | __u32 seclabel) 72 | { 73 | #ifdef GENEVE_OPTS 74 | uint8_t buf[] = GENEVE_OPTS; 75 | #else 76 | uint8_t buf[] = {}; 77 | #endif 78 | return __encap_and_redirect(skb, key, seclabel, buf, sizeof(buf)); 79 | } 80 | 81 | 82 | #endif /* ENCAP_IFINDEX */ 83 | 84 | #endif /* __LIB_ENCAP_H_ */ 85 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/lib/eth.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2017 Authors of Cilium 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | #ifndef __LIB_ETH__ 19 | #define __LIB_ETH__ 20 | 21 | #include 22 | 23 | #ifndef ETH_HLEN 24 | #define ETH_HLEN 14 25 | #endif 26 | 27 | #ifndef ETH_ALEN 28 | #define ETH_ALEN 6 29 | #endif 30 | 31 | union macaddr { 32 | struct { 33 | __u32 p1; 34 | __u16 p2; 35 | }; 36 | __u8 addr[6]; 37 | }; 38 | 39 | static inline int eth_addrcmp(const union macaddr *a, const union macaddr *b) 40 | { 41 | int tmp; 42 | 43 | tmp = a->p1 - b->p1; 44 | if (!tmp) 45 | tmp = a->p2 - b->p2; 46 | 47 | return tmp; 48 | } 49 | 50 | static inline int eth_is_bcast(const union macaddr *a) 51 | { 52 | union macaddr bcast; 53 | 54 | bcast.p1 = 0xffffffff; 55 | bcast.p2 = 0xffff; 56 | 57 | if (!eth_addrcmp(a, &bcast)) 58 | return 1; 59 | else 60 | return 0; 61 | } 62 | 63 | static inline int eth_load_saddr(struct __sk_buff *skb, __u8 *mac, int off) 64 | { 65 | return skb_load_bytes(skb, off + ETH_ALEN, mac, ETH_ALEN); 66 | } 67 | 68 | static inline int eth_store_saddr(struct __sk_buff *skb, __u8 *mac, int off) 69 | { 70 | return skb_store_bytes(skb, off + ETH_ALEN, mac, ETH_ALEN, 0); 71 | } 72 | 73 | static inline int eth_load_daddr(struct __sk_buff *skb, __u8 *mac, int off) 74 | { 75 | return skb_load_bytes(skb, off, mac, ETH_ALEN); 76 | } 77 | 78 | static inline int eth_store_daddr(struct __sk_buff *skb, __u8 *mac, int off) 79 | { 80 | return skb_store_bytes(skb, off, mac, ETH_ALEN, 0); 81 | } 82 | 83 | #endif /* __LIB_ETH__ */ 84 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/lib/events.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2017 Authors of Cilium 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | #ifndef __LIB_EVENTS_H_ 19 | #define __LIB_EVENTS_H_ 20 | 21 | #include 22 | 23 | struct bpf_elf_map __section_maps cilium_events = { 24 | .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY, 25 | .size_key = sizeof(__u32), 26 | .size_value = sizeof(__u32), 27 | .pinning = PIN_GLOBAL_NS, 28 | .max_elem = __NR_CPUS__, 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/lib/geneve.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2017 Authors of Cilium 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | #ifndef __LIB_GENEVE_H 19 | #define __LIB_GENEVE_H 20 | 21 | #define MAX_GENEVE_OPT_LEN 64 /* fixme support upto 252 bytes */ 22 | #define GENEVE_CLASS_EXPERIMENTAL 0xffff 23 | #define GENEVE_TYPE_SECLABEL 1 24 | /* This struct is passed around in the bpf program */ 25 | struct geneveopt_val { 26 | __u32 seclabel; 27 | }; 28 | 29 | struct geneve_opt { 30 | __be16 opt_class; 31 | __u8 type; 32 | #ifdef __LITTLE_ENDIAN_BITFIELD 33 | __u8 length:5; 34 | __u8 r3:1; 35 | __u8 r2:1; 36 | __u8 r1:1; 37 | #else 38 | __u8 r1:1; 39 | __u8 r2:1; 40 | __u8 r3:1; 41 | __u8 length:5; 42 | #endif 43 | __u8 opt_data[]; 44 | }; 45 | 46 | static inline int parse_geneve_options(struct geneveopt_val *val, uint8_t *buf) 47 | { 48 | struct geneve_opt *opt = (struct geneve_opt *)buf; 49 | 50 | if (opt->opt_class != GENEVE_CLASS_EXPERIMENTAL || 51 | opt->type != GENEVE_TYPE_SECLABEL || 52 | (opt->length << 2) != sizeof(val->seclabel)) 53 | return DROP_INVALID_GENEVE; 54 | 55 | val->seclabel = bpf_ntohl(*(__u32*)opt->opt_data); 56 | #ifdef DEBUG_GENEVE 57 | printk("geneve seclabel %x\n", val->seclabel); 58 | #endif 59 | return 0; 60 | } 61 | 62 | #endif /* __LIB_GENEVE_H */ 63 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/lib/ipv4.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2017 Authors of Cilium 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | #ifndef __LIB_IPV4__ 19 | #define __LIB_IPV4__ 20 | 21 | #include 22 | 23 | #include "dbg.h" 24 | 25 | static inline int ipv4_load_daddr(struct __sk_buff *skb, int off, __u32 *dst) 26 | { 27 | return skb_load_bytes(skb, off + offsetof(struct iphdr, daddr), dst, 4); 28 | } 29 | 30 | static inline int ipv4_dec_ttl(struct __sk_buff *skb, int off, struct iphdr *ip4) 31 | { 32 | __u8 new_ttl, ttl = ip4->ttl; 33 | 34 | if (ttl <= 1) 35 | return 1; 36 | 37 | new_ttl = ttl - 1; 38 | /* l3_csum_replace() takes at min 2 bytes, zero extended. */ 39 | l3_csum_replace(skb, off + offsetof(struct iphdr, check), ttl, new_ttl, 2); 40 | skb_store_bytes(skb, off + offsetof(struct iphdr, ttl), &new_ttl, sizeof(new_ttl), 0); 41 | 42 | return 0; 43 | } 44 | 45 | static inline int ipv4_hdrlen(struct iphdr *ip4) 46 | { 47 | return ip4->ihl * 4; 48 | } 49 | 50 | #endif /* __LIB_IPV4__ */ 51 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/lib/l3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2017 Authors of Cilium 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | #ifndef __LIB_L3_H_ 19 | #define __LIB_L3_H_ 20 | 21 | #include "common.h" 22 | #include "ipv6.h" 23 | #include "ipv4.h" 24 | #include "eth.h" 25 | #include "dbg.h" 26 | #include "l4.h" 27 | #include "icmp6.h" 28 | #include "csum.h" 29 | 30 | static inline int __inline__ ipv6_l3(struct __sk_buff *skb, int l3_off, 31 | __u8 *smac, __u8 *dmac) 32 | { 33 | int ret; 34 | 35 | ret = ipv6_dec_hoplimit(skb, l3_off); 36 | if (IS_ERR(ret)) 37 | return ret; 38 | 39 | if (ret > 0) { 40 | /* Hoplimit was reached */ 41 | return icmp6_send_time_exceeded(skb, l3_off); 42 | } 43 | 44 | if (smac && eth_store_saddr(skb, smac, 0) < 0) 45 | return DROP_WRITE_ERROR; 46 | 47 | if (eth_store_daddr(skb, dmac, 0) < 0) 48 | return DROP_WRITE_ERROR; 49 | 50 | return TC_ACT_OK; 51 | } 52 | 53 | static inline int __inline__ ipv4_l3(struct __sk_buff *skb, int l3_off, 54 | __u8 *smac, __u8 *dmac, struct iphdr *ip4) 55 | { 56 | if (ipv4_dec_ttl(skb, l3_off, ip4)) { 57 | /* FIXME: Send ICMP TTL */ 58 | return DROP_INVALID; 59 | } 60 | 61 | if (smac && eth_store_saddr(skb, smac, 0) < 0) 62 | return DROP_WRITE_ERROR; 63 | 64 | if (eth_store_daddr(skb, dmac, 0) < 0) 65 | return DROP_WRITE_ERROR; 66 | 67 | return TC_ACT_OK; 68 | } 69 | 70 | #ifndef DISABLE_PORT_MAP 71 | static inline int __inline__ map_lxc_in(struct __sk_buff *skb, int l4_off, 72 | struct endpoint_info *lxc, __u8 nexthdr) 73 | { 74 | struct csum_offset off = {}; 75 | uint16_t dport; 76 | int i, ret; 77 | 78 | if (!lxc->portmap[0].to) 79 | return 0; 80 | 81 | /* Ignore unknown L4 protocols */ 82 | if (nexthdr != IPPROTO_TCP && nexthdr != IPPROTO_UDP) 83 | return 0; 84 | 85 | /* Port offsets for TCP and UDP are the same */ 86 | if (skb_load_bytes(skb, l4_off + TCP_DPORT_OFF, &dport, sizeof(dport)) < 0) 87 | return DROP_INVALID; 88 | 89 | csum_l4_offset_and_flags(nexthdr, &off); 90 | 91 | #pragma unroll 92 | for (i = 0; i < PORTMAP_MAX; i++) { 93 | if (!lxc->portmap[i].to || !lxc->portmap[i].from) 94 | break; 95 | 96 | ret = l4_port_map_in(skb, l4_off, &off, &lxc->portmap[i], dport); 97 | if (IS_ERR(ret)) 98 | return ret; 99 | } 100 | 101 | return 0; 102 | } 103 | #endif /* DISABLE_PORT_MAP */ 104 | 105 | static inline struct endpoint_info *__inline__ lookup_ip6_endpoint(struct ipv6hdr *ip6) 106 | { 107 | struct endpoint_key key = {}; 108 | key.ip6 = *((union v6addr *) &ip6->daddr); 109 | key.family = ENDPOINT_KEY_IPV6; 110 | 111 | return map_lookup_elem(&cilium_lxc, &key); 112 | } 113 | 114 | static inline int ipv6_local_delivery(struct __sk_buff *skb, int l3_off, int l4_off, 115 | __u32 seclabel, struct ipv6hdr *ip6, __u8 nexthdr, 116 | struct endpoint_info *ep) 117 | { 118 | int ret; 119 | 120 | cilium_trace(skb, DBG_LOCAL_DELIVERY, ep->lxc_id, seclabel); 121 | 122 | mac_t lxc_mac = ep->mac; 123 | mac_t router_mac = ep->node_mac; 124 | 125 | /* This will invalidate the size check */ 126 | ret = ipv6_l3(skb, l3_off, (__u8 *) &router_mac, (__u8 *) &lxc_mac); 127 | if (ret != TC_ACT_OK) 128 | return ret; 129 | 130 | #ifndef DISABLE_PORT_MAP 131 | ret = map_lxc_in(skb, l4_off, ep, nexthdr); 132 | if (IS_ERR(ret)) 133 | return ret; 134 | #endif /* DISABLE_PORT_MAP */ 135 | 136 | cilium_trace(skb, DBG_LXC_FOUND, ep->ifindex, ep->sec_label); 137 | skb->cb[CB_SRC_LABEL] = seclabel; 138 | skb->cb[CB_IFINDEX] = ep->ifindex; 139 | 140 | tail_call(skb, &cilium_policy, ep->lxc_id); 141 | return DROP_MISSED_TAIL_CALL; 142 | } 143 | 144 | static inline struct endpoint_info *__inline__ lookup_ip4_endpoint(struct iphdr *ip4) 145 | { 146 | struct endpoint_key key = {}; 147 | key.ip4 = ip4->daddr; 148 | key.family = ENDPOINT_KEY_IPV4; 149 | 150 | return map_lookup_elem(&cilium_lxc, &key); 151 | } 152 | 153 | static inline int __inline__ ipv4_local_delivery(struct __sk_buff *skb, int l3_off, int l4_off, 154 | __u32 seclabel, struct iphdr *ip4, 155 | struct endpoint_info *ep) 156 | { 157 | int ret; 158 | 159 | cilium_trace(skb, DBG_LOCAL_DELIVERY, ep->lxc_id, seclabel); 160 | 161 | mac_t lxc_mac = ep->mac; 162 | mac_t router_mac = ep->node_mac; 163 | __u8 nexthdr = ip4->protocol; 164 | 165 | ret = ipv4_l3(skb, l3_off, (__u8 *) &router_mac, (__u8 *) &lxc_mac, ip4); 166 | if (ret != TC_ACT_OK) 167 | return ret; 168 | 169 | #ifndef DISABLE_PORT_MAP 170 | ret = map_lxc_in(skb, l4_off, ep, nexthdr); 171 | if (IS_ERR(ret)) 172 | return ret; 173 | #endif /* DISABLE_PORT_MAP */ 174 | 175 | cilium_trace(skb, DBG_LXC_FOUND, ep->ifindex, ep->sec_label); 176 | skb->cb[CB_SRC_LABEL] = seclabel; 177 | skb->cb[CB_IFINDEX] = ep->ifindex; 178 | 179 | tail_call(skb, &cilium_policy, ep->lxc_id); 180 | return DROP_MISSED_TAIL_CALL; 181 | } 182 | 183 | #endif 184 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/lib/lxc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2017 Authors of Cilium 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | #ifndef __LIB_LXC_H_ 19 | #define __LIB_LXC_H_ 20 | 21 | #include "common.h" 22 | #include "ipv6.h" 23 | #include "ipv4.h" 24 | #include "eth.h" 25 | #include "dbg.h" 26 | #include "csum.h" 27 | #include "l4.h" 28 | 29 | #ifndef DISABLE_SMAC_VERIFICATION 30 | static inline int is_valid_lxc_src_mac(struct ethhdr *eth) 31 | { 32 | union macaddr valid = LXC_MAC; 33 | 34 | return !eth_addrcmp(&valid, (union macaddr *) ð->h_source); 35 | } 36 | #else 37 | static inline int is_valid_lxc_src_mac(struct ethhdr *eth) 38 | { 39 | return 1; 40 | } 41 | #endif 42 | 43 | #ifndef DISABLE_SIP_VERIFICATION 44 | static inline int is_valid_lxc_src_ip(struct ipv6hdr *ip6) 45 | { 46 | union v6addr valid = {}; 47 | 48 | BPF_V6(valid, LXC_IP); 49 | 50 | return !ipv6_addrcmp((union v6addr *) &ip6->saddr, &valid); 51 | } 52 | 53 | static inline int is_valid_lxc_src_ipv4(struct iphdr *ip4) 54 | { 55 | #ifdef LXC_IPV4 56 | return ip4->saddr == LXC_IPV4; 57 | #else 58 | /* Can't send IPv4 if no IPv4 address is configured */ 59 | return 0; 60 | #endif 61 | } 62 | #else 63 | static inline int is_valid_lxc_src_ip(struct ipv6hdr *ip6) 64 | { 65 | return 1; 66 | } 67 | 68 | static inline int is_valid_lxc_src_ipv4(struct iphdr *ip4) 69 | { 70 | return 1; 71 | } 72 | #endif 73 | 74 | #ifndef DISABLE_DMAC_VERIFICATION 75 | static inline int is_valid_gw_dst_mac(struct ethhdr *eth) 76 | { 77 | union macaddr valid = NODE_MAC; 78 | 79 | return !eth_addrcmp(&valid, (union macaddr *) ð->h_dest); 80 | } 81 | #else 82 | static inline int is_valid_gw_dst_mac(struct ethhdr *eth) 83 | { 84 | return 1; 85 | } 86 | #endif 87 | 88 | #ifdef LXC_IPV4 89 | static inline int __inline__ 90 | ipv4_redirect_to_host_port(struct __sk_buff *skb, struct csum_offset *csum, 91 | int l4_off, __u16 new_port, __u16 old_port, __be32 old_ip, 92 | struct ipv4_ct_tuple *tuple, __u32 identity) 93 | { 94 | __be32 host_ip = IPV4_GATEWAY; 95 | struct proxy4_tbl_key key = { 96 | .saddr = tuple->daddr, 97 | .sport = tuple->sport, 98 | .dport = new_port, 99 | .nexthdr = tuple->nexthdr, 100 | }; 101 | struct proxy4_tbl_value value = { 102 | .orig_daddr = old_ip, 103 | .orig_dport = old_port, 104 | .lifetime = 360, 105 | .identity = identity, 106 | }; 107 | 108 | cilium_trace_capture(skb, DBG_CAPTURE_PROXY_PRE, old_port); 109 | 110 | if (l4_modify_port(skb, l4_off, TCP_DPORT_OFF, csum, 111 | new_port, old_port) < 0) 112 | return DROP_WRITE_ERROR; 113 | 114 | if (skb_store_bytes(skb, ETH_HLEN + offsetof(struct iphdr, daddr), &host_ip, 4, 0) < 0) 115 | return DROP_WRITE_ERROR; 116 | 117 | if (l3_csum_replace(skb, ETH_HLEN + offsetof(struct iphdr, check), old_ip, host_ip, 4) < 0) 118 | return DROP_CSUM_L3; 119 | 120 | if (csum->offset && 121 | csum_l4_replace(skb, l4_off, csum, old_ip, host_ip, 4 | BPF_F_PSEUDO_HDR) < 0) 122 | return DROP_CSUM_L4; 123 | 124 | cilium_trace_capture(skb, DBG_CAPTURE_PROXY_POST, new_port); 125 | 126 | cilium_trace3(skb, DBG_REV_PROXY_UPDATE, 127 | key.sport << 16 | key.dport, key.saddr, key.nexthdr); 128 | if (map_update_elem(&cilium_proxy4, &key, &value, 0) < 0) 129 | return DROP_CT_CREATE_FAILED; 130 | 131 | return 0; 132 | } 133 | #endif /* LXC_IPV4 */ 134 | 135 | static inline int __inline__ 136 | ipv6_redirect_to_host_port(struct __sk_buff *skb, struct csum_offset *csum, 137 | int l4_off, __u16 new_port, __u16 old_port, 138 | union v6addr old_ip, struct ipv6_ct_tuple *tuple, union v6addr *host_ip, 139 | __u32 identity) 140 | { 141 | struct proxy6_tbl_key key = { 142 | .saddr = tuple->daddr, 143 | .sport = tuple->sport, 144 | .dport = new_port, 145 | .nexthdr = tuple->nexthdr, 146 | }; 147 | struct proxy6_tbl_value value = { 148 | .orig_daddr = old_ip, 149 | .orig_dport = old_port, 150 | .lifetime = 360, 151 | .identity = identity, 152 | }; 153 | 154 | if (l4_modify_port(skb, l4_off, TCP_DPORT_OFF, csum, new_port, old_port) < 0) 155 | return DROP_WRITE_ERROR; 156 | 157 | if (ipv6_store_daddr(skb, host_ip->addr, ETH_HLEN) > 0) 158 | return DROP_WRITE_ERROR; 159 | 160 | if (csum->offset) { 161 | __be32 sum = csum_diff(old_ip.addr, 16, host_ip->addr, 16, 0); 162 | 163 | if (csum_l4_replace(skb, l4_off, csum, 0, sum, BPF_F_PSEUDO_HDR) < 0) 164 | return DROP_CSUM_L4; 165 | } 166 | 167 | if (map_update_elem(&cilium_proxy6, &key, &value, 0) < 0) 168 | return DROP_CT_CREATE_FAILED; 169 | 170 | return 0; 171 | } 172 | #endif 173 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/lib/policy.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2017 Authors of Cilium 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | #ifndef __LIB_POLICY_H_ 19 | #define __LIB_POLICY_H_ 20 | 21 | #include "drop.h" 22 | #include "maps.h" 23 | 24 | #ifdef POLICY_ENFORCEMENT 25 | 26 | static inline int policy_can_access(void *map, struct __sk_buff *skb, __u32 src_label, 27 | size_t cidr_addr_size, void *cidr_addr) 28 | { 29 | #ifdef DROP_ALL 30 | return DROP_POLICY; 31 | #else 32 | struct policy_entry *policy; 33 | 34 | policy = map_lookup_elem(map, &src_label); 35 | if (likely(policy)) { 36 | /* FIXME: Use per cpu counters */ 37 | __sync_fetch_and_add(&policy->packets, 1); 38 | __sync_fetch_and_add(&policy->bytes, skb->len); 39 | return TC_ACT_OK; 40 | } 41 | 42 | // cidr_addr_size is a compile time constant so this should all be inlined neatly. 43 | if (cidr_addr_size == sizeof(union v6addr) && lpm6_ingress_lookup(cidr_addr)) 44 | goto allow; 45 | if (cidr_addr_size == sizeof(__be32) && lpm4_ingress_lookup(*(__be32 *)cidr_addr)) 46 | goto allow; 47 | 48 | if (skb->cb[CB_POLICY]) 49 | goto allow; 50 | 51 | cilium_trace(skb, DBG_POLICY_DENIED, src_label, SECLABEL); 52 | 53 | #ifndef IGNORE_DROP 54 | return DROP_POLICY; 55 | #endif 56 | 57 | allow: 58 | return TC_ACT_OK; 59 | #endif /* DROP_ALL */ 60 | } 61 | 62 | /** 63 | * Mark skb to skip policy enforcement 64 | * @arg skb packet 65 | * 66 | * Will cause the packet to ignore the policy enforcement layer and 67 | * be considered accepted despite of the policy outcome. 68 | */ 69 | static inline void policy_mark_skip(struct __sk_buff *skb) 70 | { 71 | skb->cb[CB_POLICY] = 1; 72 | } 73 | 74 | static inline void policy_clear_mark(struct __sk_buff *skb) 75 | { 76 | skb->cb[CB_POLICY] = 0; 77 | } 78 | 79 | static inline int is_policy_skip(struct __sk_buff *skb) 80 | { 81 | return skb->cb[CB_POLICY]; 82 | } 83 | 84 | #else /* POLICY_ENFORCEMENT */ 85 | 86 | static inline int policy_can_access(void *map, struct __sk_buff *skb, __u32 src_label, 87 | size_t cidr_addr_size, void *cidr_addr) 88 | { 89 | return TC_ACT_OK; 90 | } 91 | 92 | static inline void policy_mark_skip(struct __sk_buff *skb) 93 | { 94 | } 95 | 96 | static inline void policy_clear_mark(struct __sk_buff *skb) 97 | { 98 | } 99 | 100 | static inline int is_policy_skip(struct __sk_buff *skb) 101 | { 102 | return 1; 103 | } 104 | #endif /* !POLICY_ENFORCEMENT */ 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/lib/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2017 Authors of Cilium 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | #ifndef __LIB_UTILS_H_ 19 | #define __LIB_UTILS_H_ 20 | 21 | #include 22 | 23 | #define min(x, y) \ 24 | ({ \ 25 | typeof(x) _x = (x); \ 26 | typeof(y) _y = (y); \ 27 | (void) (&_x == &_y); \ 28 | _x < _y ? _x : _y; \ 29 | }) 30 | 31 | #define max(x, y) \ 32 | ({ \ 33 | typeof(x) _x = (x); \ 34 | typeof(y) _y = (y); \ 35 | (void) (&_x == &_y); \ 36 | _x > _y ? _x : _y; \ 37 | }) 38 | 39 | /* Clear CB values */ 40 | static inline void bpf_clear_cb(struct __sk_buff *skb) 41 | { 42 | __u32 zero = 0; 43 | skb->cb[0] = zero; 44 | skb->cb[1] = zero; 45 | skb->cb[2] = zero; 46 | skb->cb[3] = zero; 47 | skb->cb[4] = zero; 48 | } 49 | 50 | #define NSEC_PER_SEC 1000000000UL 51 | 52 | /* Monotonic clock, scalar format. */ 53 | static inline __u64 bpf_ktime_get_nsec(void) 54 | { 55 | return ktime_get_ns(); 56 | } 57 | 58 | static inline __u32 bpf_ktime_get_sec(void) 59 | { 60 | /* Ignores remainder subtraction as we'd do in 61 | * ns_to_timespec(), but good enough here. 62 | */ 63 | return (__u64)(bpf_ktime_get_nsec() / NSEC_PER_SEC); 64 | } 65 | 66 | #if __BYTE_ORDER == __LITTLE_ENDIAN 67 | # define __bpf_ntohs(x) __builtin_bswap16(x) 68 | # define __bpf_htons(x) __builtin_bswap16(x) 69 | # define __bpf_ntohl(x) __builtin_bswap32(x) 70 | # define __bpf_htonl(x) __builtin_bswap32(x) 71 | #elif __BYTE_ORDER == __BIG_ENDIAN 72 | # define __bpf_ntohs(x) (x) 73 | # define __bpf_htons(x) (x) 74 | # define __bpf_ntohl(x) (x) 75 | # define __bpf_htonl(x) (x) 76 | #else 77 | # error "Fix your __BYTE_ORDER?!" 78 | #endif 79 | 80 | #define bpf_htons(x) \ 81 | (__builtin_constant_p(x) ? \ 82 | __constant_htons(x) : __bpf_htons(x)) 83 | #define bpf_ntohs(x) \ 84 | (__builtin_constant_p(x) ? \ 85 | __constant_ntohs(x) : __bpf_ntohs(x)) 86 | 87 | #define bpf_htonl(x) \ 88 | (__builtin_constant_p(x) ? \ 89 | __constant_htonl(x) : __bpf_htonl(x)) 90 | #define bpf_ntohl(x) \ 91 | (__builtin_constant_p(x) ? \ 92 | __constant_ntohl(x) : __bpf_ntohl(x)) 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/lxc_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2017 Authors of Cilium 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | /* 19 | * This is just a dummy header with dummy values to allow for test 20 | * compilation without the full code generation engine backend. 21 | */ 22 | 23 | #define LXC_MAC { .addr = { 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff } } 24 | #define LXC_IP 0xbe, 0xef, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1, 0x1, 0x65, 0x82, 0xbc 25 | #define LXC_IPV4 0x10203040 26 | #define LXC_ID 0x1010 27 | #define LXC_ID_NB 0x1010 28 | #ifndef SECLABEL 29 | #define SECLABEL 0xfffff 30 | #define SECLABEL_NB 0xfffff 31 | #endif 32 | #define POLICY_MAP cilium_policy_foo 33 | #define NODE_MAC { .addr = { 0xde, 0xad, 0xbe, 0xef, 0xc0, 0xde } } 34 | #define GENEVE_OPTS { 0xff, 0xff, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1e } 35 | #define DROP_NOTIFY 36 | #define CT_MAP6 cilium_ct6_111 37 | #define CT_MAP4 cilium_ct4_111 38 | #define CT_MAP_SIZE 4096 39 | #define CALLS_MAP cilium_calls_111 40 | #define LB_L3 41 | #define LB_L4 42 | #define CONNTRACK 43 | #define NR_CFG_L4_INGRESS 2 44 | #define CFG_L4_INGRESS 0, 80, 8080, 0, 1, 80, 8080, 0, (), 0 45 | #define NR_CFG_L4_EGRESS 1 46 | #define CFG_L4_EGRESS 0, 80, 8080, 0, (), 0 47 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/netdev_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2017 Authors of Cilium 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | /* 19 | * This is just a dummy header with dummy values to allow for test 20 | * compilation without the full code generation engine backend. 21 | */ 22 | #define DROP_NOTIFY 23 | #define DEBUG 24 | #define ENABLE_IPV4 25 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/bpf/node_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2017 Authors of Cilium 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | /* 20 | * 21 | * 22 | * **** WARNING **** 23 | * This is just a dummy header with dummy values to allow for test 24 | * compilation without the full code generation engine backend. 25 | * 26 | * 27 | * 28 | */ 29 | 30 | #define ROUTER_IP 0xbe, 0xef, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0 31 | #define ENCAP_IFINDEX 1 32 | #define HOST_IFINDEX 1 33 | #define HOST_IP 0xbe, 0xef, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, 0x0, 0x2, 0xf, 0xff, 0xff 34 | #define HOST_ID 1 35 | #define WORLD_ID 2 36 | #define HOST_IFINDEX_MAC { .addr = { 0xce, 0x72, 0xa7, 0x03, 0x88, 0x56 } } 37 | #define NAT46_PREFIX { .addr = { 0xbe, 0xef, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0 } } 38 | #define IPV4_MASK 0xffff 39 | #define IPV4_CLUSTER_MASK 0xff0000 40 | #define IPV4_CLUSTER_RANGE 0x100000 41 | #define IPV4_GATEWAY 0xfffff50a 42 | #define IPV4_LOOPBACK 0x1ffff50a 43 | #define ENCAP_GENEVE 1 44 | #define CALLS_MAP cilium_calls_111 45 | #define SECLABEL 2 46 | #define SECLABEL_NB 0xfffff 47 | #define ENABLE_ARP_RESPONDER 48 | #define NODE_MAC { .addr = { 0xde, 0xad, 0xbe, 0xef, 0xc0, 0xde } } 49 | #define ENABLE_IPV4 50 | #define LB_RR_MAX_SEQ 31 51 | #define TUNNEL_ENDPOINT_MAP_SIZE 65536 52 | #define ENDPOINTS_MAP_SIZE 65536 53 | #define ENABLE_TRACE 54 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/common/tests/bpf-event-test.c: -------------------------------------------------------------------------------- 1 | #include "event.h" 2 | 3 | #ifndef __NR_CPUS__ 4 | #define __NR_CPUS__ 1 5 | #endif 6 | 7 | struct bpf_elf_map __section_maps perf_test_events = { 8 | .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY, 9 | .size_key = sizeof(int), 10 | .size_value = sizeof(int), 11 | .pinning = PIN_GLOBAL_NS, 12 | .max_elem = __NR_CPUS__, 13 | }; 14 | 15 | __section_cls_entry 16 | int cls_entry(struct __sk_buff *skb) 17 | { 18 | struct event_msg msg = {0}; 19 | 20 | msg.type = EVENT_TYPE_SAMPLE; 21 | 22 | skb_load_bytes(skb, 0, &msg.data, sizeof(msg.data)); 23 | skb_event_output(skb, &perf_test_events, BPF_F_CURRENT_CPU, 24 | &msg, sizeof(msg)); 25 | 26 | return TC_ACT_OK; 27 | } 28 | 29 | BPF_LICENSE("GPL"); 30 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/common/tests/event.h: -------------------------------------------------------------------------------- 1 | #ifndef __EVENT_H_ 2 | #define __EVENT_H_ 3 | 4 | #include 5 | #include 6 | 7 | enum { 8 | EVENT_TYPE_UNSPEC = 0, 9 | EVENT_TYPE_SAMPLE, 10 | }; 11 | 12 | struct event_msg { 13 | __u8 type; 14 | __u8 data[20]; 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/common/tests/perf-event-test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2017 Authors of Cilium 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 | package main 16 | 17 | import ( 18 | "fmt" 19 | "os" 20 | 21 | "github.com/cilium/cilium/pkg/bpf" 22 | 23 | "github.com/spf13/cobra" 24 | ) 25 | 26 | var ( 27 | config = bpf.PerfEventConfig{ 28 | MapName: "perf_test_events", 29 | Type: bpf.PERF_TYPE_SOFTWARE, 30 | Config: bpf.PERF_COUNT_SW_BPF_OUTPUT, 31 | SampleType: bpf.PERF_SAMPLE_RAW, 32 | WakeupEvents: 1, 33 | } 34 | ) 35 | 36 | func receiveEvent(msg *bpf.PerfEventSample, cpu int) { 37 | fmt.Printf("%+v\n", msg) 38 | } 39 | 40 | func lostEvent(lost *bpf.PerfEventLost, cpu int) { 41 | fmt.Printf("Lost %d\n", lost.Lost) 42 | } 43 | 44 | var RootCmd = &cobra.Command{ 45 | Use: "perf-event-test", 46 | Short: "Test utility for perf events", 47 | Run: func(cmd *cobra.Command, args []string) { 48 | events, err := bpf.NewPerCpuEvents(&config) 49 | if err != nil { 50 | panic(err) 51 | } 52 | 53 | for { 54 | todo, err := events.Poll(-1) 55 | if err != nil { 56 | panic(err) 57 | } 58 | if todo > 0 { 59 | events.ReadAll(receiveEvent, lostEvent) 60 | } 61 | } 62 | 63 | }, 64 | } 65 | 66 | func main() { 67 | if err := RootCmd.Execute(); err != nil { 68 | fmt.Fprintf(os.Stderr, "%s", err) 69 | os.Exit(-1) 70 | } 71 | } 72 | 73 | func init() { 74 | flags := RootCmd.PersistentFlags() 75 | flags.IntVarP(&config.NumCpus, "num-cpus", "c", 1, "Number of CPUs") 76 | flags.IntVarP(&config.NumPages, "num-pagse", "n", 8, "Number of pages for ring buffer") 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/pkg/bpf/bpffs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016-2017 Authors of Cilium 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 | package bpf 16 | 17 | import ( 18 | "fmt" 19 | "os/exec" 20 | "path" 21 | "sync" 22 | ) 23 | 24 | var ( 25 | // Path to where bpffs is mounted (default: /sys/fs/bpf) 26 | mapRoot = "/sys/fs/bpf" 27 | 28 | // Prefix for all maps (default: tc/globals) 29 | mapPrefix = "tc/globals" 30 | 31 | // Set to true on first get request to detect misorder 32 | lockedDown = false 33 | once sync.Once 34 | ) 35 | 36 | func lockDown() { 37 | lockedDown = true 38 | } 39 | 40 | func SetMapRoot(path string) { 41 | if lockedDown { 42 | panic("SetMapRoot() call after MapRoot was read") 43 | } 44 | mapRoot = path 45 | 46 | mountMutex.Lock() 47 | for _, m := range delayedOpens { 48 | m.OpenOrCreate() 49 | } 50 | 51 | mounted = true 52 | delayedOpens = []*Map{} 53 | mountMutex.Unlock() 54 | } 55 | 56 | func GetMapRoot() string { 57 | once.Do(lockDown) 58 | return mapRoot 59 | } 60 | 61 | func SetMapPrefix(path string) { 62 | if lockedDown { 63 | panic("SetMapPrefix() call after MapPrefix was read") 64 | } 65 | mapPrefix = path 66 | } 67 | 68 | func GetMapPrefix() string { 69 | once.Do(lockDown) 70 | return mapPrefix 71 | } 72 | 73 | func MapPrefixPath() string { 74 | once.Do(lockDown) 75 | return path.Join(mapRoot, mapPrefix) 76 | } 77 | 78 | func MapPath(name string) string { 79 | once.Do(lockDown) 80 | return path.Join(mapRoot, mapPrefix, name) 81 | } 82 | 83 | var ( 84 | mountOnce sync.Once 85 | mountMutex sync.Mutex 86 | delayedOpens = []*Map{} 87 | mounted bool 88 | ) 89 | 90 | // OpenAfterMount schedules a map to be opened/created after the BPF filesystem 91 | // has been mounted. If the filesystem is already mounted, the map is 92 | // opened/created immediately. 93 | func OpenAfterMount(m *Map) error { 94 | mountMutex.Lock() 95 | defer mountMutex.Unlock() 96 | 97 | if mounted { 98 | _, err := m.OpenOrCreate() 99 | return err 100 | } 101 | 102 | delayedOpens = append(delayedOpens, m) 103 | return nil 104 | } 105 | 106 | func mountFS() error { 107 | // Mount BPF Map directory if not already done 108 | args := []string{"-q", mapRoot} 109 | _, err := exec.Command("mountpoint", args...).CombinedOutput() 110 | if err != nil { 111 | args = []string{"bpffs", mapRoot, "-t", "bpf"} 112 | out, err := exec.Command("mount", args...).CombinedOutput() 113 | if err != nil { 114 | return fmt.Errorf("Command execution failed: %s\n%s", err, out) 115 | } 116 | } 117 | 118 | mountMutex.Lock() 119 | for _, m := range delayedOpens { 120 | m.OpenOrCreate() 121 | } 122 | 123 | mounted = true 124 | delayedOpens = []*Map{} 125 | mountMutex.Unlock() 126 | 127 | return nil 128 | } 129 | 130 | // MountFS mounts the BPF filesystem and then opens/creates all maps which have 131 | // previously been scheduled to be opened/created 132 | func MountFS() error { 133 | var err error 134 | mountOnce.Do(func() { 135 | err = mountFS() 136 | }) 137 | return err 138 | } 139 | -------------------------------------------------------------------------------- /vendor/github.com/cilium/cilium/pkg/bpf/prog.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Authors of Cilium 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 | package bpf 16 | 17 | // ProgType is an enumeration for valid BPF program types 18 | type ProgType int 19 | 20 | // This enumeration must be in sync with enum bpf_prog_type in 21 | const ( 22 | ProgTypeUnspec ProgType = iota 23 | ProgTypeSocketFilter 24 | ProgTypeKprobe 25 | ProgTypeSchedCls 26 | ProgTypeSchedAct 27 | ProgTypeTracepoint 28 | ProgTypeXdp 29 | ProgTypePerfEvent 30 | ProgTypeCgroupSkb 31 | ProgTypeCgroupSock 32 | ProgTypeLwtIn 33 | ProgTypeLwtOut 34 | ProgTypeLwtXmit 35 | ProgTypeSockOps 36 | ) 37 | 38 | func (t ProgType) String() string { 39 | switch t { 40 | case ProgTypeSocketFilter: 41 | return "Socket filter" 42 | case ProgTypeKprobe: 43 | return "Kprobe" 44 | case ProgTypeSchedCls: 45 | return "Sched CLS" 46 | case ProgTypeSchedAct: 47 | return "Sched ACT" 48 | case ProgTypeTracepoint: 49 | return "Tracepoint" 50 | case ProgTypeXdp: 51 | return "XDP" 52 | case ProgTypePerfEvent: 53 | return "Perf event" 54 | case ProgTypeCgroupSkb: 55 | return "Cgroup skb" 56 | case ProgTypeCgroupSock: 57 | return "Cgroup sock" 58 | case ProgTypeLwtIn: 59 | return "LWT in" 60 | case ProgTypeLwtOut: 61 | return "LWT out" 62 | case ProgTypeLwtXmit: 63 | return "LWT xmit" 64 | case ProgTypeSockOps: 65 | return "Sock ops" 66 | } 67 | 68 | return "Unknown" 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Jeremy Saenz & Contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/category.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | // CommandCategories is a slice of *CommandCategory. 4 | type CommandCategories []*CommandCategory 5 | 6 | // CommandCategory is a category containing commands. 7 | type CommandCategory struct { 8 | Name string 9 | Commands Commands 10 | } 11 | 12 | func (c CommandCategories) Less(i, j int) bool { 13 | return c[i].Name < c[j].Name 14 | } 15 | 16 | func (c CommandCategories) Len() int { 17 | return len(c) 18 | } 19 | 20 | func (c CommandCategories) Swap(i, j int) { 21 | c[i], c[j] = c[j], c[i] 22 | } 23 | 24 | // AddCommand adds a command to a category. 25 | func (c CommandCategories) AddCommand(category string, command Command) CommandCategories { 26 | for _, commandCategory := range c { 27 | if commandCategory.Name == category { 28 | commandCategory.Commands = append(commandCategory.Commands, command) 29 | return c 30 | } 31 | } 32 | return append(c, &CommandCategory{Name: category, Commands: []Command{command}}) 33 | } 34 | 35 | // VisibleCommands returns a slice of the Commands with Hidden=false 36 | func (c *CommandCategory) VisibleCommands() []Command { 37 | ret := []Command{} 38 | for _, command := range c.Commands { 39 | if !command.Hidden { 40 | ret = append(ret, command) 41 | } 42 | } 43 | return ret 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/cli.go: -------------------------------------------------------------------------------- 1 | // Package cli provides a minimal framework for creating and organizing command line 2 | // Go applications. cli is designed to be easy to understand and write, the most simple 3 | // cli application can be written as follows: 4 | // func main() { 5 | // cli.NewApp().Run(os.Args) 6 | // } 7 | // 8 | // Of course this application does not do much, so let's make this an actual application: 9 | // func main() { 10 | // app := cli.NewApp() 11 | // app.Name = "greet" 12 | // app.Usage = "say a greeting" 13 | // app.Action = func(c *cli.Context) error { 14 | // println("Greetings") 15 | // } 16 | // 17 | // app.Run(os.Args) 18 | // } 19 | package cli 20 | 21 | //go:generate python ./generate-flag-types cli -i flag-types.json -o flag_generated.go 22 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/errors.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | // OsExiter is the function used when the app exits. If not set defaults to os.Exit. 11 | var OsExiter = os.Exit 12 | 13 | // ErrWriter is used to write errors to the user. This can be anything 14 | // implementing the io.Writer interface and defaults to os.Stderr. 15 | var ErrWriter io.Writer = os.Stderr 16 | 17 | // MultiError is an error that wraps multiple errors. 18 | type MultiError struct { 19 | Errors []error 20 | } 21 | 22 | // NewMultiError creates a new MultiError. Pass in one or more errors. 23 | func NewMultiError(err ...error) MultiError { 24 | return MultiError{Errors: err} 25 | } 26 | 27 | // Error implements the error interface. 28 | func (m MultiError) Error() string { 29 | errs := make([]string, len(m.Errors)) 30 | for i, err := range m.Errors { 31 | errs[i] = err.Error() 32 | } 33 | 34 | return strings.Join(errs, "\n") 35 | } 36 | 37 | type ErrorFormatter interface { 38 | Format(s fmt.State, verb rune) 39 | } 40 | 41 | // ExitCoder is the interface checked by `App` and `Command` for a custom exit 42 | // code 43 | type ExitCoder interface { 44 | error 45 | ExitCode() int 46 | } 47 | 48 | // ExitError fulfills both the builtin `error` interface and `ExitCoder` 49 | type ExitError struct { 50 | exitCode int 51 | message interface{} 52 | } 53 | 54 | // NewExitError makes a new *ExitError 55 | func NewExitError(message interface{}, exitCode int) *ExitError { 56 | return &ExitError{ 57 | exitCode: exitCode, 58 | message: message, 59 | } 60 | } 61 | 62 | // Error returns the string message, fulfilling the interface required by 63 | // `error` 64 | func (ee *ExitError) Error() string { 65 | return fmt.Sprintf("%v", ee.message) 66 | } 67 | 68 | // ExitCode returns the exit code, fulfilling the interface required by 69 | // `ExitCoder` 70 | func (ee *ExitError) ExitCode() int { 71 | return ee.exitCode 72 | } 73 | 74 | // HandleExitCoder checks if the error fulfills the ExitCoder interface, and if 75 | // so prints the error to stderr (if it is non-empty) and calls OsExiter with the 76 | // given exit code. If the given error is a MultiError, then this func is 77 | // called on all members of the Errors slice. 78 | func HandleExitCoder(err error) { 79 | if err == nil { 80 | return 81 | } 82 | 83 | if exitErr, ok := err.(ExitCoder); ok { 84 | if err.Error() != "" { 85 | if _, ok := exitErr.(ErrorFormatter); ok { 86 | fmt.Fprintf(ErrWriter, "%+v\n", err) 87 | } else { 88 | fmt.Fprintln(ErrWriter, err) 89 | } 90 | } 91 | OsExiter(exitErr.ExitCode()) 92 | return 93 | } 94 | 95 | if multiErr, ok := err.(MultiError); ok { 96 | for _, merr := range multiErr.Errors { 97 | HandleExitCoder(merr) 98 | } 99 | return 100 | } 101 | 102 | if err.Error() != "" { 103 | if _, ok := err.(ErrorFormatter); ok { 104 | fmt.Fprintf(ErrWriter, "%+v\n", err) 105 | } else { 106 | fmt.Fprintln(ErrWriter, err) 107 | } 108 | } 109 | OsExiter(1) 110 | } 111 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/funcs.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | // BashCompleteFunc is an action to execute when the bash-completion flag is set 4 | type BashCompleteFunc func(*Context) 5 | 6 | // BeforeFunc is an action to execute before any subcommands are run, but after 7 | // the context is ready if a non-nil error is returned, no subcommands are run 8 | type BeforeFunc func(*Context) error 9 | 10 | // AfterFunc is an action to execute after any subcommands are run, but after the 11 | // subcommand has finished it is run even if Action() panics 12 | type AfterFunc func(*Context) error 13 | 14 | // ActionFunc is the action to execute when no subcommands are specified 15 | type ActionFunc func(*Context) error 16 | 17 | // CommandNotFoundFunc is executed if the proper command cannot be found 18 | type CommandNotFoundFunc func(*Context, string) 19 | 20 | // OnUsageErrorFunc is executed if an usage error occurs. This is useful for displaying 21 | // customized usage error messages. This function is able to replace the 22 | // original error messages. If this function is not set, the "Incorrect usage" 23 | // is displayed and the execution is interrupted. 24 | type OnUsageErrorFunc func(context *Context, err error, isSubcommand bool) error 25 | 26 | // FlagStringFunc is used by the help generation to display a flag, which is 27 | // expected to be a single line. 28 | type FlagStringFunc func(Flag) string 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/README: -------------------------------------------------------------------------------- 1 | This repository holds supplemental Go packages for low-level interactions with the operating system. 2 | 3 | To submit changes to this repository, see http://golang.org/doc/contribute.html. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for 386, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·socketcall(SB),NOSPLIT,$0-36 29 | JMP syscall·socketcall(SB) 30 | 31 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 32 | JMP syscall·rawsocketcall(SB) 33 | 34 | TEXT ·seek(SB),NOSPLIT,$0-28 35 | JMP syscall·seek(SB) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 29 | JMP syscall·gettimeofday(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | B syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | B syscall·RawSyscall6(SB) 27 | 28 | TEXT ·seek(SB),NOSPLIT,$0-32 29 | B syscall·seek(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | B syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | B syscall·RawSyscall6(SB) 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | JMP syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | JMP syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mipsx.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 28 | JMP syscall·RawSyscall(SB) 29 | 30 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 31 | JMP syscall·RawSyscall6(SB) 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dev_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Functions to access/create device major and minor numbers matching the 6 | // encoding used by the Linux kernel and glibc. 7 | // 8 | // The information below is extracted and adapted from bits/sysmacros.h in the 9 | // glibc sources: 10 | // 11 | // dev_t in glibc is 64-bit, with 32-bit major and minor numbers. glibc's 12 | // default encoding is MMMM Mmmm mmmM MMmm, where M is a hex digit of the major 13 | // number and m is a hex digit of the minor number. This is backward compatible 14 | // with legacy systems where dev_t is 16 bits wide, encoded as MMmm. It is also 15 | // backward compatible with the Linux kernel, which for some architectures uses 16 | // 32-bit dev_t, encoded as mmmM MMmm. 17 | 18 | package unix 19 | 20 | // Major returns the major component of a Linux device number. 21 | func Major(dev uint64) uint32 { 22 | major := uint32((dev & 0x00000000000fff00) >> 8) 23 | major |= uint32((dev & 0xfffff00000000000) >> 32) 24 | return major 25 | } 26 | 27 | // Minor returns the minor component of a Linux device number. 28 | func Minor(dev uint64) uint32 { 29 | minor := uint32((dev & 0x00000000000000ff) >> 0) 30 | minor |= uint32((dev & 0x00000ffffff00000) >> 12) 31 | return minor 32 | } 33 | 34 | // Mkdev returns a Linux device number generated from the given major and minor 35 | // components. 36 | func Mkdev(major, minor uint32) uint64 { 37 | dev := uint64((major & 0x00000fff) << 8) 38 | dev |= uint64((major & 0xfffff000) << 32) 39 | dev |= uint64((minor & 0x000000ff) << 0) 40 | dev |= uint64((minor & 0xffffff00) << 12) 41 | return dev 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/dirent.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // readInt returns the size-bytes unsigned integer in native byte order at offset off. 12 | func readInt(b []byte, off, size uintptr) (u uint64, ok bool) { 13 | if len(b) < int(off+size) { 14 | return 0, false 15 | } 16 | if isBigEndian { 17 | return readIntBE(b[off:], size), true 18 | } 19 | return readIntLE(b[off:], size), true 20 | } 21 | 22 | func readIntBE(b []byte, size uintptr) uint64 { 23 | switch size { 24 | case 1: 25 | return uint64(b[0]) 26 | case 2: 27 | _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808 28 | return uint64(b[1]) | uint64(b[0])<<8 29 | case 4: 30 | _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 31 | return uint64(b[3]) | uint64(b[2])<<8 | uint64(b[1])<<16 | uint64(b[0])<<24 32 | case 8: 33 | _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 34 | return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 | 35 | uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56 36 | default: 37 | panic("syscall: readInt with unsupported size") 38 | } 39 | } 40 | 41 | func readIntLE(b []byte, size uintptr) uint64 { 42 | switch size { 43 | case 1: 44 | return uint64(b[0]) 45 | case 2: 46 | _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808 47 | return uint64(b[0]) | uint64(b[1])<<8 48 | case 4: 49 | _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 50 | return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 51 | case 8: 52 | _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 53 | return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | 54 | uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 55 | default: 56 | panic("syscall: readInt with unsupported size") 57 | } 58 | } 59 | 60 | // ParseDirent parses up to max directory entries in buf, 61 | // appending the names to names. It returns the number of 62 | // bytes consumed from buf, the number of entries added 63 | // to names, and the new names slice. 64 | func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) { 65 | origlen := len(buf) 66 | count = 0 67 | for max != 0 && len(buf) > 0 { 68 | reclen, ok := direntReclen(buf) 69 | if !ok || reclen > uint64(len(buf)) { 70 | return origlen, count, names 71 | } 72 | rec := buf[:reclen] 73 | buf = buf[reclen:] 74 | ino, ok := direntIno(rec) 75 | if !ok { 76 | break 77 | } 78 | if ino == 0 { // File absent in directory. 79 | continue 80 | } 81 | const namoff = uint64(unsafe.Offsetof(Dirent{}.Name)) 82 | namlen, ok := direntNamlen(rec) 83 | if !ok || namoff+namlen > uint64(len(rec)) { 84 | break 85 | } 86 | name := rec[namoff : namoff+namlen] 87 | for i, c := range name { 88 | if c == 0 { 89 | name = name[:i] 90 | break 91 | } 92 | } 93 | // Check for useless names before allocating a string. 94 | if string(name) == "." || string(name) == ".." { 95 | continue 96 | } 97 | max-- 98 | count++ 99 | names = append(names, string(name)) 100 | } 101 | return origlen - len(buf), count, names 102 | } 103 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build ppc64 s390x mips mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/file_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import ( 8 | "os" 9 | "syscall" 10 | ) 11 | 12 | // FIXME: unexported function from os 13 | // syscallMode returns the syscall-specific mode bits from Go's portable mode bits. 14 | func syscallMode(i os.FileMode) (o uint32) { 15 | o |= uint32(i.Perm()) 16 | if i&os.ModeSetuid != 0 { 17 | o |= syscall.S_ISUID 18 | } 19 | if i&os.ModeSetgid != 0 { 20 | o |= syscall.S_ISGID 21 | } 22 | if i&os.ModeSticky != 0 { 23 | o |= syscall.S_ISVTX 24 | } 25 | // No mapping for Go's ModeTemporary (plan9 only). 26 | return 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 12 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 13 | var fcntl64Syscall uintptr = SYS_FCNTL 14 | 15 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 16 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 17 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 18 | if errno == 0 { 19 | return nil 20 | } 21 | return errno 22 | } 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm linux,mips linux,mipsle 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscall 15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 16 | 17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | syscall.Entersyscall() 19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 20 | syscall.Exitsyscall() 21 | return r, 0, syscall.Errno(errno) 22 | } 23 | 24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 25 | syscall.Entersyscall() 26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 27 | syscall.Exitsyscall() 28 | return r, 0, syscall.Errno(errno) 29 | } 30 | 31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 32 | syscall.Entersyscall() 33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 34 | syscall.Exitsyscall() 35 | return r, 0, syscall.Errno(errno) 36 | } 37 | 38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 40 | return r, 0, syscall.Errno(errno) 41 | } 42 | 43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret 24 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 25 | { 26 | struct ret r; 27 | 28 | errno = 0; 29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 30 | r.err = errno; 31 | return r; 32 | } 33 | 34 | // Define the use function in C so that it is not inlined. 35 | 36 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 37 | 38 | void 39 | use(void *p __attribute__ ((unused))) 40 | { 41 | } 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_sparc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,sparc64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern sysconf 12 | func realSysconf(name int) int64 13 | 14 | func sysconf(name int) (n int64, err syscall.Errno) { 15 | r := realSysconf(name) 16 | if r < 0 { 17 | return 0, syscall.GetErrno() 18 | } 19 | return r, 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/openbsd_pledge.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build openbsd 6 | // +build 386 amd64 arm 7 | 8 | package unix 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | const ( 16 | SYS_PLEDGE = 108 17 | ) 18 | 19 | // Pledge implements the pledge syscall. For more information see pledge(2). 20 | func Pledge(promises string, paths []string) error { 21 | promisesPtr, err := syscall.BytePtrFromString(promises) 22 | if err != nil { 23 | return err 24 | } 25 | promisesUnsafe, pathsUnsafe := unsafe.Pointer(promisesPtr), unsafe.Pointer(nil) 26 | if paths != nil { 27 | var pathsPtr []*byte 28 | if pathsPtr, err = syscall.SlicePtrFromStrings(paths); err != nil { 29 | return err 30 | } 31 | pathsUnsafe = unsafe.Pointer(&pathsPtr[0]) 32 | } 33 | _, _, e := syscall.Syscall(SYS_PLEDGE, uintptr(promisesUnsafe), uintptr(pathsUnsafe), 0) 34 | if e != 0 { 35 | return e 36 | } 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,race linux,race freebsd,race 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/race0.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Socket control messages 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // UnixCredentials encodes credentials into a socket control message 12 | // for sending to another process. This can be used for 13 | // authentication. 14 | func UnixCredentials(ucred *Ucred) []byte { 15 | b := make([]byte, CmsgSpace(SizeofUcred)) 16 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 17 | h.Level = SOL_SOCKET 18 | h.Type = SCM_CREDENTIALS 19 | h.SetLen(CmsgLen(SizeofUcred)) 20 | *((*Ucred)(cmsgData(h))) = *ucred 21 | return b 22 | } 23 | 24 | // ParseUnixCredentials decodes a socket control message that contains 25 | // credentials in a Ucred structure. To receive such a message, the 26 | // SO_PASSCRED option must be enabled on the socket. 27 | func ParseUnixCredentials(m *SocketControlMessage) (*Ucred, error) { 28 | if m.Header.Level != SOL_SOCKET { 29 | return nil, EINVAL 30 | } 31 | if m.Header.Type != SCM_CREDENTIALS { 32 | return nil, EINVAL 33 | } 34 | ucred := *(*Ucred)(unsafe.Pointer(&m.Data[0])) 35 | return &ucred, nil 36 | } 37 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/sockcmsg_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Socket control messages 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // Round the length of a raw sockaddr up to align it properly. 14 | func cmsgAlignOf(salen int) int { 15 | salign := sizeofPtr 16 | // NOTE: It seems like 64-bit Darwin, DragonFly BSD and 17 | // Solaris kernels still require 32-bit aligned access to 18 | // network subsystem. 19 | if darwin64Bit || dragonfly64Bit || solaris64Bit { 20 | salign = 4 21 | } 22 | return (salen + salign - 1) & ^(salign - 1) 23 | } 24 | 25 | // CmsgLen returns the value to store in the Len field of the Cmsghdr 26 | // structure, taking into account any necessary alignment. 27 | func CmsgLen(datalen int) int { 28 | return cmsgAlignOf(SizeofCmsghdr) + datalen 29 | } 30 | 31 | // CmsgSpace returns the number of bytes an ancillary element with 32 | // payload of the passed data length occupies. 33 | func CmsgSpace(datalen int) int { 34 | return cmsgAlignOf(SizeofCmsghdr) + cmsgAlignOf(datalen) 35 | } 36 | 37 | func cmsgData(h *Cmsghdr) unsafe.Pointer { 38 | return unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(cmsgAlignOf(SizeofCmsghdr))) 39 | } 40 | 41 | // SocketControlMessage represents a socket control message. 42 | type SocketControlMessage struct { 43 | Header Cmsghdr 44 | Data []byte 45 | } 46 | 47 | // ParseSocketControlMessage parses b as an array of socket control 48 | // messages. 49 | func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) { 50 | var msgs []SocketControlMessage 51 | i := 0 52 | for i+CmsgLen(0) <= len(b) { 53 | h, dbuf, err := socketControlMessageHeaderAndData(b[i:]) 54 | if err != nil { 55 | return nil, err 56 | } 57 | m := SocketControlMessage{Header: *h, Data: dbuf} 58 | msgs = append(msgs, m) 59 | i += cmsgAlignOf(int(h.Len)) 60 | } 61 | return msgs, nil 62 | } 63 | 64 | func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) { 65 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 66 | if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) { 67 | return nil, nil, EINVAL 68 | } 69 | return h, b[cmsgAlignOf(SizeofCmsghdr):h.Len], nil 70 | } 71 | 72 | // UnixRights encodes a set of open file descriptors into a socket 73 | // control message for sending to another process. 74 | func UnixRights(fds ...int) []byte { 75 | datalen := len(fds) * 4 76 | b := make([]byte, CmsgSpace(datalen)) 77 | h := (*Cmsghdr)(unsafe.Pointer(&b[0])) 78 | h.Level = SOL_SOCKET 79 | h.Type = SCM_RIGHTS 80 | h.SetLen(CmsgLen(datalen)) 81 | data := cmsgData(h) 82 | for _, fd := range fds { 83 | *(*int32)(data) = int32(fd) 84 | data = unsafe.Pointer(uintptr(data) + 4) 85 | } 86 | return b 87 | } 88 | 89 | // ParseUnixRights decodes a socket control message that contains an 90 | // integer array of open file descriptors from another process. 91 | func ParseUnixRights(m *SocketControlMessage) ([]int, error) { 92 | if m.Header.Level != SOL_SOCKET { 93 | return nil, EINVAL 94 | } 95 | if m.Header.Type != SCM_RIGHTS { 96 | return nil, EINVAL 97 | } 98 | fds := make([]int, len(m.Data)>>2) 99 | for i, j := 0, 0; i < len(m.Data); i += 4 { 100 | fds[j] = int(*(*int32)(unsafe.Pointer(&m.Data[i]))) 101 | j++ 102 | } 103 | return fds, nil 104 | } 105 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/str.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // The primary use of this package is inside other packages that provide a more 15 | // portable interface to the system, such as "os", "time" and "net". Use 16 | // those packages rather than this one if you can. 17 | // For details of the functions and data types in this package consult 18 | // the manuals for the appropriate operating system. 19 | // These calls return err == nil to indicate success; otherwise 20 | // err represents an operating system error describing the failure and 21 | // holds a value of type syscall.Errno. 22 | package unix // import "golang.org/x/sys/unix" 23 | 24 | // ByteSliceFromString returns a NUL-terminated slice of bytes 25 | // containing the text of s. If s contains a NUL byte at any 26 | // location, it returns (nil, EINVAL). 27 | func ByteSliceFromString(s string) ([]byte, error) { 28 | for i := 0; i < len(s); i++ { 29 | if s[i] == 0 { 30 | return nil, EINVAL 31 | } 32 | } 33 | a := make([]byte, len(s)+1) 34 | copy(a, s) 35 | return a, nil 36 | } 37 | 38 | // BytePtrFromString returns a pointer to a NUL-terminated array of 39 | // bytes containing the text of s. If s contains a NUL byte at any 40 | // location, it returns (nil, EINVAL). 41 | func BytePtrFromString(s string) (*byte, error) { 42 | a, err := ByteSliceFromString(s) 43 | if err != nil { 44 | return nil, err 45 | } 46 | return &a[0], nil 47 | } 48 | 49 | // Single-word zero for use when we need a valid pointer to 0 bytes. 50 | // See mkunix.pl. 51 | var _zero uintptr 52 | 53 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 54 | return int64(ts.Sec), int64(ts.Nsec) 55 | } 56 | 57 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 58 | return int64(tv.Sec), int64(tv.Usec) * 1000 59 | } 60 | 61 | func (ts *Timespec) Nano() int64 { 62 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 63 | } 64 | 65 | func (tv *Timeval) Nano() int64 { 66 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 67 | } 68 | 69 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 70 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = int32(sec) 38 | tv.Usec = int32(usec) 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint32(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint32(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = sec 38 | tv.Usec = usec 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint64(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint64(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func Getpagesize() int { return 4096 } 13 | 14 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 15 | 16 | func NsecToTimespec(nsec int64) (ts Timespec) { 17 | ts.Sec = int32(nsec / 1e9) 18 | ts.Nsec = int32(nsec % 1e9) 19 | return 20 | } 21 | 22 | func NsecToTimeval(nsec int64) (tv Timeval) { 23 | nsec += 999 // round up to microsecond 24 | tv.Usec = int32(nsec % 1e9 / 1e3) 25 | tv.Sec = int32(nsec / 1e9) 26 | return 27 | } 28 | 29 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 30 | func Gettimeofday(tv *Timeval) (err error) { 31 | // The tv passed to gettimeofday must be non-nil 32 | // but is otherwise unused. The answers come back 33 | // in the two registers. 34 | sec, usec, err := gettimeofday(tv) 35 | tv.Sec = int32(sec) 36 | tv.Usec = int32(usec) 37 | return err 38 | } 39 | 40 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 41 | k.Ident = uint32(fd) 42 | k.Filter = int16(mode) 43 | k.Flags = uint16(flags) 44 | } 45 | 46 | func (iov *Iovec) SetLen(length int) { 47 | iov.Len = uint32(length) 48 | } 49 | 50 | func (msghdr *Msghdr) SetControllen(length int) { 51 | msghdr.Controllen = uint32(length) 52 | } 53 | 54 | func (cmsg *Cmsghdr) SetLen(length int) { 55 | cmsg.Len = uint32(length) 56 | } 57 | 58 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 59 | var length = uint64(count) 60 | 61 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 62 | 63 | written = int(length) 64 | 65 | if e1 != 0 { 66 | err = e1 67 | } 68 | return 69 | } 70 | 71 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 72 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 16384 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = sec 38 | tv.Usec = usec 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint64(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint64(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = nsec / 1e9 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,linux 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_ppc64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | 8 | package unix 9 | 10 | //sys EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) 11 | //sys Dup2(oldfd int, newfd int) (err error) 12 | //sys Fchown(fd int, uid int, gid int) (err error) 13 | //sys Fstat(fd int, stat *Stat_t) (err error) 14 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) 15 | //sys Ftruncate(fd int, length int64) (err error) 16 | //sysnb Getegid() (egid int) 17 | //sysnb Geteuid() (euid int) 18 | //sysnb Getgid() (gid int) 19 | //sysnb Getrlimit(resource int, rlim *Rlimit) (err error) = SYS_UGETRLIMIT 20 | //sysnb Getuid() (uid int) 21 | //sysnb InotifyInit() (fd int, err error) 22 | //sys Ioperm(from int, num int, on int) (err error) 23 | //sys Iopl(level int) (err error) 24 | //sys Lchown(path string, uid int, gid int) (err error) 25 | //sys Listen(s int, n int) (err error) 26 | //sys Lstat(path string, stat *Stat_t) (err error) 27 | //sys Pause() (err error) 28 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = SYS_PREAD64 29 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = SYS_PWRITE64 30 | //sys Seek(fd int, offset int64, whence int) (off int64, err error) = SYS_LSEEK 31 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) 32 | //sys sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) 33 | //sys Setfsgid(gid int) (err error) 34 | //sys Setfsuid(uid int) (err error) 35 | //sysnb Setregid(rgid int, egid int) (err error) 36 | //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 37 | //sysnb Setresuid(ruid int, euid int, suid int) (err error) 38 | //sysnb Setrlimit(resource int, rlim *Rlimit) (err error) 39 | //sysnb Setreuid(ruid int, euid int) (err error) 40 | //sys Shutdown(fd int, how int) (err error) 41 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) 42 | //sys Stat(path string, stat *Stat_t) (err error) 43 | //sys Statfs(path string, buf *Statfs_t) (err error) 44 | //sys SyncFileRange(fd int, off int64, n int64, flags int) (err error) = SYS_SYNC_FILE_RANGE2 45 | //sys Truncate(path string, length int64) (err error) 46 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) 47 | //sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) 48 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 49 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) 50 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) 51 | //sysnb setgroups(n int, list *_Gid_t) (err error) 52 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) 53 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) 54 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) 55 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) 56 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 57 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) 58 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) 59 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) 60 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) 61 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) 62 | //sys mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) 63 | 64 | func Getpagesize() int { return 65536 } 65 | 66 | //sysnb Gettimeofday(tv *Timeval) (err error) 67 | //sysnb Time(t *Time_t) (tt Time_t, err error) 68 | 69 | //sys Utime(path string, buf *Utimbuf) (err error) 70 | 71 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 72 | 73 | func NsecToTimespec(nsec int64) (ts Timespec) { 74 | ts.Sec = nsec / 1e9 75 | ts.Nsec = nsec % 1e9 76 | return 77 | } 78 | 79 | func NsecToTimeval(nsec int64) (tv Timeval) { 80 | nsec += 999 // round up to microsecond 81 | tv.Sec = nsec / 1e9 82 | tv.Usec = nsec % 1e9 / 1e3 83 | return 84 | } 85 | 86 | func (r *PtraceRegs) PC() uint64 { return r.Nip } 87 | 88 | func (r *PtraceRegs) SetPC(pc uint64) { r.Nip = pc } 89 | 90 | func (iov *Iovec) SetLen(length int) { 91 | iov.Len = uint64(length) 92 | } 93 | 94 | func (msghdr *Msghdr) SetControllen(length int) { 95 | msghdr.Controllen = uint64(length) 96 | } 97 | 98 | func (cmsg *Cmsghdr) SetLen(length int) { 99 | cmsg.Len = uint64(length) 100 | } 101 | 102 | //sysnb pipe(p *[2]_C_int) (err error) 103 | 104 | func Pipe(p []int) (err error) { 105 | if len(p) != 2 { 106 | return EINVAL 107 | } 108 | var pp [2]_C_int 109 | err = pipe(&pp) 110 | p[0] = int(pp[0]) 111 | p[1] = int(pp[1]) 112 | return 113 | } 114 | 115 | //sysnb pipe2(p *[2]_C_int, flags int) (err error) 116 | 117 | func Pipe2(p []int, flags int) (err error) { 118 | if len(p) != 2 { 119 | return EINVAL 120 | } 121 | var pp [2]_C_int 122 | err = pipe2(&pp, flags) 123 | p[0] = int(pp[0]) 124 | p[1] = int(pp[1]) 125 | return 126 | } 127 | 128 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) 129 | 130 | func Poll(fds []PollFd, timeout int) (n int, err error) { 131 | if len(fds) == 0 { 132 | return poll(nil, 0, timeout) 133 | } 134 | return poll(&fds[0], len(fds), timeout) 135 | } 136 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int64(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_no_getwd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build dragonfly freebsd netbsd openbsd 6 | 7 | package unix 8 | 9 | const ImplementsGetwd = false 10 | 11 | func Getwd() (string, error) { return "", ENOTSUP } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = nsec / 1e9 15 | ts.Nsec = nsec % 1e9 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = nsec % 1e9 / 1e3 22 | tv.Sec = nsec / 1e9 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 10 | 11 | func NsecToTimespec(nsec int64) (ts Timespec) { 12 | ts.Sec = nsec / 1e9 13 | ts.Nsec = nsec % 1e9 14 | return 15 | } 16 | 17 | func NsecToTimeval(nsec int64) (tv Timeval) { 18 | nsec += 999 // round up to microsecond 19 | tv.Usec = nsec % 1e9 / 1e3 20 | tv.Sec = int64(nsec / 1e9) 21 | return 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (cmsg *Cmsghdr) SetLen(length int) { 29 | cmsg.Len = uint32(length) 30 | } 31 | 32 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 33 | // TODO(aram): implement this, see issue 5847. 34 | panic("unimplemented") 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | // TODO(aram): remove these before Go 1.3. 10 | const ( 11 | SYS_EXECVE = 59 12 | SYS_FCNTL = 62 13 | ) 14 | --------------------------------------------------------------------------------