Skip to content

Commit 93e49c9

Browse files
committed
add conntrack zone serialization
this allows to use the zone for conntrack delete
1 parent 219bba2 commit 93e49c9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

conntrack_linux.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,11 @@ func (s *ConntrackFlow) toNlData() ([]*nl.RtAttr, error) {
439439
}
440440
}
441441

442+
if s.Zone != 0 {
443+
ctZone := nl.NewRtAttr(nl.CTA_ZONE, nl.BEUint16Attr(s.Zone))
444+
payload = append(payload, ctZone)
445+
}
446+
442447
return payload, nil
443448
}
444449

conntrack_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,8 @@ func TestConntrackDeleteV4(t *testing.T) {
15421542
t.Fatalf("failed to create netlink handle: %s", err)
15431543
}
15441544

1545+
ctZone := uint16(123)
1546+
15451547
flow := ConntrackFlow{
15461548
FamilyType: FAMILY_V4,
15471549
Forward: IPTuple{
@@ -1563,6 +1565,7 @@ func TestConntrackDeleteV4(t *testing.T) {
15631565
ProtoInfo: &ProtoInfoTCP{
15641566
State: nl.TCP_CONNTRACK_ESTABLISHED,
15651567
},
1568+
Zone: ctZone,
15661569
}
15671570

15681571
// Create the entry using the handle
@@ -1587,6 +1590,7 @@ func TestConntrackDeleteV4(t *testing.T) {
15871590
ConntrackOrigDstPort: flow.Forward.DstPort,
15881591
},
15891592
protoFilter: unix.IPPROTO_TCP,
1593+
zoneFilter: &ctZone,
15901594
}
15911595
var match *ConntrackFlow
15921596
for _, f := range flows {
@@ -1647,6 +1651,8 @@ func TestConntrackDeleteV6(t *testing.T) {
16471651
t.Fatalf("failed to create netlink handle: %s", err)
16481652
}
16491653

1654+
ctZone := uint16(123)
1655+
16501656
flow := ConntrackFlow{
16511657
FamilyType: FAMILY_V6,
16521658
Forward: IPTuple{
@@ -1668,6 +1674,7 @@ func TestConntrackDeleteV6(t *testing.T) {
16681674
ProtoInfo: &ProtoInfoTCP{
16691675
State: nl.TCP_CONNTRACK_ESTABLISHED,
16701676
},
1677+
Zone: ctZone,
16711678
}
16721679

16731680
// Create the entry using the handle
@@ -1692,6 +1699,7 @@ func TestConntrackDeleteV6(t *testing.T) {
16921699
ConntrackOrigDstPort: flow.Forward.DstPort,
16931700
},
16941701
protoFilter: unix.IPPROTO_TCP,
1702+
zoneFilter: &ctZone,
16951703
}
16961704
var match *ConntrackFlow
16971705
for _, f := range flows {

0 commit comments

Comments
 (0)