istio: Calico eBPF mode leads to readiness probe failures with ambient [fixed in Calico 3.29]

Is this the right place to submit this?

  • This is not a security vulnerability or a crashing bug
  • This is not a question about how to use Istio

Bug Description

We tested several applications in different namespaces, readiness/liveness probes failed everywhere after labeling ns istio.io/dataplane-mode=ambient

Type     Reason     Age                    From     Message
  ----     ------     ----                   ----     -------
  Warning  Unhealthy  33m (x1643 over 10h)   kubelet  Liveness probe failed: dial tcp 192.168.140.251:1080: i/o timeout
  Warning  Unhealthy  18m (x5231 over 10h)   kubelet  Readiness probe failed: dial tcp 192.168.140.251:1080: i/o timeout
  Warning  BackOff    3m45s (x2064 over 9h)  kubelet  Back-off restarting failed container --- in pod ---

and recover after unlabeling.

Relevant for 1.22.3 and 1.23.0

Version

istioctl version
client version: 1.23.0
control plane version: 1.23.0
data plane version: 1.23.0 (5 proxies)

kubectl version
Client Version: v1.30.0
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.29.4

calicoctl version
Client Version:    v3.28.1
Git commit:        601856343
Cluster Version:   v3.27.2
Cluster Type:      k8s,bgp,kubeadm,kdd

Additional Information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 25 (15 by maintainers)

Most upvoted comments

I merged a fix on our side in master. 3.29 is going to be released soon. I also backported it to 3.28 as well. @kapistka the 3.28 hash release calico/node:release-v3.28 carries the fix unless you want to wait for 3.28.2

Thanks everyone, especially @tomastigera !

@tomastigera work fine, thanks

I will try to repro it and dig deeper

@tomastigera So far, I don’t understand the difference between working and non-working apps.

spec:
    bpfDataIfacePattern: ^(bond.*|eth.*|tunl0$)
    bpfEnabled: true
    bpfEnforceRPF: Disabled
    bpfExternalServiceMode: Tunnel
    bpfHostConntrackBypass: false
    bpfLogLevel: ""
    defaultEndpointToHostAction: Accept
    floatingIPs: Disabled
    logSeverityScreen: Info
    reportingInterval: 0s

calico-kube-controllers and all calico-nodes restarted.

After k label ns argocd istio.io/dataplane-mode=ambient

Name:             argocd-notifications-controller-cd6c4ff47-srq4x
Namespace:        argocd
Annotations:      ambient.istio.io/redirection: enabled
                  cni.projectcalico.org/containerID: ad6bd3d2738bcca7ee2601237cfa2e2d14342fda1bd1d2ae067c8642fd4ebb8e
                  cni.projectcalico.org/podIP: 192.168.122.137/32
                  cni.projectcalico.org/podIPs: 192.168.122.137/32
Status:           Running
IP:               192.168.122.137
IPs:
  IP:           192.168.122.137
Controlled By:  ReplicaSet/argocd-notifications-controller-cd6c4ff47
Containers:
  argocd-notifications-controller:
    Port:          <none>
    Host Port:     <none>
    Args:
      /usr/local/bin/argocd-notifications
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    143
    Ready:          False
    Liveness:       tcp-socket :9001 delay=0s timeout=1s period=10s #success=1 #failure=3
Events:
  Type     Reason     Age                    From     Message
  ----     ------     ----                   ----     -------
  Warning  Unhealthy  21m (x816 over 19h)    kubelet  Liveness probe failed: dial tcp 192.168.122.137:9001: i/o timeout

curl instead of kubelet (ns in mesh)

curl -v telnet://192.168.122.137:9001
*   Trying 192.168.122.137:9001...
* connect to 192.168.122.137 port 9001 from 10.32.94.164 port 50018 failed: Operation timed out
* Failed to connect to 192.168.122.137 port 9001 after 4084 ms: Couldn't connect to server
* Closing connection
curl: (28) Failed to connect to 192.168.122.137 port 9001 after 4084 ms: Couldn't connect to server

After k label ns argocd istio.io/dataplane-mode- curl instead of kubelet:

