pkg/compiler: refactor attribute handling

Introduce common infrastructure for describing and parsing attribute
instead of custom per-attribute code scattered across several locations.

Change align attribute syntax from the weird align_N to align[N].
This also allows to use literal constants as N.

Introduce notion of builtin constants.
Currently we have only PTR_SIZE, which is needed to replace
align_ptr with align[PTR_SIZE].
This commit is contained in:
Dmitry Vyukov 2020-04-14 07:00:48 +02:00
parent a116470dc3
commit 0781895e0f
51 changed files with 322 additions and 282 deletions

View File

@ -116,8 +116,8 @@ Attributes are:
```
"packed": the struct does not have paddings and has default alignment 1
"align_N": the struct has alignment N
"size": the struct is padded up to the specified size
"align[N]": the struct has alignment N
"size[N]": the struct is padded up to the specified size N
```
## Unions
@ -135,7 +135,7 @@ Attributes are:
```
"varlen": union size is not maximum of all option but rather length of a particular chosen option
"size": the union is padded up to the specified size
"size[N]": the union is padded up to the specified size N
```
## Resources

62
pkg/compiler/attrs.go Normal file
View File

@ -0,0 +1,62 @@
// Copyright 2020 syzkaller project authors. All rights reserved.
// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
package compiler
import (
"github.com/google/syzkaller/pkg/ast"
)
type attrDesc struct {
Name string
// For now we assume attributes can have only 1 argument and it's an integer,
// enough to cover existing cases.
HasArg bool
CheckConsts func(comp *compiler, parent ast.Node, attr *ast.Type)
}
var (
attrPacked = &attrDesc{Name: "packed"}
attrVarlen = &attrDesc{Name: "varlen"}
attrSize = &attrDesc{Name: "size", HasArg: true}
attrAlign = &attrDesc{Name: "align", HasArg: true}
structAttrs = makeAttrs(attrPacked, attrSize, attrAlign)
unionAttrs = makeAttrs(attrVarlen, attrSize)
)
func init() {
attrSize.CheckConsts = func(comp *compiler, parent ast.Node, attr *ast.Type) {
_, typ, name := parent.Info()
if comp.structIsVarlen(name) {
comp.error(attr.Pos, "varlen %v %v has size attribute", typ, name)
}
sz := attr.Args[0].Value
if sz == 0 || sz > 1<<20 {
comp.error(attr.Args[0].Pos, "size attribute has bad value %v"+
", expect [1, 1<<20]", sz)
}
}
attrAlign.CheckConsts = func(comp *compiler, parent ast.Node, attr *ast.Type) {
_, _, name := parent.Info()
a := attr.Args[0].Value
if a&(a-1) != 0 || a == 0 || a > 1<<30 {
comp.error(attr.Pos, "bad struct %v alignment %v (must be a sane power of 2)", name, a)
}
}
}
func structOrUnionAttrs(n *ast.Struct) map[string]*attrDesc {
if n.IsUnion {
return unionAttrs
}
return structAttrs
}
func makeAttrs(attrs ...*attrDesc) map[string]*attrDesc {
m := make(map[string]*attrDesc)
for _, attr := range attrs {
m[attr.Name] = attr
}
return m
}

View File

