Skip to content

Commit

Permalink
bpf, external ip: fix service xlation for containers
Browse files Browse the repository at this point in the history
We need to compile the service lookup back in for bpf_lxc when in the
config ENABLE_EXTERNAL_IP is set. Reason is that for !local IPs we
correctly bypass the xlation in the host ns, but given BPF cgroups hook
is not ns aware, it's also bypassed for containers which is not the
behavior of iptables based kube-proxy. Therefore, the only way to fix
it is to rely in this case on the veth ingress hook and finalize the
external IP xlation there. Spotted by Andre's amazing kube-proxy test
suite.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
  • Loading branch information
borkmann committed Jan 10, 2020
1 parent 4ac28ce commit 6426c86
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions bpf/bpf_lxc.c
Expand Up @@ -114,7 +114,7 @@ static inline int ipv6_l3_from_lxc(struct __sk_buff *skb,
* entry for destination endpoints where we can't encode the state in the
* address.
*/
#ifndef ENABLE_HOST_SERVICES_FULL
#if !defined(ENABLE_HOST_SERVICES_FULL) || defined(ENABLE_EXTERNAL_IP)
{
struct lb6_service *svc;

Expand All @@ -126,7 +126,7 @@ static inline int ipv6_l3_from_lxc(struct __sk_buff *skb,
hairpin_flow |= ct_state_new.loopback;
}
}
#endif /* ENABLE_HOST_SERVICES_FULL */
#endif

skip_service_lookup:
/* The verifier wants to see this assignment here in case the above goto
Expand Down Expand Up @@ -450,7 +450,7 @@ static inline int handle_ipv4_from_lxc(struct __sk_buff *skb, __u32 *dstID)
}

ct_state_new.orig_dport = key.dport;
#ifndef ENABLE_HOST_SERVICES_FULL
#if !defined(ENABLE_HOST_SERVICES_FULL) || defined(ENABLE_EXTERNAL_IP)
{
struct lb4_service *svc;

Expand All @@ -462,7 +462,7 @@ static inline int handle_ipv4_from_lxc(struct __sk_buff *skb, __u32 *dstID)
hairpin_flow |= ct_state_new.loopback;
}
}
#endif /* ENABLE_HOST_SERVICES_FULL */
#endif

skip_service_lookup:
/* The verifier wants to see this assignment here in case the above goto
Expand Down
2 changes: 1 addition & 1 deletion daemon/bpf.sha
@@ -1,2 +1,2 @@
GO_BINDATA_SHA1SUM=153de6bc36b9f1b7e4a43560dde22755e1a4494b
GO_BINDATA_SHA1SUM=ced2e65d8eea14751229ee8f4f37da8115449d3b
BPF_FILES=../bpf/COPYING ../bpf/Makefile ../bpf/Makefile.bpf ../bpf/bpf_alignchecker.c ../bpf/bpf_features.h ../bpf/bpf_hostdev_ingress.c ../bpf/bpf_ipsec.c ../bpf/bpf_lxc.c ../bpf/bpf_netdev.c ../bpf/bpf_network.c ../bpf/bpf_overlay.c ../bpf/bpf_sock.c ../bpf/bpf_xdp.c ../bpf/cilium-map-migrate.c ../bpf/filter_config.h ../bpf/include/bpf/api.h ../bpf/include/elf/elf.h ../bpf/include/elf/gelf.h ../bpf/include/elf/libelf.h ../bpf/include/iproute2/bpf_elf.h ../bpf/include/linux/bpf.h ../bpf/include/linux/bpf_common.h ../bpf/include/linux/byteorder.h ../bpf/include/linux/byteorder/big_endian.h ../bpf/include/linux/byteorder/little_endian.h ../bpf/include/linux/icmp.h ../bpf/include/linux/icmpv6.h ../bpf/include/linux/if_arp.h ../bpf/include/linux/if_ether.h ../bpf/include/linux/if_packet.h ../bpf/include/linux/in.h ../bpf/include/linux/in6.h ../bpf/include/linux/ioctl.h ../bpf/include/linux/ip.h ../bpf/include/linux/ipv6.h ../bpf/include/linux/perf_event.h ../bpf/include/linux/swab.h ../bpf/include/linux/tcp.h ../bpf/include/linux/type_mapper.h ../bpf/include/linux/udp.h ../bpf/init.sh ../bpf/lib/arp.h ../bpf/lib/common.h ../bpf/lib/config.h ../bpf/lib/conntrack.h ../bpf/lib/conntrack_map.h ../bpf/lib/conntrack_test.h ../bpf/lib/csum.h ../bpf/lib/dbg.h ../bpf/lib/drop.h ../bpf/lib/encap.h ../bpf/lib/eps.h ../bpf/lib/eth.h ../bpf/lib/events.h ../bpf/lib/icmp6.h ../bpf/lib/ipv4.h ../bpf/lib/ipv6.h ../bpf/lib/ipv6_test.h ../bpf/lib/l3.h ../bpf/lib/l4.h ../bpf/lib/lb.h ../bpf/lib/lxc.h ../bpf/lib/maps.h ../bpf/lib/metrics.h ../bpf/lib/nat.h ../bpf/lib/nat46.h ../bpf/lib/nodeport.h ../bpf/lib/policy.h ../bpf/lib/signal.h ../bpf/lib/tailcall.h ../bpf/lib/trace.h ../bpf/lib/utils.h ../bpf/lib/xdp.h ../bpf/lxc_config.h ../bpf/netdev_config.h ../bpf/node_config.h ../bpf/probes/raw_change_tail.t ../bpf/probes/raw_fib_lookup.t ../bpf/probes/raw_insn.h ../bpf/probes/raw_invalidate_hash.t ../bpf/probes/raw_lpm_map.t ../bpf/probes/raw_lru_map.t ../bpf/probes/raw_main.c ../bpf/probes/raw_max_insn.t ../bpf/probes/raw_sock_cookie.t ../bpf/run_probes.sh ../bpf/sockops/Makefile ../bpf/sockops/bpf_redir.c ../bpf/sockops/bpf_sockops.c ../bpf/sockops/bpf_sockops.h ../bpf/sockops/sockops_config.h

0 comments on commit 6426c86

Please sign in to comment.