curl -v telnet://192.168.122.137:9001
*   Trying 192.168.122.137:9001...
* Connected to 192.168.122.137 (192.168.122.137) port 9001
conntrack -L -p tcp --dport 9001
tcp      6 104 TIME_WAIT src=10.32.94.164 dst=192.168.122.137 sport=38376 dport=9001 src=192.168.122.137 dst=10.32.94.164 sport=9001 dport=38376 [ASSURED] mark=0 use=1
tcp      6 14 TIME_WAIT src=10.32.94.164 dst=192.168.122.137 sport=37588 dport=9001 src=192.168.122.137 dst=10.32.94.164 sport=9001 dport=37588 [ASSURED] mark=0 use=1
tcp      6 114 TIME_WAIT src=10.32.94.164 dst=192.168.122.137 sport=36576 dport=9001 src=192.168.122.137 dst=10.32.94.164 sport=9001 dport=36576 [ASSURED] mark=0 use=1
tcp      6 4 TIME_WAIT src=10.32.94.164 dst=192.168.122.137 sport=38666 dport=9001 src=192.168.122.137 dst=10.32.94.164 sport=9001 dport=38666 [ASSURED] mark=0 use=1
tcp      6 94 TIME_WAIT src=10.32.94.164 dst=192.168.122.137 sport=39208 dport=9001 src=192.168.122.137 dst=10.32.94.164 sport=9001 dport=39208 [ASSURED] mark=0 use=1
tcp      6 24 TIME_WAIT src=10.32.94.164 dst=192.168.122.137 sport=48670 dport=9001 src=192.168.122.137 dst=10.32.94.164 sport=9001 dport=48670 [ASSURED] mark=0 use=1
tcp      6 64 TIME_WAIT src=10.32.94.164 dst=192.168.122.137 sport=60162 dport=9001 src=192.168.122.137 dst=10.32.94.164 sport=9001 dport=60162 [ASSURED] mark=0 use=1
tcp      6 74 TIME_WAIT src=10.32.94.164 dst=192.168.122.137 sport=42344 dport=9001 src=192.168.122.137 dst=10.32.94.164 sport=9001 dport=42344 [ASSURED] mark=0 use=1
tcp      6 84 TIME_WAIT src=10.32.94.164 dst=192.168.122.137 sport=54438 dport=9001 src=192.168.122.137 dst=10.32.94.164 sport=9001 dport=54438 [ASSURED] mark=0 use=1
tcp      6 54 TIME_WAIT src=10.32.94.164 dst=192.168.122.137 sport=35432 dport=9001 src=192.168.122.137 dst=10.32.94.164 sport=9001 dport=35432 [ASSURED] mark=0 use=1
tcp      6 34 TIME_WAIT src=10.32.94.164 dst=192.168.122.137 sport=58694 dport=9001 src=192.168.122.137 dst=10.32.94.164 sport=9001 dport=58694 [ASSURED] mark=0 use=1
tcp      6 44 TIME_WAIT src=10.32.94.164 dst=192.168.122.137 sport=45686 dport=9001 src=192.168.122.137 dst=10.32.94.164 sport=9001 dport=45686 [ASSURED] mark=0 use=1
conntrack v1.4.8 (conntrack-tools): 12 flow entries have been shown.

I think Istio’s expectation is that conntrack will pick up the link-local IP and reverse the SNAT and deliver the packet to the host. This does not happen and the packet is instead routed to eth0 via the default route where we unexpectedly see it again.

Thanks. This makes sense. We do rely on conntrack not being skipped here. We can’t really not rely on it (e.g. by catching the packet on the way back out with iptables and DNAT-ing it to restore the original dest address) because we don’t know the original dest address at that point, and we are in general trying to get out of the business of using heuristics to “guess” the host node IP, since that is generally very fragile and full of corner cases that break (as we have seen in the past).

if you set bpfHostConntrackBypass=false in felixconfiguration

@tomastigera thanx, it worked for me, but partially! For some apps, probes work, for some they don’t.

Calico does not redirect the packet at the pod’s device to eth0. It sets a mark 0x1000000 and afaict the packet continues into host name space and into iptables.

cali1f808cfe5dc-E: Traffic is towards host namespace, marking with 0x1000000

I think Istio’s expectation is that conntrack will pick up the link-local IP and reverse the SNAT and deliver the packet to the host. This does not happen and the packet is instead routed to eth0 via the default route where we unexpectedly see it again. My hunch is that if you set bpfHostConntrackBypass=false in felixconfiguration then it will not skip the conntrack on the way back. I do not see the relevant IP rule in the iptables dump above, but I have no reason to double that it is there in raw table (it is on by default) and disables conntrack for the returning packet. Calico does not exclude link local IPs from notrack (which I guess it should 😕 )

Is that link-local address assigned to any local interface?

