mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Simplify and format gVisor codebase.
The changes are just output of `gofmt -s -w .`.
This commit is contained in:
+84
-84
@@ -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: {},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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{}{}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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{},
|
||||
}),
|
||||
|
||||
@@ -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: {},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
@@ -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(),
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
}}}}}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+102
-102
@@ -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
|
||||
|
||||
@@ -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"),
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user