|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | + |
| 3 | +Date: Sat, 12 Oct 2024 09:33:24 +0800 |
| 4 | +Subject: fix disable per-package lb |
| 5 | + |
| 6 | +Signed-off-by: l1b0k < [email protected]> |
| 7 | +--- |
| 8 | + bpf/bpf_lxc.c | 5 ++--- |
| 9 | + daemon/cmd/daemon_main.go | 3 +++ |
| 10 | + pkg/datapath/linux/config/config.go | 5 +++++ |
| 11 | + pkg/option/config.go | 6 ++++++ |
| 12 | + 4 files changed, 16 insertions(+), 3 deletions(-) |
| 13 | + |
| 14 | +diff --git a/bpf/bpf_lxc.c b/bpf/bpf_lxc.c |
| 15 | +index 2773e2c276..7e424204e2 100644 |
| 16 | +--- a/bpf/bpf_lxc.c |
| 17 | ++++ b/bpf/bpf_lxc.c |
| 18 | +@@ -58,9 +58,9 @@ |
| 19 | + * Most services with L7 LB flag can not be redirected to their proxy port |
| 20 | + * in bpf_sock, so we must check for those via per packet LB as well. |
| 21 | + */ |
| 22 | +-#if !defined(ENABLE_SOCKET_LB_FULL) || \ |
| 23 | ++#if (!defined(ENABLE_SOCKET_LB_FULL) || \ |
| 24 | + defined(ENABLE_SOCKET_LB_HOST_ONLY) || \ |
| 25 | +- defined(ENABLE_L7_LB) |
| 26 | ++ defined(ENABLE_L7_LB) ) && !defined(DISABLE_PER_PACKET_LB) |
| 27 | + # define ENABLE_PER_PACKET_LB 1 |
| 28 | + #endif |
| 29 | + |
| 30 | +@@ -1247,7 +1247,6 @@ static __always_inline int __tail_handle_ipv4(struct __ctx_buff *ctx) |
| 31 | + |
| 32 | + if (unlikely(!is_valid_lxc_src_ipv4(ip4))) |
| 33 | + return DROP_INVALID_SIP; |
| 34 | +- |
| 35 | + #ifdef ENABLE_PER_PACKET_LB |
| 36 | + { |
| 37 | + struct ipv4_ct_tuple tuple = {}; |
| 38 | +diff --git a/daemon/cmd/daemon_main.go b/daemon/cmd/daemon_main.go |
| 39 | +index de2ad4900b..8b495d972f 100644 |
| 40 | +--- a/daemon/cmd/daemon_main.go |
| 41 | ++++ b/daemon/cmd/daemon_main.go |
| 42 | +@@ -1147,6 +1147,9 @@ func initializeFlags() { |
| 43 | + flags.MarkHidden(option.EnableStaleCiliumEndpointCleanup) |
| 44 | + option.BindEnv(option.EnableStaleCiliumEndpointCleanup) |
| 45 | + |
| 46 | ++ flags.Bool(option.DisablePerPacketLB, false, "Disable svc func.") |
| 47 | ++ option.BindEnv(option.DisablePerPacketLB) |
| 48 | ++ |
| 49 | + viper.BindPFlags(flags) |
| 50 | + } |
| 51 | + |
| 52 | +diff --git a/pkg/datapath/linux/config/config.go b/pkg/datapath/linux/config/config.go |
| 53 | +index 060328adf9..4201e878fb 100644 |
| 54 | +--- a/pkg/datapath/linux/config/config.go |
| 55 | ++++ b/pkg/datapath/linux/config/config.go |
| 56 | +@@ -98,6 +98,11 @@ func (h *HeaderfileWriter) WriteNodeConfig(w io.Writer, cfg *datapath.LocalNodeC |
| 57 | + |
| 58 | + cDefinesMap["KERNEL_HZ"] = fmt.Sprintf("%d", option.Config.KernelHz) |
| 59 | + |
| 60 | ++ if option.Config.DisablePerPacketLB { |
| 61 | ++ log.Infof("Disabling per-packet LB policy") |
| 62 | ++ cDefinesMap["DISABLE_PER_PACKET_LB"] = "1" |
| 63 | ++ } |
| 64 | ++ |
| 65 | + if option.Config.EnableIPv6 { |
| 66 | + extraMacrosMap["ROUTER_IP"] = routerIP.String() |
| 67 | + fw.WriteString(defineIPv6("ROUTER_IP", routerIP)) |
| 68 | +diff --git a/pkg/option/config.go b/pkg/option/config.go |
| 69 | +index d4d9643f4e..80b5eb2c7c 100644 |
| 70 | +--- a/pkg/option/config.go |
| 71 | ++++ b/pkg/option/config.go |
| 72 | +@@ -1104,6 +1104,8 @@ const ( |
| 73 | + // EnableStaleCiliumEndpointCleanup sets whether Cilium should perform cleanup of |
| 74 | + // stale CiliumEndpoints during init. |
| 75 | + EnableStaleCiliumEndpointCleanup = "enable-stale-cilium-endpoint-cleanup" |
| 76 | ++ |
| 77 | ++ DisablePerPacketLB = "disable-per-package-lb" |
| 78 | + ) |
| 79 | + |
| 80 | + // Default string arguments |
| 81 | +@@ -2262,6 +2264,8 @@ type DaemonConfig struct { |
| 82 | + // This will attempt to remove local CiliumEndpoints that are not managed by Cilium |
| 83 | + // following Endpoint restoration. |
| 84 | + EnableStaleCiliumEndpointCleanup bool |
| 85 | ++ |
| 86 | ++ DisablePerPacketLB bool |
| 87 | + } |
| 88 | + |
| 89 | + var ( |
| 90 | +@@ -3257,6 +3261,8 @@ func (c *DaemonConfig) Populate() { |
| 91 | + c.EnableK8sTerminatingEndpoint = viper.GetBool(EnableK8sTerminatingEndpoint) |
| 92 | + c.EnableStaleCiliumEndpointCleanup = viper.GetBool(EnableStaleCiliumEndpointCleanup) |
| 93 | + |
| 94 | ++ c.DisablePerPacketLB = viper.GetBool(DisablePerPacketLB) |
| 95 | ++ |
| 96 | + // Disable Envoy version check if L7 proxy is disabled. |
| 97 | + c.DisableEnvoyVersionCheck = viper.GetBool(DisableEnvoyVersionCheck) |
| 98 | + if !c.EnableL7Proxy { |
| 99 | +-- |
| 100 | +2.46.0 |
| 101 | + |
0 commit comments