I think this is what you are after here, LMK if not

           <...>-1954511 [010] b..1. 617201.255659: bpf_trace_printk: cali1f808cfe5dc-I: New packet at ifindex=8; mark=0
           <...>-1954511 [010] b..1. 617201.255661: bpf_trace_printk: cali1f808cfe5dc-I: IP id=15193 len=60
           <...>-1954511 [010] b..1. 617201.255662: bpf_trace_printk: cali1f808cfe5dc-I: IP s=a9fe077f d=af4be84
           <...>-1954511 [010] b..1. 617201.255662: bpf_trace_printk: cali1f808cfe5dc-I: IP ihl=20 bytes
           <...>-1954511 [010] b..1. 617201.255663: bpf_trace_printk: cali1f808cfe5dc-I: TCP; ports: s=12346 d=12345
           <...>-1954511 [010] b..1. 617201.255664: bpf_trace_printk: cali1f808cfe5dc-I: CT: lookup from a9fe077f:12346
           <...>-1954511 [010] b..1. 617201.255665: bpf_trace_printk: cali1f808cfe5dc-I: CT: lookup to   af4be84:12345
           <...>-1954511 [010] b..1. 617201.255666: bpf_trace_printk: cali1f808cfe5dc-I: CT: Miss for TCP SYN, NEW flow.
           <...>-1954511 [010] b..1. 617201.255667: bpf_trace_printk: cali1f808cfe5dc-I: CT: result: NEW.
           <...>-1954511 [010] b..1. 617201.255667: bpf_trace_printk: cali1f808cfe5dc-I: conntrack entry flags 0x0
           <...>-1954511 [010] b..1. 617201.255668: bpf_trace_printk: cali1f808cfe5dc-I: NAT: 1st level lookup addr=af4be84 port=12345 tcp
           <...>-1954511 [010] b..1. 617201.255669: bpf_trace_printk: cali1f808cfe5dc-I: NAT: Miss.
           <...>-1954511 [010] b..1. 617201.255670: bpf_trace_printk: cali1f808cfe5dc-I: Socket cookie: 1182
           <...>-1954511 [010] b..1. 617201.255672: bpf_trace_printk: cali1f808cfe5dc-I: About to jump to policy program.
           <...>-1954511 [010] b..1. 617201.255672: bpf_trace_printk: cali1f808cfe5dc-I: policy allow prog at 117
           <...>-1954511 [010] b..1. 617201.255673: bpf_trace_printk: cali1f808cfe5dc-I: policy deny prog at 119
           <...>-1954511 [010] b..1. 617201.255673: bpf_trace_printk: cali1f808cfe5dc-I: jump to policy prog at 28
           <...>-1954511 [010] b..1. 617201.255675: bpf_trace_printk: cali1f808cfe5dc-I: Entering calico_tc_skb_accepted_entrypoint
           <...>-1954511 [010] b..1. 617201.255677: bpf_trace_printk: cali1f808cfe5dc-I: Entering calico_tc_skb_accepted
           <...>-1954511 [010] b..1. 617201.255677: bpf_trace_printk: cali1f808cfe5dc-I: src=a9fe077f dst=af4be84
           <...>-1954511 [010] b..1. 617201.255678: bpf_trace_printk: cali1f808cfe5dc-I: post_nat=af4be84:12345
           <...>-1954511 [010] b..1. 617201.255678: bpf_trace_printk: cali1f808cfe5dc-I: tun_ip=0
           <...>-1954511 [010] b..1. 617201.255679: bpf_trace_printk: cali1f808cfe5dc-I: pol_rc=1
           <...>-1954511 [010] b..1. 617201.255679: bpf_trace_printk: cali1f808cfe5dc-I: sport=12346
           <...>-1954511 [010] b..1. 617201.255680: bpf_trace_printk: cali1f808cfe5dc-I: dport=12345
           <...>-1954511 [010] b..1. 617201.255680: bpf_trace_printk: cali1f808cfe5dc-I: flags=0
           <...>-1954511 [010] b..1. 617201.255680: bpf_trace_printk: cali1f808cfe5dc-I: ct_rc=0
           <...>-1954511 [010] b..1. 617201.255681: bpf_trace_printk: cali1f808cfe5dc-I: ct_related=0
           <...>-1954511 [010] b..1. 617201.255681: bpf_trace_printk: cali1f808cfe5dc-I: mark=0x1000000
           <...>-1954511 [010] b..1. 617201.255682: bpf_trace_printk: cali1f808cfe5dc-I: ip->ttl 64
           <...>-1954511 [010] b..1. 617201.255682: bpf_trace_printk: cali1f808cfe5dc-I: jump to idx 7 prog at 121
           <...>-1954511 [010] b..1. 617201.255684: bpf_trace_printk: cali1f808cfe5dc-I: Entering calico_tc_skb_new_flow
           <...>-1954511 [010] b..1. 617201.255684: bpf_trace_printk: cali1f808cfe5dc-I: Allowed by policy: ACCEPT
           <...>-1954511 [010] b..1. 617201.255685: bpf_trace_printk: cali1f808cfe5dc-I: CT-ALL packet mark is: 0x0
           <...>-1954511 [010] b..1. 617201.255686: bpf_trace_printk: cali1f808cfe5dc-I: CT-ALL Creating tracking entry type 0 at 180868505170664.
           <...>-1954511 [010] b..1. 617201.255687: bpf_trace_printk: cali1f808cfe5dc-I: CT-ALL tracking entry flags 0x0
           <...>-1954511 [010] b..1. 617201.255687: bpf_trace_printk: cali1f808cfe5dc-I: CT-ALL SNAT orig 0:0
           <...>-1954511 [010] b..1. 617201.255688: bpf_trace_printk: cali1f808cfe5dc-I: NEW src_to_dst->ifindex 0
           <...>-1954511 [010] b..1. 617201.255688: bpf_trace_printk: cali1f808cfe5dc-I: CT-ALL approved dest side - to EP
           <...>-1954511 [010] b..1. 617201.255691: bpf_trace_printk: cali1f808cfe5dc-I: Final result=ALLOW (0). Program execution time: 30237ns
           <...>-1954511 [010] ..s2. 617201.255736: bpf_trace_printk: cali1f808cfe5dc-E: New packet at ifindex=8; mark=0
           <...>-1954511 [010] ..s2. 617201.255738: bpf_trace_printk: cali1f808cfe5dc-E: IP id=0 len=60
           <...>-1954511 [010] ..s2. 617201.255738: bpf_trace_printk: cali1f808cfe5dc-E: IP s=af4be84 d=a9fe077f
           <...>-1954511 [010] ..s2. 617201.255739: bpf_trace_printk: cali1f808cfe5dc-E: IP ihl=20 bytes
           <...>-1954511 [010] ..s2. 617201.255739: bpf_trace_printk: cali1f808cfe5dc-E: TCP; ports: s=12345 d=12346
           <...>-1954511 [010] ..s2. 617201.255740: bpf_trace_printk: cali1f808cfe5dc-E: CT: lookup from af4be84:12345
           <...>-1954511 [010] ..s2. 617201.255741: bpf_trace_printk: cali1f808cfe5dc-E: CT: lookup to   a9fe077f:12346
           <...>-1954511 [010] ..s2. 617201.255741: bpf_trace_printk: cali1f808cfe5dc-E: CT: Hit! NORMAL entry.
           <...>-1954511 [010] ..s2. 617201.255742: bpf_trace_printk: cali1f808cfe5dc-E: CT: First response packet? ifindex=8
           <...>-1954511 [010] ..s2. 617201.255745: bpf_trace_printk: cali1f808cfe5dc-E: Host RPF check src=af4be84 skb loose if 8
           <...>-1954511 [010] ..s2. 617201.255746: bpf_trace_printk: cali1f808cfe5dc-E: Host RPF check src=af4be84 skb iface=8
           <...>-1954511 [010] ..s2. 617201.255747: bpf_trace_printk: cali1f808cfe5dc-E: Host RPF check rc 0 result 1
           <...>-1954511 [010] ..s2. 617201.255747: bpf_trace_printk: cali1f808cfe5dc-E: CT: result: 0x2
           <...>-1954511 [010] ..s2. 617201.255748: bpf_trace_printk: cali1f808cfe5dc-E: conntrack entry flags 0x0
           <...>-1954511 [010] ..s2. 617201.255748: bpf_trace_printk: cali1f808cfe5dc-E: CT Hit
           <...>-1954511 [010] ..s2. 617201.255749: bpf_trace_printk: cali1f808cfe5dc-E: jump to idx 2 prog at 105
           <...>-1954511 [010] ..s2. 617201.255751: bpf_trace_printk: cali1f808cfe5dc-E: Entering calico_tc_skb_accepted_entrypoint
           <...>-1954511 [010] ..s2. 617201.255751: bpf_trace_printk: cali1f808cfe5dc-E: Entering calico_tc_skb_accepted
           <...>-1954511 [010] ..s2. 617201.255752: bpf_trace_printk: cali1f808cfe5dc-E: src=af4be84 dst=a9fe077f
           <...>-1954511 [010] ..s2. 617201.255752: bpf_trace_printk: cali1f808cfe5dc-E: post_nat=0:0
           <...>-1954511 [010] ..s2. 617201.255753: bpf_trace_printk: cali1f808cfe5dc-E: tun_ip=0
           <...>-1954511 [010] ..s2. 617201.255753: bpf_trace_printk: cali1f808cfe5dc-E: pol_rc=1
           <...>-1954511 [010] ..s2. 617201.255753: bpf_trace_printk: cali1f808cfe5dc-E: sport=12345
           <...>-1954511 [010] ..s2. 617201.255754: bpf_trace_printk: cali1f808cfe5dc-E: dport=12346
           <...>-1954511 [010] ..s2. 617201.255754: bpf_trace_printk: cali1f808cfe5dc-E: flags=20
           <...>-1954511 [010] ..s2. 617201.255755: bpf_trace_printk: cali1f808cfe5dc-E: ct_rc=2
           <...>-1954511 [010] ..s2. 617201.255755: bpf_trace_printk: cali1f808cfe5dc-E: ct_related=0
           <...>-1954511 [010] ..s2. 617201.255755: bpf_trace_printk: cali1f808cfe5dc-E: mark=0x1000000
           <...>-1954511 [010] ..s2. 617201.255756: bpf_trace_printk: cali1f808cfe5dc-E: ip->ttl 64
           <...>-1954511 [010] ..s2. 617201.255757: bpf_trace_printk: cali1f808cfe5dc-E: Traffic is towards host namespace, marking with 0x1000000.
           <...>-1954511 [010] ..s2. 617201.255758: bpf_trace_printk: cali1f808cfe5dc-E: Final result=ALLOW (0). Program execution time: 19968ns
            curl-1954511 [010] b.s2. 617201.255780: bpf_trace_printk: eth0------------E: New packet at ifindex=113; mark=1000000
            curl-1954511 [010] b.s2. 617201.255781: bpf_trace_printk: eth0------------E: IP id=0 len=60
            curl-1954511 [010] b.s2. 617201.255782: bpf_trace_printk: eth0------------E: IP s=af4be84 d=a9fe077f
            curl-1954511 [010] b.s2. 617201.255782: bpf_trace_printk: eth0------------E: IP ihl=20 bytes
            curl-1954511 [010] b.s2. 617201.255783: bpf_trace_printk: eth0------------E: TCP; ports: s=12345 d=12346
            curl-1954511 [010] b.s2. 617201.255784: bpf_trace_printk: eth0------------E: CT: lookup from af4be84:12345
            curl-1954511 [010] b.s2. 617201.255784: bpf_trace_printk: eth0------------E: CT: lookup to   a9fe077f:12346
            curl-1954511 [010] b.s2. 617201.255785: bpf_trace_printk: eth0------------E: CT: Hit! NORMAL entry.
            curl-1954511 [010] b.s2. 617201.255786: bpf_trace_printk: eth0------------E: CT: Packet not allowed by ingress/egress approval flags (FH).
            curl-1954511 [010] b.s2. 617201.255787: bpf_trace_printk: eth0------------E: CT: result: 0x6
            curl-1954511 [010] b.s2. 617201.255787: bpf_trace_printk: eth0------------E: conntrack entry flags 0x0
            curl-1954511 [010] b.s2. 617201.255787: bpf_trace_printk: eth0------------E: CT Hit
            curl-1954511 [010] b.s2. 617201.255788: bpf_trace_printk: eth0------------E: jump to idx 2 prog at 21
            curl-1954511 [010] b.s2. 617201.255789: bpf_trace_printk: eth0------------E: Entering calico_tc_skb_accepted_entrypoint
            curl-1954511 [010] b.s2. 617201.255790: bpf_trace_printk: eth0------------E: Entering calico_tc_skb_accepted
            curl-1954511 [010] b.s2. 617201.255790: bpf_trace_printk: eth0------------E: src=af4be84 dst=a9fe077f
            curl-1954511 [010] b.s2. 617201.255791: bpf_trace_printk: eth0------------E: post_nat=0:0
            curl-1954511 [010] b.s2. 617201.255791: bpf_trace_printk: eth0------------E: tun_ip=0
            curl-1954511 [010] b.s2. 617201.255791: bpf_trace_printk: eth0------------E: pol_rc=1
            curl-1954511 [010] b.s2. 617201.255792: bpf_trace_printk: eth0------------E: sport=12345
            curl-1954511 [010] b.s2. 617201.255792: bpf_trace_printk: eth0------------E: dport=12346
            curl-1954511 [010] b.s2. 617201.255792: bpf_trace_printk: eth0------------E: flags=20
            curl-1954511 [010] b.s2. 617201.255793: bpf_trace_printk: eth0------------E: ct_rc=6
            curl-1954511 [010] b.s2. 617201.255793: bpf_trace_printk: eth0------------E: ct_related=0
            curl-1954511 [010] b.s2. 617201.255793: bpf_trace_printk: eth0------------E: mark=0x1000000
            curl-1954511 [010] b.s2. 617201.255794: bpf_trace_printk: eth0------------E: ip->ttl 63
            curl-1954511 [010] b.s2. 617201.255795: bpf_trace_printk: eth0------------E: Final result=DENY (0). Program execution time: 14016ns

