Fix: add missed parameters of struct ConntrackMtinfoBase (#182)

according to https://elixir.bootlin.com/linux/v5.17.7/source/include/uapi/linux/netfilter/xt_conntrack.h#L47 there are u16 parameters: MatchFlags and InvertFlags
This commit is contained in:
xiaoff 2022-09-05 02:05:03 +08:00 committed by GitHub
parent 64ce05980f
commit 6cd15ed863
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -41,6 +41,8 @@ type ConntrackMtinfoBase struct {
OrigDstPort uint16
ReplSrcPort uint16
ReplDstPort uint16
MatchFlags uint16
InvertFlags uint16
}
// See https://elixir.bootlin.com/linux/v5.17.7/source/include/uapi/linux/netfilter/xt_conntrack.h#L38
@ -98,6 +100,8 @@ func (x *ConntrackMtinfoBase) marshalAB(fam TableFamily, rev uint32, ab *aligned
ab.PutUint16(x.OrigDstPort)
ab.PutUint16(x.ReplSrcPort)
ab.PutUint16(x.ReplDstPort)
ab.PutUint16(x.MatchFlags)
ab.PutUint16(x.InvertFlags)
return nil
}
@ -148,6 +152,12 @@ func (x *ConntrackMtinfoBase) unmarshalAB(fam TableFamily, rev uint32, ab *align
if x.ReplDstPort, err = ab.Uint16(); err != nil {
return err
}
if x.MatchFlags, err = ab.Uint16(); err != nil {
return err
}
if x.InvertFlags, err = ab.Uint16(); err != nil {
return err
}
return nil
}

View File

@ -38,6 +38,8 @@ func TestMatchConntrack(t *testing.T) {
OrigDstPort: 321,
ReplSrcPort: 789,
ReplDstPort: 987,
MatchFlags: 0x01,
InvertFlags: 0x01,
},
StateMask: 0x55,
StatusMask: 0xaa,
@ -65,6 +67,8 @@ func TestMatchConntrack(t *testing.T) {
OrigDstPort: 321,
ReplSrcPort: 789,
ReplDstPort: 987,
MatchFlags: 0x01,
InvertFlags: 0x01,
},
StateMask: 0x55,
StatusMask: 0xaa,
@ -92,6 +96,8 @@ func TestMatchConntrack(t *testing.T) {
OrigDstPort: 321,
ReplSrcPort: 789,
ReplDstPort: 987,
MatchFlags: 0x01,
InvertFlags: 0x01,
},
StateMask: 0x55aa,
StatusMask: 0xaa55,
@ -119,6 +125,8 @@ func TestMatchConntrack(t *testing.T) {
OrigDstPort: 321,
ReplSrcPort: 789,
ReplDstPort: 987,
MatchFlags: 0x01,
InvertFlags: 0x01,
},
StateMask: 0x55aa,
StatusMask: 0xaa55,
@ -147,6 +155,8 @@ func TestMatchConntrack(t *testing.T) {
OrigDstPort: 321,
ReplSrcPort: 789,
ReplDstPort: 987,
MatchFlags: 0x01,
InvertFlags: 0x01,
},
StateMask: 0x55aa,
StatusMask: 0xaa55,
@ -180,6 +190,8 @@ func TestMatchConntrack(t *testing.T) {
OrigDstPort: 321,
ReplSrcPort: 789,
ReplDstPort: 987,
MatchFlags: 0x01,
InvertFlags: 0x01,
},
StateMask: 0x55aa,
StatusMask: 0xaa55,