diff --git a/pkg/abi/tpu/tpu.go b/pkg/abi/tpu/tpu.go index d42193be0..65a6e99e5 100644 --- a/pkg/abi/tpu/tpu.go +++ b/pkg/abi/tpu/tpu.go @@ -49,95 +49,95 @@ const ( // TPUV4InterruptsMap maps BAR indices to valid register offsets. var ( TPUV4InterruptsMap = map[uint64]map[uint64]struct{}{ - 2: map[uint64]struct{}{ - 0x15b0008: struct{}{}, - 0x15b0000: struct{}{}, - 0x16b0008: struct{}{}, - 0x16b0000: struct{}{}, - 0x17b0008: struct{}{}, - 0x17b0000: struct{}{}, - 0x18b0008: struct{}{}, - 0x18b0000: struct{}{}, - 0x19b0020: struct{}{}, - 0x19b0000: struct{}{}, - 0x19b0008: struct{}{}, - 0x19b0010: struct{}{}, - 0x19b0018: struct{}{}, - 0x1ab0020: struct{}{}, - 0x1ab0000: struct{}{}, - 0x1ab0008: struct{}{}, - 0x1ab0010: struct{}{}, - 0x1ab0018: struct{}{}, - 0x4720000: struct{}{}, - 0x1bb0000: struct{}{}, - 0x1bb0008: struct{}{}, - 0x1bb0010: struct{}{}, - 0x1bb0018: struct{}{}, - 0x90000: struct{}{}, - 0xb0000: struct{}{}, - 0xd0000: struct{}{}, - 0xf0000: struct{}{}, - 0x110000: struct{}{}, - 0x130000: struct{}{}, - 0x150000: struct{}{}, - 0x170000: struct{}{}, - 0x190000: struct{}{}, - 0x1b0000: struct{}{}, - 0x1d0000: struct{}{}, - 0x1f0000: struct{}{}, - 0x210000: struct{}{}, - 0x230000: struct{}{}, - 0x250000: struct{}{}, - 0x270000: struct{}{}, - 0x290000: struct{}{}, - 0x2b0000: struct{}{}, - 0x2d0000: struct{}{}, - 0x2f0000: struct{}{}, - 0x310000: struct{}{}, - 0x4720018: struct{}{}, + 2: { + 0x15b0008: {}, + 0x15b0000: {}, + 0x16b0008: {}, + 0x16b0000: {}, + 0x17b0008: {}, + 0x17b0000: {}, + 0x18b0008: {}, + 0x18b0000: {}, + 0x19b0020: {}, + 0x19b0000: {}, + 0x19b0008: {}, + 0x19b0010: {}, + 0x19b0018: {}, + 0x1ab0020: {}, + 0x1ab0000: {}, + 0x1ab0008: {}, + 0x1ab0010: {}, + 0x1ab0018: {}, + 0x4720000: {}, + 0x1bb0000: {}, + 0x1bb0008: {}, + 0x1bb0010: {}, + 0x1bb0018: {}, + 0x90000: {}, + 0xb0000: {}, + 0xd0000: {}, + 0xf0000: {}, + 0x110000: {}, + 0x130000: {}, + 0x150000: {}, + 0x170000: {}, + 0x190000: {}, + 0x1b0000: {}, + 0x1d0000: {}, + 0x1f0000: {}, + 0x210000: {}, + 0x230000: {}, + 0x250000: {}, + 0x270000: {}, + 0x290000: {}, + 0x2b0000: {}, + 0x2d0000: {}, + 0x2f0000: {}, + 0x310000: {}, + 0x4720018: {}, }, } // TPUV4liteInterruptsMap maps BAR indices to valid register offsets. TPUV4liteInterruptsMap = map[uint64]map[uint64]struct{}{ - 2: map[uint64]struct{}{ - 0x19b0020: struct{}{}, - 0x19b0000: struct{}{}, - 0x19b0008: struct{}{}, - 0x19b0010: struct{}{}, - 0x19b0018: struct{}{}, - 0x1ab0020: struct{}{}, - 0x1ab0000: struct{}{}, - 0x1ab0008: struct{}{}, - 0x1ab0010: struct{}{}, - 0x1ab0018: struct{}{}, - 0x4720000: struct{}{}, - 0x1bb0000: struct{}{}, - 0x1bb0008: struct{}{}, - 0x1bb0010: struct{}{}, - 0x1bb0018: struct{}{}, - 0x90000: struct{}{}, - 0xb0000: struct{}{}, - 0xd0000: struct{}{}, - 0xf0000: struct{}{}, - 0x110000: struct{}{}, - 0x130000: struct{}{}, - 0x150000: struct{}{}, - 0x170000: struct{}{}, - 0x190000: struct{}{}, - 0x1b0000: struct{}{}, - 0x1d0000: struct{}{}, - 0x1f0000: struct{}{}, - 0x210000: struct{}{}, - 0x230000: struct{}{}, - 0x250000: struct{}{}, - 0x270000: struct{}{}, - 0x290000: struct{}{}, - 0x2b0000: struct{}{}, - 0x2d0000: struct{}{}, - 0x2f0000: struct{}{}, - 0x310000: struct{}{}, - 0x4720018: struct{}{}, + 2: { + 0x19b0020: {}, + 0x19b0000: {}, + 0x19b0008: {}, + 0x19b0010: {}, + 0x19b0018: {}, + 0x1ab0020: {}, + 0x1ab0000: {}, + 0x1ab0008: {}, + 0x1ab0010: {}, + 0x1ab0018: {}, + 0x4720000: {}, + 0x1bb0000: {}, + 0x1bb0008: {}, + 0x1bb0010: {}, + 0x1bb0018: {}, + 0x90000: {}, + 0xb0000: {}, + 0xd0000: {}, + 0xf0000: {}, + 0x110000: {}, + 0x130000: {}, + 0x150000: {}, + 0x170000: {}, + 0x190000: {}, + 0x1b0000: {}, + 0x1d0000: {}, + 0x1f0000: {}, + 0x210000: {}, + 0x230000: {}, + 0x250000: {}, + 0x270000: {}, + 0x290000: {}, + 0x2b0000: {}, + 0x2d0000: {}, + 0x2f0000: {}, + 0x310000: {}, + 0x4720018: {}, }, } ) diff --git a/pkg/bpf/program_builder_test.go b/pkg/bpf/program_builder_test.go index 10e6fd919..33ce913ed 100644 --- a/pkg/bpf/program_builder_test.go +++ b/pkg/bpf/program_builder_test.go @@ -236,12 +236,12 @@ func TestProgramBuilderOutcomes(t *testing.T) { }, wantLocal: FragmentOutcomes{ MayJumpToUnresolvedLabels: map[string]struct{}{ - "label1": struct{}{}, + "label1": {}, }, }, wantOverall: FragmentOutcomes{ MayJumpToUnresolvedLabels: map[string]struct{}{ - "label1": struct{}{}, + "label1": {}, }, }, }, @@ -255,7 +255,7 @@ func TestProgramBuilderOutcomes(t *testing.T) { }, wantOverall: FragmentOutcomes{ MayJumpToUnresolvedLabels: map[string]struct{}{ - "label1": struct{}{}, + "label1": {}, }, MayFallThrough: true, }, @@ -291,14 +291,14 @@ func TestProgramBuilderOutcomes(t *testing.T) { }, wantLocal: FragmentOutcomes{ MayJumpToUnresolvedLabels: map[string]struct{}{ - "truelabel": struct{}{}, - "falselabel": struct{}{}, + "truelabel": {}, + "falselabel": {}, }, }, wantOverall: FragmentOutcomes{ MayJumpToUnresolvedLabels: map[string]struct{}{ - "truelabel": struct{}{}, - "falselabel": struct{}{}, + "truelabel": {}, + "falselabel": {}, }, }, }, @@ -312,7 +312,7 @@ func TestProgramBuilderOutcomes(t *testing.T) { }, wantOverall: FragmentOutcomes{ MayJumpToUnresolvedLabels: map[string]struct{}{ - "falselabel": struct{}{}, + "falselabel": {}, }, MayFallThrough: true, }, @@ -327,7 +327,7 @@ func TestProgramBuilderOutcomes(t *testing.T) { }, wantOverall: FragmentOutcomes{ MayJumpToUnresolvedLabels: map[string]struct{}{ - "falselabel": struct{}{}, + "falselabel": {}, }, MayJumpToKnownOffsetBeyondFragment: true, }, @@ -339,17 +339,17 @@ func TestProgramBuilderOutcomes(t *testing.T) { }, wantLocal: FragmentOutcomes{ MayReturnImmediate: map[linux.BPFAction]struct{}{ - 1337: struct{}{}, + 1337: {}, }, }, wantLocalMayReturn: true, wantOverall: FragmentOutcomes{ MayJumpToUnresolvedLabels: map[string]struct{}{ - "falselabel": struct{}{}, + "falselabel": {}, }, MayFallThrough: true, // From jump in previous test. MayReturnImmediate: map[linux.BPFAction]struct{}{ - 1337: struct{}{}, + 1337: {}, }, }, }, @@ -364,11 +364,11 @@ func TestProgramBuilderOutcomes(t *testing.T) { wantLocalMayReturn: true, wantOverall: FragmentOutcomes{ MayJumpToUnresolvedLabels: map[string]struct{}{ - "falselabel": struct{}{}, + "falselabel": {}, }, MayFallThrough: false, // Jump no longer pointing at end of fragment. MayReturnImmediate: map[linux.BPFAction]struct{}{ - 1337: struct{}{}, + 1337: {}, }, MayReturnRegisterA: true, }, @@ -383,10 +383,10 @@ func TestProgramBuilderOutcomes(t *testing.T) { }, wantOverall: FragmentOutcomes{ MayJumpToUnresolvedLabels: map[string]struct{}{ - "falselabel": struct{}{}, + "falselabel": {}, }, MayReturnImmediate: map[linux.BPFAction]struct{}{ - 1337: struct{}{}, + 1337: {}, }, MayReturnRegisterA: true, MayFallThrough: true, @@ -402,10 +402,10 @@ func TestProgramBuilderOutcomes(t *testing.T) { }, wantOverall: FragmentOutcomes{ MayJumpToUnresolvedLabels: map[string]struct{}{ - "falselabel": struct{}{}, + "falselabel": {}, }, MayReturnImmediate: map[linux.BPFAction]struct{}{ - 1337: struct{}{}, + 1337: {}, }, MayReturnRegisterA: true, MayFallThrough: true, @@ -424,10 +424,10 @@ func TestProgramBuilderOutcomes(t *testing.T) { }, wantOverall: FragmentOutcomes{ MayJumpToUnresolvedLabels: map[string]struct{}{ - "falselabel": struct{}{}, + "falselabel": {}, }, MayReturnImmediate: map[linux.BPFAction]struct{}{ - 1337: struct{}{}, + 1337: {}, }, MayReturnRegisterA: true, MayFallThrough: true, @@ -440,17 +440,17 @@ func TestProgramBuilderOutcomes(t *testing.T) { }, wantLocal: FragmentOutcomes{ MayJumpToUnresolvedLabels: map[string]struct{}{ - "falselabel": struct{}{}, + "falselabel": {}, }, MayJumpToKnownOffsetBeyondFragment: true, }, wantOverall: FragmentOutcomes{ MayJumpToKnownOffsetBeyondFragment: true, MayJumpToUnresolvedLabels: map[string]struct{}{ - "falselabel": struct{}{}, + "falselabel": {}, }, MayReturnImmediate: map[linux.BPFAction]struct{}{ - 1337: struct{}{}, + 1337: {}, }, MayReturnRegisterA: true, }, @@ -466,7 +466,7 @@ func TestProgramBuilderOutcomes(t *testing.T) { wantOverall: FragmentOutcomes{ MayJumpToKnownOffsetBeyondFragment: true, MayReturnImmediate: map[linux.BPFAction]struct{}{ - 1337: struct{}{}, + 1337: {}, }, MayReturnRegisterA: true, MayFallThrough: true, diff --git a/pkg/metric/metric_test.go b/pkg/metric/metric_test.go index 0d1dd6c71..c21b0e10a 100644 --- a/pkg/metric/metric_test.go +++ b/pkg/metric/metric_test.go @@ -63,7 +63,7 @@ func verifyPrometheusParsing(t *testing.T) { } var buf bytes.Buffer if _, err := prometheus.Write(&buf, prometheus.ExportOptions{}, map[*prometheus.Snapshot]prometheus.SnapshotExportOptions{ - snapshot: prometheus.SnapshotExportOptions{}, + snapshot: {}, }); err != nil { t.Errorf("failed to get Prometheus snapshot: %v", err) return diff --git a/pkg/prometheus/prometheus_test.go b/pkg/prometheus/prometheus_test.go index 6cc745d08..df0936bf3 100644 --- a/pkg/prometheus/prometheus_test.go +++ b/pkg/prometheus/prometheus_test.go @@ -1741,10 +1741,10 @@ func TestGroupSameNameMetrics(t *testing.T) { func TestNumberPacker(t *testing.T) { interestingIntegers := map[uint64]struct{}{ - uint64(0): struct{}{}, - uint64(0x5555555555555555): struct{}{}, - uint64(0xaaaaaaaaaaaaaaaa): struct{}{}, - uint64(0xffffffffffffffff): struct{}{}, + uint64(0): {}, + uint64(0x5555555555555555): {}, + uint64(0xaaaaaaaaaaaaaaaa): {}, + uint64(0xffffffffffffffff): {}, } for numBits := 0; numBits < 2; numBits++ { newIntegers := map[uint64]struct{}{} diff --git a/pkg/seccomp/seccomp.go b/pkg/seccomp/seccomp.go index c845e9b3c..a26efcd6b 100644 --- a/pkg/seccomp/seccomp.go +++ b/pkg/seccomp/seccomp.go @@ -452,7 +452,7 @@ func (ssrs singleSyscallRuleSet) Render(program *syscallProgram, ls *labelSet, n ruleFrag.MustHaveJumpedToOrReturned( []label{nextRule}, map[linux.BPFAction]struct{}{ - ra.action: struct{}{}, + ra.action: {}, }) program.Label(nextRule) } diff --git a/pkg/sentry/devices/nvproxy/nvproxy_driver_parity_test.go b/pkg/sentry/devices/nvproxy/nvproxy_driver_parity_test.go index 79f0c666c..d192df77a 100644 --- a/pkg/sentry/devices/nvproxy/nvproxy_driver_parity_test.go +++ b/pkg/sentry/devices/nvproxy/nvproxy_driver_parity_test.go @@ -211,16 +211,16 @@ var typeMap = map[string]reflect.Type{ // typeAllowlist is a set of types that are allowed on the nvproxy side. var typeAllowlist = map[reflect.Kind]struct{}{ - reflect.Int8: struct{}{}, - reflect.Uint8: struct{}{}, - reflect.Int16: struct{}{}, - reflect.Uint16: struct{}{}, - reflect.Int32: struct{}{}, - reflect.Uint32: struct{}{}, - reflect.Int64: struct{}{}, - reflect.Uint64: struct{}{}, - reflect.Array: struct{}{}, - reflect.Struct: struct{}{}, + reflect.Int8: {}, + reflect.Uint8: {}, + reflect.Int16: {}, + reflect.Uint16: {}, + reflect.Int32: {}, + reflect.Uint32: {}, + reflect.Int64: {}, + reflect.Uint64: {}, + reflect.Array: {}, + reflect.Struct: {}, } func isDriverBaseType(t string) bool { diff --git a/pkg/sentry/devices/nvproxy/version.go b/pkg/sentry/devices/nvproxy/version.go index ea938932a..a6c101a15 100644 --- a/pkg/sentry/devices/nvproxy/version.go +++ b/pkg/sentry/devices/nvproxy/version.go @@ -696,7 +696,7 @@ func Init() { // have a struct defined in nvproxy, but we know the driver struct name. func simpleIoctl(structName string) []DriverStruct { return []DriverStruct{ - DriverStruct{ + { Name: structName, Type: nil, }, @@ -740,7 +740,7 @@ func getStructName(params any) []DriverStruct { } return []DriverStruct{ - DriverStruct{ + { Name: driverName, Type: paramType, }, diff --git a/pkg/sentry/fsimpl/sys/sys_integration_test.go b/pkg/sentry/fsimpl/sys/sys_integration_test.go index 73ddef55d..0b7d547f6 100644 --- a/pkg/sentry/fsimpl/sys/sys_integration_test.go +++ b/pkg/sentry/fsimpl/sys/sys_integration_test.go @@ -218,28 +218,28 @@ func TestEnableTPUProxyPathsV5(t *testing.T) { } devices := []PCIDeviceInfo{ - PCIDeviceInfo{ + { group: "0", pciPath: pciPath0, pciAddress: "0000:00:04.0", name: "vfio0", nestedDeviceIndex: -1, }, - PCIDeviceInfo{ + { group: "1", pciPath: pciPath0, pciAddress: "0000:00:05.0", name: "vfio1", nestedDeviceIndex: -1, }, - PCIDeviceInfo{ + { group: "2", pciPath: pciPath1, pciAddress: "0000:10:05.0", name: "vfio2", nestedDeviceIndex: 3, }, - PCIDeviceInfo{ + { group: "3", pciPath: pciPath1, pciAddress: "0000:10:05.0/0000:03:00.1", diff --git a/pkg/sentry/fsimpl/tmpfs/tmpfs.go b/pkg/sentry/fsimpl/tmpfs/tmpfs.go index 5c698b5cb..3d3c22a43 100644 --- a/pkg/sentry/fsimpl/tmpfs/tmpfs.go +++ b/pkg/sentry/fsimpl/tmpfs/tmpfs.go @@ -182,10 +182,10 @@ func (fstype FilesystemType) GetFilesystem(ctx context.Context, vfsObj *vfs.Virt // also supports "security" and (if configured) POSIX ACL namespaces // "system.posix_acl_access" and "system.posix_acl_default". allowXattrPrefix := map[string]struct{}{ - linux.XATTR_TRUSTED_PREFIX: struct{}{}, - linux.XATTR_USER_PREFIX: struct{}{}, + linux.XATTR_TRUSTED_PREFIX: {}, + linux.XATTR_USER_PREFIX: {}, // The "security" namespace is allowed, but it always returns an error. - linux.XATTR_SECURITY_PREFIX: struct{}{}, + linux.XATTR_SECURITY_PREFIX: {}, } tmpfsOpts, tmpfsOptsOk := opts.InternalData.(FilesystemOpts) diff --git a/pkg/sentry/kernel/syscalls.go b/pkg/sentry/kernel/syscalls.go index 259890fd5..a585f8bef 100644 --- a/pkg/sentry/kernel/syscalls.go +++ b/pkg/sentry/kernel/syscalls.go @@ -33,7 +33,7 @@ import ( // outOfRangeSyscallNumber is used to represent a syscall number that is out of the // range [0, maxSyscallNum] in monitoring. -var outOfRangeSyscallNumber = []*metric.FieldValue{&metric.FieldValue{"-1"}} +var outOfRangeSyscallNumber = []*metric.FieldValue{{"-1"}} // SyscallSupportLevel is a syscall support levels. type SyscallSupportLevel int diff --git a/pkg/sentry/platform/systrap/sysmsg_thread.go b/pkg/sentry/platform/systrap/sysmsg_thread.go index 56587d260..000ccebd3 100644 --- a/pkg/sentry/platform/systrap/sysmsg_thread.go +++ b/pkg/sentry/platform/systrap/sysmsg_thread.go @@ -99,7 +99,7 @@ func (p *sysmsgThread) Debugf(format string, v ...any) { func sysmsgSyscallNotifyRules() []bpf.Instruction { rules := []seccomp.RuleSet{ - seccomp.RuleSet{ + { Rules: seccomp.MakeSyscallRules(map[uintptr]seccomp.SyscallRule{ unix.SYS_EXIT_GROUP: seccomp.MatchAll{}, }), diff --git a/pkg/tcpip/checker/checker.go b/pkg/tcpip/checker/checker.go index a9355def2..68b5a96ac 100644 --- a/pkg/tcpip/checker/checker.go +++ b/pkg/tcpip/checker/checker.go @@ -1254,7 +1254,7 @@ func MLDMulticastAddressUnordered(expectedGroups map[tcpip.Address]struct{}) Tra // containing a valid MLD message as far as the size is concerned. func MLDMulticastAddress(want tcpip.Address) TransportChecker { return MLDMulticastAddressUnordered(map[tcpip.Address]struct{}{ - want: struct{}{}, + want: {}, }) } @@ -1626,7 +1626,7 @@ func IGMPGroupAddressUnordered(expectedGroups map[tcpip.Address]struct{}) Transp // IGMPGroupAddress creates a checker that checks the IGMP Group Address field. func IGMPGroupAddress(want tcpip.Address) TransportChecker { return IGMPGroupAddressUnordered(map[tcpip.Address]struct{}{ - want: struct{}{}, + want: {}, }) } diff --git a/pkg/tcpip/checksum/checksum_test.go b/pkg/tcpip/checksum/checksum_test.go index 652abd62c..b3492cdda 100644 --- a/pkg/tcpip/checksum/checksum_test.go +++ b/pkg/tcpip/checksum/checksum_test.go @@ -58,8 +58,8 @@ func TestChecksumer(t *testing.T) { { name: "TwoEvenViews", data: [][]byte{ - []byte{98, 1, 9, 0}, - []byte{9, 0, 5, 4}, + {98, 1, 9, 0}, + {9, 0, 5, 4}, }, want: 30981, }, diff --git a/pkg/tcpip/link/veth/veth.go b/pkg/tcpip/link/veth/veth.go index c5df69ef7..0cd2c416d 100644 --- a/pkg/tcpip/link/veth/veth.go +++ b/pkg/tcpip/link/veth/veth.go @@ -90,10 +90,10 @@ func NewPair(mtu uint32) (*Endpoint, *Endpoint) { backlogQueue: make(chan vethPacket, backlogQueueSize), mtu: mtu, endpoints: [2]Endpoint{ - Endpoint{ + { linkAddr: tcpip.GetRandMacAddr(), }, - Endpoint{ + { linkAddr: tcpip.GetRandMacAddr(), }, }, diff --git a/pkg/tcpip/network/internal/ip/generic_multicast_protocol_test.go b/pkg/tcpip/network/internal/ip/generic_multicast_protocol_test.go index 6d021a5b1..01ffd784c 100644 --- a/pkg/tcpip/network/internal/ip/generic_multicast_protocol_test.go +++ b/pkg/tcpip/network/internal/ip/generic_multicast_protocol_test.go @@ -458,7 +458,7 @@ func TestLeaveGroup(t *testing.T) { t.Run(test.name, func(t *testing.T) { for _, subTest := range subTests { t.Run(subTest.name, func(t *testing.T) { - for _, queryAddr := range []tcpip.Address{test.addr, tcpip.Address{}} { + for _, queryAddr := range []tcpip.Address{test.addr, {}} { t.Run(fmt.Sprintf("QueryAddr=%s", queryAddr), func(t *testing.T) { mgp := mockMulticastGroupProtocol{t: t, skipProtocolAddress: addr2} clock := faketime.NewManualClock() @@ -1435,7 +1435,7 @@ func TestMakeAllNonMemberCancelsDelayedReportJob(t *testing.T) { if leave { recordType = ip.MulticastGroupProtocolV2ReportRecordChangeToIncludeMode } - return checkFields{sentV2Reports: []mockReportV2{{records: []mockReportV2Record{mockReportV2Record{ + return checkFields{sentV2Reports: []mockReportV2{{records: []mockReportV2Record{{ recordType: recordType, groupAddress: addr, }}}}} diff --git a/pkg/tcpip/network/internal/multicast/route_table_test.go b/pkg/tcpip/network/internal/multicast/route_table_test.go index 631ed309c..6116dbe57 100644 --- a/pkg/tcpip/network/internal/multicast/route_table_test.go +++ b/pkg/tcpip/network/internal/multicast/route_table_test.go @@ -417,8 +417,8 @@ func TestRemoveAllInstalledRoutes(t *testing.T) { } routes := map[stack.UnicastSourceAndMulticastDestination]stack.MulticastRoute{ - defaultRouteKey: defaultRoute, - stack.UnicastSourceAndMulticastDestination{otherAddress, otherAddress}: defaultRoute, + defaultRouteKey: defaultRoute, + {otherAddress, otherAddress}: defaultRoute, } for key, route := range routes { diff --git a/pkg/tcpip/nftables/nftables_test.go b/pkg/tcpip/nftables/nftables_test.go index 6777aee25..e96ca7d54 100644 --- a/pkg/tcpip/nftables/nftables_test.go +++ b/pkg/tcpip/nftables/nftables_test.go @@ -3068,9 +3068,9 @@ func TestLoopCheckOnRegisterAndUnregister(t *testing.T) { { tname: "jump to non-existent chain", chains: map[string]*Chain{ - "base_chain": &Chain{ + "base_chain": { baseChainInfo: arbitraryInfoPolicyAccept, - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "non_existent_chain"}))}, }}, }, @@ -3080,9 +3080,9 @@ func TestLoopCheckOnRegisterAndUnregister(t *testing.T) { { tname: "goto to non-existent chain", chains: map[string]*Chain{ - "base_chain": &Chain{ + "base_chain": { baseChainInfo: arbitraryInfoPolicyAccept, - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_GOTO), ChainName: "non_existent_chain"}))}, }}, }, @@ -3092,9 +3092,9 @@ func TestLoopCheckOnRegisterAndUnregister(t *testing.T) { { tname: "jump to itself", chains: map[string]*Chain{ - "base_chain": &Chain{ + "base_chain": { baseChainInfo: arbitraryInfoPolicyAccept, - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "base_chain"}))}, }}, }, @@ -3104,9 +3104,9 @@ func TestLoopCheckOnRegisterAndUnregister(t *testing.T) { { tname: "goto to itself", chains: map[string]*Chain{ - "base_chain": &Chain{ + "base_chain": { baseChainInfo: arbitraryInfoPolicyAccept, - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_GOTO), ChainName: "base_chain"}))}, }}, }, @@ -3116,14 +3116,14 @@ func TestLoopCheckOnRegisterAndUnregister(t *testing.T) { { tname: "simple 2-chain loop", chains: map[string]*Chain{ - "base_chain": &Chain{ + "base_chain": { baseChainInfo: arbitraryInfoPolicyAccept, - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain"}))}, }}, }, - "aux_chain": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain": { + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_GOTO), ChainName: "base_chain"}))}, }}, }, @@ -3133,19 +3133,19 @@ func TestLoopCheckOnRegisterAndUnregister(t *testing.T) { { tname: "2-chain loop with entry point outside loop", chains: map[string]*Chain{ - "base_chain": &Chain{ + "base_chain": { baseChainInfo: arbitraryInfoPolicyAccept, - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain"}))}, }}, }, - "aux_chain": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain": { + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_GOTO), ChainName: "aux_chain2"}))}, }}, }, - "aux_chain2": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain2": { + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_GOTO), ChainName: "aux_chain"}))}, }}, }, @@ -3155,19 +3155,19 @@ func TestLoopCheckOnRegisterAndUnregister(t *testing.T) { { tname: "simple 3-chain loop", chains: map[string]*Chain{ - "base_chain": &Chain{ + "base_chain": { baseChainInfo: arbitraryInfoPolicyAccept, - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain"}))}, }}, }, - "aux_chain": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain": { + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain2"}))}, }}, }, - "aux_chain2": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain2": { + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_GOTO), ChainName: "base_chain"}))}, }}, }, @@ -3177,29 +3177,29 @@ func TestLoopCheckOnRegisterAndUnregister(t *testing.T) { { tname: "3-chain loop with entry point 2 points outside loop", chains: map[string]*Chain{ - "base_chain": &Chain{ + "base_chain": { baseChainInfo: arbitraryInfoPolicyAccept, - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain"}))}, }}, }, - "aux_chain": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain": { + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_GOTO), ChainName: "aux_chain2"}))}, }}, }, - "aux_chain2": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain2": { + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain3"}))}, }}, }, - "aux_chain3": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain3": { + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_GOTO), ChainName: "aux_chain4"}))}, }}, }, - "aux_chain4": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain4": { + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain2"}))}, }}, }, @@ -3209,24 +3209,24 @@ func TestLoopCheckOnRegisterAndUnregister(t *testing.T) { { tname: "simple 4-chain loop", chains: map[string]*Chain{ - "base_chain": &Chain{ + "base_chain": { baseChainInfo: arbitraryInfoPolicyAccept, - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain"}))}, }}, }, - "aux_chain": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain": { + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_GOTO), ChainName: "aux_chain2"}))}, }}, }, - "aux_chain2": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain2": { + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain3"}))}, }}, }, - "aux_chain3": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain3": { + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_GOTO), ChainName: "base_chain"}))}, }}, }, @@ -3236,24 +3236,24 @@ func TestLoopCheckOnRegisterAndUnregister(t *testing.T) { { tname: "simple 5-chain loop", chains: map[string]*Chain{ - "base_chain": &Chain{ + "base_chain": { baseChainInfo: arbitraryInfoPolicyAccept, - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain"}))}, }}, }, - "aux_chain": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain": { + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_GOTO), ChainName: "aux_chain2"}))}, }}, }, - "aux_chain2": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain2": { + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain3"}))}, }}, }, - "aux_chain3": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain3": { + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_GOTO), ChainName: "base_chain"}))}, }}, }, @@ -3267,31 +3267,31 @@ func TestLoopCheckOnRegisterAndUnregister(t *testing.T) { // 1 <- 2 <-> 3 tname: "complex 2-3 loop", chains: map[string]*Chain{ - "base_chain": &Chain{ + "base_chain": { baseChainInfo: arbitraryInfoPolicyAccept, - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{ mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain"})), mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain2"})), }, }}, }, - "aux_chain": &Chain{ + "aux_chain": { comment: "strictly target", - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NF_DROP)}))}, }}, }, - "aux_chain2": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain2": { + rules: []*Rule{{ ops: []operation{ mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain"})), mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain3"})), }, }}, }, - "aux_chain3": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain3": { + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_GOTO), ChainName: "aux_chain2"}))}, }}, }, @@ -3301,32 +3301,32 @@ func TestLoopCheckOnRegisterAndUnregister(t *testing.T) { { tname: "simple loop amongst other rules and operations", chains: map[string]*Chain{ - "base_chain": &Chain{ + "base_chain": { baseChainInfo: arbitraryInfoPolicyAccept, rules: []*Rule{ - &Rule{ops: []operation{mustCreateImmediate(t, linux.NFT_REG_1, newBytesData([]byte{0, 1, 2, 3}))}}, - &Rule{ops: []operation{mustCreateImmediate(t, linux.NFT_REG32_14, newBytesData([]byte{0, 1, 2, 3}))}}, - &Rule{ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain"}))}}, + {ops: []operation{mustCreateImmediate(t, linux.NFT_REG_1, newBytesData([]byte{0, 1, 2, 3}))}}, + {ops: []operation{mustCreateImmediate(t, linux.NFT_REG32_14, newBytesData([]byte{0, 1, 2, 3}))}}, + {ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain"}))}}, }, }, - "aux_chain": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain": { + rules: []*Rule{{ ops: []operation{ mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NF_DROP)})), mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_GOTO), ChainName: "aux_chain2"})), }, }}, }, - "aux_chain2": &Chain{ - rules: []*Rule{&Rule{ + "aux_chain2": { + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain3"}))}, }}, }, - "aux_chain3": &Chain{ + "aux_chain3": { rules: []*Rule{ - &Rule{ops: []operation{mustCreateImmediate(t, linux.NFT_REG_1, newBytesData([]byte{0, 1, 2, 3}))}}, - &Rule{ops: []operation{mustCreateImmediate(t, linux.NFT_REG32_14, newBytesData([]byte{0, 1, 2, 3}))}}, - &Rule{ops: []operation{ + {ops: []operation{mustCreateImmediate(t, linux.NFT_REG_1, newBytesData([]byte{0, 1, 2, 3}))}}, + {ops: []operation{mustCreateImmediate(t, linux.NFT_REG32_14, newBytesData([]byte{0, 1, 2, 3}))}}, + {ops: []operation{ mustCreateImmediate(t, linux.NFT_REG_4, newBytesData([]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15})), mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_GOTO), ChainName: "aux_chain"})), mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NF_DROP)})), @@ -3339,33 +3339,33 @@ func TestLoopCheckOnRegisterAndUnregister(t *testing.T) { { tname: "base chain jump to 3 other chains", chains: map[string]*Chain{ - "base_chain": &Chain{ + "base_chain": { baseChainInfo: arbitraryInfoPolicyAccept, rules: []*Rule{ - &Rule{ + { ops: []operation{ mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain"})), mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain2"})), }, }, - &Rule{ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain3"}))}}, + {ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain3"}))}}, }, }, - "aux_chain": &Chain{ + "aux_chain": { comment: "strictly target", - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_2, newBytesData([]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}))}, }}, }, - "aux_chain2": &Chain{ + "aux_chain2": { comment: "strictly target", - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_3, newBytesData([]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}))}, }}, }, - "aux_chain3": &Chain{ + "aux_chain3": { comment: "strictly target", - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_4, newBytesData([]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}))}, }}, }, @@ -3375,33 +3375,33 @@ func TestLoopCheckOnRegisterAndUnregister(t *testing.T) { { tname: "base chain jump to 3 other chains with last chain dropping", chains: map[string]*Chain{ - "base_chain": &Chain{ + "base_chain": { baseChainInfo: arbitraryInfoPolicyAccept, rules: []*Rule{ - &Rule{ + { ops: []operation{ mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain"})), mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain2"})), }, }, - &Rule{ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain3"}))}}, + {ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain3"}))}}, }, }, - "aux_chain": &Chain{ + "aux_chain": { comment: "strictly target", - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_2, newBytesData([]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}))}, }}, }, - "aux_chain2": &Chain{ + "aux_chain2": { comment: "strictly target", - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_3, newBytesData([]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}))}, }}, }, - "aux_chain3": &Chain{ + "aux_chain3": { comment: "strictly target", - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NF_DROP)}))}, }}, }, @@ -3411,34 +3411,34 @@ func TestLoopCheckOnRegisterAndUnregister(t *testing.T) { { tname: "base chain jump to 3 other chains with last rule in base chain dropping", chains: map[string]*Chain{ - "base_chain": &Chain{ + "base_chain": { baseChainInfo: arbitraryInfoPolicyAccept, rules: []*Rule{ - &Rule{ + { ops: []operation{ mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain"})), mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain2"})), }, }, - &Rule{ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain3"}))}}, - &Rule{ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NF_DROP)}))}}, + {ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain3"}))}}, + {ops: []operation{mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NF_DROP)}))}}, }, }, - "aux_chain": &Chain{ + "aux_chain": { comment: "strictly target", - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_2, newBytesData([]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}))}, }}, }, - "aux_chain2": &Chain{ + "aux_chain2": { comment: "strictly target", - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_3, newBytesData([]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}))}, }}, }, - "aux_chain3": &Chain{ + "aux_chain3": { comment: "strictly target", - rules: []*Rule{&Rule{ + rules: []*Rule{{ ops: []operation{mustCreateImmediate(t, linux.NFT_REG_4, newBytesData([]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}))}, }}, }, @@ -3448,10 +3448,10 @@ func TestLoopCheckOnRegisterAndUnregister(t *testing.T) { { tname: "jump to the same chain", chains: map[string]*Chain{ - "base_chain": &Chain{ + "base_chain": { baseChainInfo: arbitraryInfoPolicyAccept, rules: []*Rule{ - &Rule{ + { ops: []operation{ mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain"})), mustCreateImmediate(t, linux.NFT_REG_VERDICT, newVerdictData(Verdict{Code: VC(linux.NFT_JUMP), ChainName: "aux_chain"})), @@ -3459,9 +3459,9 @@ func TestLoopCheckOnRegisterAndUnregister(t *testing.T) { }, }, }, - "aux_chain": &Chain{ + "aux_chain": { comment: "strictly target", - rules: []*Rule{&Rule{}}, + rules: []*Rule{{}}, }, }, verdict: Verdict{Code: VC(linux.NF_ACCEPT)}, // from base chain policy diff --git a/pkg/tcpip/tests/integration/multicast_forward_test.go b/pkg/tcpip/tests/integration/multicast_forward_test.go index 53c73aac7..68caf0257 100644 --- a/pkg/tcpip/tests/integration/multicast_forward_test.go +++ b/pkg/tcpip/tests/integration/multicast_forward_test.go @@ -97,7 +97,7 @@ func (m *fakeMulticastEventDispatcher) OnUnexpectedInputInterface(context stack. var ( v4Addrs = map[addrType]tcpip.Address{ anyAddr: header.IPv4Any, - emptyAddr: tcpip.Address{}, + emptyAddr: {}, linkLocalMulticastAddr: testutil.MustParse4("224.0.0.1"), linkLocalUnicastAddr: testutil.MustParse4("169.254.0.10"), multicastAddr: testutil.MustParse4("225.0.0.0"), @@ -107,7 +107,7 @@ var ( v6Addrs = map[addrType]tcpip.Address{ anyAddr: header.IPv6Any, - emptyAddr: tcpip.Address{}, + emptyAddr: {}, linkLocalMulticastAddr: testutil.MustParse6("ff02::a"), linkLocalUnicastAddr: testutil.MustParse6("fe80::a"), multicastAddr: testutil.MustParse6("ff0e::a"), diff --git a/runsc/boot/filter/config/config_precompiled.go b/runsc/boot/filter/config/config_precompiled.go index 279863613..5e2ed962d 100644 --- a/runsc/boot/filter/config/config_precompiled.go +++ b/runsc/boot/filter/config/config_precompiled.go @@ -57,7 +57,7 @@ func allPrecompiledPlatforms() ([]platform.SeccompInfo, error) { // precompile seccomp filters. func optionsToPrecompile() ([]Options, error) { type expandFn func(opt Options) ([]Options, error) - opts := []Options{Options{}} + opts := []Options{{}} for _, fn := range []expandFn{ // Expand all platforms. func(opt Options) ([]Options, error) { diff --git a/runsc/boot/filter/config/config_test.go b/runsc/boot/filter/config/config_test.go index 509c3b2ca..5eb1ec50b 100644 --- a/runsc/boot/filter/config/config_test.go +++ b/runsc/boot/filter/config/config_test.go @@ -27,34 +27,34 @@ import ( func TestIoctlFirstArgumentIsNonNegativeFD(t *testing.T) { for name, options := range map[string]Options{ - "default systrap": Options{ + "default systrap": { Platform: (&systrap.Systrap{}).SeccompInfo(), }, - "default kvm": Options{ + "default kvm": { Platform: (&kvm.KVM{}).SeccompInfo(), }, - "nvproxy": Options{ + "nvproxy": { Platform: (&systrap.Systrap{}).SeccompInfo(), NVProxy: true, }, - "tpuproxy": Options{ + "tpuproxy": { Platform: (&systrap.Systrap{}).SeccompInfo(), TPUProxy: true, }, - "host network": Options{ + "host network": { Platform: (&systrap.Systrap{}).SeccompInfo(), HostNetwork: true, }, - "host network with raw sockets": Options{ + "host network with raw sockets": { Platform: (&systrap.Systrap{}).SeccompInfo(), HostNetwork: true, HostNetworkRawSockets: true, }, - "profiling": Options{ + "profiling": { Platform: (&systrap.Systrap{}).SeccompInfo(), ProfileEnable: true, }, - "host filesystem": Options{ + "host filesystem": { Platform: (&systrap.Systrap{}).SeccompInfo(), HostFilesystem: true, }, diff --git a/runsc/boot/vfs.go b/runsc/boot/vfs.go index b99ff205f..3b6bdf8f2 100644 --- a/runsc/boot/vfs.go +++ b/runsc/boot/vfs.go @@ -1310,8 +1310,8 @@ func createDeviceFiles(ctx context.Context, creds *auth.Credentials, info *conta // spec.Linux.Devices. So manually create appropriate device files. mode := os.FileMode(0666) nvidiaDevs := []specs.LinuxDevice{ - specs.LinuxDevice{Path: "/dev/nvidiactl", Type: "c", Major: nvgpu.NV_MAJOR_DEVICE_NUMBER, Minor: nvgpu.NV_CONTROL_DEVICE_MINOR, FileMode: &mode}, - specs.LinuxDevice{Path: "/dev/nvidia-uvm", Type: "c", Major: int64(info.nvidiaUVMDevMajor), Minor: nvgpu.NVIDIA_UVM_PRIMARY_MINOR_NUMBER, FileMode: &mode}, + {Path: "/dev/nvidiactl", Type: "c", Major: nvgpu.NV_MAJOR_DEVICE_NUMBER, Minor: nvgpu.NV_CONTROL_DEVICE_MINOR, FileMode: &mode}, + {Path: "/dev/nvidia-uvm", Type: "c", Major: int64(info.nvidiaUVMDevMajor), Minor: nvgpu.NVIDIA_UVM_PRIMARY_MINOR_NUMBER, FileMode: &mode}, } devClient := devutil.GoferClientFromContext(ctx) if devClient == nil { diff --git a/runsc/cmd/install_test.go b/runsc/cmd/install_test.go index a7067bf0e..981274f15 100644 --- a/runsc/cmd/install_test.go +++ b/runsc/cmd/install_test.go @@ -52,15 +52,15 @@ func (r *runtimeDef) UnmarshalJSON(data []byte) error { var defaultInput = map[string]any{ "runtimes": map[string]*runtimeDef{ - "runtime1": &runtimeDef{ + "runtime1": { path: "runtime1_path", runtimeArgs: []string{"some", "args"}, }, - "other runtime": &runtimeDef{ + "other runtime": { path: "other_runtime_path", runtimeArgs: []string{"some", "other", "args"}, }, - "myRuntime": &runtimeDef{ + "myRuntime": { path: "myRuntimePath", runtimeArgs: []string{"super", "cool", "args"}, }, @@ -89,15 +89,15 @@ func TestInstall(t *testing.T) { input: defaultInput, output: map[string]any{ "runtimes": map[string]*runtimeDef{ - "runtime1": &runtimeDef{ + "runtime1": { path: "runtime1_path", runtimeArgs: []string{"some", "args"}, }, - "other runtime": &runtimeDef{ + "other runtime": { path: "other_runtime_path", runtimeArgs: []string{"some", "other", "args"}, }, - "myRuntime": &runtimeDef{ + "myRuntime": { path: "some_runsc_path", runtimeArgs: []string{"new", "cool", "args"}, }, @@ -119,15 +119,15 @@ func TestInstall(t *testing.T) { input: defaultInput, output: map[string]any{ "runtimes": map[string]*runtimeDef{ - "runtime1": &runtimeDef{ + "runtime1": { path: "runtime1_path", runtimeArgs: []string{"some", "args"}, }, - "other runtime": &runtimeDef{ + "other runtime": { path: "other_runtime_path", runtimeArgs: []string{"some", "other", "args"}, }, - "myRuntime": &runtimeDef{ + "myRuntime": { path: "myRuntimePath", runtimeArgs: []string{"super", "cool", "args"}, }, @@ -147,19 +147,19 @@ func TestInstall(t *testing.T) { input: defaultInput, output: map[string]any{ "runtimes": map[string]*runtimeDef{ - "runtime1": &runtimeDef{ + "runtime1": { path: "runtime1_path", runtimeArgs: []string{"some", "args"}, }, - "newRuntime": &runtimeDef{ + "newRuntime": { path: "newPath", runtimeArgs: []string{"new", "cool", "args"}, }, - "other runtime": &runtimeDef{ + "other runtime": { path: "other_runtime_path", runtimeArgs: []string{"some", "other", "args"}, }, - "myRuntime": &runtimeDef{ + "myRuntime": { path: "myRuntimePath", runtimeArgs: []string{"super", "cool", "args"}, }, @@ -222,11 +222,11 @@ func TestUninstall(t *testing.T) { input: defaultInput, output: map[string]any{ "runtimes": map[string]*runtimeDef{ - "runtime1": &runtimeDef{ + "runtime1": { path: "runtime1_path", runtimeArgs: []string{"some", "args"}, }, - "myRuntime": &runtimeDef{ + "myRuntime": { path: "myRuntimePath", runtimeArgs: []string{"super", "cool", "args"}, }, diff --git a/runsc/cmd/util/tpu.go b/runsc/cmd/util/tpu.go index 8c00b313e..c17094560 100644 --- a/runsc/cmd/util/tpu.go +++ b/runsc/cmd/util/tpu.go @@ -38,8 +38,8 @@ const ( ) var ( - tpuV4DeviceIDs = map[uint64]struct{}{tpu.TPUV4DeviceID: struct{}{}, tpu.TPUV4liteDeviceID: struct{}{}} - tpuV5DeviceIDs = map[uint64]struct{}{tpu.TPUV5eDeviceID: struct{}{}, tpu.TPUV5pDeviceID: struct{}{}} + tpuV4DeviceIDs = map[uint64]struct{}{tpu.TPUV4DeviceID: {}, tpu.TPUV4liteDeviceID: {}} + tpuV5DeviceIDs = map[uint64]struct{}{tpu.TPUV5eDeviceID: {}, tpu.TPUV5pDeviceID: {}} pciDeviceRegex = regexp.MustCompile(`0000:([[:xdigit:]]{2}|[[:xdigit:]]{4}):[[:xdigit:]]{2}\.[[:xdigit:]]{1,2}`) ) diff --git a/runsc/container/container_test.go b/runsc/container/container_test.go index a120cd85b..19f7e8b48 100644 --- a/runsc/container/container_test.go +++ b/runsc/container/container_test.go @@ -3462,7 +3462,7 @@ func TestRootfsEROFS(t *testing.T) { nil, // Case 2: EROFS rootfs with a LISAFS backed gofer mount. - []specs.Mount{ + { { Type: "bind", Destination: "/tmp", diff --git a/runsc/container/serialization_test.go b/runsc/container/serialization_test.go index 818346d47..98e1963d0 100644 --- a/runsc/container/serialization_test.go +++ b/runsc/container/serialization_test.go @@ -33,7 +33,7 @@ import ( var ignoreList = map[string]struct{}{ // Part of the OCI runtime spec, it uses an `interface{}` type which it // promises is JSON-serializable in the comments. - "Container.Spec.Windows.CredentialSpec": struct{}{}, + "Container.Spec.Windows.CredentialSpec": {}, } // implementsSerializableInterface returns true if the given type implements diff --git a/runsc/container/trace_test.go b/runsc/container/trace_test.go index 7f2129817..00379384b 100644 --- a/runsc/container/trace_test.go +++ b/runsc/container/trace_test.go @@ -375,7 +375,7 @@ func TestProcfsDump(t *testing.T) { t.Errorf("expected at least 3 FDs for the sleep process, got %+v", procfsDump[0].FDs) } else { modes := [3]uint32{} - for i, _ := range []*os.File{os.Stdin, os.Stdout, os.Stderr} { + for i := range []*os.File{os.Stdin, os.Stdout, os.Stderr} { stat := unix.Stat_t{} err := unix.Fstat(i, &stat) if err != nil { @@ -412,13 +412,13 @@ func TestProcfsDump(t *testing.T) { } wantCgroup := []kernel.TaskCgroupEntry{ - kernel.TaskCgroupEntry{HierarchyID: 7, Controllers: "pids", Path: "/"}, - kernel.TaskCgroupEntry{HierarchyID: 6, Controllers: "memory", Path: "/"}, - kernel.TaskCgroupEntry{HierarchyID: 5, Controllers: "job", Path: "/"}, - kernel.TaskCgroupEntry{HierarchyID: 4, Controllers: "devices", Path: "/"}, - kernel.TaskCgroupEntry{HierarchyID: 3, Controllers: "cpuset", Path: "/"}, - kernel.TaskCgroupEntry{HierarchyID: 2, Controllers: "cpuacct", Path: "/"}, - kernel.TaskCgroupEntry{HierarchyID: 1, Controllers: "cpu", Path: "/"}, + {HierarchyID: 7, Controllers: "pids", Path: "/"}, + {HierarchyID: 6, Controllers: "memory", Path: "/"}, + {HierarchyID: 5, Controllers: "job", Path: "/"}, + {HierarchyID: 4, Controllers: "devices", Path: "/"}, + {HierarchyID: 3, Controllers: "cpuset", Path: "/"}, + {HierarchyID: 2, Controllers: "cpuacct", Path: "/"}, + {HierarchyID: 1, Controllers: "cpu", Path: "/"}, } if len(procfsDump[0].Cgroup) != len(wantCgroup) { t.Errorf("expected 7 cgroup controllers, got %+v", procfsDump[0].Cgroup) diff --git a/test/metricsviz/metricsviz_cli/metricsviz_cli_test.go b/test/metricsviz/metricsviz_cli/metricsviz_cli_test.go index d2fd54034..6f04d3f31 100644 --- a/test/metricsviz/metricsviz_cli/metricsviz_cli_test.go +++ b/test/metricsviz/metricsviz_cli/metricsviz_cli_test.go @@ -85,7 +85,7 @@ func TestMetricsvizCLI(t *testing.T) { []byte("some log with a newline\n"), []byte("a log with\rcarriage return in the middle"), []byte("a log with\nmultiple\nnewlines"), - []byte{0x01, 0x02, 0x00, 0x03}, // Non-ASCII bytes. + {0x01, 0x02, 0x00, 0x03}, // Non-ASCII bytes. } if _, err := logFile.Write(randomLogs[rand.IntN(len(randomLogs))]); err != nil { t.Fatalf("Failed to write random log: %v", err) diff --git a/test/runtimes/proctor/lib/python.go b/test/runtimes/proctor/lib/python.go index 74a555825..5155e0f9a 100644 --- a/test/runtimes/proctor/lib/python.go +++ b/test/runtimes/proctor/lib/python.go @@ -38,21 +38,21 @@ import ( // generate a command to run all un-excluded tests from that library together. var exclude = map[string][]string{ // TODO(b/271473320): Un-exclude once this bug is fixed. Fails with overlay. - "test_os": []string{"TestScandir.test_attributes"}, + "test_os": {"TestScandir.test_attributes"}, // Broken test. Fails with runc too. - "test_asyncio.test_base_events": []string{ + "test_asyncio.test_base_events": { "BaseEventLoopWithSelectorTests.test_create_connection_service_name", }, // TODO(b/162978767): Un-exclude once this bug is fixed. - "test_fcntl": []string{"TestFcntl.test_fcntl_64_bit"}, + "test_fcntl": {"TestFcntl.test_fcntl_64_bit"}, // TODO(b/341776233): Un-exclude once this bug is fixed. - "test_pathlib": []string{ + "test_pathlib": { "PathSubclassTest.test_is_mount", "PathTest.test_is_mount", "PosixPathTest.test_is_mount", }, // TODO(b/76174079): Un-exclude once this bug is fixed. - "test_posix": []string{ + "test_posix": { "PosixTester.test_sched_priority", "PosixTester.test_sched_rr_get_interval", "PosixTester.test_get_and_set_scheduler_and_param", // sched_setparam(2) is not supported. @@ -60,9 +60,9 @@ var exclude = map[string][]string{ "TestPosixSpawnP.test_setscheduler_only_param", }, // TODO(b/76174079): Un-exclude once this bug is fixed. - "test_resource": []string{"ResourceTest.test_prlimit"}, + "test_resource": {"ResourceTest.test_prlimit"}, // TODO(b/271949964): Un-exclude test cases as they are fixed. - "test_socket": []string{ + "test_socket": { "BasicUDPLITETest.testRecvFrom", "BasicUDPLITETest.testRecvFromNegative", "BasicUDPLITETest.testSendtoAndRecv", @@ -108,7 +108,7 @@ var exclude = map[string][]string{ "UDPLITETimeoutTest.testUDPLITETimeout", }, // TODO(b/341780803): Un-exclude once this bug is fixed. - "test_termios": []string{ + "test_termios": { "TestFunctions.test_tcdrain", "TestFunctions.test_tcflow", "TestFunctions.test_tcflush", diff --git a/tools/nvidia_driver_differ/driver_ast_parser_test.go b/tools/nvidia_driver_differ/driver_ast_parser_test.go index 86ce3300e..cbb795880 100644 --- a/tools/nvidia_driver_differ/driver_ast_parser_test.go +++ b/tools/nvidia_driver_differ/driver_ast_parser_test.go @@ -79,10 +79,10 @@ func TestParser(t *testing.T) { Records: parser.RecordDefs{ "TestStruct": parser.RecordDef{ Fields: []parser.RecordField{ - parser.RecordField{Name: "a", Type: "int", Offset: 0}, - parser.RecordField{Name: "b", Type: "int", Offset: 4}, - parser.RecordField{Name: "e", Type: "TestStruct::e_t[4]", Offset: 8}, - parser.RecordField{Name: "f", Type: "TestUnion", Offset: 40}, + {Name: "a", Type: "int", Offset: 0}, + {Name: "b", Type: "int", Offset: 4}, + {Name: "e", Type: "TestStruct::e_t[4]", Offset: 8}, + {Name: "f", Type: "TestUnion", Offset: 40}, }, Size: 44, IsUnion: false, @@ -90,10 +90,10 @@ func TestParser(t *testing.T) { }, "TestStruct2": parser.RecordDef{ Fields: []parser.RecordField{ - parser.RecordField{Name: "a", Type: "int", Offset: 0}, - parser.RecordField{Name: "b", Type: "int", Offset: 4}, - parser.RecordField{Name: "e", Type: "TestStruct::e_t[4]", Offset: 8}, - parser.RecordField{Name: "f", Type: "TestUnion", Offset: 40}, + {Name: "a", Type: "int", Offset: 0}, + {Name: "b", Type: "int", Offset: 4}, + {Name: "e", Type: "TestStruct::e_t[4]", Offset: 8}, + {Name: "f", Type: "TestUnion", Offset: 40}, }, Size: 44, IsUnion: false, @@ -101,8 +101,8 @@ func TestParser(t *testing.T) { }, "TestStruct::e_t": parser.RecordDef{ Fields: []parser.RecordField{ - parser.RecordField{Name: "c", Type: "OtherInt", Offset: 0}, - parser.RecordField{Name: "d", Type: "OtherInt", Offset: 4}, + {Name: "c", Type: "OtherInt", Offset: 0}, + {Name: "d", Type: "OtherInt", Offset: 4}, }, Size: 8, IsUnion: false, @@ -110,8 +110,8 @@ func TestParser(t *testing.T) { }, "TestUnion": parser.RecordDef{ Fields: []parser.RecordField{ - parser.RecordField{Name: "u_a", Type: "int", Offset: 0}, - parser.RecordField{Name: "u_b", Type: "int", Offset: 0}, + {Name: "u_a", Type: "int", Offset: 0}, + {Name: "u_b", Type: "int", Offset: 0}, }, Size: 4, IsUnion: true,