full.txt

@howardjohn thank for bringing it to Calico maintainers attention! Do you happen to have the bpf logs from the pod’s interface which must come just before the eth0 logs? (perhaps logs for the ingress to the pod as well) Seems like the program attached to the pod’s interface decideds wrongly that the packet should be forwarded to eth0 instead of letting the packet go to the host. This might be due to how 169.254.7.127/32 is routed.

It is not immediately obvious to me why the packet is ultimately denied on eth0 even though it is on the “accept” path, but that is not the problem here, the packet should not end up there in the first place. It has nothing to do with a policy and a policy allowing link local would not help here.

Trace logs (I did curl instead of kubelet, same thing though. local port 12346, health check port 12345)

            curl-1954511 [010] b.s2. 617201.255780: bpf_trace_printk: eth0------------E: New packet at ifindex=113; mark=1000000
            curl-1954511 [010] b.s2. 617201.255781: bpf_trace_printk: eth0------------E: IP id=0 len=60
            curl-1954511 [010] b.s2. 617201.255782: bpf_trace_printk: eth0------------E: IP s=af4be84 d=a9fe077f
            curl-1954511 [010] b.s2. 617201.255782: bpf_trace_printk: eth0------------E: IP ihl=20 bytes
            curl-1954511 [010] b.s2. 617201.255783: bpf_trace_printk: eth0------------E: TCP; ports: s=12345 d=12346
            curl-1954511 [010] b.s2. 617201.255784: bpf_trace_printk: eth0------------E: CT: lookup from af4be84:12345
            curl-1954511 [010] b.s2. 617201.255784: bpf_trace_printk: eth0------------E: CT: lookup to   a9fe077f:12346
            curl-1954511 [010] b.s2. 617201.255785: bpf_trace_printk: eth0------------E: CT: Hit! NORMAL entry.
            curl-1954511 [010] b.s2. 617201.255786: bpf_trace_printk: eth0------------E: CT: Packet not allowed by ingress/egress approval flags (FH).
            curl-1954511 [010] b.s2. 617201.255787: bpf_trace_printk: eth0------------E: CT: result: 0x6
            curl-1954511 [010] b.s2. 617201.255787: bpf_trace_printk: eth0------------E: conntrack entry flags 0x0
            curl-1954511 [010] b.s2. 617201.255787: bpf_trace_printk: eth0------------E: CT Hit
            curl-1954511 [010] b.s2. 617201.255788: bpf_trace_printk: eth0------------E: jump to idx 2 prog at 21
            curl-1954511 [010] b.s2. 617201.255789: bpf_trace_printk: eth0------------E: Entering calico_tc_skb_accepted_entrypoint
            curl-1954511 [010] b.s2. 617201.255790: bpf_trace_printk: eth0------------E: Entering calico_tc_skb_accepted
            curl-1954511 [010] b.s2. 617201.255790: bpf_trace_printk: eth0------------E: src=af4be84 dst=a9fe077f
            curl-1954511 [010] b.s2. 617201.255791: bpf_trace_printk: eth0------------E: post_nat=0:0
            curl-1954511 [010] b.s2. 617201.255791: bpf_trace_printk: eth0------------E: tun_ip=0
            curl-1954511 [010] b.s2. 617201.255791: bpf_trace_printk: eth0------------E: pol_rc=1
            curl-1954511 [010] b.s2. 617201.255792: bpf_trace_printk: eth0------------E: sport=12345
            curl-1954511 [010] b.s2. 617201.255792: bpf_trace_printk: eth0------------E: dport=12346
            curl-1954511 [010] b.s2. 617201.255792: bpf_trace_printk: eth0------------E: flags=20
            curl-1954511 [010] b.s2. 617201.255793: bpf_trace_printk: eth0------------E: ct_rc=6
            curl-1954511 [010] b.s2. 617201.255793: bpf_trace_printk: eth0------------E: ct_related=0
            curl-1954511 [010] b.s2. 617201.255793: bpf_trace_printk: eth0------------E: mark=0x1000000
            curl-1954511 [010] b.s2. 617201.255794: bpf_trace_printk: eth0------------E: ip->ttl 63
            curl-1954511 [010] b.s2. 617201.255795: bpf_trace_printk: eth0------------E: Final result=DENY (0). Program execution time: 14016ns