@ -235,12 +235,7 @@ func (comp *compiler) checkTypes() {
case *ast.Struct:
comp.checkStruct(checkCtx{}, n)
case *ast.Call:
for _, a := range n.Args {
comp.checkType(checkCtx{}, a.Type, checkIsArg)
}
if n.Ret != nil {
comp.checkType(checkCtx{}, n.Ret, checkIsArg|checkIsRet)
}
comp.checkCall(n)
}
}
}
@ -269,17 +264,9 @@ func (comp *compiler) checkAttributeValues() {
switch n := decl.(type) {
case *ast.Struct:
for _, attr := range n.Attrs {
if attr.Ident == "size" {
_, typ, name := n.Info()
if comp.structIsVarlen(n.Name.Name) {
comp.error(attr.Pos, "varlen %v %v has size attribute",
typ, name)
}
sz := attr.Args[0].Value
if sz == 0 || sz > 1<<20 {
comp.error(attr.Args[0].Pos, "size attribute has bad value %v"+
", expect [1, 1<<20]", sz)
}
desc := structOrUnionAttrs(n)[attr.Ident]
if desc.CheckConsts != nil {
desc.CheckConsts(comp, n, attr)
}
}
}
@ -716,20 +703,15 @@ func (comp *compiler) checkStruct(ctx checkCtx, n *ast.Struct) {
for _, f := range n.Fields {
comp.checkType(ctx, f.Type, flags)
}
for _, attr := range n.Attrs {
if unexpected, _, ok := checkTypeKind(attr, kindIdent); !ok {
comp.error(attr.Pos, "unexpected %v, expect attribute", unexpected)
return
}
if len(attr.Colon) != 0 {
comp.error(attr.Colon[0].Pos, "unexpected ':'")
return
}
comp.parseAttrs(structOrUnionAttrs(n), n, n.Attrs)
}
func (comp *compiler) checkCall(n *ast.Call) {
for _, a := range n.Args {
comp.checkType(checkCtx{}, a.Type, checkIsArg)
}
if n.IsUnion {
comp.parseUnionAttrs(n)
} else {
comp.parseStructAttrs(n)
if n.Ret != nil {
comp.checkType(checkCtx{}, n.Ret, checkIsArg|checkIsRet)
}
}
@ -1128,11 +1110,13 @@ func (comp *compiler) checkVarlen(n *ast.Struct) {
// Non-varlen unions can't have varlen fields.
// Non-packed structs can't have varlen fields in the middle.
if n.IsUnion {
if varlen, _ := comp.parseUnionAttrs(n); varlen {
attrs := comp.parseAttrs(unionAttrs, n, n.Attrs)
if attrs[attrVarlen] != 0 {
return
}
} else {
if packed, _, _ := comp.parseStructAttrs(n); packed {
attrs := comp.parseAttrs(structAttrs, n, n.Attrs)
if attrs[attrPacked] != 0 {
return
}
}

View File

@ -63,6 +63,9 @@ func createCompiler(desc *ast.Description, target *targets.Target, eh ast.ErrorH
structDescs: make(map[prog.StructKey]*prog.StructDesc),
structNodes: make(map[*prog.StructDesc]*ast.Struct),
structVarlen: make(map[string]bool),
builtinConsts: map[string]uint64{
"PTR_SIZE": target.PtrSize,
},
}
for name, n := range builtinTypedefs {
comp.typedefs[name] = n
@ -132,9 +135,10 @@ type compiler struct {
used map[string]bool // contains used structs/resources
usedTypedefs map[string]bool
structDescs map[prog.StructKey]*prog.StructDesc
structNodes map[*prog.StructDesc]*ast.Struct
structVarlen map[string]bool
structDescs map[prog.StructKey]*prog.StructDesc
structNodes map[*prog.StructDesc]*ast.Struct
structVarlen map[string]bool
builtinConsts map[string]uint64
}
type warn struct {
@ -157,7 +161,8 @@ func (comp *compiler) structIsVarlen(name string) bool {
}
s := comp.structs[name]
if s.IsUnion {
if varlen, _ := comp.parseUnionAttrs(s); varlen {
res := comp.parseAttrs(unionAttrs, s, s.Attrs)
if res[attrVarlen] != 0 {
comp.structVarlen[name] = true
return true
}
@ -174,77 +179,48 @@ func (comp *compiler) structIsVarlen(name string) bool {
return varlen
}
func (comp *compiler) parseUnionAttrs(n *ast.Struct) (varlen bool, size uint64) {
size = sizeUnassigned
for _, attr := range n.Attrs {
switch attr.Ident {
case "varlen":
if len(attr.Args) != 0 {
comp.error(attr.Pos, "%v attribute has args", attr.Ident)
}
varlen = true
case "size":
size = comp.parseSizeAttr(attr)
default:
comp.error(attr.Pos, "unknown union %v attribute %v",
n.Name.Name, attr.Ident)
func (comp *compiler) parseAttrs(descs map[string]*attrDesc, parent ast.Node, attrs []*ast.Type) (res map[*attrDesc]uint64) {
_, parentType, parentName := parent.Info()
res = make(map[*attrDesc]uint64)
for _, attr := range attrs {
if unexpected, _, ok := checkTypeKind(attr, kindIdent); !ok {
comp.error(attr.Pos, "unexpected %v, expect attribute", unexpected)
return
}
if len(attr.Colon) != 0 {
comp.error(attr.Colon[0].Pos, "unexpected ':'")
return
}
desc := descs[attr.Ident]
if desc == nil {
comp.error(attr.Pos, "unknown %v %v attribute %v", parentType, parentName, attr.Ident)
return
}
val := uint64(1)
if desc.HasArg {
val = comp.parseAttrArg(attr)
} else if len(attr.Args) != 0 {
comp.error(attr.Pos, "%v attribute has args", attr.Ident)
return
}
res[desc] = val
}
return
}
func (comp *compiler) parseStructAttrs(n *ast.Struct) (packed bool, size, align uint64) {
size = sizeUnassigned
for _, attr := range n.Attrs {
switch {
case attr.Ident == "packed":
if len(attr.Args) != 0 {
comp.error(attr.Pos, "%v attribute has args", attr.Ident)
}
packed = true
case attr.Ident == "align_ptr":
if len(attr.Args) != 0 {
comp.error(attr.Pos, "%v attribute has args", attr.Ident)
}
align = comp.ptrSize
case strings.HasPrefix(attr.Ident, "align_"):
if len(attr.Args) != 0 {
comp.error(attr.Pos, "%v attribute has args", attr.Ident)
}
a, err := strconv.ParseUint(attr.Ident[6:], 10, 64)
if err != nil {
comp.error(attr.Pos, "bad struct %v alignment %v",
n.Name.Name, attr.Ident[6:])
continue
}
if a&(a-1) != 0 || a == 0 || a > 1<<30 {
comp.error(attr.Pos, "bad struct %v alignment %v (must be a sane power of 2)",
n.Name.Name, a)
}
align = a
case attr.Ident == "size":
size = comp.parseSizeAttr(attr)
default:
comp.error(attr.Pos, "unknown struct %v attribute %v",
n.Name.Name, attr.Ident)
}
}
return
}
func (comp *compiler) parseSizeAttr(attr *ast.Type) uint64 {
func (comp *compiler) parseAttrArg(attr *ast.Type) uint64 {
if len(attr.Args) != 1 {
comp.error(attr.Pos, "%v attribute is expected to have 1 argument", attr.Ident)
return sizeUnassigned
return 0
}
sz := attr.Args[0]
if unexpected, _, ok := checkTypeKind(sz, kindInt); !ok {
comp.error(sz.Pos, "unexpected %v, expect int", unexpected)
return sizeUnassigned
return 0
}
if len(sz.Colon) != 0 || len(sz.Args) != 0 {
comp.error(sz.Pos, "size attribute has colon or args")
return sizeUnassigned
comp.error(sz.Pos, "%v attribute has colon or args", attr.Ident)
return 0
}
return sz.Value
}

View File

@ -68,11 +68,14 @@ func (comp *compiler) extractConsts() map[string]*ConstInfo {
v = n.Value.Ident
}
name := n.Name.Name
if _, builtin := comp.builtinConsts[name]; builtin {
comp.error(pos, "redefining builtin const %v", name)
}
info.defines[name] = v
info.consts[name] = true
comp.addConst(infos, pos, name)
case *ast.Call:
if comp.target.SyscallNumbers && !strings.HasPrefix(n.CallName, "syz_") {
info.consts[comp.target.SyscallPrefix+n.CallName] = true
comp.addConst(infos, pos, comp.target.SyscallPrefix+n.CallName)
}
}
}
@ -85,13 +88,11 @@ func (comp *compiler) extractConsts() map[string]*ConstInfo {
for i, arg := range args {
if desc.Args[i].Type.Kind == kindInt {
if arg.Ident != "" {
info := getConstInfo(infos, arg.Pos)
info.consts[arg.Ident] = true
comp.addConst(infos, arg.Pos, arg.Ident)
}
for _, col := range arg.Colon {
if col.Ident != "" {
info := getConstInfo(infos, col.Pos)
info.consts[col.Ident] = true
comp.addConst(infos, col.Pos, col.Ident)
}
}
}
@ -104,9 +105,8 @@ func (comp *compiler) extractConsts() map[string]*ConstInfo {
switch n := decl.(type) {
case *ast.Struct:
for _, attr := range n.Attrs {
if attr.Ident == "size" {
info := getConstInfo(infos, attr.Pos)
info.consts[attr.Args[0].Ident] = true
if structOrUnionAttrs(n)[attr.Ident].HasArg {
comp.addConst(infos, attr.Pos, attr.Args[0].Ident)
}
}
}
@ -114,14 +114,21 @@ func (comp *compiler) extractConsts() map[string]*ConstInfo {
comp.desc.Walk(ast.Recursive(func(n0 ast.Node) {
if n, ok := n0.(*ast.Int); ok {
info := getConstInfo(infos, n.Pos)
info.consts[n.Ident] = true
comp.addConst(infos, n.Pos, n.Ident)
}
}))
return convertConstInfo(infos)
}
func (comp *compiler) addConst(infos map[string]*constInfo, pos ast.Pos, name string) {
if _, builtin := comp.builtinConsts[name]; builtin {
return
}
info := getConstInfo(infos, pos)
info.consts[name] = true
}
type constInfo struct {
consts map[string]bool
defines map[string]string
@ -179,7 +186,17 @@ func (comp *compiler) assignSyscallNumbers(consts map[string]uint64) {
// patchConsts replaces all symbolic consts with their numeric values taken from consts map.
// Updates desc and returns set of unsupported syscalls and flags.
func (comp *compiler) patchConsts(consts map[string]uint64) {
func (comp *compiler) patchConsts(consts0 map[string]uint64) {
consts := make(map[string]uint64)
for name, val := range consts0 {
consts[name] = val
}
for name, val := range comp.builtinConsts {
if _, ok := consts[name]; ok {
panic(fmt.Sprintf("builtin const %v already defined", name))
}
consts[name] = val
}
for _, decl := range comp.desc.Nodes {
switch decl.(type) {
case *ast.IntFlags:
@ -210,7 +227,7 @@ func (comp *compiler) patchConsts(consts map[string]uint64) {
}
if n, ok := decl.(*ast.Struct); ok {
for _, attr := range n.Attrs {
if attr.Ident == "size" {
if structOrUnionAttrs(n)[attr.Ident].HasArg {
comp.patchTypeConst(attr.Args[0], consts, &missing)
}
}

View File

@ -239,15 +239,16 @@ func (ctx *structGen) walkStruct(t *prog.StructType) {
varlen = true
}
}
packed, sizeAttr, alignAttr := comp.parseStructAttrs(structNode)
t.AlignAttr = alignAttr
comp.layoutStruct(t, varlen, packed)
attrs := comp.parseAttrs(structAttrs, structNode, structNode.Attrs)
t.AlignAttr = attrs[attrAlign]
comp.layoutStruct(t, varlen, attrs[attrPacked] != 0)
t.TypeSize = 0
if !varlen {
for _, f := range t.Fields {
t.TypeSize += f.Size()
}
if sizeAttr != sizeUnassigned {
sizeAttr, hasSize := attrs[attrSize]
if hasSize {
if t.TypeSize > sizeAttr {
comp.error(structNode.Attrs[0].Pos, "struct %v has size attribute %v"+
" which is less than struct size %v",
@ -267,24 +268,26 @@ func (ctx *structGen) walkUnion(t *prog.UnionType) {
}
comp := ctx.comp
structNode := comp.structNodes[t.StructDesc]
varlen, sizeAttr := comp.parseUnionAttrs(structNode)
attrs := comp.parseAttrs(unionAttrs, structNode, structNode.Attrs)
t.TypeSize = 0
if !varlen {
for i, fld := range t.Fields {
sz := fld.Size()
if sizeAttr != sizeUnassigned && sz > sizeAttr {
comp.error(structNode.Fields[i].Pos, "union %v has size attribute %v"+
" which is less than field %v size %v",
structNode.Name.Name, sizeAttr, fld.Name(), sz)
}
if t.TypeSize < sz {
t.TypeSize = sz
}
if attrs[attrVarlen] != 0 {
return
}
sizeAttr, hasSize := attrs[attrSize]
for i, fld := range t.Fields {
sz := fld.Size()
if hasSize && sz > sizeAttr {
comp.error(structNode.Fields[i].Pos, "union %v has size attribute %v"+
" which is less than field %v size %v",
structNode.Name.Name, sizeAttr, fld.Name(), sz)
}
if sizeAttr != sizeUnassigned {
t.TypeSize = sizeAttr
if t.TypeSize < sz {
t.TypeSize = sz
}
}
if hasSize {
t.TypeSize = sizeAttr
}
}
func (comp *compiler) genStructDesc(res *prog.StructDesc, n *ast.Struct, dir prog.Dir, varlen bool) {
@ -456,11 +459,12 @@ func (comp *compiler) typeAlign(t0 prog.Type) uint64 {
case *prog.ArrayType:
return comp.typeAlign(t.Type)
case *prog.StructType:
packed, _, alignAttr := comp.parseStructAttrs(comp.structNodes[t.StructDesc])
if alignAttr != 0 {
return alignAttr // overrided by user attribute
n := comp.structNodes[t.StructDesc]
attrs := comp.parseAttrs(structAttrs, n, n.Attrs)
if align := attrs[attrAlign]; align != 0 {
return align // overrided by user attribute
}
if packed {
if attrs[attrPacked] != 0 {
return 1
}
align := uint64(0)

View File

@ -189,7 +189,7 @@ type templ_struct0[A, B] {
len len[parent, int16]
typ const[A, int16]
data B
} [align_4]
} [align[4]]
type templ_struct1[C] {
f1 const[C, int8]

View File

@ -152,20 +152,12 @@ s3 {
f7 int32:33 ### bitfield of size 33 is too large for base type of size 32
f8 const[0, int32:C1] ### literal const bitfield sizes are not supported
f9 const[0] ### wrong number of arguments for type const, expect value, base type
} [packed, align_4]
s4 {
f1 int8
} [align_7] ### bad struct s4 alignment 7 (must be a sane power of 2)
} [packed, align[4]]
s5 {
f1 int8
} [varlen] ### unknown struct s5 attribute varlen
s6 {
f1 int8
} [align_foo] ### bad struct s6 alignment foo
s7 {
f1 ptr64[in, int32]
}
@ -298,7 +290,7 @@ type templ_struct0[A, B] {
len len[parent, int16]
typ const[A, int16]
data B
} [align_4]
} [align[4]]
type templ_struct1[STR] {
f string[STR, 40]

View File

@ -63,6 +63,7 @@ use_sr {
s3 s3
s4 s4
s6 s6
s8 s8
sr1 sr1
sr2 sr2
sr5 sr5
@ -116,6 +117,10 @@ s7 {
f2 u0
}
s8 {
f1 int8
} [align[7]] ### bad struct s8 alignment 7 (must be a sane power of 2)
u0 [
f len[f1, int32] ### len target f1 does not exist
]

View File

@ -82,7 +82,7 @@ cmsghdr {
cmsg_level flags[cmsg_levels, int32]
cmsg_type int32
data array[int8]
} [align_ptr]
} [align[PTR_SIZE]]
accept_filter {
af_name string[accept_filter_names, 16]

View File

@ -351,7 +351,7 @@ sctp_initmsg {
sctp_prim {
ssp_addr sockaddr_storage_sctp
ssp_assoc_id assoc_id
} [packed, align_4]
} [packed, align[4]]
sockaddr_sctp [
in sockaddr_in
@ -376,7 +376,7 @@ sctp_paddrparams {
spp_ipv6_flowlabel int32
spp_pathmaxrxt int16
spp_dscp int8
} [packed, align_4]
} [packed, align[4]]
sctp_spp_flags = SPP_HB_ENABLE, SPP_HB_DISABLE, SPP_HB_DEMAND, SPP_PMTUD_ENABLE, SPP_PMTUD_DISABLE, SPP_HB_TIME_IS_ZERO, SPP_IPV6_FLOWLABEL, SPP_DSCP
@ -440,7 +440,7 @@ sctp_paddrinfo {
spinfo_srtt int32
spinfo_rto int32
spinfo_mtu int32
} [packed, align_4]
} [packed, align[4]]
sctp_sack_info {
sack_assoc_id assoc_id
@ -494,7 +494,7 @@ sctp_paddrthlds {
spt_pathmaxrxt int16
spt_pathpfthld int16
spt_pathcpthld int16
} [packed, align_4]
} [packed, align[4]]
sctp_sndinfo {
snd_sid int16

View File

@ -72,7 +72,7 @@ cmsghdr_un_rights {
level const[SOL_SOCKET, int32]
type const[SCM_RIGHTS, int32]
fds array[fd]
} [align_ptr]
} [align[PTR_SIZE]]
cmsghdr_un_cred {
len len[parent, intptr]
@ -81,4 +81,4 @@ cmsghdr_un_cred {
pid pid
uid uid
gid gid
} [align_ptr]
} [align[PTR_SIZE]]

View File

@ -265,7 +265,7 @@ ipv4_option_ra {
ipv4_options {
options array[ipv4_option]
} [packed, align_4]
} [packed, align[4]]
ipv4_types = IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_IPV4, IPPROTO_TCP, IPPROTO_ST, IPPROTO_EGP, IPPROTO_PIGP, IPPROTO_RCCMON, IPPROTO_NVPII, IPPROTO_PUP, IPPROTO_ARGUS, IPPROTO_EMCON, IPPROTO_XNET, IPPROTO_CHAOS, IPPROTO_UDP, IPPROTO_MUX, IPPROTO_MEAS, IPPROTO_HMP, IPPROTO_PRM, IPPROTO_IDP, IPPROTO_TRUNK1, IPPROTO_TRUNK2, IPPROTO_LEAF1, IPPROTO_LEAF2, IPPROTO_RDP, IPPROTO_IRTP, IPPROTO_TP, IPPROTO_BLT, IPPROTO_NSP, IPPROTO_INP, IPPROTO_DCCP, IPPROTO_3PC, IPPROTO_IDPR, IPPROTO_XTP, IPPROTO_DDP, IPPROTO_CMTP, IPPROTO_TPXX, IPPROTO_IL, IPPROTO_SDRP, IPPROTO_IDRP, IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_MHRP, IPPROTO_BHA, IPPROTO_ESP, IPPROTO_AH, IPPROTO_INLSP, IPPROTO_SWIPE, IPPROTO_NHRP, IPPROTO_MOBILE, IPPROTO_TLSP, IPPROTO_SKIP, IPPROTO_AHIP, IPPROTO_CFTP, IPPROTO_HELLO, IPPROTO_SATEXPAK, IPPROTO_KRYPTOLAN, IPPROTO_RVD, IPPROTO_IPPC, IPPROTO_ADFS, IPPROTO_SATMON, IPPROTO_VISA, IPPROTO_IPCV, IPPROTO_CPNX, IPPROTO_CPHB, IPPROTO_WSN, IPPROTO_PVP, IPPROTO_BRSATMON, IPPROTO_ND, IPPROTO_WBMON, IPPROTO_WBEXPAK, IPPROTO_EON, IPPROTO_VMTP, IPPROTO_SVMTP, IPPROTO_VINES, IPPROTO_TTP, IPPROTO_IGP, IPPROTO_DGP, IPPROTO_TCF, IPPROTO_IGRP, IPPROTO_OSPFIGP, IPPROTO_SRPC, IPPROTO_LARP, IPPROTO_MTP, IPPROTO_AX25, IPPROTO_IPEIP, IPPROTO_MICP, IPPROTO_SCCSP, IPPROTO_ETHERIP, IPPROTO_ENCAP, IPPROTO_APES, IPPROTO_GMTP, IPPROTO_IPCOMP, IPPROTO_IPCOMP, IPPROTO_MH, IPPROTO_UDPLITE, IPPROTO_HIP, IPPROTO_SHIM6, IPPROTO_PIM, IPPROTO_CARP, IPPROTO_PGM, IPPROTO_MPLS, IPPROTO_PFSYNC
@ -564,7 +564,7 @@ ipv6_hopots_ext_header {
length bytesize8[options, int8]
pad array[const[0, int8], 6]
options array[ipv6_tlv_option]
} [packed, align_8]
} [packed, align[8]]
ipv6_routing_types = IPV6_RTHDR_LOOSE, IPV6_RTHDR_STRICT, IPV6_RTHDR_TYPE_0
@ -575,7 +575,7 @@ ipv6_rt_hdr {
segments_left int8
reserved const[0, int32]
data array[ipv6_addr]
} [packed, align_8]
} [packed, align[8]]
ipv6_fragment_ext_header {
next_header flags[ipv6_types, int8]
@ -585,14 +585,14 @@ ipv6_fragment_ext_header {
reserved2 const[0, int8:2]
fragment_off_lo int8:5
identification int32[100:104]
} [packed, align_8]
} [packed, align[8]]
ipv6_dstopts_ext_header {
next_header flags[ipv6_types, int8]
length bytesize8[options, int8]
pad array[const[0, int8], 6]
options array[ipv6_tlv_option]
} [packed, align_8]
} [packed, align[8]]
ipv6_tlv_option [
generic ipv6_tlv_generic
@ -938,7 +938,7 @@ tcp_fastopen_option {
tcp_options {
options array[tcp_option]
} [packed, align_4]
} [packed, align[4]]
tcp_flags = 0, TH_FIN, TH_SYN, TH_RST, TH_PUSH, TH_ACK, TH_URG, TH_ECE, TH_CWR

View File

@ -41,7 +41,7 @@ fidl_vector {
type fidl_aligned[T] {
var T
} [align_8]
} [align[8]]
type parallel_array[A, B] {
a array[A]

View File

@ -466,7 +466,7 @@ bpf_prog_info {
jited_line_info_rec_size int32
nr_prog_tags int32
prog_tags ptr64[in, int64]
} [align_8]
} [align[8]]
bpf_get_map_info_arg {
prog fd_bpf_map
@ -482,7 +482,7 @@ bpf_map_info {
max_entries int32
map_flags int32
name array[int8, BPF_OBJ_NAME_LEN]
} [align_8]
} [align[8]]
bpf_get_btf_info_arg {
btf fd_btf
@ -494,7 +494,7 @@ bpf_btf_info {
btf ptr64[out, array[int8]]
btf_size bytesize[btf, int32]
id bpf_btf_id[opt]
} [align_8]
} [align[8]]
bpf_prog_query {
target_fd fd_cgroup
@ -503,12 +503,12 @@ bpf_prog_query {
attach_flags int32
prog_ids ptr64[out, array[int32]]
prog_cnt len[prog_ids, int32]
} [align_8]
} [align[8]]
bpf_raw_tracepoint {
name ptr64[in, string]
prog_fd fd_bpf_prog
} [align_8]
} [align[8]]
bpf_btf_load {
btf ptr64[in, bpf_btf_program]
@ -516,7 +516,7 @@ bpf_btf_load {
btf_size bytesize[btf, int32]
btf_log_size bytesize[btf_log_buf, int32]
btf_log_level bool32
} [align_8]
} [align[8]]
bpf_btf_program {
header btf_header
@ -533,7 +533,7 @@ btf_header {
str_off bytesize[types, int32]
str_len bytesize[bpf_btf_program:strings, int32]
types array[btf_type]
} [align_4]
} [align[4]]
btf_type [
int btf_type_int

View File

@ -130,7 +130,7 @@ binder_objects {
obj0 binder_object
obj1 binder_object
obj2 binder_object
} [packed, align_8]
} [packed, align[8]]
binder_offsets {
off0 offsetof[binder_transaction_data:buffer:obj0, int64]

View File

@ -263,7 +263,7 @@ sockaddr_ib {
# TODO: not completely clear what's in ib_addr.data.
ib_addr {
data array[int8, 16]
} [align_8]
} [align[8]]
rdma_port_space = RDMA_PS_IPOIB, RDMA_PS_IB, RDMA_PS_TCP, RDMA_PS_UDP
ib_event_type = IB_EVENT_CQ_ERR, IB_EVENT_QP_FATAL, IB_EVENT_QP_REQ_ERR, IB_EVENT_QP_ACCESS_ERR, IB_EVENT_COMM_EST, IB_EVENT_SQ_DRAINED, IB_EVENT_PATH_MIG, IB_EVENT_PATH_MIG_ERR, IB_EVENT_DEVICE_FATAL, IB_EVENT_PORT_ACTIVE, IB_EVENT_PORT_ERR, IB_EVENT_LID_CHANGE, IB_EVENT_PKEY_CHANGE, IB_EVENT_SM_CHANGE, IB_EVENT_SRQ_ERR, IB_EVENT_SRQ_LIMIT_REACHED, IB_EVENT_QP_LAST_WQE_REACHED, IB_EVENT_CLIENT_REREGISTER, IB_EVENT_GID_CHANGE, IB_EVENT_WQ_FATAL

View File

@ -197,7 +197,7 @@ fuse_dirent {
namelen len[name, int32]
type int32
name stringnoz
} [align_8]
} [align[8]]
fuse_direntplus {
entry fuse_entry_out

View File

@ -101,7 +101,7 @@ type xt_entry_match[NAME, REV] {
type xt_entry_match_t[NAME, DATA, REV] {
header xt_entry_match[NAME, REV]
data DATA
} [align_ptr]
} [align[PTR_SIZE]]
xt_unspec_matches [
cgroup0 xt_entry_match_t["cgroup", xt_cgroup_info_v0, 0]
@ -318,13 +318,13 @@ xt_conntrack_mtinfo1 {
common xt_conntrack_mtinfo_common
state_mask flags[xt_conntrack_state8, int8]
status_mask flags[xt_conntrack_status8, int8]
} [align_4]
} [align[4]]
xt_conntrack_mtinfo2 {
common xt_conntrack_mtinfo_common
state_mask flags[xt_conntrack_state, int16]
status_mask flags[xt_conntrack_status, int16]
} [align_4]
} [align[4]]
xt_conntrack_mtinfo3 {
common xt_conntrack_mtinfo_common
@ -334,7 +334,7 @@ xt_conntrack_mtinfo3 {
origdst_port_high sock_port
replsrc_port_high sock_port
repldst_port_high sock_port
} [align_4]
} [align[4]]
xt_conntrack_flags = XT_CONNTRACK_STATE, XT_CONNTRACK_PROTO, XT_CONNTRACK_ORIGSRC, XT_CONNTRACK_ORIGDST, XT_CONNTRACK_REPLSRC, XT_CONNTRACK_REPLDST, XT_CONNTRACK_STATUS, XT_CONNTRACK_EXPIRES, XT_CONNTRACK_ORIGSRC_PORT, XT_CONNTRACK_ORIGDST_PORT, XT_CONNTRACK_REPLSRC_PORT, XT_CONNTRACK_REPLDST_PORT, XT_CONNTRACK_DIRECTION, XT_CONNTRACK_STATE_ALIAS
xt_conntrack_state8 = XT_CONNTRACK_STATE_INVALID, XT_CONNTRACK_STATE_SNAT, XT_CONNTRACK_STATE_DNAT

View File

@ -32,12 +32,12 @@ define ARPT_FILTER_VALID_HOOKS (1 << NF_ARP_IN) | (1 << NF_ARP_OUT) | (1 << NF_A
arpt_replace_entries {
entries array[arpt_entry, 3]
underflow arpt_entry_underflow
} [packed, align_ptr]
} [packed, align[PTR_SIZE]]
arpt_entry {
matches arpt_entry_matches
target arpt_targets
} [packed, align_ptr]
} [packed, align[PTR_SIZE]]
arpt_entry_matches {
arp arpt_arp_or_uncond
@ -46,12 +46,12 @@ arpt_entry_matches {
comefrom const[0, int32]
counters xt_counters
# Note: matches should go here, but they seem to be unused in arp tables.
} [align_ptr]
} [align[PTR_SIZE]]
arpt_entry_underflow {
matches arpt_entry_underflow_matches
target xt_target_t["", const[NF_ACCEPT_VERDICT, int32], 0]
} [align_ptr]
} [align[PTR_SIZE]]
arpt_entry_underflow_matches {
arp arpt_arp_uncond

View File

@ -139,7 +139,7 @@ type ebt_entry_match[NAME] {
name string[NAME, EBT_EXTENSION_MAXNAMELEN]
revision const[0, int8]
match_size bytesize[ebt_entry_match_t:data, int32]
} [align_ptr]
} [align[PTR_SIZE]]
type ebt_entry_match_t[NAME, DATA] {
header ebt_entry_match[NAME]
@ -148,7 +148,7 @@ type ebt_entry_match_t[NAME, DATA] {
type xt_padded[TYPE] {
data TYPE
} [align_ptr]
} [align[PTR_SIZE]]
ebt_matches [
m802_3 ebt_entry_match_t["802_3", ebt_802_3_info]

View File

@ -49,7 +49,7 @@ type ipt_replace_t[NAME, NENTRIES, NHOOKS, HOOKS, MATCHES, TARGETS, H0, H1, H2,
type ipt_replace_entries[NENTRIES, MATCHES, TARGETS] {
entries array[ipt_entry[MATCHES, TARGETS], NENTRIES]
underflow ipt_entry_underflow
} [packed, align_ptr]
} [packed, align[PTR_SIZE]]
type ipt_hook const[0, int32]
type ipt_unused const[-1, int32]
@ -57,7 +57,7 @@ type ipt_unused const[-1, int32]
type ipt_entry[MATCHES, TARGETS] {
matches ipt_entry_matches[MATCHES]
target TARGETS
} [packed, align_ptr]
} [packed, align[PTR_SIZE]]
type ipt_entry_matches[MATCHES] {
ip ipt_ip_or_uncond
@ -67,12 +67,12 @@ type ipt_entry_matches[MATCHES] {
comefrom const[0, int32]
counters xt_counters
matches array[MATCHES, 0:2]
} [align_ptr]
} [align[PTR_SIZE]]
ipt_entry_underflow {
matches ipt_entry_underflow_matches
target xt_target_t["", const[NF_ACCEPT_VERDICT, int32], 0]
} [align_ptr]
} [align[PTR_SIZE]]
ipt_entry_underflow_matches {
ip ipt_ip_uncond

View File

@ -52,12 +52,12 @@ type ip6t_replace_t[NAME, NENTRIES, NHOOKS, HOOKS, MATCHES, TARGETS, H0, H1, H2,
type ip6t_replace_entries[NENTRIES, MATCHES, TARGETS] {
entries array[ip6t_entry[MATCHES, TARGETS], NENTRIES]
underflow ip6t_entry_underflow
} [packed, align_ptr]
} [packed, align[PTR_SIZE]]
type ip6t_entry[MATCHES, TARGETS] {
matches ip6t_entry_matches[MATCHES]
target TARGETS
} [packed, align_ptr]
} [packed, align[PTR_SIZE]]
type ip6t_entry_matches[MATCHES] {
ipv6 ip6t_ip6_or_uncond
@ -67,12 +67,12 @@ type ip6t_entry_matches[MATCHES] {
comefrom const[0, int32]
counters xt_counters
matches array[MATCHES, 0:2]
} [align_ptr]
} [align[PTR_SIZE]]
ip6t_entry_underflow {
matches ip6t_entry_underflow_matches
target xt_target_t["", const[NF_ACCEPT_VERDICT, int32], 0]
} [align_ptr]
} [align[PTR_SIZE]]
ip6t_entry_underflow_matches {
ipv6 ip6t_ip6_uncond

View File

@ -35,7 +35,7 @@ type xt_target_t[NAME, DATA, REV] {
name string[NAME, XT_EXTENSION_MAXNAMELEN]
revision const[REV, int8]
data DATA
} [align_ptr]
} [align[PTR_SIZE]]
xt_unspec_targets [
STANDARD xt_target_t["", flags[nf_verdicts, int32], 0]

View File

@ -181,11 +181,11 @@ cmsghdr {
cmsg_level flags[cmsg_levels, int32]
cmsg_type int32
data array[int8]
} [align_ptr]
} [align[PTR_SIZE]]
type cmsghdr_t[SOL, TYP, DATA] {
unaligned cmsghdr_unaligned[SOL, TYP, DATA]
} [align_ptr]
} [align[PTR_SIZE]]
type cmsghdr_unaligned[SOL, TYP, DATA] {
cmsg_len len[parent, intptr]

View File

@ -79,21 +79,21 @@ cmsghdr_alg_iv {
type const[ALG_SET_IV, int32]
ivlen len[iv, int32]
iv array[int8]
} [align_ptr]
} [align[PTR_SIZE]]
cmsghdr_alg_op {
len len[parent, intptr]
level const[SOL_ALG, int32]
type const[ALG_SET_OP, int32]
op flags[alg_op_op, int32]
} [align_ptr]
} [align[PTR_SIZE]]
cmsghdr_alg_assoc {
len len[parent, intptr]
level const[SOL_ALG, int32]
type const[ALG_SET_AEAD_ASSOCLEN, int32]
assoc int32
} [align_ptr]
} [align[PTR_SIZE]]
af_alg_type = CRYPTO_ALG_TYPE_MASK, CRYPTO_ALG_TYPE_CIPHER, CRYPTO_ALG_TYPE_COMPRESS, CRYPTO_ALG_TYPE_AEAD, CRYPTO_ALG_TYPE_SKCIPHER, CRYPTO_ALG_TYPE_HASH, CRYPTO_ALG_TYPE_SHASH, CRYPTO_ALG_TYPE_AHASH, CRYPTO_ALG_TYPE_RNG, CRYPTO_ALG_TYPE_AKCIPHER, CRYPTO_ALG_TYPE_PCOMPRESS, CRYPTO_ALG_LARVAL, CRYPTO_ALG_DEAD, CRYPTO_ALG_DYING, CRYPTO_ALG_ASYNC, CRYPTO_ALG_NEED_FALLBACK, CRYPTO_ALG_TESTED, CRYPTO_ALG_INSTANCE, CRYPTO_ALG_KERN_DRIVER_ONLY, CRYPTO_ALG_INTERNAL

View File

@ -74,7 +74,7 @@ can_j1939_pgn {
pgn_pf flags[can_j1939_pgn_pf, int8]
pgn_flags flags[can_j1939_pgn_flags, int8]
pgn_unused const[0, int8]
} [align_4]
} [align[4]]
can_j1939_pgn_ps = 0, 1, 2
can_j1939_pgn_pf = 0, 1, 0xf0, 0xff

View File

@ -21,7 +21,7 @@ sockaddr_in {
sockaddr_storage_in {
addr sockaddr_in
} [size[SOCKADDR_STORAGE_SIZE], align_ptr]
} [size[SOCKADDR_STORAGE_SIZE], align[PTR_SIZE]]
socket$inet(domain const[AF_INET], type flags[socket_type], proto int32) sock_in
accept$inet(fd sock_in, peer ptr[out, sockaddr_in, opt], peerlen ptr[inout, len[peer, int32]]) sock_in

View File

@ -23,7 +23,7 @@ sockaddr_in6 {
sockaddr_storage_in6 {
addr sockaddr_in6
} [size[SOCKADDR_STORAGE_SIZE], align_ptr]
} [size[SOCKADDR_STORAGE_SIZE], align[PTR_SIZE]]
socket$inet6(domain const[AF_INET6], type flags[socket_type], proto int32) sock_in6
accept$inet6(fd sock_in6, peer ptr[out, sockaddr_in6, opt], peerlen ptr[inout, len[peer, int32]]) sock_in6

View File

@ -45,28 +45,28 @@ cmsghdr_sctp_init {
level const[IPPROTO_SCTP, int32]
type const[SCTP_INIT, int32]
msg sctp_initmsg
} [align_ptr]
} [align[PTR_SIZE]]
cmsghdr_sctp_sndrcv {
len len[parent, intptr]
level const[IPPROTO_SCTP, int32]
type const[SCTP_SNDRCV, int32]
msg sctp_sndrcvinfo
} [align_ptr]
} [align[PTR_SIZE]]
cmsghdr_sctp_sndinfo {
len len[parent, intptr]
level const[IPPROTO_SCTP, int32]
type const[SCTP_SNDINFO, int32]
msg sctp_sndinfo
} [align_ptr]
} [align[PTR_SIZE]]
cmsghdr_sctp_prinfo {
len len[parent, intptr]
level const[IPPROTO_SCTP, int32]
type const[SCTP_PRINFO, int32]
msg sctp_prinfo
} [align_ptr]
} [align[PTR_SIZE]]
sctp_prinfo {
pr_policy flags[sctp_pr_policies, int16]
@ -78,7 +78,7 @@ cmsghdr_sctp_authinfo {
level const[IPPROTO_SCTP, int32]
type const[SCTP_AUTHINFO, int32]
msg sctp_authinfo
} [align_ptr]
} [align[PTR_SIZE]]
sctp_authinfo {
auth_keynumber int16
@ -89,14 +89,14 @@ cmsghdr_sctp_dstaddrv4 {
level const[IPPROTO_SCTP, int32]
type const[SCTP_DSTADDRV4, int32]
msg ipv4_addr
} [align_ptr]
} [align[PTR_SIZE]]
cmsghdr_sctp_dstaddrv6 {
len len[parent, intptr]
level const[IPPROTO_SCTP, int32]
type const[SCTP_DSTADDRV6, int32]
msg ipv6_addr
} [align_ptr]
} [align[PTR_SIZE]]
# Specific SCTP socket options
@ -360,7 +360,7 @@ sctp_initmsg {
sctp_prim {
ssp_assoc_id assoc_id
ssp_addr sockaddr_storage_sctp
} [packed, align_4]
} [packed, align[4]]
sockaddr_storage_sctp [
in sockaddr_storage_in
@ -381,7 +381,7 @@ sctp_paddrparams {
spp_flags flags[sctp_spp_flags, int32]
spp_ipv6_flowlabel int32
spp_dscp int8
} [packed, align_4]
} [packed, align[4]]
sctp_spp_flags = SPP_HB_ENABLE, SPP_HB_DISABLE, SPP_HB_DEMAND, SPP_HB_TIME_IS_ZERO, SPP_PMTUD_ENABLE, SPP_PMTUD_DISABLE, SPP_SACKDELAY_ENABLE, SPP_SACKDELAY_DISABLE
@ -459,7 +459,7 @@ sctp_paddrinfo {
spinfo_srtt int32
spinfo_rto int32
spinfo_mtu int32
} [packed, align_4]
} [packed, align[4]]
sctp_delayed_sack [
sack_info sctp_sack_info

View File

@ -68,7 +68,7 @@ sadb_sa {
sadb_sa_auth int8[SADB_AALG_NONE:SADB_AALG_MAX]
sadb_sa_encrypt int8[SADB_X_CALG_NONE:SADB_X_CALG_MAX]
sadb_sa_flags flags[sadb_sa_flags, int32]
} [packed, align_8]
} [packed, align[8]]
sadb_sa_flags = SADB_SAFLAGS_PFS, SADB_SAFLAGS_NOPMTUDISC, SADB_SAFLAGS_DECAP_DSCP, SADB_SAFLAGS_NOECN
@ -79,7 +79,7 @@ sadb_lifetime {
sadb_lifetime_bytes int64
sadb_lifetime_addtime int64
sadb_lifetime_usetime int64
} [packed, align_8]
} [packed, align[8]]
sadb_address {
sadb_len bytesize8[parent, int16]
@ -88,7 +88,7 @@ sadb_address {
sadb_address_prefixlen flags[xfrm_prefixlens, int8]
sadb_address_reserved const[0, int16]
addr sadb_address_addr
} [packed, align_8]
} [packed, align[8]]
sadb_address_addr [
in sockaddr_in
@ -101,7 +101,7 @@ sadb_key {
sadb_key_bits bitsize[key, int16]
sadb_key_reserved const[0, int16]
key array[int8]
} [packed, align_8]
} [packed, align[8]]
sadb_ident {
sadb_len bytesize8[parent, int16]
@ -109,7 +109,7 @@ sadb_ident {
sadb_ident_type int16
sadb_ident_reserved const[0, int16]
sadb_ident_id int64
} [packed, align_8]
} [packed, align[8]]
sadb_spirange {
sadb_len bytesize8[parent, int16]
@ -117,7 +117,7 @@ sadb_spirange {
sadb_spirange_min xfrm_spi
sadb_spirange_max xfrm_spi
sadb_spirange_reserved const[0, int32]
} [packed, align_8]
} [packed, align[8]]
sadb_x_policy {
sadb_len bytesize8[parent, int16]
@ -128,7 +128,7 @@ sadb_x_policy {
sadb_x_policy_id xfrm_policy_index
sadb_x_policy_priority int32
policy sadb_x_ipsecrequest
} [packed, align_8]
} [packed, align[8]]
sadb_x_ipsecrequest {
sadb_x_ipsecrequest_len bytesize8[parent, int16]
@ -140,7 +140,7 @@ sadb_x_ipsecrequest {
sadb_x_ipsecrequest_reserved2 const[0, int32]
saddr sadb_filter_addr
daddr sadb_filter_addr
} [packed, align_8]
} [packed, align[8]]
sadb_x_sa2 {
sadb_len bytesize8[parent, int16]
@ -150,21 +150,21 @@ sadb_x_sa2 {
sadb_x_sa2_reserved2 const[0, int16]
sadb_x_sa2_sequence netlink_seq
sadb_x_sa2_reqid xfrm_req_id
} [packed, align_8]
} [packed, align[8]]
sadb_x_nat_t_type {
sadb_len bytesize8[parent, int16]
sadb_exttype const[SADB_X_EXT_NAT_T_TYPE, int16]
sadb_x_nat_t_type_type int8
sadb_x_nat_t_type_reserved array[const[0, int8], 3]
} [packed, align_8]
} [packed, align[8]]
sadb_x_nat_t_port {
sadb_len bytesize8[parent, int16]
sadb_exttype flags[sadb_nat_port_type, int16]
sadb_x_nat_t_port_port sock_port
sadb_x_nat_t_port_reserved const[0, int16]
} [packed, align_8]
} [packed, align[8]]
sadb_x_sec_ctx {
sadb_len bytesize8[parent, int16]
@ -173,7 +173,7 @@ sadb_x_sec_ctx {
sadb_x_ctx_doi int8
sadb_x_ctx_len bytesize[ctx, int16]
ctx array[int8]
} [packed, align_8]
} [packed, align[8]]
sadb_x_kmaddress {
sadb_len bytesize8[parent, int16]
@ -181,7 +181,7 @@ sadb_x_kmaddress {
sadb_x_kmaddress_reserved const[0, int32]
src sadb_address_addr
dst sadb_address_addr
} [packed, align_8]
} [packed, align[8]]
sadb_x_filter {
sadb_len bytesize8[parent, int16]
@ -191,7 +191,7 @@ sadb_x_filter {
sadb_x_filter_family flags[socket_domain, int16]
sadb_x_filter_splen flags[sadb_filter_addr_len, int8]
sadb_x_filter_dplen flags[sadb_filter_addr_len, int8]
} [packed, align_8]
} [packed, align[8]]
sadb_filter_addr [
in ipv4_addr

View File

@ -87,7 +87,7 @@ type netlink_msg_t[TYPE, PAYLOAD, ATTRS] {
pid netlink_port_id
payload PAYLOAD
attrs array[ATTRS]
} [packed, align_4]
} [packed, align[4]]
type netlink_msg[TYPE, PAYLOAD, ATTRS] netlink_msg_t[const[TYPE, int16], PAYLOAD, ATTRS]
@ -96,7 +96,7 @@ type nlattr_t[TYPE, PAYLOAD] {
nla_type TYPE
payload PAYLOAD
size void
} [packed, align_4]
} [packed, align[4]]
type nlattr_tt[TYPE, NETORDER, NESTED, PAYLOAD] {
nla_len offsetof[size, int16]
@ -105,7 +105,7 @@ type nlattr_tt[TYPE, NETORDER, NESTED, PAYLOAD] {
NLA_F_NESTED const[NESTED, int16:1]
payload PAYLOAD
size void
} [packed, align_4]
} [packed, align[4]]
type nlattr[TYPE, PAYLOAD] nlattr_t[const[TYPE, int16], PAYLOAD]
# nlattr with NLA_F_NESTED set.

View File

@ -21,10 +21,10 @@ genlmsghdr {
cmd int8[0:32]
version const[0, int8]
reserved const[0, int16]
} [align_4]
} [align[4]]
type genlmsghdr_t[CMD] {
cmd const[CMD, int8]
version const[0, int8]
reserved const[0, int16]
} [align_4]
} [align[4]]

View File

@ -21,13 +21,13 @@ devlink_devname {
devlink_nl_policy_nsim {
DEVLINK_ATTR_BUS_NAME nlattr[DEVLINK_ATTR_BUS_NAME, string["netdevsim"]]
DEVLINK_ATTR_DEV_NAME nlattr[DEVLINK_ATTR_DEV_NAME, devlink_devname]
} [packed, align_4]
} [packed, align[4]]
devlink_nl_policy_pci {
DEVLINK_ATTR_BUS_NAME nlattr[DEVLINK_ATTR_BUS_NAME, string["pci"]]
# 0000:00:10.0 is a fixed pci address what is moved from initial network namespace by initialize_devlink()
DEVLINK_ATTR_DEV_NAME nlattr[DEVLINK_ATTR_DEV_NAME, string["0000:00:10.0"]]
} [packed, align_4]
} [packed, align[4]]
devlink_handle [
nsim devlink_nl_policy_nsim
@ -38,7 +38,7 @@ devlink_port_handle {
port_handle devlink_handle
# 0:3 is in sync with number of ports created by netdevsim_add()
DEVLINK_ATTR_PORT_INDEX nlattr[DEVLINK_ATTR_PORT_INDEX, int32[0:3]]
} [packed, align_4]
} [packed, align[4]]
type msghdr_nl_devlink[CMD] msghdr_netlink[netlink_msg_t[genl_devlink_family_id, genlmsghdr_t[CMD], devlink_handle]]
sendmsg$DEVLINK_CMD_GET(fd sock_nl_generic, msg ptr[in, msghdr_nl_devlink[DEVLINK_CMD_GET]], f flags[send_flags])
@ -55,14 +55,14 @@ devlink_nl_policy_reload [
devlink_reload {
handle devlink_handle
arg devlink_nl_policy_reload
} [packed, align_4]
} [packed, align[4]]
type msghdr_nl_devlink_port_get msghdr_netlink[netlink_msg_t[genl_devlink_family_id, genlmsghdr_t[DEVLINK_CMD_PORT_GET], devlink_port_get]]
sendmsg$DEVLINK_CMD_PORT_GET(fd sock_nl_generic, msg ptr[in, msghdr_nl_devlink_port_get], f flags[send_flags])
devlink_port_get {
port_handle devlink_port_handle
} [packed, align_4]
} [packed, align[4]]
type msghdr_nl_devlink_port_set msghdr_netlink[netlink_msg_t[genl_devlink_family_id, genlmsghdr_t[DEVLINK_CMD_PORT_SET], devlink_port_set]]
sendmsg$DEVLINK_CMD_PORT_SET(fd sock_nl_generic, msg ptr[in, msghdr_nl_devlink_port_set], f flags[send_flags])
@ -70,4 +70,4 @@ sendmsg$DEVLINK_CMD_PORT_SET(fd sock_nl_generic, msg ptr[in, msghdr_nl_devlink_p
devlink_port_set {
port_handle devlink_port_handle
DEVLINK_ATTR_PORT_TYPE nlattr[DEVLINK_ATTR_PORT_TYPE, int16[DEVLINK_PORT_TYPE_NOTSET:DEVLINK_PORT_TYPE_IB]]
} [packed, align_4]
} [packed, align[4]]

View File

@ -24,23 +24,23 @@ sendmsg$TEAM_CMD_PORT_LIST_GET(fd sock_nl_generic, msg ptr[in, msghdr_nl_team[TE
team_nl_policy {
TEAM_ATTR_TEAM_IFINDEX nlattr[TEAM_ATTR_TEAM_IFINDEX, ifindex_team]
TEAM_ATTR_LIST_OPTION nlnest[TEAM_ATTR_LIST_OPTION, array[nlattr[TEAM_ATTR_ITEM_OPTION, team_attr_option]]]
} [packed, align_4]
} [packed, align[4]]
type team_nl_option_policy[NAME, TYPE, DATA] {
TEAM_ATTR_OPTION_NAME nlattr[TEAM_ATTR_OPTION_NAME, string[NAME, TEAM_STRING_MAX_LEN]]
TEAM_ATTR_OPTION_TYPE nlattr[TEAM_ATTR_OPTION_TYPE, const[TYPE, int8]]
TEAM_ATTR_OPTION_DATA nlattr[TEAM_ATTR_OPTION_DATA, DATA]
} [packed, align_4]
} [packed, align[4]]
type team_nl_option_policy_per_port[NAME, TYPE, DATA] {
opt team_nl_option_policy[NAME, TYPE, DATA]
TEAM_ATTR_OPTION_PORT_IFINDEX nlattr[TEAM_ATTR_OPTION_PORT_IFINDEX, ifindex]
} [packed, align_4]
} [packed, align[4]]
type team_nl_option_policy_array[NAME, TYPE, DATA, SIZE] {
opt team_nl_option_policy[NAME, TYPE, DATA]
TEAM_ATTR_OPTION_ARRAY_INDEX nlattr[TEAM_ATTR_OPTION_ARRAY_INDEX, int32[0:SIZE]]
} [packed, align_4]
} [packed, align[4]]
team_attr_option [
name team_nl_option_policy["mode", NLA_STRING, string[team_attr_option_mode]]

View File

@ -26,7 +26,7 @@ netlink_msg_netfilter {
hdr nfgenmsg
# No body. Generic attribute can represent a random body.
attrs array[nl_generic_attr]
} [align_4]
} [align[4]]
type netlink_msg_netfilter_t[SUBSYS, CMD, POLICY] netlink_msg_netfilter_tt[SUBSYS, CMD, array[POLICY]]
@ -39,14 +39,14 @@ type netlink_msg_netfilter_tt[SUBSYS, CMD, POLICY] {
pid const[0, int32]
hdr nfgenmsg
attrs POLICY
} [align_4]
} [align[4]]
nfgenmsg {
nfgen_family flags[nfproto, int8]
version const[NFNETLINK_V0, int8]
# res_id seems to mean things like cpu/queue/group number, so prefer small values.
res_id int16be[0:10]
} [align_4]
} [align[4]]
nfnl_subsys = NFNL_SUBSYS_CTNETLINK, NFNL_SUBSYS_CTNETLINK_EXP, NFNL_SUBSYS_QUEUE, NFNL_SUBSYS_ULOG, NFNL_SUBSYS_OSF, NFNL_SUBSYS_IPSET, NFNL_SUBSYS_ACCT, NFNL_SUBSYS_CTNETLINK_TIMEOUT, NFNL_SUBSYS_CTHELPER, NFNL_SUBSYS_NFTABLES, NFNL_SUBSYS_NFT_COMPAT
nfproto = NFPROTO_UNSPEC, NFPROTO_INET, NFPROTO_IPV4, NFPROTO_ARP, NFPROTO_NETDEV, NFPROTO_BRIDGE, NFPROTO_IPV6, NFPROTO_DECNET

View File

@ -43,13 +43,13 @@ type nft_nlmsghdr[CMD] {
nlmsg_seq const[0, int32]
nlmsg_pid const[0, int32]
hdr nfgenmsg_nft
} [align_4]
} [align[4]]
nfgenmsg_nft {
nfgen_family const[0, int8]
version const[NFNETLINK_V0, int8]
res_id const[NFNL_SUBSYS_NFTABLES, int16be]
} [align_4]
} [align[4]]
nft_batch_message [
NFT_MSG_NEWTABLE netlink_msg_netfilter_t[NFNL_SUBSYS_NFTABLES, NFT_MSG_NEWTABLE, nft_table_policy]

View File

@ -939,7 +939,7 @@ type tcf_action_policy[NAME, VALUES] {
TCA_ACT_KIND nlattr[TCA_ACT_KIND, string[NAME]]
TCA_ACT_OPTIONS nlnest[TCA_ACT_OPTIONS, array[VALUES]]
TCA_ACT_COOKIE nlattr[TCA_ACT_COOKIE, array[int8]]
} [packed, align_4]
} [packed, align[4]]
act_bpf_policy [
TCA_ACT_BPF_PARMS nlattr[TCA_ACT_BPF_PARMS, tc_act_bpf]
@ -1165,7 +1165,7 @@ m_pedit_sel {
keys array[tc_pedit_key, 128]
keys_ex array[m_pedit_key_ex, 128]
extended bool8
} [packed, align_4]
} [packed, align[4]]
tc_pedit_sel {
tc_gen tc_gen
@ -1265,12 +1265,12 @@ type tcf_ematch_hdr[KIND] {
kind const[KIND, int16]
flags int16
pad const[0, int16]
} [align_4]
} [align[4]]
type tcf_ematch_hdr_t[KIND, PAYLOAD] {
header tcf_ematch_hdr[KIND]
payload PAYLOAD
} [align_4]
} [align[4]]
tcf_em_cmp {
val int32
@ -1287,7 +1287,7 @@ tcf_em_nbyte {
len bytesize[payload, int16:12]
layer flags[tcf_layers, int8:4]
payload array[int8, 0:10]
} [align_4]
} [align[4]]
tc_u32_key {
mask int32be

View File

@ -50,7 +50,7 @@ type cmsghdr_rds_t[TYPE, DATA] {
cmsg_level const[SOL_RDS, int32]
cmsg_type const[TYPE, int32]
data DATA
} [align_ptr]
} [align[PTR_SIZE]]
rds_rdma_args {
cookie rds_rdma_cookie_t
@ -105,7 +105,7 @@ rds_rdma_cookie_t {
# This should be a resource, but it's unclear how to obtain it.
key int32
off int32
} [align_8]
} [align[8]]
rds_transport = RDS_TRANS_IB, RDS_TRANS_IWARP, RDS_TRANS_TCP, RDS_TRANS_NONE
rds_rdma_flags = RDS_RDMA_READWRITE, RDS_RDMA_FENCE, RDS_RDMA_INVALIDATE, RDS_RDMA_USE_ONCE, RDS_RDMA_DONTWAIT, RDS_RDMA_NOTIFY_ME, RDS_RDMA_SILENT

View File

@ -49,7 +49,7 @@ type tipc_tlv_desc[TYP, DATA] {
tlv_len bytesize[parent, int16be]
tlv_type const[TYP, int16be]
data DATA
} [align_4]
} [align[4]]
tipc_link_config {
value int32be

View File

@ -81,7 +81,7 @@ vmaddr_cid [
vmaddr_cid64 {
cid vmaddr_cid
pad const[0, int32]
} [align_8]
} [align[8]]
vhost_memory {
nregions len[regions, int32]

View File

@ -60,15 +60,15 @@ resource fd_dir[fd]: AT_FDCWD
# E.g. pid/uid stored as intptr/int64.
type alignptr[T] {
v T
} [align_ptr]
} [align[PTR_SIZE]]
type align32[T] {
v T
} [align_4]
} [align[4]]
type align64[T] {
v T
} [align_8]
} [align[8]]
type signalno int32[0:65]
type signalnoptr intptr[0:65]
@ -446,7 +446,7 @@ rseq {
cpu_id const[0, int32]
rseq_cs ptr64[in, rseq_cs, opt]
flags flags[rseq_cs_flags, int32]
} [align_32]
} [align[32]]
rseq_cs {
version const[0, int32]
@ -454,7 +454,7 @@ rseq_cs {
start_ip int64
post_commit_offset int64
abort_ip int64
} [align_32]
} [align[32]]
rseq_cs_flags = RSEQ_CS_FLAG_NO_RESTART_ON_PREEMPT, RSEQ_CS_FLAG_NO_RESTART_ON_SIGNAL, RSEQ_CS_FLAG_NO_RESTART_ON_MIGRATE

View File

@ -410,7 +410,7 @@ ipv4_option_ra {
ipv4_options {
options array[ipv4_option]
} [packed, align_4]
} [packed, align[4]]
ipv4_types = IPPROTO_IP, IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_IPIP, IPPROTO_TCP, IPPROTO_EGP, IPPROTO_PUP, IPPROTO_UDP, IPPROTO_IDP, IPPROTO_TP, IPPROTO_DCCP, IPPROTO_IPV6, IPPROTO_RSVP, IPPROTO_GRE, IPPROTO_ESP, IPPROTO_AH, IPPROTO_MTP, IPPROTO_BEETPH, IPPROTO_ENCAP, IPPROTO_PIM, IPPROTO_COMP, IPPROTO_SCTP, IPPROTO_UDPLITE, IPPROTO_MPLS, IPPROTO_RAW, IPPROTO_L2TP
@ -467,14 +467,14 @@ ipv6_types = IPPROTO_IP, IPPROTO_ICMP, IPPROTO_IGMP, IPPROTO_IPIP, IPPROTO_TCP,
ipv6_addr_empty {
a0 array[const[0x0, int8], 16]
} [packed, align_4]
} [packed, align[4]]
type ipv6_addr_t[LAST] {
a0 const[0xfe, int8]
a1 const[0x80, int8]
a2 array[const[0x0, int8], 13]
a3 LAST
} [packed, align_4]
} [packed, align[4]]
ipv6_addr_initdev {
a0 const[0xfe, int8]
@ -482,39 +482,39 @@ ipv6_addr_initdev {
a2 array[const[0x0, int8], 12]
a3 int8[0:1]
a4 proc[1, 1, int8]
} [packed, align_4]
} [packed, align[4]]
ipv6_addr_loopback {
a0 const[0, int64be]
a1 const[1, int64be]
} [packed, align_4]
} [packed, align[4]]
ipv6_addr_ipv4 {
a0 array[const[0x0, int8], 10]
a1 array[const[0xff, int8], 2]
a3 ipv4_addr
} [packed, align_4]
} [packed, align[4]]
ipv6_addr_multicast1 {
a0 const[0xff, int8]
a1 const[0x1, int8]
a2 array[const[0x0, int8], 13]
a3 const[0x1, int8]
} [packed, align_4]
} [packed, align[4]]
ipv6_addr_multicast2 {
a0 const[0xff, int8]
a1 const[0x2, int8]
a2 array[const[0x0, int8], 13]
a3 const[0x1, int8]
} [packed, align_4]
} [packed, align[4]]
type ipv6_addr_private[BYTE2] {
a0 const[0xfc, int8]
a1 const[BYTE2, int8]
a2 array[const[0x0, int8], 13]
a3 int8[0:1]
} [packed, align_4]
} [packed, align[4]]
ipv6_addr_random = `20010000000000000000000000000000`, `20010000000000000000000000000001`, `20010000000000000000000000000002`
@ -563,7 +563,7 @@ ipv6_hopots_ext_header {
length bytesize8[options, int8]
pad array[const[0, int8], 6]
options array[ipv6_tlv_option]
} [packed, align_8]
} [packed, align[8]]
ipv6_routing_types = IPV6_SRCRT_STRICT, IPV6_SRCRT_TYPE_0, IPV6_SRCRT_TYPE_2
@ -574,7 +574,7 @@ ipv6_rt_hdr {
segments_left int8
reserved const[0, int32]
data array[ipv6_addr]
} [packed, align_8]
} [packed, align[8]]
ipv6_sr_hdr {
nexthdr flags[ipv6_types, int8]
@ -591,7 +591,7 @@ ipv6_sr_hdr {
# we won't be able to calculate segments_left because it will need to
# refer to a field of a subobject. What may help is allowing specifying
# subfields as len/bytesize targets, e.g. "len[payload.segments]", or "bytesize[parent_struct.foo]".
} [packed, align_8]
} [packed, align[8]]
ipv6_sr_flags = SR6_FLAG1_PROTECTED, SR6_FLAG1_OAM, SR6_FLAG1_ALERT, SR6_FLAG1_HMAC
@ -603,14 +603,14 @@ ipv6_fragment_ext_header {
reserved2 const[0, int8:2]
fragment_off_lo int8:5
identification int32[100:104]
} [packed, align_8]
} [packed, align[8]]
ipv6_dstopts_ext_header {
next_header flags[ipv6_types, int8]
length bytesize8[options, int8]
pad array[const[0, int8], 6]
options array[ipv6_tlv_option]
} [packed, align_8]
} [packed, align[8]]
ipv6_tlv_option [
generic ipv6_tlv_generic
@ -821,7 +821,7 @@ tcp_exp_smc_option {
tcp_options {
options array[tcp_option]
} [packed, align_4]
} [packed, align[4]]
tcp_flags = TCPHDR_FIN, TCPHDR_SYN, TCPHDR_RST, TCPHDR_PSH, TCPHDR_ACK, TCPHDR_URG, TCPHDR_ECE, TCPHDR_CWR, TCPHDR_SYN_ECN

View File

@ -1379,7 +1379,7 @@ ath9k_bulk_packet {
pkt_len len[data, int16]
pkt_tag const[ATH_USB_RX_STREAM_MODE_TAG, int16]
data array[int8]
} [packed, align_4]
} [packed, align[4]]
htc_frame [
ready htc_ready_frame

View File

@ -79,7 +79,7 @@ cmsghdr {
cmsg_level flags[cmsg_levels, int32]
cmsg_type int32
data array[int8]
} [align_ptr]
} [align[PTR_SIZE]]
# Socket options

