diff options
| author | Andrey Konovalov <andreyknvl@google.com> | 2017-01-25 16:18:05 +0100 |
|---|---|---|
| committer | Andrey Konovalov <andreyknvl@google.com> | 2017-01-25 20:31:13 +0100 |
| commit | 63b16a5d5cfd3b41f596daccd56d32b2548ec119 (patch) | |
| tree | 3dfa93b07083b7ee4c21aa430aeedc92b9a16bb4 /sysgen | |
| parent | c8d03a05f3acd375badcde94264909d149784778 (diff) | |
prog, sys: add csum type, embed checksums for ipv4 packets
This change adds a `csum[kind, type]` type.
The only available kind right now is `ipv4`.
Using `csum[ipv4, int16be]` in `ipv4_header` makes syzkaller calculate
and embed correct checksums into ipv4 packets.
Diffstat (limited to 'sysgen')
| -rw-r--r-- | sysgen/sysgen.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/sysgen/sysgen.go b/sysgen/sysgen.go index 6906c7697..bfead2088 100644 --- a/sysgen/sysgen.go +++ b/sysgen/sysgen.go @@ -500,6 +500,19 @@ func generateArg( byteSize = decodeByteSizeType(typ) } fmt.Fprintf(out, "&LenType{%v, Buf: \"%v\", ByteSize: %v}", intCommon(size, bigEndian, bitfieldLen), a[0], byteSize) + case "csum": + if want := 2; len(a) != want { + failf("wrong number of arguments for %v arg %v, want %v, got %v", typ, name, want, len(a)) + } + size, bigEndian, bitfieldLen := decodeIntType(a[1]) + var kind string + switch a[0] { + case "ipv4": + kind = "CsumIPv4" + default: + failf("unknown checksum kind '%v'", a[0]) + } + fmt.Fprintf(out, "&CsumType{%v, Kind: %v}", intCommon(size, bigEndian, bitfieldLen), kind) case "flags": canBeArg = true size := uint64(ptrSize) |