DENY(0) == CALI_REASON_UNKNOWN

We don’t have any NetworkPolicies. We use Calico eBPF dataplane mode:

spec:
  bpfDataIfacePattern: ^(bond.*|eth.*|tunl0$)
  bpfExternalServiceMode: Tunnel
  bpfEnabled: true
  bpfEnforceRPF: Disabled
  bpfLogLevel: ""
  defaultEndpointToHostAction: Accept
  floatingIPs: Disabled
  logSeverityScreen: Info
  reportingInterval: 0s

This is how the iptable-tables looks on the node (app is in a mesh, all istio ambient components are deployed). iptables -L

# Warning: iptables-legacy tables present, use iptables-legacy to see them
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere             /* cali:zkuE8qdwsVpH6Kd2 */ /* Accept packets from flows that pre-date BPF. */ mark match 0x5000000/0x5000000 ctstate RELATED,ESTABLISHED
DROP       all  --  anywhere             anywhere             /* cali:XQL0mC-L6wldZdgN */ /* Drop packets from unknown flows. */ mark match 0x5000000/0x5000000
ACCEPT     all  --  anywhere             anywhere             /* cali:pbFdTFCLcV-MVLSS */ mark match 0x1000000/0x1000000
DROP       all  --  anywhere             anywhere             /* cali:u_TyW7ph8QsYnThE */ mark match ! 0x1000000/0x1000000
KUBE-FIREWALL  all  --  anywhere             anywhere

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere             /* cali:umcmOn0WnTNOKJrp */ /* Pre-approved by BPF programs. */ mark match 0x3000000/0x3000000
DROP       all  --  anywhere             anywhere             /* cali:NnQ109Z-tVFkJGc1 */ /* From workload without BPF seen mark */ mark match ! 0x1000000/0x1000000
MARK       all  --  anywhere             anywhere             /* cali:YmI_zfAgHIHbINEV */ /* Mark pre-established flows. */ ctstate RELATED,ESTABLISHED MARK or 0x8000000
cali-to-wl-dispatch  all  --  anywhere             anywhere             /* cali:-EFgmtwMJVO64q9s */ /* To workload, check workload is known. */
ACCEPT     all  --  anywhere             anywhere             /* cali:wP1i1sEU71uRzM5d */ /* To workload, mark has already been verified. */
ACCEPT     all  --  anywhere             anywhere             /* cali:3t5V_2xe4DFVlHBq */ /* From  */ /* bpfout.cali */ /*  device, mark verified, accept. */

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
MARK       all  --  anywhere             anywhere             /* cali:CD7jZCSqPP_KjGsd */ /* Mark pre-established flows. */ ctstate RELATED,ESTABLISHED MARK or 0x8000000
KUBE-FIREWALL  all  --  anywhere             anywhere

