Skip to content

Commit 4759eb3

Browse files
authored
Merge pull request #8943 from tomastigera/tomas-bpf-fv-test-fix
[BPF] fix rendering ipv6 iptables rules
2 parents 11810ab + d0e8573 commit 4759eb3

File tree

3 files changed

+27
-20
lines changed

3 files changed

+27
-20
lines changed

felix/dataplane/linux/int_dataplane.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,9 @@ func (d *InternalDataplane) setUpIptablesBPF() {
15121512
// only go to the host. Make sure that they are not forwarded.
15131513
fwdRules = append(fwdRules, rules.ICMPv6Filter(d.ruleRenderer.IptablesFilterDenyAction())...)
15141514
}
1515-
} else {
1515+
}
1516+
1517+
if t.IPVersion == 4 || d.config.BPFIpv6Enabled {
15161518
// Let the BPF programs know if Linux conntrack knows about the flow.
15171519
fwdRules = append(fwdRules, bpfMarkPreestablishedFlowsRules()...)
15181520
// The packet may be about to go to a local workload. However, the local workload may not have a BPF

felix/fv/bpf_test.go

+9-9
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")
@@ -4579,16 +4580,15 @@ func describeBPFTests(opts ...bpfTestOpt) bool {
45794580
fc.Spec.BPFEnabled = &bpfEnabled
45804581
_, err := calicoClient.FelixConfigurations().Update(context.Background(), fc, options2.SetOptions{})
45814582
Expect(err).NotTo(HaveOccurred())
4582-
return
4583+
} else {
4584+
// Fall back on creating it...
4585+
fc = api.NewFelixConfiguration()
4586+
fc.Name = "default"
4587+
fc.Spec.BPFEnabled = &bpfEnabled
4588+
fc, err = calicoClient.FelixConfigurations().Create(context.Background(), fc, options2.SetOptions{})
4589+
Expect(err).NotTo(HaveOccurred())
45834590
}
45844591

4585-
// Fall back on creating it...
4586-
fc = api.NewFelixConfiguration()
4587-
fc.Name = "default"
4588-
fc.Spec.BPFEnabled = &bpfEnabled
4589-
fc, err = calicoClient.FelixConfigurations().Create(context.Background(), fc, options2.SetOptions{})
4590-
Expect(err).NotTo(HaveOccurred())
4591-
45924592
// Wait for BPF to be active.
45934593
ensureAllNodesBPFProgramsAttached(tc.Felixes)
45944594
}
@@ -4601,7 +4601,7 @@ func describeBPFTests(opts ...bpfTestOpt) bool {
46014601
log.Info("Pongs received")
46024602
}
46034603

4604-
if testOpts.protocol == "tcp" && testOpts.dsr {
4604+
if testOpts.protocol == "tcp" && (testOpts.dsr || testOpts.ipv6) {
46054605
verifyConnectivityWhileEnablingBPF := func(from, to *workload.Workload) {
46064606
By("Starting persistent connection")
46074607
pc = from.StartPersistentConnection(to.IP, 8055, workload.PersistentConnectionOpts{

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)