View File

@ -67,7 +67,7 @@ cmsghdr_un_rights {
level const[SOL_SOCKET, int32]
type const[SCM_RIGHTS, int32]
fds array[fd]
} [align_ptr]
} [align[PTR_SIZE]]
cmsghdr_un_cred {
len len[parent, intptr]
@ -76,4 +76,4 @@ cmsghdr_un_cred {
pid pid
uid uid
gid gid
} [align_ptr]
} [align[PTR_SIZE]]

View File

@ -77,7 +77,7 @@ cmsghdr {
cmsg_level flags[cmsg_levels, int32]
cmsg_type int32
data array[int8]
} [align_ptr]
} [align[PTR_SIZE]]
# Socket options

View File

@ -66,7 +66,7 @@ cmsghdr_un_rights {
level const[SOL_SOCKET, int32]
type const[SCM_RIGHTS, int32]
fds array[fd]
} [align_ptr]
} [align[PTR_SIZE]]
cmsghdr_un_cred {
len len[parent, intptr]
@ -76,4 +76,4 @@ cmsghdr_un_cred {
pid pid
uid uid
gid gid
} [align_ptr]
} [align[PTR_SIZE]]

View File

@ -15,7 +15,7 @@ any0 {
f4 int64
f5 anybitfields
f6 array[any1]
} [align_8]
} [align[8]]
any1 {
f1 ptr[in, int8, opt]
@ -23,7 +23,7 @@ any1 {
f3 ptr64[in, int8, opt]
f4 anyunion1
f5 array[int8]
} [packed, align_2]
} [packed, align[2]]
anyunion0 [
res32 anyres32

View File

@ -60,7 +60,7 @@ type nlattr_t[TYPE, PAYLOAD] {
nla_type TYPE
payload PAYLOAD
size void
} [packed, align_4]
} [packed, align[4]]
type nlattr_tt[TYPE, NETORDER, NESTED, PAYLOAD] {
nla_len offsetof[size, int16]
@ -69,7 +69,7 @@ type nlattr_tt[TYPE, NETORDER, NESTED, PAYLOAD] {
NLA_F_NESTED const[NESTED, int16:1]
payload PAYLOAD
size void
} [packed, align_4]
} [packed, align[4]]
type nlattr[TYPE, PAYLOAD] nlattr_t[const[TYPE, int16], PAYLOAD]
type nlnest[TYPE, PAYLOAD] nlattr_tt[const[TYPE, int16:14], 0, 1, PAYLOAD]
@ -228,7 +228,7 @@ syz_bf_struct25 {
f3 int16:1
f4 int16
f5 void
} [packed, align_4]
} [packed, align[4]]
type syz_bf_align[T] {
f0 int8

View File

@ -74,7 +74,7 @@ syz_align3_noalign {
syz_align3_align4 {
f0 int8
} [align_4]
} [align[4]]
syz_align3 {
f0 int8
@ -85,7 +85,7 @@ syz_align3 {
syz_align4_internal {
f0 int8
f1 int16
} [packed, align_4]
} [packed, align[4]]
syz_align4 {
f0 syz_align4_internal
@ -120,7 +120,7 @@ syz_align8 {
f3 int16:1
f4 int16:1
f5 int16:1
} [packed, align_8]
} [packed, align[8]]
# Structs