Skip to content

Commit d0e8573

Browse files
committed
[BPF] fix bypassing linux conntrack option
1 parent fa0a31e commit d0e8573

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

felix/fv/bpf_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ func describeBPFTests(opts ...bpfTestOpt) bool {
462462
felix.Exec("conntrack", "-L")
463463
felix.Exec("calico-bpf", "policy", "dump", "cali8d1e69e5f89", "all", "--asm")
464464
if testOpts.ipv6 {
465+
felix.Exec("conntrack", "-L", "-f", "ipv6")
465466
felix.Exec("ip6tables-save", "-c")
466467
felix.Exec("ip", "-6", "link")
467468
felix.Exec("ip", "-6", "addr")

felix/rules/static.go

+15-10
Original file line numberDiff line numberDiff line change
@@ -1152,18 +1152,23 @@ func (r *DefaultRuleRenderer) StaticBPFModeRawChains(ipVersion uint8,
11521152
Action: GotoAction{Target: ChainRawBPFUntrackedPolicy},
11531153
Comment: []string{"Jump to target for packets with Bypass mark"},
11541154
},
1155-
Rule{
1156-
Match: Match().DestAddrType(AddrTypeLocal),
1157-
Action: SetMaskedMarkAction{Mark: tcdefs.MarkSeenSkipFIB, Mask: tcdefs.MarkSeenSkipFIB},
1158-
Comment: []string{"Mark traffic towards the host - it is TRACKed"},
1159-
},
1160-
Rule{
1161-
Match: Match().NotDestAddrType(AddrTypeLocal),
1162-
Action: GotoAction{Target: ChainRawUntrackedFlows},
1163-
Comment: []string{"Check if forwarded traffic needs to be TRACKed"},
1164-
},
11651155
)
11661156

1157+
if bypassHostConntrack {
1158+
rawRules = append(rawRules,
1159+
Rule{
1160+
Match: Match().DestAddrType(AddrTypeLocal),
1161+
Action: SetMaskedMarkAction{Mark: tcdefs.MarkSeenSkipFIB, Mask: tcdefs.MarkSeenSkipFIB},
1162+
Comment: []string{"Mark traffic towards the host - it is TRACKed"},
1163+
},
1164+
Rule{
1165+
Match: Match().NotDestAddrType(AddrTypeLocal),
1166+
Action: GotoAction{Target: ChainRawUntrackedFlows},
1167+
Comment: []string{"Check if forwarded traffic needs to be TRACKed"},
1168+
},
1169+
)
1170+
}
1171+
11671172
rawPreroutingChain := &Chain{
11681173
Name: ChainRawPrerouting,
11691174
Rules: rawRules,

0 commit comments

Comments
 (0)