Skip to content

Commit 119bd3c

Browse files
authored
Merge pull request #352 from l1b0k/main
fix: cilium networkpolicty cause health check problem
2 parents 1f4ec0d + 5771995 commit 119bd3c

File tree

2 files changed

+106
-0
lines changed

2 files changed

+106
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
From b59d5981140af48f9c8bf2c284d6f78acb3855f4 Mon Sep 17 00:00:00 2001
2+
From: l1b0k <libokang.dev@gmail.com>
3+
Date: Mon, 23 May 2022 17:43:50 +0800
4+
Subject: [PATCH 1/2] terway: support kubelet health check
5+
6+
when package travel cross netns fw mark will lost ,this will cause bpf unable to identify host network.
7+
8+
Signed-off-by: l1b0k <libokang.dev@gmail.com>
9+
---
10+
bpf/bpf_lxc.c | 6 ++----
11+
1 file changed, 2 insertions(+), 4 deletions(-)
12+
13+
diff --git a/bpf/bpf_lxc.c b/bpf/bpf_lxc.c
14+
index bca0dab5b4..bad751ecc8 100644
15+
--- a/bpf/bpf_lxc.c
16+
+++ b/bpf/bpf_lxc.c
17+
@@ -1238,8 +1238,7 @@ int tail_ipv6_to_endpoint(struct __ctx_buff *ctx)
18+
* as the host. So we can ignore the ipcache
19+
* if it reports the source as HOST_ID.
20+
*/
21+
- if (sec_label != HOST_ID)
22+
- src_identity = sec_label;
23+
+ src_identity = sec_label;
24+
}
25+
}
26+
cilium_dbg(ctx, info ? DBG_IP_ID_MAP_SUCCEED6 : DBG_IP_ID_MAP_FAILED6,
27+
@@ -1546,8 +1545,7 @@ int tail_ipv4_to_endpoint(struct __ctx_buff *ctx)
28+
* as the host. So we can ignore the ipcache
29+
* if it reports the source as HOST_ID.
30+
*/
31+
- if (sec_label != HOST_ID)
32+
- src_identity = sec_label;
33+
+ src_identity = sec_label;
34+
}
35+
}
36+
cilium_dbg(ctx, info ? DBG_IP_ID_MAP_SUCCEED4 : DBG_IP_ID_MAP_FAILED4,
37+
--
38+
2.36.1
39+
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
From 10e9e56f274e072dfac53f90f0ecaa4608896526 Mon Sep 17 00:00:00 2001
2+
From: l1b0k <libokang.dev@gmail.com>
3+
Date: Mon, 23 May 2022 16:35:52 +0800
4+
Subject: [PATCH 2/2] node: don't exclude IPs which is already included
5+
6+
if we use node ip for service externalIP, this will cause node ip be excluded
7+
8+
Signed-off-by: l1b0k <libokang.dev@gmail.com>
9+
---
10+
pkg/node/ip_linux.go | 20 +++++++++++++++++++-
11+
1 file changed, 19 insertions(+), 1 deletion(-)
12+
13+
diff --git a/pkg/node/ip_linux.go b/pkg/node/ip_linux.go
14+
index 732f62babe..e1df3344b2 100644
15+
--- a/pkg/node/ip_linux.go
16+
+++ b/pkg/node/ip_linux.go
17+
@@ -15,6 +15,7 @@
18+
package node
19+
20+
import (
21+
+ "net"
22+
"strings"
23+
24+
"github.com/vishvananda/netlink"
25+
@@ -33,6 +34,9 @@ func initExcludedIPs() {
26+
if err != nil {
27+
return
28+
}
29+
+
30+
+ includedIPs := make(map[string]struct{})
31+
+ var toExcludeIPs []net.IP
32+
for _, l := range links {
33+
// ... also all down devices since they won't be reachable.
34+
if l.Attrs().OperState == netlink.OperUp {
35+
@@ -44,6 +48,13 @@ func initExcludedIPs() {
36+
}
37+
}
38+
if skip {
39+
+ addr, err := netlink.AddrList(l, netlink.FAMILY_ALL)
40+
+ if err != nil {
41+
+ continue
42+
+ }
43+
+ for _, a := range addr {
44+
+ includedIPs[a.IP.String()] = struct{}{}
45+
+ }
46+
continue
47+
}
48+
}
49+
@@ -52,7 +63,14 @@ func initExcludedIPs() {
50+
continue
51+
}
52+
for _, a := range addr {
53+
- excludedIPs = append(excludedIPs, a.IP)
54+
+ toExcludeIPs = append(toExcludeIPs, a.IP)
55+
+ }
56+
+ }
57+
+
58+
+ for _, value := range toExcludeIPs {
59+
+ _, ok := includedIPs[value.String()]
60+
+ if !ok {
61+
+ excludedIPs = append(excludedIPs, value)
62+
}
63+
}
64+
}
65+
--
66+
2.36.1
67+

0 commit comments

Comments
 (0)