Chain KUBE-FIREWALL (2 references)
target     prot opt source               destination
DROP       all  -- !127.0.0.0/8          127.0.0.0/8          /* block incoming localnet connections */ ! ctstate RELATED,ESTABLISHED,DNAT

Chain KUBE-KUBELET-CANARY (0 references)
target     prot opt source               destination

Chain cali-to-wl-dispatch (1 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere             /* cali:ip9Ie-N0ygln2FmJ */
cali-to-wl-dispatch-2  all  --  anywhere             anywhere            [goto]  /* cali:aKuF5mfs7bBaHL8s */
ACCEPT     all  --  anywhere             anywhere             /* cali:ots2jZWMCeb1_7Hq */
ACCEPT     all  --  anywhere             anywhere             /* cali:t3ZZigb_WwyAHI_n */
cali-to-wl-dispatch-6  all  --  anywhere             anywhere            [goto]  /* cali:MDlJOiSKDOpYwvKH */
ACCEPT     all  --  anywhere             anywhere             /* cali:jKD3WcLX9myrfdPb */
cali-to-wl-dispatch-a  all  --  anywhere             anywhere            [goto]  /* cali:PyRJ4V0WRoiW8EQH */
ACCEPT     all  --  anywhere             anywhere             /* cali:ym2iORpUWfr-Y7mJ */
ACCEPT     all  --  anywhere             anywhere             /* cali:PO07IO89pQImViIZ */
ACCEPT     all  --  anywhere             anywhere             /* cali:2OVfoLzt6OrmrHNz */
ACCEPT     all  --  anywhere             anywhere             /* cali:XTfTxKfxy5nBZzeL */
DROP       all  --  anywhere             anywhere             /* cali:48_1pc4AHu50JuoN */ /* Unknown interface */

Chain cali-to-wl-dispatch-2 (1 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere             /* cali:gC93MCeQsiM-jHid */
ACCEPT     all  --  anywhere             anywhere             /* cali:9I1ckTPA41IgCzPr */
DROP       all  --  anywhere             anywhere             /* cali:e8jQaOdbbuww7jBd */ /* Unknown interface */

Chain cali-to-wl-dispatch-6 (1 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere             /* cali:yfg4vrzh5-gvW06Z */
ACCEPT     all  --  anywhere             anywhere             /* cali:Kks65fTZp3hobK7U */
ACCEPT     all  --  anywhere             anywhere             /* cali:sfawFw6p1vB_d8ek */
ACCEPT     all  --  anywhere             anywhere             /* cali:eVDR9iyipKix7vSL */
ACCEPT     all  --  anywhere             anywhere             /* cali:02rmnECCALsLybC8 */
DROP       all  --  anywhere             anywhere             /* cali:Ue-N3DxZsu6napKu */ /* Unknown interface */

Chain cali-to-wl-dispatch-a (1 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere             /* cali:NiXEupcXTAmX41fl */
ACCEPT     all  --  anywhere             anywhere             /* cali:EmkP9JsnpN-xMjjB */
DROP       all  --  anywhere             anywhere             /* cali:36VgSPd4dVl1qXBo */ /* Unknown interface */

iptables -t nat -L

# Warning: iptables-legacy tables present, use iptables-legacy to see them
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
cali-POSTROUTING  all  --  anywhere             anywhere             /* cali:O3lYWMrLQYEMJtB5 */

Chain KUBE-KUBELET-CANARY (0 references)
target     prot opt source               destination

Chain cali-POSTROUTING (1 references)
target     prot opt source               destination
MASQUERADE  all  --  anywhere             anywhere             /* cali:ggLCSZ9_r9uXnHIo */ /* BPF loopback SNAT */ mark match 0x3600000/0x3f00000 random-fully
cali-fip-snat  all  --  anywhere             anywhere             /* cali:THrmnLhAi3cxMLBO */
cali-nat-outgoing  all  --  anywhere             anywhere             /* cali:ez7mOi3T8N6rtIlJ */
MASQUERADE  all  --  anywhere             anywhere             /* cali:pSEn2f1JTKrHlo8S */ ADDRTYPE match src-type !LOCAL limit-out ADDRTYPE match src-type LOCAL random-fully

Chain cali-fip-snat (1 references)
target     prot opt source               destination

Chain cali-nat-outgoing (1 references)
target     prot opt source               destination
MASQUERADE  all  --  anywhere             anywhere             /* cali:k9SjE1bWVYbIZgCm */ mark match 0x3800000/0x3f00000 random-fully

In the pod in mesh. iptables -L

# Warning: iptables-legacy tables present, use iptables-legacy to see them
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

iptables -t nat -L

# Warning: iptables-legacy tables present, use iptables-legacy to see them
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

istio-cni logs after labeling ns

2024-08-21T15:47:04.510238Z     info    cni-agent       Namespace app is enabled in ambient mesh
2024-08-21T15:47:04.510328Z     info    cni-agent       adding pod to the mesh  ns=app name=app
2024-08-21T15:47:04.517268Z     info    iptables        Running iptables-legacy-restore with the following input:
* nat
-N ISTIO_OUTPUT
-A OUTPUT -j ISTIO_OUTPUT
-A ISTIO_OUTPUT -d 169.254.7.127 -p tcp -m tcp -j ACCEPT
-A ISTIO_OUTPUT -p tcp -m mark --mark 0x111/0xfff -j ACCEPT
-A ISTIO_OUTPUT ! -d 127.0.0.1/32 -o lo -j ACCEPT
-A ISTIO_OUTPUT ! -d 127.0.0.1/32 -p tcp -m mark ! --mark 0x539/0xfff -j REDIRECT --to-ports 15001
COMMIT
* mangle
-N ISTIO_PRERT
-N ISTIO_OUTPUT
-A PREROUTING -j ISTIO_PRERT
-A OUTPUT -j ISTIO_OUTPUT
-A ISTIO_PRERT -m mark --mark 0x539/0xfff -j CONNMARK --set-xmark 0x111/0xfff
-A ISTIO_PRERT -s 169.254.7.127 -p tcp -m tcp -j ACCEPT
-A ISTIO_PRERT ! -d 127.0.0.1/32 -p tcp -i lo -j ACCEPT
-A ISTIO_PRERT -p tcp -m tcp --dport 15008 -m mark ! --mark 0x539/0xfff -j TPROXY --on-port 15008 --tproxy-mark 0x111/0xfff
-A ISTIO_PRERT -p tcp -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A ISTIO_PRERT ! -d 127.0.0.1/32 -p tcp -m mark ! --mark 0x539/0xfff -j TPROXY --on-port 15006 --tproxy-mark 0x111/0xfff
-A ISTIO_OUTPUT -m connmark --mark 0x111/0xfff -j CONNMARK --restore-mark --nfmask 0xffffffff --ctmask 0xffffffff
COMMIT
2024-08-21T15:47:04.517321Z     info    Running command (with wait lock): iptables-legacy-restore --noflush -v --wait=30
2024-08-21T15:47:04.519569Z     info    cni-agent       sending pod add to ztunnel      uid=5117bb2f-69cd-459d-a500-cc352d9b705a name=app namespace=app serviceAccount=default